weewx-mqtt configuration wrong?

118 views
Skip to first unread message

Stefan Ferber

unread,
Dec 28, 2020, 12:52:54 PM12/28/20
to weewx-user
Just installed the mqtt extension https://github.com/weewx/weewx/wiki/mqtt and configured the /etc/weewx/weewx.conf file

    [[MQTT]]
        server_url = "mqtt://mqtt-local:<password-hidden-here>@homeassistant.local:1883"
        topic = weewx
        unit_system = METRIC

But the broker does not receive any message on this topic.

Checking the log files everything looks fine:

Dec 28 18:34:49 raspberrypi systemd[1]: Starting LSB: weewx weather system...
Dec 28 18:34:52 raspberrypi weewx[31732] INFO __main__: Initializing weewx version 4.2.0
Dec 28 18:34:52 raspberrypi weewx[31732] INFO __main__: Using Python 3.7.3 (default, Dec 20 2019, 18:57:59) #012[GCC 8.3.0]
Dec 28 18:34:52 raspberrypi weewx[31732] INFO __main__: Platform Linux-4.19.97+-armv6l-with-debian-10.3
Dec 28 18:34:52 raspberrypi weewx[31732] INFO __main__: Locale is 'de_DE.UTF-8'
Dec 28 18:34:52 raspberrypi weewx[31732] INFO __main__: PID file is /var/run/weewx.pid
Dec 28 18:34:52 raspberrypi weewx[31720]: Starting weewx weather system: weewx.
Dec 28 18:34:52 raspberrypi systemd[1]: Started LSB: weewx weather system.
Dec 28 18:34:52 raspberrypi weewx[31736] INFO __main__: Using configuration file /etc/weewx/weewx.conf
Dec 28 18:34:53 raspberrypi weewx[31736] INFO __main__: Debug is 0
Dec 28 18:34:53 raspberrypi weewx[31736] INFO weewx.engine: Loading station type TE923 (weewx.drivers.te923)
Dec 28 18:34:53 raspberrypi weewx[31736] INFO weewx.drivers.te923: driver version is 0.41.1
Dec 28 18:34:53 raspberrypi weewx[31736] INFO weewx.drivers.te923: polling interval is 10
Dec 28 18:34:53 raspberrypi weewx[31736] INFO weewx.drivers.te923: sensor map is {'windLinkStatus': 'link_wind', 'windBatteryStatus': 'bat_wind', 'rainLinkStatus': 'link_rain', 'rainBatteryStatus': 'bat_rain', 'uvLinkStatus': 'link_uv', 'uvBatteryStatus': 'bat_uv', 'inTemp': 't_in', 'inHumidity': 'h_in', 'outTemp': 't_1', 'outHumidity': 'h_1', 'outTempBatteryStatus': 'bat_1', 'outLinkStatus': 'link_1', 'extraTemp1': 't_2', 'extraHumid1': 'h_2', 'extraBatteryStatus1': 'bat_2', 'extraLinkStatus1': 'link_2', 'extraTemp2': 't_3', 'extraHumid2': 'h_3', 'extraBatteryStatus2': 'bat_3', 'extraLinkStatus2': 'link_3', 'extraTemp3': 't_4', 'extraHumid3': 'h_4', 'extraBatteryStatus3': 'bat_4', 'extraLinkStatus3': 'link_4', 'extraTemp4': 't_5', 'extraHumid4': 'h_5', 'extraBatteryStatus4': 'bat_5', 'extraLinkStatus4': 'link_5'}
Dec 28 18:34:53 raspberrypi weewx[31736] INFO weewx.drivers.te923: Found device on USB bus= device=
Dec 28 18:34:55 raspberrypi weewx[31736] ERROR weewx.drivers.te923: Failed attempt 1 of 5 to read data: [Errno 110] Operation timed out
Dec 28 18:34:58 raspberrypi weewx[31736] INFO weewx.drivers.te923: logger capacity 208 records
Dec 28 18:34:58 raspberrypi weewx[31736] INFO weewx.drivers.te923: station time is 1582844400.0, computer time is 1609176898
Dec 28 18:34:58 raspberrypi weewx[31736] INFO weewx.engine: StdConvert target unit is 0x1
Dec 28 18:34:58 raspberrypi weewx[31736] INFO weewx.engine: Archive will use data binding wx_binding
Dec 28 18:34:58 raspberrypi weewx[31736] INFO weewx.engine: Record generation will be attempted in 'hardware'
Dec 28 18:34:58 raspberrypi weewx[31736] INFO weewx.engine: Using archive interval of 300 seconds (specified in weewx configuration)
Dec 28 18:34:59 raspberrypi weewx[31736] INFO weewx.restx: StationRegistry: Registration not requested.
Dec 28 18:34:59 raspberrypi weewx[31736] INFO weewx.restx: Wunderground-PWS: Data for station IBADENWR90 will be posted
Dec 28 18:34:59 raspberrypi weewx[31736] INFO weewx.restx: PWSweather: Posting not enabled.
Dec 28 18:34:59 raspberrypi weewx[31736] INFO weewx.restx: CWOP: Posting not enabled.
Dec 28 18:34:59 raspberrypi weewx[31736] INFO weewx.restx: WOW: Posting not enabled.
Dec 28 18:34:59 raspberrypi weewx[31736] INFO weewx.restx: AWEKAS: Posting not enabled.
Dec 28 18:34:59 raspberrypi weewx[31736] INFO user.mqtt: service version is 0.23
Dec 28 18:34:59 raspberrypi weewx[31736] INFO user.mqtt: binding to archive
Dec 28 18:34:59 raspberrypi weewx[31736] INFO user.mqtt: topic is weewx
Dec 28 18:34:59 raspberrypi weewx[31736] INFO user.mqtt: desired unit system is METRIC
Dec 28 18:34:59 raspberrypi weewx[31736] INFO user.mqtt: data will be uploaded to mqtt://mqtt-local:x...@homeassistant.local:1883
Dec 28 18:34:59 raspberrypi weewx[31736] INFO __main__: Starting up weewx version 4.2.0
Dec 28 18:34:59 raspberrypi weewx[31736] INFO weewx.engine: Using binding 'wx_binding' to database 'weewx.sdb'
Dec 28 18:34:59 raspberrypi weewx[31736] INFO weewx.manager: Starting backfill of daily summaries
Dec 28 18:34:59 raspberrypi weewx[31736] INFO weewx.drivers.te923: reading records from logger since 1609176600
Dec 28 18:35:00 raspberrypi weewx[31736] INFO weewx.drivers.te923: read 0 records from logger
Dec 28 18:35:00 raspberrypi weewx[31736] INFO weewx.engine: Starting main packet loop.
 
the "loop" also reports success

Dec 28 18:34:59 raspberrypi weewx[31736] INFO user.mqtt: service version is 0.23
Dec 28 18:34:59 raspberrypi weewx[31736] INFO user.mqtt: binding to archive
Dec 28 18:34:59 raspberrypi weewx[31736] INFO user.mqtt: topic is weewx
Dec 28 18:34:59 raspberrypi weewx[31736] INFO user.mqtt: desired unit system is METRIC
Dec 28 18:34:59 raspberrypi weewx[31736] INFO user.mqtt: data will be uploaded to mqtt://mqtt-local:x...@homeassistant.local:1883

manual testing with same settings works fine:
pi@raspberrypi:~ $ mosquitto_pub -h homeassistant.local -m "my personal weewx message" -t weewx -u mqtt-local -P <password-hidden-here> -d
Client mosqpub|31800-raspberry sending CONNECT
Client mosqpub|31800-raspberry received CONNACK (0)
Client mosqpub|31800-raspberry sending PUBLISH (d0, q0, r0, m1, 'weewx', ... (25 bytes))
Client mosqpub|31800-raspberry sending DISCONNECT

same with root user

pi@raspberrypi:~ $ sudo mosquitto_pub -h homeassistant.local -m "my personal root weewx" -t weewx -u mqtt-local -P <password-hidden-here> -d
Client mosqpub|31809-raspberry sending CONNECT
Client mosqpub|31809-raspberry received CONNACK (0)
Client mosqpub|31809-raspberry sending PUBLISH (d0, q0, r0, m1, 'weewx', ... (22 bytes))
Client mosqpub|31809-raspberry sending DISCONNECT

Any ideas what I did wrong here?

vince

unread,
Dec 28, 2020, 2:07:50 PM12/28/20
to weewx-user
I'd start in weewx.conf by setting debug=1 at the top, and in your MQTT section set log_success=true and log_failure=true.   Then restart weewx and check your logs.

A better test of your MQTT is to publish in one shell and subscribe in another.   Just open two windows.

In one shell:   mosquito_pub -h homeassistant.local -t weewx -u mqtt-local -P <password> -m "hello world" 
In the other:    mosquito_sub -h homeassistant.local -t weewx -u mqtt-local -P <password>

You should see 'hello world' appear in the shell that is subscribing.

bell...@gmail.com

unread,
Dec 28, 2020, 2:47:19 PM12/28/20
to weewx-user
A couple more things to check out.
1. If my memory is correct the mqtt extension publishes ‘aggregate’ (json format) to <topic name>/loop and individual to <topic name>/observation_<units>. So after the simple pub/sub test, try subscribing to weewx/# and see what you get.
2. From your log snippet you are publishing on archive record generation. Which from your log is 300 seconds.  So, will need to wait for this to happen before anything will be published.
rich

Stefan Ferber

unread,
Dec 29, 2020, 2:22:22 AM12/29/20
to weewx-user
Thx for your great hints. The weewx-mqtt configuration was correct. I was listening to the topic weewx but if you read (AND really understand AND follow  ;-) the documentation, it is published on <topic name>/loop and <topic name>/observation_<units>.  
Here is the output of weewx/loop payload arriving every 5 minutes:

{ "dateTime": "1609226100.0", "windLinkStatus": "1.0", "windBatteryStatus": "0.0", "rainLinkStatus": "0.0", "rainBatteryStatus": "0.0", "uvLinkStatus": "1.0", "uvBatteryStatus": "0.0", "inTemp_C": "23.970689655172414", "inHumidity": "38.0", "outTemp_C": "2.603448275862065", "outHumidity": "84.0", "outTempBatteryStatus": "0.0", "outLinkStatus": "0.0", "extraTemp1_C": "23.000000000000025", "extraHumid1": "39.0", "extraBatteryStatus1": "0.0", "extraLinkStatus1": "0.0", "extraTemp2_C": "21.299999999999986", "extraHumid2": "43.0", "extraBatteryStatus2": "0.0", "extraLinkStatus2": "0.0", "extraTemp3_C": "25.165517241379295", "extraHumid3": "65.62068965517241", "extraBatteryStatus3": "0.0", "extraLinkStatus3": "0.0", "extraTemp4_C": "21.62068965517242", "extraHumid4": "43.0", "extraBatteryStatus4": "0.0", "extraLinkStatus4": "0.0", "rainTotal": "218.0166668040001", "rain_cm": "0.0", "barometer_mbar": "948.5258620689654", "forecast": "4.0", "storm": "0.0", "pressure_mbar": "916.376047509162", "altimeter_mbar": "947.8952290346878", "cloudbase_meter": "582.7279829856743", "dewpoint_C": "0.1756150230575394", "heatindex_C": "2.603448275862065", "humidex_C": "2.603448275862065", "inDewpoint_C": "8.76924066086359", "rainRate_cm_per_hour": "0.0", "interval_minute": "5.0", "hourRain_cm": "0.0", "rain24_cm": "0.21166666679999935", "dayRain_cm": "0.1411111112000185", "usUnits": "16.0" }

... the floating point number with 22 digits are little bit overkill.

Thx so much - issue closed ;-)

bell...@gmail.com

unread,
Dec 29, 2020, 9:14:26 AM12/29/20
to weewx-user
Check out the [[[inputs]]] section to format the output.
Reply all
Reply to author
Forward
0 new messages