MQTT - windir & windGustDir Missing in payload and ET units error

168 views
Skip to first unread message

HoracioDos

unread,
May 28, 2023, 10:44:33 AM5/28/23
to weewx-user
Hello.
I can't get windDir and windGustDir data in MQTT uploader. I was able to add other  missing measurements successfully like ET, windchill, windrun and interval.

This is my MQTT section in weewx.conf
    [[MQTT]]
        server_url = mqtt://usr:pwd@localhost:1883/

        topic = weewx
        unit_system = METRIC
        binding = archive, loop
        aggregation = aggregate
        log_success = False
        log_failure = True
        [[[inputs]]]
            [[[[altimeter]]]]
                name = altimeter_hPa
                units = hPa
            [[[[barometer]]]]
                name = barometer_hPa
                units = hPa
            [[[[pressure]]]]
                name = pressure_hPa
                units = hPa
            [[[[dayRain]]]]
                name = dayRain_mm
                units = mm
            [[[[rainRate]]]]
                name = rainRate_mm_per_hour
                units = mm_per_hour
            [[[[hourRain]]]]
                name = hourRain_mm
                units= mm
            [[[[rain24]]]]
                name = rain24_mm
                units= mm
            [[[[rain]]]]
                name = rain_mm
                units= mm
            [[[[windchill]]]]
                name = windchill_C
                units= degree_C
            [[[[windDir]]]]
                name = windDir
                #units= degree_compass
                units= ordinal_compass
            [[[[windGustDir]]]]
                name = windGustDir
                #units= degree_compass
                units= ordinal_compass
            [[[[ET]]]]
                name = ET_mm
                units= mm
                #units = mm_per_day
            [[[[windrun]]]]
                name = windrun_km
                units= km
            [[[[interval]]]]
                name = interval
                #units= seconds
        [[[tls]]]

There is another problem if I set units = mm_per_day for ET MQTT fails with this error. 

May 28 11:30:58 pi2weewx python3[1673]: weewx[1673] DEBUG weewx.units: Unable to convert from cm to mm_per_day
May 28 11:30:58 pi2weewx python3[1673]: weewx[1673] ERROR weewx.restx: MQTT: Unexpected exception of type <class 'KeyError'>
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] ERROR weewx.restx: *** Traceback (most recent call last):
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] DEBUG weewx.reportengine: Running reports for latest time in the database.
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] ERROR weewx.restx: ***   File "/usr/share/weewx/weewx/restx.py", line 382, in run_loop
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] ERROR weewx.restx: ***     self.process_record(_record, dbmanager)
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] DEBUG weewx.reportengine: Report 'SeasonsReport' not enabled. Skipping.
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] ERROR weewx.restx: ***   File "/usr/share/weewx/user/mqtt.py", line 476, in process_record
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] DEBUG weewx.reportengine: Report 'SmartphoneReport' not enabled. Skipping.
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] ERROR weewx.restx: ***     data = self.filter_data(record)
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] DEBUG weewx.reportengine: Report 'MobileReport' not enabled. Skipping.
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] ERROR weewx.restx: ***   File "/usr/share/weewx/user/mqtt.py", line 455, in filter_data
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] DEBUG weewx.reportengine: Report 'StandardReport' not enabled. Skipping.
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] ERROR weewx.restx: ***     v = weewx.units.convert(from_t, to_units)[0]
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] DEBUG weewx.reportengine: Running report 'FTP'
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] ERROR weewx.restx: ***   File "/usr/share/weewx/weewx/units.py", line 1454, in convert
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] ERROR weewx.restx: ***     conversion_func = conversionDict[val_t[1]][target_unit]
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] ERROR weewx.restx: *** KeyError: 'mm_per_day'
May 28 11:30:59 pi2weewx python3[1673]: weewx[1673] CRITICAL weewx.restx: MQTT: Thread terminating. Reason: 'mm_per_day'

As far I understand ET is a rate in mm_per_day unit and it is supported in this commit. I had to set it (units = mm) to make it work
Thanks!!

Tom Keffer

unread,
May 28, 2023, 3:41:58 PM5/28/23
to weewx...@googlegroups.com
In an archive record, ET is the amount of evaporation over the archive interval. So, it's an absolute quantity, like mm, not a rate, like mm/day. Think of it as anti-rain. You have rain measured in mm, just like ET.

Don't know anything about MQTT.

--
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/3d8d240d-4fda-43d7-bae4-a83e2135da38n%40googlegroups.com.

gjr80

unread,
May 28, 2023, 4:10:25 PM5/28/23
to weewx-user
What station/driver are you using? It may be that your station/driver do not emit windGust and windGustDir. If you don't know whether it does emit them you can get a quick indication by running running WeeWX directly, if your station does emit them windGust and windGustDir will appear in loop packets/archive records. If windGust and windGustDir are not they you may have an issue, but most likely it is because your station/driver does not emit them.

Gary

vince

unread,
May 28, 2023, 5:43:40 PM5/28/23
to weewx-user
Use mosquitto_sub in a shell window to subscribe to your weewx/loop topic and see what it emits.  It might be a few minutes before you see anything.

# mosquitto_sub -h localhost -u usr -P pwd -t weewx/loop

HoracioDos

unread,
May 28, 2023, 9:02:32 PM5/28/23
to weewx-user
Hello gjr80.
These are loop and archive packets for a WS3080 (FineoffsetUSB driver). I replaced batteries for the external unit today and the anemometer and the vane are not connected right now. But measurements (winGustDir and winDir are there) Perhaps mqqt uploader dismisses them because of their None value, but it used to show degree_compass or ordinal_compass values.

sudo weewxd ./weewx.conf
Type beaufort has been deprecated. Use unit beaufort instead.
LOOP:   2023-05-28 21:35:56 -03 (1685320556) 'altimeter': '1028.8271485350715', 'appTemp': '20.901397238047462', 'barometer': '1028.664390950742', 'beaufort': '0', 'cloudbase': '955.0783561
23699', 'dateTime': '1685320556', 'delay': '3', 'dewpoint': '12.586215280280845', 'ET': 'None', 'heatindex': '19.78444444444445', 'humidex': '22.67031814034537', 'inDewpoint': '11.515064192
304733', 'inHumidity': '54.0', 'inTemp': '21.200000000000003', 'maxSolarRad': '0.0', 'outHumidity': '62.0', 'outTemp': '20.1', 'outTempBatteryStatus': '0', 'pressure': '1024.0', 'ptr': '257
36', 'radiation': '0.0', 'rain': '0.0', 'rainRate': '0.0', 'rainTotal': '0.0', 'rxCheckPercent': '100', 'status': '0', 'usUnits': '16', 'UV': '0.0', 'windchill': '20.100000000000005', 'wind
Dir': 'None', 'windGust': '0.0', 'windGustDir': 'None', 'windrun': 'None', 'windSpeed': '0.0'

REC:    2023-05-28 21:35:00 -03 (1685320500) 'altimeter': '1028.751859099341', 'appTemp': '20.901397238047462', 'barometer': '1028.5890493205457', 'beaufort': '0.0', 'cloudbase': '955.07835
6123699', 'dateTime': '1685320500', 'delay': '1.0', 'dewpoint': '12.586215280280845', 'ET': '0.0', 'heatindex': '19.78444444444445', 'humidex': '22.67031814034537', 'inDewpoint': '11.491899
274493772', 'inHumidity': '54.0', 'inTemp': '21.175000000000004', 'interval': '5.0', 'maxSolarRad': '0.0', 'outHumidity': '62.0', 'outTemp': '20.1', 'outTempBatteryStatus': '0.0', 'pressure
': '1023.9250000000001', 'ptr': '25736.0', 'radiation': '0.0', 'rain': '0.0', 'rainRate': '0.0', 'rainTotal': '0.0', 'rxCheckPercent': '100.0', 'status': '0.0', 'usUnits': '16', 'UV': '0.0'
, 'windchill': '20.100000000000005', 'windDir': 'None', 'windGust': '0.0', 'windGustDir': 'None', 'windrun': '0.0', 'windSpeed': '0.0'


This is an example of the ZABBIX-Sender plugin and binding is set to "archive" only. 
 
May 28 21:25:56 pi2weewx python3[6443]: weewx[6443] DEBUG user.zbxsender: pi2weewx weewx_inHumidity 54.0
May 28 21:25:56 pi2weewx python3[6443]: weewx[6443] DEBUG user.zbxsender: pi2weewx weewx_inTemp 21.200000000000003
May 28 21:25:56 pi2weewx python3[6443]: weewx[6443] DEBUG user.zbxsender: pi2weewx weewx_outHumidity 62.0
May 28 21:25:56 pi2weewx python3[6443]: weewx[6443] DEBUG user.zbxsender: pi2weewx weewx_outTemp 20.1
May 28 21:25:56 pi2weewx python3[6443]: weewx[6443] DEBUG user.zbxsender: pi2weewx weewx_pressure 1024.0000000000002
May 28 21:25:56 pi2weewx python3[6443]: weewx[6443] DEBUG user.zbxsender: pi2weewx weewx_windSpeed 0.0
May 28 21:25:56 pi2weewx python3[6443]: weewx[6443] DEBUG user.zbxsender: pi2weewx weewx_windDir N/A
May 28 21:25:56 pi2weewx python3[6443]: weewx[6443] DEBUG user.zbxsender: pi2weewx weewx_windGust 0.0
May 28 21:25:56 pi2weewx python3[6443]: weewx[6443] DEBUG user.zbxsender: pi2weewx weewx_windGustDir N/A
May 28 21:25:56 pi2weewx python3[6443]: weewx[6443] DEBUG user.zbxsender: pi2weewx weewx_rain 0.0
May 28 21:25:56 pi2weewx python3[6443]: weewx[6443] DEBUG user.zbxsender: pi2weewx weewx_radiation 0.0


I want to replace ZBX sender plugin by enabling mqtt uploader and getting data from ZABBIX server directly through mosquitto broker
Thanks!

vince

unread,
May 28, 2023, 9:05:15 PM5/28/23
to weewx-user
Kinda impossible to convert 'None' to a number.  That's your issue.

HoracioDos

unread,
May 28, 2023, 9:18:21 PM5/28/23
to weewx-user
Hello Tom. Thanks for your answer. I understood all wrong when I read issue #160 and its commit

Thanks  again for clearing things up

HoracioDos

unread,
May 28, 2023, 9:34:22 PM5/28/23
to weewx-user
Hello Vince.
I think it should work if I want to convert to ordinal_compass. This a section from ZBX-Sender plugin where windir and winGustDir values are converted to ordinal_compass.  I get  "N/A" = None
My knowledge is quite limited to analize this problem in depth. I'm going to connect things again and report back.  

    def send_data(self, packet):
         pu = packet.get(self.unit_system)
         s = ""
         f = Formatter()
         for key,value in packet.items():
             if key == 'windDir':
                vt = ValueTuple(value, 'degree_compass', 'group_direction')
                new_value = f.to_ordinal_compass(vt)
             elif key == 'windGustDir':
                vt = ValueTuple(value, 'degree_compass', 'group_direction')
                new_value = f.to_ordinal_compass(vt)
             else:
                new_value = str(value)
             l=self.host + " " + self.prefix+key + " " + new_value + "\n"
             s+=l
             if weewx.debug >= 1:
                logdbg(l)

Thanks!!

On Sunday, May 28, 2023 at 10:05:15 PM UTC-3 vince wrote:
Kinda impossible to convert 'None' to a number.  That's your issue.

On Sunday, May 28, 2023 at 6:02:32 PM UTC-7 HoracioDos wrote:
Hello gjr80.
These are loop and archive packets for a WS3080 (FineoffsetUSB driver). I replaced batteries for the external unit today and the anemometer and the vane are not connected right now. But measurements (winGustDir and winDir are there) Perhaps mqqt uploader dismisses them because of their None value, but it used to show degree_compass or ordinal_compass values.
........

gjr80

unread,
May 29, 2023, 7:53:40 PM5/29/23
to weewx-user
My apologies, you said windDir and windGustDir and I read windGust and windGustDir. Vince is exactly right; the MQTT uploader ignores fields whose value is None. If you want to change this behaviour you need to modify the MQTT uploader code. If you convert to ordinal compass points None values will come back as a string 'N/A'.

Gary

Horacio

unread,
Jun 4, 2023, 11:42:12 AM6/4/23
to weewx...@googlegroups.com
Hello.
I connected the wind vane and the anemometer and I get readings but
mqtt uploader cancels if I set:

[[[[windDir]]]]
name = windDir_ordinal
units= ordinal_compass
[[[[windGustDir]]]]
name = windGustDir_ordinal
units= ordinal_compass

Jun 04 11:50:13 pi2weewx python3[5961]: weewx[5961] ERROR weewx.restx:
*** Traceback (most recent call last):
Jun 04 11:50:13 pi2weewx python3[5961]: weewx[5961] ERROR weewx.restx:
*** File "/usr/share/weewx/weewx/restx.py", line 382, in run_loop
Jun 04 11:50:13 pi2weewx python3[5961]: weewx[5961] ERROR weewx.restx:
*** self.process_record(_record, dbmanager)
Jun 04 11:50:13 pi2weewx python3[5961]: weewx[5961] ERROR weewx.restx:
*** File "/usr/share/weewx/user/mqtt.py", line 476, in
process_record
Jun 04 11:50:13 pi2weewx python3[5961]: weewx[5961] ERROR weewx.restx:
*** data = self.filter_data(record)
Jun 04 11:50:13 pi2weewx python3[5961]: weewx[5961] ERROR weewx.restx:
*** File "/usr/share/weewx/user/mqtt.py", line 455, in filter_data
Jun 04 11:50:13 pi2weewx python3[5961]: weewx[5961] ERROR weewx.restx:
*** v = weewx.units.convert(from_t, to_units)[0]
Jun 04 11:50:13 pi2weewx python3[5961]: weewx[5961] ERROR weewx.restx:
*** File "/usr/share/weewx/weewx/units.py", line 1454, in convert
Jun 04 11:50:13 pi2weewx python3[5961]: weewx[5961] ERROR weewx.restx:
*** conversion_func = conversionDict[val_t[1]][target_unit]
Jun 04 11:50:13 pi2weewx python3[5961]: weewx[5961] ERROR weewx.restx:
*** KeyError: 'degree_compass'
Jun 04 11:50:13 pi2weewx python3[5961]: weewx[5961] CRITICAL
weewx.restx: MQTT: Thread terminating. Reason: 'degree_compass'

and it works fine with this config.

[[[[windDir]]]]
name = windDir_ordinal
units= degree_compass
[[[[windGustDir]]]]
name = windGustDir_ordinal
units= degree_compass

If I'm not mistaken, ordinal_compass is a valid unit.
Thanks!
> --
> You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/kh2LOJ5b3C4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/bbd793aa-1010-4bcf-b1af-81df16f0a76bn%40googlegroups.com.

gjr80

unread,
Jun 4, 2023, 12:48:19 PM6/4/23
to weewx-user
Unfortunately you are mistaken, ordinal_compass is not a WeeWX unit, rather it is a formatting option. The reason you are seeing the error is that WeeWX does not have any unit conversion functions defined for degree_compass units. Impossible to say much more without knowing what code you are using/changes you have made. Suffice to say that anything that attempts to explicitly or implicitly force a unit conversion from degree_compass will fail with a similar error.

Gary 

Horacio

unread,
Jun 4, 2023, 1:20:47 PM6/4/23
to weewx...@googlegroups.com
Hello! Point taken. My mistake! Thank you very much for clarifying this matter.
> To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/25ac1b5d-5a5e-4228-b40d-1d6f8d772eben%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages