Problem adding a new measurement beyond extended DB

87 views
Skip to first unread message

bdf0506

unread,
Oct 5, 2023, 2:59:07 PM10/5/23
to weewx-user
I've got a very long list of sensors and am now all the way up to ExtraTemp14 :). The extended database goes up to ExtraTemp9, so I've manually added to the database structure to allow for more. ExtraTemp10-13 are fine, but ExtraTemp14 is giving me a hard time since I need to tell it what units to come in with. ExtraTemp10-13 use default units.

Here's the error I keep getting in the logs:

Oct 5 14:29:57 weewx[19] ERROR weewx.engine: Import of driver failed: For extraTemp14 invalid units, degree_C. (<class 'ValueError'>)
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** Traceback (most recent call last):
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** File "/home/weewx/bin/weewx/engine.py", line 119, in setupStation
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** self.console = loader_function(config_dict, self)
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** File "/home/weewx/bin/user/MQTTSubscribe.py", line 1951, in loader
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** return MQTTSubscribeDriver(**config_dict[DRIVER_NAME]) # pragma: no cover
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** File "/home/weewx/bin/user/MQTTSubscribe.py", line 1977, in __init__
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** self.subscriber = MQTTSubscriber(stn_dict, self.logger)
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** File "/home/weewx/bin/user/MQTTSubscribe.py", line 1566, in __init__
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** self.manager = TopicManager(self.archive_topic, topics_dict, self.logger)
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** File "/home/weewx/bin/user/MQTTSubscribe.py", line 844, in __init__
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** self.subscribed_topics[topic]['fields'][topic] = self._configure_field(topic_dict, topic_dict, topic, field_defaults)
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** File "/home/weewx/bin/user/MQTTSubscribe.py", line 964, in _configure_field
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** raise ValueError("For %s invalid units, %s." % (field['name'], field_dict['units']))
Oct 5 14:29:57 weewx[19] CRITICAL weewx.engine: **** ValueError: For extraTemp14 invalid units, degree_C.
Oct 5 14:29:57 weewx[19] CRITICAL __main__: Unable to load driver: For extraTemp14 invalid units, degree_C.
Oct 5 14:29:57 weewx[19] CRITICAL __main__: **** Exiting...

From my weewx.conf:

xxxxxxxx

[MQTTSubscribeDriver]
    # This section is for the MQTTSubscribe driver.

    # The driver to use:
    driver = user.MQTTSubscribe

    # The MQTT server.
    # Default is localhost.
    host = unraid.home

    # The port to connect to.
    # Default is 1883.
    port = 1883

    # Maximum period in seconds allowed between communications with the broker.
    # Default is 60.
    keepalive = 60

    # username for broker authentication.
    # Default is None.
    username = mqtt

    # password for broker authentication.
    # Default is None.
    password = mqtt

    # Configuration for the message callback.
    [[message_callback]]
        type = individual

# for fields that aren't the default, specify them here.
    [[weewx]]
        [[[observations]]]
            extraTemp9 = group_temperature
            extraTemp10 = group_temperature
            extraTemp11 = group_temperature
            extraTemp12 = group_temperature
            extraTemp13 = group_temperature
            extraTemp14 = group_temperature
            extraTemp15 = group_temperature
            extraHumid9 = group_percent
            extraHumid10 = group_percent
            extraHumid11 = group_percent
            extraHumid12 = group_percent
            extraHumid13 = group_percent
            extraHumid14 = group_percent
            extraHumid15 = group_percent
            rain2 = group_rain
            windDir2 = group_direction
            windSpeed2 = group_speed
            outTemp2 = group_temperature
            outHumidity2 = group_percent
            luminosity = group_illuminance

    # The topics to subscribe to.
    [[topics]]
        unit_system = US
        [[[rtl_433/devices/Acurite-Tower/9235/temperature_C]]]
              name = extraTemp14
              units = degree_C
        [[[rtl_433/devices/Acurite-Tower/9235/humidity]]]
              name = extraHumid14
        [[[rtl_433/devices/Acurite-Tower/9235/battery_ok]]]
              name = batteryStatus14

xxxxxxxx

It's struggling because I am telling it that the units are coming in degree_C and I need weewx to convert it. Is there a config file somewhere where I need to properly map the unit to extraTemp14?

Thank you!

bell...@gmail.com

unread,
Oct 5, 2023, 4:57:06 PM10/5/23
to weewx-user
You need to tell MQTTSubscribe/WeeWX what 'unit_group' 'extratemp14' belongs to. If I remember correctly this is needed because MQTTSubscribe uses WeeWX to perform the conversion. See, https://www.weewx.com/docs/customizing.htm#Assigning_a_unit_group. So you would want something like.

import weewx.units
weewx.units.obs_group_dict['extratemp14'] = 'group_temperature'

Where to add this, I'm not sure. I think the recommended place is in __init__.py in the bin/user directory.
-rich

bdf0506

unread,
Oct 5, 2023, 5:06:06 PM10/5/23
to weewx-user
So I tried something to that effect, and still no dice. I referenced this old thread that it looks like you may have been active in: https://groups.google.com/g/weewx-user/c/_ysq-eyjJrM/m/mJFiwufeCwAJ

within bin/user/units.py I have:

import weewx

import weewx.units
weewx.units.obs_group_dict['extraTemp14'] = 'group_temperature'
weewx.units.obs_group_dict['extraHumid14'] = 'group_percent'

class Units(weewx.engine.StdService):
    pass

Then in weewx.conf, I have:

[Engine]

    # The following section specifies which services should be run and in what order.
    [[Services]]
        prep_services = weewx.engine.StdTimeSynch, user.units.Units
        data_services =
        process_services = weewx.engine.StdConvert, weewx.engine.StdCalibrate, weewx.engine.StdQC, weewx.wxservices.StdWXCalculate

But then I still get the same errors. Anything else I am missing?

vince

unread,
Oct 5, 2023, 5:26:00 PM10/5/23
to weewx-user
If everything up to extraTempN to 13 is working, I'd suspect you either have a typo someplace related to extraTemp14....or you didn't add extraTemp14 to the schema....or you didn't restart weewx after altering the schema and/or config.  Eliminate those possibilities just to know you have a clean altered system...

gjr80

unread,
Oct 5, 2023, 5:33:05 PM10/5/23
to weewx-user
/home/weewx/bin/user/extensions.py or /usr/share/weewx/user/extensions.py is the generally recommended location. There are two requirements (1) the code must be in a location such that it is executed each time WeeWX starts and (2) it is advisable to place the code in a location that is not overwritten during a WeeWX upgrade. extensions.py was made for just such cases. 

Another alternative if you have written your own driver and the extra fields are tightly linked to that driver is to place the code in the driver.

The former always works, the latter always work but may be overwritten depending on the driver.

Gary

bell...@gmail.com

unread,
Oct 5, 2023, 7:47:21 PM10/5/23
to weewx-user
@Gary, good to know about extensions.py. Thanks!

@Vince, I was thinking the same thing. But, I think the difference is that this sensor is reporting in Celsius and it needs to be converted to Fahrenheit.

@bdf0506, try putting the code in extensions.py.

1. This is the recommended way and therefore better supported than my hack.
2. I think the reason my hack didn’t work for you is because I was running MQTTSubscribe as a service. So my ‘Noop’ service was loaded before MQTTSubscribeService was loaded. This means weewx.units.obs_group_dict was updated. Because you running MQTTSubscribe as a driver, the services have not been loaded and therefore weewx.units.obs_group_dict is not updated.
rich

bdf0506

unread,
Oct 5, 2023, 8:37:07 PM10/5/23
to weewx-user
That makes sense as to why it wasn't working, since I am running MQTTSubscribe as a driver instead of a service. The other extraTemp readings did not need to do any conversions, so that's why those never gave me any problems.

If I put the code in bin/user/__init__.py or bin/user/extensions.py, it works as intended.  Thanks for the help, everyone.

Reply all
Reply to author
Forward
0 new messages