-
Notifications
You must be signed in to change notification settings - Fork 639
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
Espurna device unavailable in Homeassistant integration after restart from HS #1637
Comments
Discovery is sent as retained message, so it should survive both both broker (if retained cache is configured) and HA restarts. I tried restarting HA with discovered switch and logs show that it picked up the device instantly. Could it be that the broker deletes "old" retained messages? Another thing to note is that discovery messages are sent only on first successful MQTT client connection: espurna/code/espurna/homeassistant.ino Line 264 in ec4883a
Which can only be changed later by turning HA discovery ON to OFF or vice versa espurna/code/espurna/homeassistant.ino Line 289 in ec4883a
BTW thanks for pointing out the birth message, that is something new to have in mind |
Interesting I'll try do debug the issue further and look where the root of the problem lies. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
I figured out the problem I think the normal configuration of mosquitto most users use is without a retained cache, so hopefully this can be fixed by re sending the homeassistant discovery message after the mqtt connection has been reconnected. |
Yep. That was part of the #1370, but I need to re-think that a bit to make it less tangly. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
Hi.. @mcspr |
Problem above is not HA-specific, as far as I could tell. We default to MQTT persistence, which stores both device status and HA discovery. In case persistence is disabled, or MQTT broker does not persist state between resets, not much we can do about it. If
|
Forgive my ignorance @mcspr , but homeassistant doesn't publish a status in the "homeassistant/status" topic, changing it from "online" to "offline"? |
Emphasis on IF, have to implement it first :) |
birth message should trigger discovery, enabled by default ref. xoseperez#1637 clean-up discovery code to properly re-init when something goes wrong also restore manual discovery trigger from WebUI
birth message should trigger discovery, enabled by default ref. xoseperez#1637 clean-up discovery code to properly re-init when something goes wrong also restore manual discovery trigger from WebUI
Bug description
I'm using Homeassistant with a separat mqtt broker not the embedded one in Homeassistant.
This leads to the espurna integration devices becoming unavailable when I restart Homeassistant.
From my understanding the discovery mqtt messages need to be re-send after Homeassistant restarts.
When using the embedded mqtt brocker of Homeassistant this does not generate a problem because the mqtt brocker goes offline too.
From my understanding the relevant code is this part.
espurna/code/espurna/homeassistant.ino
Lines 384 to 387 in ec4883a
Proposed solution
A solution would be to allow the user to specify a topic and payload where espurna listens for the birth_message of Homeassistant, so that when the topic is updated e.g. with 'online' the espurna config is send again.
Example usage in the zigbee2mqtt project and relevant documentation from Homeassistant.
Steps to reproduce
Restart homeassistant while using an external mqtt broker.
Expected behavior
espurna device integration is available again.
Device information
[MAIN] ESPURNA 1.13.5 (83195fd)
The rest is not relevant (I think).
The text was updated successfully, but these errors were encountered: