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
when hass discovery is turned on listen for hass restart and resend discovery data #8753
Comments
I'll have a look, for now you could simply expand the automation for Syncing Power State that is in our docs. |
That actually won't work (unless I'm missing something) as the devices won't even exist and therefore topics won't be subscribed to at all. That is correct that the LWT must be added to the configuration yaml... |
First I need a better understanding of a problem that I don't have. After a reboot of HAss the only thing I do is sync the states using the automation, never lost a device. |
I’m pretty new to both hass and tasmota...let me do some testing a bit more but I’m near certain I have devices that would never show up as available after hass restart (even after the 5 minute window). I’ll confirm with further detail though. |
If Home Assistant is restarted but the broker is not restarted, Tasmota don't have any way of knowing that HA has been restarted. That is why, the automation for HA explained in the docs, is the solution for this. |
Yeah, confirmed the devices never show up as available (for me at least). Interestingly, I updated the window to 10 seconds and did see status updates coming through the mqtt debug logging info from hass but the device stays as unavailable until I 'rediscover' them. Also of note, after clicking an unavailable device from the lovelace UI the state messages actually stopped coming through (not sure if hass subscribes on stored info during startup but then unsubscribes when you interact with the thing when it's unavailable or what). In any case, I've never had any issues with the zwave2mqtt stuff, everything rediscovers and becomes available immediately when hass starts. Initially I thought it was because it set the retain flag on the discovery messages but I dug into the code a bit a bit and realized it's doing as requested here. |
Seems that there is something else going on in your case. Some odd config. The discovery message is needed to be sent just once and the mqtt broker stores it in its database (the message is retained by default) and everytime your HA is restarted, the discovery message retained in the broker, is sent to your HA. |
Ah, just realized some (many?) people use the integrated broker which is probably why some don't see this issue as much (assuming it restarts when hass restarts?). In other cases the results would be sporadic at best. I run a separate broker which is probably why I've been scratching my head wondering why the out-of-box behavior is so strange/bad with mqtt. |
I assure you the config messages sent from tasmota to hass are not sent with the retained flag. I confirmed this already. |
I use the addon mosquitto in HA and I don't have that issue. Do you have any other config in configuration.yaml? Which broker do you use? |
Ok, that's it. They are by default retained. |
I have not. These are some Here are crude notes of setup steps:
|
I use |
As @ascillato told you, Tasmota Discovery send all the topic with the retained flag, example:
If the retained flag isn't there the broker have no idea of the device connected and then a new subscribe is needed. Also, Hass has its internal database where all the discovered devices are stored. I don't know |
Retained messages work fine with example:
In
Hass UI:
|
I regularly send/use messages with the retained flag with Here's an example of a retained message as sent by zwave2mqtt when subscribed via the HASS UI:
Also the LWT messages are set as retained by tasmota:
But I'll keep digging. Something weird for sure. |
Let me know if you find something, it could benefit other users too. |
Well, I've confirmed
Again, retained messages work fine with rmq so something is up with tasmota (or some config option is off for me or the build that's installed). |
Ok, for the sake of knowledge I checked under HA logs and all the messages are retained as expected:
Even the LWT are ok:
|
OK, some of my comments appear to be misguided. Does HASS subscribe to a wildcard Maybe you could test this using mosquitto_sub against your mosquitto server using a topic like this? |
If I subscribe to #, I receive ALL the retained messages from the database in mosquitto. So, it is good to know that your broker is not working as expected for HA. |
Yeah ok. That sounds like a bug in the rmq implementation of mqtt then. That must mean hass uses the wildcards for its startup process as well. This feature might still be good in general though? I’ll open a bug with rmq about it as well and link to this. |
Sorry but this request is not possible. That is why the HA startup automation is explained in the Tasmota. When HA restarts, there is no standard/default way for Tasmota to know that HA have restarted. And sending again and again the discovery is not as the mqtt discovery standard is made or needed. Sorry. Closing as the issue with retained messages in the broker is not related to Tasmota. |
There is a way...that’s exactly what zwave2mqtt does. |
I’m ok if you don’t want to implement this but seems a little premature to close while discussion is still going on. It was even mentioned earlier that it could make the HA automation unnecessary as an added benefit. |
Closed doesn't mean we don't take into consideration. I've already ping an HA dev to see if we can implement it. |
The idea of |
Fair enough. I’m not sure I follow what you need more from HA. What’s not available from the HA side currently? Or what do you want differently from them? |
To make HA publish to If that mqtt message were automatic and be present by default in HA, we will add to Tasmota a subscription (if setoption19 is 1) to that standard topic to listen as you requested because it is a really good idea and good approach. In fact, this should solve the problem that some users make relays and buttons as retained messages to not use startup automations but making other issues like ghost switching. |
Ah I see you just want it as the default. Got it. Thanks for the consideration and working through that craziness! |
Thanks for pointing to this idea. And if you want to forget of those retained issues, use the super reliable Mosquitto. I really recommend it. Super lightweight and fast. |
I’m looking into it now. I use amqp as well so it was easy to add it into the mix. I also have auth with ldap which sounds like it may be fun with mosquitto :( |
Tasmota publishes its discovery messages with retainflag set, so there is absolutely no need for what's requested here. I don't think bugs in brokers breaking basic functionality such as "retain" should be fixed in Tasmota. |
Totally agree. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
one automation can do wonders.... if you wish you can spam so19 1 to all devices on HA restart |
Yes, maybe something like that could be useful, this is the current status:
Once home-assistant/core#36537 is merged, it will be possible to configure will and birth message from the HA UI, it's currently |
Thanks for looking at this. I think is going to be very useful.
what about as @travisghansen's and as zigbee2mqtt ?
|
In my tests every reboot triggered the topic Hass/status when back online.
Em seg, 22 de jun de 2020 21:43, Adrian Scillato <notifications@github.com>
escreveu:
… @emontnemery <https://github.com/emontnemery>
Thanks for looking at this. I think is going to be very useful.
HA does NOT allow configuring a disconnect topic+message to be published
on an intentional disconnect, i.e. restart or shutdown of HA. It would make
sense to add this feature, although it's perfectly possible to implement
with an automation. Any suggestion for naming such an addition?
what about as @travisghansen <https://github.com/travisghansen>'s and as
zigbee2mqtt ?
hass/status ONLINE
hass/status OFFLINE
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#8753 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB2YR3RB4KQYBCY2JC2HQT3RX73DNANCNFSM4OEBHVRA>
.
|
On connect it will but lwt messages only get sent on ungraceful disconnects...so you only get offline messages if things go bad but if you cleanly shut down no. |
Starting with Home Assistant version 0.113, Home Assistant publishes messages when it goes online and offline: home-assistant/core#37371 without need for user configuration or automations. MQTT birth message defaults to: I think Tasmota can subscribe to |
Good one Erik!
What would interest me is the |
Home Assistant version 0.113 is released with this change 😄 |
Already? Damn, I need to hurry up! :D |
Have you looked for this feature in other issues and in the docs? Yes
Is your feature request related to a problem? Please describe.
I see lots of people having issues with hass restarting and losing access to devices. After digging around I think the solution should be to resend discovery data when hass is detected as restarted.
Describe the solution you'd like
Listen to
hass/status
topic and when a payload ofonline
is received resend all the configuration messages (and possibly states).Describe alternatives you've considered
Currently handling this via Node-RED and publishing the
SetOption19
command to the group topic which retriggers at least discovery messages.Additional context
I've been scratching my head for a bit trying to understand why mqtt discovery fails on restart with various devices but my zwave2mqtt devices come up after every hass restart. After some digging I realized it's listening to
hass/status
mqtt topic and republishing when hass restarts. From my reading around on forums etc I think this will solve a lot of headaches and misunderstandings with quite a few users.Thanks!
(Please, remember to close the issue when the problem has been addressed)
The text was updated successfully, but these errors were encountered: