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.

On Thursday, October 5, 2023 at 7:47:21 PM UTC-4 [email protected] wrote:

> @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
>
> On Thursday, 5 October 2023 at 17:06:06 UTC-4 bdf0506 wrote:
>
>> 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?
>> On Thursday, October 5, 2023 at 4:57:06 PM UTC-4 [email protected] wrote:
>>
>>> 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
>>>
>>> On Thursday, 5 October 2023 at 14:59:07 UTC-4 bdf0506 wrote:
>>>
>>>> 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!
>>>>
>>>>

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/c4882eb7-d42d-44d2-8ab2-3474de6a3a25n%40googlegroups.com.

Reply via email to