Formatting and using new units

189 views
Skip to first unread message

bgra...@umw.edu

unread,
Jul 4, 2024, 3:06:51 PM7/4/24
to weewx-user
Hello all,
I am slowly moving my weewx 4.10.2 ubuntu VP2+ station to an RPI5 with Bookworm. Lacking in indepth knowledge of html and python, I'm having lots of trouble with formats and units. I had it working on the Standard skin (see attache file) but many things have changed on how this is now done. Before I was adding to weewx.conf but it appears more complicated for 5.0.
The file shows my present Standard page and then the attempted version in 5.0. I'm not sure how to add the "µ" symbol or to round data with too many decimal places.
What I have in 5.0 seems to be running but doesn't look very nice.
Could someone please point me in the correct direction? I have looked at the customization section of the wiki but am not sure how to proceed. The Geiger counter data is stored in Signal1 and Signal2 of weewx.sdb.

MQTT section from weewx.conf
        ##################
        ## Radmon+ Geiger counter from emonpi
        ##################

        [[[gccpm]]]
            name = signal1
            [[[[message]]]]
                type = individual
        [[[gcdose]]]
            name = signal2
            [[[[message]]]]
                type = individual
        ####################################
        ## Soil Moisture / Soil Temp from emoncms
        ####################################
        [[[4103]]]
            name = soilMoist1
            [[[[message]]]]
                type = individual
        [[[4102]]]
            name = soilTemp3
            [[[[message]]]]
                type = individual
        [[[4108]]]
            name = signal3
            [[[[message]]]]
                type = individual

Thanks in advance. Everything is rtunning with no errors so far.
Bob
Standard skin on weewx 4.pdf

bgra...@umw.edu

unread,
Jul 9, 2024, 11:12:26 AM7/9/24
to weewx-user
Sorry to keep going on this but I have no takers so far.

I have added this to weewx.conf:
[[StandardReport]]
        # This is the old "Standard" skin. By default, it is not enabled.
        skin = Standard
        enable = true

         [[[Units]]]
            [[[[Groups]]]]
                group_fraction     = ppm                #added for CO2 monitor 11/30/21
                group_severt       = µSv
                group_conductivity = dSm
                group_cpm          = cpm
         [[[[StringFormats]]]]
                ppm                = %.0f  # 12/2/21
                cpm                = %.0f
                µSv                = %.2f
                dSm                = %.2f

and this to units.py:

obs_group_dict = ListOfDicts({
"signal1"                   : "group_cpm",
    "signal2"                   : "group_severt",

USUnits = ListOfDicts({
"group_severt"      : "µSv",

As mentioned earlier, this is working fine in 4.10.2 but I just can't get going in 5.1 (pip install). Everything else seems to be working well.
Any help would be greatly appreciated. 
Cheers,
Bob

Tom Keffer

unread,
Jul 9, 2024, 9:00:44 PM7/9/24
to weewx...@googlegroups.com
I think you're not getting a response because the question is a little confusing. 

As I understand it, you have added some new observation types, and now you're wondering why they are not working with V5.0? Is that correct?

First, adding the unit group assignments to units.py is never a good idea, because units.py will get replaced in the next upgrade. Instead, you should add them to any user code (that is, code that lives under the subdirectory 'bin/user') because that never gets touched. Most customizations involve some bit of Python code (such as a search list extension, etc.), and that's a good place to put the assignment. Alternatively, if there is no Python code involved, you can put it in user/extensions.py --- that's what it's there for.

Second, I hope you did not literally make the additions to units.py that you showed below. That would cause obs_group_dict to forget all the WeeWX native types! Same with USUnits.

Instead, you should follow the outline in the section Customizing unit groups in the Customization Guide.

Give it a look. If you're still confused, come back here and we'll see if we can straighten things out.


--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/b95fcbf4-c577-4908-b941-516dfa21e7e9n%40googlegroups.com.

vince

unread,
Jul 9, 2024, 11:59:53 PM7/9/24
to weewx-user
I would again suggest you use your working v4 system as a reference and do the same edits to your new v5 system.

Nothing has changed related to formatting your data in the cheetah .tmpl templates.  See 

bgra...@umw.edu

unread,
Jul 10, 2024, 11:37:44 AM7/10/24
to weewx-user
Thanks for the replies. Sorry for the confusing question which is probably because I'm confused about why things aren't working.
To narrow this down, I have a Geiger counter sending data to weewx which is being stored in weewx.sdb under signal1 and signal2. This seems to be working.
I have added the following to weewx.conf (Standard skin) under units, groups and  string format (see original message above).

signal1 = cpm  group_cpm  = cpm   cpm = %.0f
signal2 =  µSv  group_severt = µSv   µSv  = %.2f

I have this in my weewx.conf for 4.10.2 where it's working but does not work in 5.1 when pasted into weewx.conf. In 4.10.2, I have not used any extra code for an extension. I'm not sure of how to format something like 'geiger.py' for weewx 5.1 but maybe that is what I need to do. Vince pointed me to a cheetah-generator formatting section which I had not seen before so maybe I could use something like this in my index.html.tmpl (?). 

I have restored the original units.py. That modification was just an uneducated guess on my part.

What I have in 5.1 is working. It would just look better if it displayed the units and format better.

CO2 level                        458 ppm at 11:00   [this one works correctly]
Radiation Count Level  16.857143 at 11:15
Radiation Dose              0.095714 at 11:15

Thanks for your help.
Cheers,
Bob

bgra...@umw.edu

unread,
Jul 10, 2024, 2:50:53 PM7/10/24
to weewx-user
Tom,
I have attempted to construct a file user/geiger.py from the customizing groups/units directions. I haven't tried it yet because I wanted you to see if I am on the right track here. I'm not sure of the syntax necessary. The class statement  looks odd as if somethig should come after the ":"
class Addgeigerdose(StdService):
class Addgeigercpm(StdService):
Anyway, please comment when you have time. Thanks.
Bob

### geiger.py
###########################
import weewx
from weewx.engine import StdService
import weewx.units

weewx.units.obs_group_dict['geigerdose'] = 'group_severt'
weewx.units.obs_group_dict['geigercpm'] = 'group_cpm'

class Addgeigerdose(StdService):
class Addgeigercpm(StdService):

weewx.units.USUnits['group_severt'] = 'µSv'
weewx.units.MetricUnits['group_severt'] = 'µSv'
weewx.units.MetricWXUnits['group_severt'] = 'µSv'

weewx.units.USUnits['group_cpm'] = 'cpm'
weewx.units.MetricUnits['group_cpm'] = 'cpm'
weewx.units.MetricWXUnits['group_cpm'] = 'cpm'

weewx.units.default_unit_format_dict['µSv'] = '%.1f'
weewx.units.default_unit_label_dict['µSv'] = ' µSv'

weewx.units.default_unit_format_dict['cpm'] = '%.0f'
weewx.units.default_unit_label_dict['cpm'] = ' cpm'

Glenn McKechnie

unread,
Jul 10, 2024, 9:25:55 PM7/10/24
to weewx...@googlegroups.com
Just to recap on what has been said already. Are you certain that the bin/user/extensions.py file in your 4.10.2 installation doesn't have the required additions in it already?

That's where I thought you had put them.

Cheers
 Glenn

Various WeeWx addons at
https://github.com/glennmckechnie


--
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+...@googlegroups.com.

bgra...@umw.edu

unread,
Jul 11, 2024, 7:48:29 AM7/11/24
to weewx-user
Hi Glenn,
Yes, that’s where the extensions are and where you helped me set them up. Thank you for remembering for me as I fear old age is is taking its toll here… All is good as I see why it was working in 4.10.2. Problem solved!
My apologies to all for the unnecessary questions which had already been answered by Glenn. Thanks Tom and Vince for your suggestions.
Cheers,
Bob

Reply all
Reply to author
Forward
0 new messages