Anything in the user directory (/home/weewx/bin/user or /usr/share/weewx/user depending on the WeeWX install type) is upgrade safe. Of course, despite this you should still keep a backup of key WeeWX files.
Gary On Wednesday, 20 September 2023 at 17:02:50 UTC+10 remy.l...@gmail.com wrote: > Thank you Gary for all these detailed explanations! Thank you also for > your patience... > Thanks to you I was finally able to finish integrating the data into the > weewx database as I wanted! > Without your precious help, I would* NEVER* have gotten there! > > Just one last quick question, if weewx is updated, do you know if the > /usr/share/weewx/user/extensions.py file is modified or if it is kept as is? > > Thanks a lot again Gary! > > Le lundi 18 septembre 2023 à 14:05:53 UTC+2, gjr80 a écrit : > >> Some answers/guidance below. >> >> Gary >> >> On Monday, 18 September 2023 at 00:55:03 UTC+10 remy.l...@gmail.com >> wrote: >> >> However, I have a new question as I haven't been able to understand >> exactly the weewx documentation on this subject. I clearly saw that the >> case of adding electricity consumption to the database had been processed >> but I did not understand the entire explanation given. >> >> To put it simply, I retrieve data in CSV format which I integrate at >> regular intervals into the weewx database using wee_import.py (my weather >> station does not have a USB output and the data is retrieved from AWEKAS). >> To the weather data, I would have liked to add for the period considered: >> - CPU load data (unitless) >> - The total and used memory of the Raspberry (kB unit) >> - The total and used capacity of the SSD (Gb unit) >> - Power consumption (Watt unit) >> - Water consumption (unit per liter) >> >> I created the fields I needed in the existing WeeWX database without >> problem with wee_database >> >> What I couldn't do: >> - Create a new base group (for example group_memory with the new Kb and >> Gb units). What file exactly should be modified or created and where is it >> located? >> >> Compared to the documentation, I would tend to make a file >> "/usr/share/weewx/user/memory.py" with in it: >> >> >> >> >> >> >> >> >> >> *import weewx.unitsweewx.units.obs_group_dict['rocketForce'] = >> 'group_memory'weewx.units.USUnits['group_memory'] = >> 'byte'weewx.units.MetricUnits['group_memory'] = >> 'byte'weewx.units.MetricWXUnits['group_memory'] = >> 'byte'weewx.units.default_unit_format_dict['byte'] = >> '%.1f'weewx.units.default_unit_label_dict['byte'] = ' byte'* >> >> Is my approach correct? How to create the units kB and gB? >> >> >> Not quite. First up, no need for memory.py, just use >> /usr/share/weewx/user/extensions.py, that is what is is meant for. Next, >> WeeWX already has a unit named byte which is used with unit group >> group_data. You can certainly define your own unit group group_memory >> but why, it just adds the possibility for confusion. The one thing WeeWX >> does not have is unit names representing kilobyte and gigabyte (and >> megabyte), these you will need to define or otherwise handle yourself. To >> add units kilobyte, megabyte and gigabyte you need to define the unit >> conversion functions for each unit as well as specifying a number format >> and unit label for each unit. We generally specify unit conversion >> functions using lambda functions, in the case unit kilobyte we need to >> specify how to convert from kilobyte to each of the other units that may >> be used within unit group group_data; ie kilobyte to bit, kilobyte to >> byte, kilobyte to megabyte and kilobyte to gigabyte. We might do this as >> follows: >> >> weewx.units.conversionDict['kilobyte'] = {'bit': lambda x: x * 8192.0, >> 'byte': lambda x: x * 1024.0, >> 'megabyte': lambda x: x / >> 1024.0, >> 'gigabyte': lambda x: x / >> 1048576.0} >> >> Likewise for each of the other group_data units. To define a unit label >> and number format for the kilobyte unit you would use something like: >> >> weewx.units.default_unit_label_dict['kilobyte'] = ' kB' >> weewx.units.default_unit_format_dict['kilobyte'] = '%.1f' >> >> Again, likewise for the other units. >> >> Overall you would end up with something like: >> >> weewx.units.conversionDict['bit'] = {'byte': lambda x: x / 8.0, >> 'kilobyte': lambda x: x / 8192.0, >> 'megabyte': lambda x: x / 8388608.0, >> 'gigabyte': lambda x: x / 8589934592 >> <(858)%20993-4592>.0} >> weewx.units.conversionDict['byte'] = {'bit': lambda x: x * 8.0, >> 'kilobyte': lambda x: x / 1024.0, >> 'megabyte': lambda x: x / 1048576.0 >> , >> 'gigabyte': lambda x: x / >> 1073741824.0} >> weewx.units.conversionDict['kilobyte'] = {'bit': lambda x: x * 8192.0, >> 'byte': lambda x: x * 1024.0, >> 'megabyte': lambda x: x / >> 1024.0, >> 'gigabyte': lambda x: x / >> 1048576.0} >> weewx.units.conversionDict['megabyte'] = {'bit': lambda x: x * 8388608.0, >> 'byte': lambda x: x * 1048576.0, >> 'kilobyte': lambda x: x * >> 1024.0, >> 'gigabyte': lambda x: x / >> 1024.0} >> weewx.units.conversionDict['gigabyte'] = {'bit': lambda x: x * 8589934592 >> <(858)%20993-4592>.0, >> 'byte': lambda x: x >> * 1073741824.0, >> 'kilobyte': lambda x: x >> * 1048576.0, >> 'megabyte': lambda x: x * >> 1024.0} >> weewx.units.default_unit_label_dict['kilobyte'] = ' kB' >> weewx.units.default_unit_format_dict['kilobyte'] = '%.1f' >> weewx.units.default_unit_label_dict['megabyte'] = ' MB' >> weewx.units.default_unit_format_dict['megabyte'] = '%.1f' >> weewx.units.default_unit_label_dict['gigabyte'] = ' GB' >> weewx.units.default_unit_format_dict['gigabyte'] = '%.1f' >> >> Note the above uses the binary interpretation of a kilobyte; ie 1kB = >> 1024 bytes, 1MB = 1024kB and 1GB = 1024MB. If you wish to use the Metric >> interpretation of a kilobyte; ie 1kB = 1000 bytes, 1MB = 1000kB and 1GB = >> 1000MB some of the above conversion factors will need to be changed >> accordingly. >> >> - For data that is unitless such as charge1, charge5 and charge15 >> (assuming that the field names of the weewx.sdb database are >> charge1,charge5,charge15 and that the names of the header fields of the CSV >> file to import are charge1, charge5 and charge15), will the import be done >> by putting in the CSV import configuration file for wee_import.py: >> source = CSV >> >> [CSV] >> .... >> [[FieldMap]] >> dateTime = dateTime, unix_epoch >> .... >> charge1 = charge1 >> charge5 = charge5 >> charge15 = charge15 >> >> >> WeeWX has unit group group_count and unit count to handle unitless >> fields. All you need to do is assign your fields to group_count in the >> same way you assigned your wet bulb field to group_temperature. >> >> >> -- 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 weewx-user+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/77b65ae0-6d43-4291-b2ae-1c3a4baf761an%40googlegroups.com.