mr-manuel / venus-os_dbus-mqtt-temperature

This Venus OS driver gets the data from MQTT and displays it as temperature sensor.
MIT License
8 stars 0 forks source link

Same MQTT client ID #1

Closed michalemmer closed 3 weeks ago

michalemmer commented 4 weeks ago

Hello Manuel, I use dbus-mqtt-temperature to read temperature sensors, which are distributed in the house, via MQTT in VenusOS. This looks good so far, but the script/program loses the connection to the MQTT broker (Mosquito) from time to time. See log. After the automatic restart of the script, the connection is re-established. But the messages every 2 seconds are strange. I have the same behavior with VenusOS 3.31 and 3.41 both on Raspberry Pi 4.

2024-08-17 19:10:27.479863500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:27.479868500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:29.503916500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:29.503922500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:31.524644500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:31.524754500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:33.545377500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:33.545674500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:35.569849500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:35.570203500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:37.591652500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:37.592059500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:37.852898500 ERROR:root:Driver stopped. Timeout of 90 seconds exceeded, since no new MQTT message was received in this time.
2024-08-17 19:10:37.969605500 *** starting dbus-mqtt-temperature ***
2024-08-17 19:10:39.971206500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:39.971943500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:41.993251500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:41.993257500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:44.013971500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:44.014277500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:46.038946500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:46.039233500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:48.061113500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:48.061469500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:50.088468500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:50.088772500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:52.109185500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:52.109481500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:54.130847500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:54.131213500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:56.155770500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:56.156118500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:10:58.180865500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:10:58.181222500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect
2024-08-17 19:11:00.205951500 WARNING:root:MQTT client: Got disconnected
2024-08-17 19:11:00.206251500 WARNING:root:MQTT client: Unexpected MQTT disconnection. Will auto-reconnect

The temperature values are updated every 30 seconds on the MQTT broker.

What could be the problem. Thanks. Michael

mr-manuel commented 4 weeks ago

Best would be to check the MQTT Broker log. It could be that all your MQTT temperature sensors have the same MQTT client ID. Have they a different device instance in the config file?

https://github.com/mr-manuel/venus-os_dbus-mqtt-temperature/blob/feb2a3a384396ac978b1ce8c94d353ea13d99d1b/dbus-mqtt-temperature/config.sample.ini#L20

michalemmer commented 4 weeks ago

Thanks for the tip. Yes, it was the problem with the same device_instance. But not on the same VenusOS. I have 2 VenusOS installations in parallel, both of which have subscribed to the same topic on my MQTT broker. The same device_instance was set in both config files. After changing the device_instance in the config file of one of the two installations, the error messages disappeared. In the Mosquito log, you can see that the client ID‘s of both VenusOS installations are identical. See the different IP addresses in the log. Perhaps you could add a prefix or suffix for the client ID in the config file or code in the host name of the VenusOS. Just two ideas if you have several VenusOS in parallel and use the same device_instance. Thanks again for your help.

1723967760: Client MqttTemperature_100 already connected, closing old connection. 1723967760: New client connected from 192.xxx.xxx.186:33821 as MqttTemperature_100 (p2, c1, k60). 1723967761: Client MqttTemperature_100 already connected, closing old connection. 1723967761: New client connected from 192.xxx.xxx.169:49845 as MqttTemperature_100 (p2, c1, k60).

mr-manuel commented 4 weeks ago

I will add the VRM ID to the MQTT client name.

mr-manuel commented 3 weeks ago

This was fixed with v0.0.4.