Hi, In the AddElectricity example it is convenient to include the code that customises the units and unit groups in the same .py file as the the code that adds the fields to the archive record, but there is no requirement that it be done this way always. The only requirement is that the code be executed before WeeWX first uses your new fields. If you go back to the section Adding a new type to the database <http://www.weewx.com/docs/customizing.htm#add_archive_type> you will see mention of a couple of ways to include some code to be executed (look for the para starting 'Now, where do we put this bit of code?'). In this case you should follow the first suggestion and put your code in user/extensions.py. In your case just add something like (untested):
import weewx.units weewx.units.obs_group_dict['Vbat'] = 'group_volt' weewx.units.obs_group_dict['Vsolar'] = 'group_volt' save the file and restart WeeWX and WeeWX should interpret Vbat and Vsolar as voltages. Gary On Thursday, 25 April 2019 07:43:31 UTC+10, wysiwyg wrote: > > Hello ! > > I have added a few observations to my weewx. > I use a battery and a solar panel to supply my sensor, so I added Vbat, > Isolar, Vsolar. > > This is working for a few month as unitless values (I can draw graph, use > cheetah labels like $day.Isolar.max, all is fine). > > Now I would like to use suitable units. > > > let's start slowly, so I followed the documentation of voltage, because > group_volt already exists :-) > I read here: > http://www.weewx.com/docs/customizing.htm#Assigning_a_unit_group > > and created a file: > /usr/share/weewx/user/electricity.py > > containing: > import weewx > from weewx.engine import StdService > > import weewx.units > weewx.units.obs_group_dict['Vbat'] = 'group_volt' > weewx.units.obs_group_dict['Vsolar'] = 'group_volt' > #weewx.units.obs_group_dict['WVbat'] = 'group_volt' > #weewx.units.obs_group_dict['WVsolar'] = 'group_volt' > > class AddElectricity(StdService): > > WVbat / WVsolar are not used yet (not in database), it will be my vbat & > Vsolar values for wind sensor that I have not finished to develop yet. > I commented to avoid issues as those 2 are not yet in database schema. > > I prepared my file based on the example from documentation: > > import weewx > from weewx.engine import StdService > > import weewx.units > weewx.units.obs_group_dict['electricity'] = 'group_energy' > > class AddElectricity(StdService): # [...] > > But then, I wonder how it should be said to weewx that this new file is > here, waiting for processing? > > I assume it's probably need to add something in [engine] section of > weewx.conf. > I tried the following without sucess (added in dat_services) > > > [Engine] > > [[Services]] > # This section specifies the services that should be run. They are > # grouped by type, and the order of services within each group > # determines the order in which the services will be run. > prep_services = weewx.engine.StdTimeSynch > data_services = user.electricity.AddElectricity > process_services = weewx.engine.StdConvert, weewx.engine. > StdCalibrate, weewx.engine.StdQC, weewx.wxservices.StdWXCalculate > archive_services = weewx.engine.StdArchive > restful_services = weewx.restx.StdStationRegistry, weewx.restx. > StdWunderground, weewx.restx.StdAWEKAS, user.windy.Windy > #restful_services = weewx.restx.StdStationRegistry, > weewx.restx.StdWunderground, weewx.restx.StdPWSweather, > weewx.restx.StdCWOP, weewx.restx.StdWOW, weewx$ > report_services = weewx.engine.StdPrint, weewx.engine.StdReport > > > help welcome :-) > > > > > -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
