MQTT Belchertown server_url Syntax?

155 views
Skip to first unread message

Geni

unread,
Mar 12, 2022, 6:23:16 AM3/12/22
to weewx-user
I have a local MQTT broker Mosquitto on a Synology (Docker image).
With Tasmotta flashed switches this works fine

I use this extension https://github.com/matthewwall/weewx-mqtt

What should be the syntax for the server_url in weewx?
    [[MQTT]]
        server_url = 192.168.56.1:1883/
        topic = weather
        unit_system = METRIC
        binding = loop, archive
        aggregation = aggregate


In my attempts there were the following errors
Mar 12 10:52:09 Wetter-Raspi weewx[12110] ERROR weewx.restx: ***   File "/usr/share/weewx/weewx/restx.py", line 385, in run_loop
Mar 12 10:52:09 Wetter-Raspi weewx[12110] ERROR weewx.restx: ***     self.process_record(_record, dbmanager)
Mar 12 10:52:09 Wetter-Raspi weewx[12110] ERROR weewx.restx: ***   File "/usr/share/weewx/user/mqtt.py", line 494, in process_record
Mar 12 10:52:09 Wetter-Raspi weewx[12110] ERROR weewx.restx: ***     mc.connect(url.hostname, url.port)
Mar 12 10:52:09 Wetter-Raspi weewx[12110] ERROR weewx.restx: ***   File "/usr/lib/python3/dist-packages/paho/mqtt/client.py", line 838, in connect
Mar 12 10:52:09 Wetter-Raspi weewx[12110] ERROR weewx.restx: ***     self.connect_async(host, port, keepalive, bind_address)
Mar 12 10:52:09 Wetter-Raspi weewx[12110] ERROR weewx.restx: ***   File "/usr/lib/python3/dist-packages/paho/mqtt/client.py", line 893, in connect_async
Mar 12 10:52:09 Wetter-Raspi weewx[12110] ERROR weewx.restx: ***     raise ValueError('Invalid host.')
Mar 12 10:52:09 Wetter-Raspi weewx[12110] ERROR weewx.restx: *** ValueError: Invalid host.
Mar 12 10:52:09 Wetter-Raspi weewx[12110] CRITICAL weewx.restx: MQTT: Thread terminating. Reason: Invalid host.

Does this work with my chosen MQTT extension?
Are there any better variants for this?

Thank you in advanced

Michael

unread,
Mar 12, 2022, 8:11:19 AM3/12/22
to weewx-user
Hi,

try it with this syntax:

Michael

Geni

unread,
Mar 12, 2022, 10:17:43 AM3/12/22
to weewx-user
Not much better, I had already tried
Mar 12 16:12:13 Wetter-Raspi weewx[16406] DEBUG user.mqtt: Failed upload attempt 1: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 12 16:12:18 Wetter-Raspi weewx[16406] DEBUG user.mqtt: Failed upload attempt 2: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 12 16:12:23 Wetter-Raspi weewx[16406] DEBUG user.mqtt: Failed upload attempt 3: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 12 16:12:28 Wetter-Raspi weewx[16406] ERROR weewx.restx: MQTT: Failed to publish record 2022-03-12 16:12:13 CET (1647097933): Failed upload after 3 tries
Mar 12 16:12:28 Wetter-Raspi weewx[16406] DEBUG user.mqtt: Failed upload attempt 1: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 12 16:12:33 Wetter-Raspi weewx[16406] DEBUG user.mqtt: Failed upload attempt 2: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 12 16:12:38 Wetter-Raspi weewx[16406] DEBUG user.mqtt: Failed upload attempt 3: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 12 16:12:43 Wetter-Raspi weewx[16406] ERROR weewx.restx: MQTT: Failed to publish record 2022-03-12 16:12:13 CET (1647097933): Failed upload after 3 tries
Mar 12 16:12:43 Wetter-Raspi weewx[16406] DEBUG user.mqtt: Failed upload attempt 1: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 12 16:12:48 Wetter-Raspi weewx[16406] DEBUG user.mqtt: Failed upload attempt 2: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 12 16:12:53 Wetter-Raspi weewx[16406] DEBUG user.mqtt: Failed upload attempt 3: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 12 16:12:58 Wetter-Raspi weewx[16406] ERROR weewx.restx: MQTT: Failed to publish record 2022-03-12 16:12:15 CET (1647097935): Failed upload after 3 tries
Mar 12 16:12:58 Wetter-Raspi weewx[16406] DEBUG user.mqtt: Failed upload attempt 1: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt

Michael

unread,
Mar 12, 2022, 11:38:01 AM3/12/22
to weewx-user
Not better, but different ;)
In the last error message the MQTT were not sent by weewx at all.
With the new error message the MQTT data are not accepted by the MQTT server. Is the user you entered in the weewx configuration also allowed to receive the data on the MQTT server?
Here you can find a good description about MQTT and weewx: https://www.woellsdorf-wetter.de/software/mosquitto.html

Michael

Geni

unread,
Mar 14, 2022, 8:34:49 AM3/14/22
to weewx-user
I have installed the Mosquitt-Broker on a Raspi 3, there are the problems with the localhost since Mosquitto 2.x and I have not found a solution that works correctly. MQTT-Fehler02.txt.jpg

With the MQTT.fx the test works now, although the message above says something else.

On my weather raspi the following message comes up:
MQTT-Fehler01.txt.jpg

Question: Can weewx and the Mosquitto run on a Raspi 3+?

Geni

vince

unread,
Mar 14, 2022, 1:17:10 PM3/14/22
to weewx-user
Yes of course they can run on any model pi.

Google the message you highlighted in yellow and red for many threads about this.

In v2 the default is to listen only on localhost so you need to configure it to listen on all interfaces.  See https://mosquitto.org/man/mosquitto-conf-5.html and the 'listener' section.  Set your bind_address to 0.0.0.0 to listen on all interfaces.

Geni

unread,
Mar 15, 2022, 10:56:04 AM3/15/22
to weewx-user
I have now installed the Mosquitto on the weewx-raspi that still has Buster Lite and there was still the version 1.5.7 installed. The error is only " Address already in use".

pi@Wetter-Raspi:~$ mosquitto -v
1647355421: mosquitto version 1.5.7 starting
1647355421: Using default config.
1647355421: Opening ipv4 listen socket on port 1883.
1647355421: Error: Address already in use

weewx produces the following:

Mar 15 15:38:36 Wetter-Raspi weewx[1491] INFO weewx.manager: Starting backfill of daily summaries
Mar 15 15:38:36 Wetter-Raspi weewx[1491] INFO weewx.manager: Daily summaries up to date
Mar 15 15:38:36 Wetter-Raspi weewx[1491] DEBUG weewx.drivers.vantage: Getting archive packets since 2022-03-15 15:30:00 CET (1647354600)
Mar 15 15:38:36 Wetter-Raspi weewx[1491] DEBUG weewx.drivers.vantage: Gentle wake up of console successful
Mar 15 15:38:36 Wetter-Raspi weewx[1491] DEBUG weewx.drivers.vantage: Retrieving 0 page(s); starting index= 0
Mar 15 15:38:36 Wetter-Raspi weewx[1491] INFO weewx.engine: Starting main packet loop.
Mar 15 15:38:36 Wetter-Raspi weewx[1491] DEBUG weewx.drivers.vantage: Gentle wake up of console successful
Mar 15 15:38:36 Wetter-Raspi weewx[1491] DEBUG weewx.drivers.vantage: Requesting 200 LOOP packets.
Mar 15 15:38:36 Wetter-Raspi weewx[1491] DEBUG weewx.drivers.vantage: Gentle wake up of console successful
Mar 15 15:38:37 Wetter-Raspi weewx[1491] DEBUG user.mqtt: Failed upload attempt 1: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 15 15:38:42 Wetter-Raspi weewx[1491] DEBUG user.mqtt: Failed upload attempt 2: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 15 15:38:47 Wetter-Raspi weewx[1491] DEBUG user.mqtt: Failed upload attempt 3: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 15 15:38:52 Wetter-Raspi weewx[1491] ERROR weewx.restx: MQTT: Failed to publish record 2022-03-15 15:38:37 CET (1647355117): Failed upload after 3 tries
Mar 15 15:38:52 Wetter-Raspi weewx[1491] DEBUG user.mqtt: Failed upload attempt 1: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 15 15:38:57 Wetter-Raspi weewx[1491] DEBUG user.mqtt: Failed upload attempt 2: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 15 15:39:01 Wetter-Raspi CRON[1514]: (pi) CMD (sudo wget -q http://alarm.meteocentrale.ch/images/map/schweiz_index.png -O /home/pi/wetter/meteo/uwz.png)
Mar 15 15:39:01 Wetter-Raspi automount[535]: key ".config" not found in map source(s).
Mar 15 15:39:02 Wetter-Raspi weewx[1491] DEBUG user.mqtt: Failed upload attempt 3: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt
Mar 15 15:39:07 Wetter-Raspi weewx[1491] ERROR weewx.restx: MQTT: Failed to publish record 2022-03-15 15:38:37 CET (1647355117): Failed upload after 3 tries

I think the error comes from "https://github.com/matthewwall/weewx-mqtt/archive/master.zip".
This has not been maintained for more than 2 years, is there an alternative?

The function test with MQTT.fx works fine

How can I narrow down the error?

Geni

vince

unread,
Mar 15, 2022, 1:16:10 PM3/15/22
to weewx-user
On Tuesday, March 15, 2022 at 7:56:04 AM UTC-7 Geni wrote:
I have now installed the Mosquitto on the weewx-raspi that still has Buster Lite and there was still the version 1.5.7 installed. The error is only " Address already in use".

pi@Wetter-Raspi:~$ mosquitto -v
1647355421: mosquitto version 1.5.7 starting
1647355421: Using default config.
1647355421: Opening ipv4 listen socket on port 1883.
1647355421: Error: Address already in use


You have the mosquitto MQTT server already listening, so this is normal.
Run "sudo netstat -tupln" and you will see the broker is listening.

A simple MQTT test is to use mosquitto_sub and mosquitto_pub in two shell windows.

In the first window:        "mosquitto_sub -h x.x.x.x -t testing
In the second window:  "mosquitto_pub -h x.x.x.x -t testing -m testing123"

(Use your ip address instead of x.x.x.x in the commands above)

 

Geni

unread,
Mar 16, 2022, 6:57:57 AM3/16/22
to weewx-user
The test works only if user and password are specified
mosquitto_sub -h 192.168.99.99 -t weather/#
mosquitto_pub -h 192.168.99.99 -u uuuu -P pwpwpw -t weather -m Testing123


But nothing arrives in Mosquitto from weewx. In the syslog:
MQTT-Fehler03.txt.jpg
Reply all
Reply to author
Forward
0 new messages