New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restarting home assistant and mosquitto at the same time leaves zigbee entities unavailable until zigbee2mqtt restarts #9629
Comments
I am seeing this exact same issue, usually with a restart of the VM running Mosquitto/HA. Edit: If HA restarts and Mosquitto is still running, everything works perfectly. I think this is probably a Home Assistant problem. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
Still happens with Home Assistant 2021.11.5 |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
Still happens with Zigbee2MqTT 1.22.2 commit: 414c51f |
@matejdro are you using the availability feature? https://www.zigbee2mqtt.io/guide/configuration/device-availability.html |
From what I can see, no (I never turned it on explicitly and I can't see it in any of the configs). |
@matejdro could you provide the z2m debug log of this? See https://www.zigbee2mqtt.io/guide/usage/debug.html on how to enable debug logging. |
Logs from the first post are already captured with debug enabled. Here it is again:
(also, can you remove the stale label please just in case? It looks like bot did not do it). |
@matejdro what is logged after: |
Nothing. After couple of seconds, usual "Received Zigbee message from ... " will continue, but there are no logs related to the MQTT. |
Can you configure the HA birth/last will topic to Does this change the logging after receiving |
Changed and I got bunch of messages after that:
However, issue still persists. Also, possibly related: home-assistant/core#59647 |
Could you check if the latest-dev fixes this issue? After z2m receives Changes will be available in the dev branch in a few hours from now. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html) |
@Koenkk can you reopen this? It looks like stale tag was not removed for some reason. I did not have the time to check out latest dev build yet. |
Tried out the 1.22.2-dev commit: 93921c6, issue persists. Logs on restart:
|
@matejdro I believe this is a HA issue, as you can see in the logs z2m publishes a online message:
This should make all devices be available in HA, I suggest creating an issue at the HA issue tracker. |
I guess it is up to the HA then. There is already an issue there, albeit it did not appear to gain any traction: home-assistant/core#59647 Thanks. |
@Koenkk continuing discussion from the other thread (home-assistant/core#59647 (comment)): After restarting mosquitto, Could that signal that Z2M is the issue, not the hass? |
@matejdro the availability messages from z2m have a retain flag, so Home Assistant should receive the state on a HA restart. If that is not the case it is a HA bug. |
@matejdro what is the latest known working version? And can you re-confirm that version works? (could also be due to a HA update) |
Went through versions, This is with everything else (config, ha version, mosquitto version) staying the same. |
Could you provide the debug log of 1.27.0 vs latest z2m of this problem? See https://www.zigbee2mqtt.io/guide/usage/debug.html on how to enable debug logging. |
I have been following this issue and experience it as well. @Koenkk Here are the latest logs with z2m experiencing this problem (restarted HA and mosquito at this time). Entities in HA remain unavailable until I restarted z2m (after these logs) I haven't rolled back to try and bisect the issue, so can't confirm or deny if this has always been this way, etc |
Here are logs from 1.27.0: latest z2m logs are on above post (#9629 (comment)) |
Can you check if your MQTT broker is configured to persist retained messages?
|
I do not have persistence enabled (it is off by default) in Eclipse Mosquitto. I would prefer to not be constantly writing to disk for something that I don't feel needs to be written to disk, but will give it a try and then decide if I want to keep it as a long term solution. I will look into enabling it and perform the test. https://mosquitto.org/man/mosquitto-conf-5.html Is there a reason why z2m can't/shouldnt just resend the config messages on mqtt reconnect, if it does at startup? |
I'm with xconverge here, disk persistence was off until now and I don't really want to turn it on (unnecessary disk writing plus I like the idea of MQTT server being restarted gives me a clean slate with all old MQTT data thrown away). Z2M worked without persistence until 1.27.0, so why are the new versions suddenly a problem? |
I run it via docker. The image looks pretty stripped of development dependencies though so unless you have a better idea I will clone and build from source and just run locally (or build an image) I also think that the change looks logical, so if you want to put it in a test or dev build because you are pretty confident and just want it sanity checked, I could do that too |
No need to install dev dependencies, |
That code change did not seem to fix the problem for me unfortunately. The logs and behavior all look similar. I do notice that the topic for each device:
with:
Are not being resent after the mqtt reconnection |
Can you add a |
I realized the timeout wasnt firing Line 110 in f440c86
so I commented out these 2 lines and things seem to work properly now Line 144 in f440c86
Looks like maybe a race condition a bit where we send the reinitialize, start a 2 second timer, and in the meantime we receive the reininitalize and clear the timer so it never fires? |
Yes that is exactly it I think, this is a regression/somewhat of a race condition caused from 6314b86 which was released in 1.27.1 ... I think? |
I propose removing this block entirely from onMessage?
|
I responded in #17891 |
Fixed in #17891 |
Is the fix supposed to be in |
It is not in 1.31.2 and is currently just in the dev build. |
Can confirm that this is not the issue anymore in 1.32.0. Thanks a lot! |
I have a similar problem but only concerns groups. The only solution I have found is to add an entity to each group that is already part of it so that the group entity reappears on the HA side.
in groups.yaml don't change anything. Home Assistant 2023.7.2 Z2M 1.32.1-dev commit: ee1a5f0 Thanks |
Just had the same issue in Z2M 1.32.1. |
This issue appears to be back in 1.34.0. EDIT: It happened once, but I cannot reproduce it anymore. Will try a bit more. |
How to reproduce it (minimal and precise)
docker container restart hass mosquitto
)BUG: All Zigbee2MQTT entities will be unavailable
To fix the problem, I also have to restart Zigbee2MQTT afterwards (restarting from web UI is sufficient).
It is possible that the problem lies on the Home Assistant side, but up until recently I was also using zwavejs2mqtt with mqtt discovery entities and I did not experience that issue with it (only zigbee entities got unavailable).
Debug info
Only thing from the logs is this, which is not particularly useful:
Mosquitto version: 2.0.13
Home Assistant version: 2021.11.3
Zigbee2MQTT version: 1.22.0 commit: 0a1fccf
Adapter hardware: Smartlight CC2652P
Adapter firmware version: 20210708
The text was updated successfully, but these errors were encountered: