Bug v4.17.0 Zigbee2MQTT?

One option would be to enable persistence in Mosquitto:

What do you think?

That seems to make sense to me!
I just hope we won’t store too much.
Otherwise we should see if there’s a way to set a maximum storage size…

Persistence only stores retained messages (to be verified), so it won’t store much, I think :slight_smile:

1 Like

I may be looking at the problem the wrong way, but wouldn’t it be up to Gladys to store that information?

Indeed, that’s an option. That said, wouldn’t it be a shame to re-implement this behavior, which is probably used by Zigbee2mqtt in several places, where Mosquitto handles it natively?

I’d be more in favor of enabling persistence, which would avoid other bugs in the future if Zigbee2mqtt starts using that feature elsewhere.

So I started a PR on the topic:

I took the opportunity to remove the shell script that launched the container and switch to Node code. At least it’s tested now, and more reliable.

I also took the opportunity to address this issue:

It greatly speeds up tests!

1 Like

Did you generate a test image?

Yes, I’ve partially tested it for now but it seems to work!

Docker image:

gladysassistant/gladys:fix-zigbee2mqtt-disconnect-bug

Tested in real conditions, the migration worked successfully!

2023-04-07T04:20:42+0200 \u003cinfo\u003e init.js:38 (Zigbee2mqttManager.init) Zigbee2mqtt USB dongle attached to /dev/ttyUSB0
2023-04-07T04:20:42+0200 \u003cinfo\u003e checkForContainerUpdates.js:14 (Zigbee2mqttManager.checkForContainerUpdates) Checking for current installed versions and required updates...
2023-04-07T04:20:42+0200 \u003cinfo\u003e checkForContainerUpdates.js:18 (Zigbee2mqttManager.checkForContainerUpdates) MQTT container: update #3 of the container required...
2023-04-07T04:20:42+0200 \u003cinfo\u003e checkForContainerUpdates.js:35 (Zigbee2mqttManager.checkForContainerUpdates) MQTT container: update #3 of the container done
2023-04-07T04:20:42+0200 \u003cinfo\u003e checkForContainerUpdates.js:40 (Zigbee2mqttManager.checkForContainerUpdates) Z2M container: update #3 of the container required...
2023-04-07T04:20:43+0200 \u003cinfo\u003e checkForContainerUpdates.js:57 (Zigbee2mqttManager.checkForContainerUpdates) Z2M container: update #3 of the container done
2023-04-07T04:20:43+0200 \u003cinfo\u003e installMqttContainer.js:29 (Zigbee2mqttManager.installMqttContainer) MQTT broker is being installed as Docker container...
2023-04-07T04:20:43+0200 \u003cinfo\u003e installMqttContainer.js:30 (Zigbee2mqttManager.installMqttContainer) Pulling eclipse-mosquitto:2 image...
2023-04-07T04:20:46+0200 \u003cinfo\u003e installMqttContainer.js:34 (Zigbee2mqttManager.installMqttContainer) Preparing broker environment...
2023-04-07T04:20:46+0200 \u003cinfo\u003e installMqttContainer.js:41 (Zigbee2mqttManager.installMqttContainer) Writing Mosquitto config file in /var/lib/gladysassistant/zigbee2mqtt/mqtt/mosquitto.conf
2023-04-07T04:20:46+0200 \u003cinfo\u003e installMqttContainer.js:50 (Zigbee2mqttManager.installMqttContainer) Creating container with data in "/var/lib/gladysassistant" on host...
2023-04-07T04:20:47+0200 \u003cinfo\u003e installMqttContainer.js:64 (Zigbee2mqttManager.installMqttContainer) MQTT broker is restarting...
2023-04-07T04:20:52+0200 \u003cinfo\u003e installMqttContainer.js:72 (Zigbee2mqttManager.installMqttContainer) Creating user/pass...
2023-04-07T04:20:53+0200 \u003cinfo\u003e installMqttContainer.js:81 (Zigbee2mqttManager.installMqttContainer) MQTT broker is restarting...
2023-04-07T04:20:59+0200 \u003cinfo\u003e installMqttContainer.js:86 (Zigbee2mqttManager.installMqttContainer) MQTT broker container successfully started and configured
2023-04-07T04:20:59+0200 \u003cinfo\u003e installZ2mContainer.js:34 (Zigbee2mqttManager.installZ2mContainer) Zigbee2mqtt is being installed as Docker container...
2023-04-07T04:20:59+0200 \u003cinfo\u003e installZ2mContainer.js:35 (Zigbee2mqttManager.installZ2mContainer) Pulling koenkk/zigbee2mqtt:latest image...
2023-04-07T04:21:02+0200 \u003cinfo\u003e installZ2mContainer.js:38 (Zigbee2mqttManager.installZ2mContainer) Configuration of Device /dev/ttyUSB0
2023-04-07T04:21:02+0200 \u003cinfo\u003e installZ2mContainer.js:43 (Zigbee2mqttManager.installZ2mContainer) Creation of container...
2023-04-07T04:21:03+0200 \u003cinfo\u003e installZ2mContainer.js:46 (Zigbee2mqttManager.installZ2mContainer) Zigbee2mqtt successfully installed and configured as Docker container
2023-04-07T04:21:03+0200 \u003cinfo\u003e installZ2mContainer.js:59 (Zigbee2mqttManager.installZ2mContainer) Preparing Zigbee2mqtt environment...
2023-04-07T04:21:03+0200 \u003cinfo\u003e installZ2mContainer.js:72 (Zigbee2mqttManager.installZ2mContainer) Zigbee2mqtt container is starting...
2023-04-07T04:21:08+0200 \u003cinfo\u003e installZ2mContainer.js:78 (Zigbee2mqttManager.installZ2mContainer) Zigbee2mqtt container successfully started
2023-04-07T04:21:08+0200 \u003cinfo\u003e connect.js:14 (Zigbee2mqttManager.connect) Connecting Gladys to mqtt://localhost:1884 MQTT broker...
2023-04-07T04:21:09+0200 \u003cinfo\u003e connect.js:24 (MqttClient.\u003canonymous\u003e) Connected to MQTT container mqtt://localhost:1884
2023-04-07T04:21:09+0200 \u003cinfo\u003e subscribe.js:12 (Zigbee2mqttManager.subscribe) Subscribing to MQTT topic zigbee2mqtt/#

Directory /var/lib/gladysassistant/zigbee2mqtt/mqtt:

Restarting Mosquitto no longer seems to bother Gladys! :slight_smile:

3 Likes

@AlexTrovato In principle there’s no risk of the disk growing noticeably:

We’ll also gain reliability since if Mosquitto restarts while Gladys is offline and there are messages in the broker, we won’t lose them :slight_smile:

7 Likes

Bug fixed in Gladys Assistant v4.20:

1 Like