-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Enable disabled entity cause disable all others with no retain flag #129759
Enable disabled entity cause disable all others with no retain flag #129759
Comments
Hey there @emontnemery, @jbouwh, @bdraco, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) mqtt documentation |
Note that I am not seeing any configuration details and logs, which makes it hard to tell what is happenig in detail. |
Also: when you do not use a retained flag for your config message, you should resend it after Home Assistant is restarted ( so after the Birth message, or repeated), or Home Assistant will have no clue about the entitiy and its state, and it will only hold some registry entities with customizations if the discovery payload has a |
Can you help me to step by step reproduce this my self (including a sample state update)? Explain step by step what you would expect and what happens and should be correct to your opinion. |
Under normal conditions:
|
I did some testing. It seems when en entity is not enabled, it is not listening for state updates, till it is added to Home Assistant. |
Yes, I will try explain step by step:
Important info:
where Payload of subscribe topics (for enable and disable entices) are sending from external system completely and independent from state of entice in HA. In other words external system sending values for all entices every 3 min.
Regarding below:
I use 1st option, sending MQTT discovery msg after HA restart, no using 2nd availability or retained. About this:
Agree that after change from disabled to enabled this one particular entity should get unavailable state and wait for subscribed topic for update the state. But unavailability become ALL enabled entices from all devices w/o retained flags! Should one this one be unavailable. So for example at 22:27:33 I enable ONE disabled entice and after that all enabled entices become unavailable. This all enabled and updated every 3 min entices are w/o retention and availability flag. Please note every 3 min is publishing (sending to HA MQTT) subscribed topics, from external system. Additional please note that there missing all payloads and subscribed topics after enabled only one entice w/o retention flag and availability. But in background of the below picture you can found logbook where you see that there was updated values and become unavailable. BTW. Just found something that could help. In normal state (when no try enabled entice) In MQTT Info page (like on picture below) there is no showed definition (subscribed topic) for disabled entices. But disabled entices are listed in gray and you can enable it. Also they has been created by MQTT discovery msg. Because there is no definition here then maybe MQTT HA logic is waiting again for discover msg? But this have no sense... |
So your conclusion is:
You would expect the entity that is to be enabled to be unavailable till it receives a state update, but the other entities should keep its state. Instead all other, already enabled entities, loose their state as well. Is that correct? |
Yes, this is correct. But... Lost state for all others entices w/o retained or availability till received new values (in my case every 3 min) would be not a problem, if this be working :) But above not working, on screenshots I try shown that after 40 min all working earlier entices that become unavaliable was not updated (should be updated in my case up to 3 min) after enable only one entice and I need send again about 900 MQTT discovery msg for all others entices w/o retained flag or availability. This is root of my cause. |
I did test with 2 entities (2 different devices). One loaded, one disabled (, all without retain flag). Then I published state for the enabled entity and enabled the disabled one. The state of the already enabled entity became unavailable. So I was able to reproduce your issue. I guess this might be something outside the MQTT integration. When we enable an entity after 30 sec it seems to influence the states of all already loaded entities. |
I'm happy that you reproduce the issue. However if no MQTT area then maybe you know who I should call? From my perspective enabling disabled entice could execute similar functions like restart HA because under "MQTT Info" missing all definitions of entices (after enable entice no subscription topic, payloads etc). The same is after restart HA. |
Enabling or disabling an entity makes the MQTT config entry reload. This means the behavior after enabling or disabling an entity is the same as when Home Assistant starts. If you don't want discovery messages to be retained, you need to listen to home assistant's birth message and publish the discovery messages when that's received. If you don't want state messages to be retained, you should periodically retransmit them also when they've not changed, perhaps once every 5 minutes. @kzajac83 it's a bit unclear to me if your concern is non-retained discovery messages, non-retained state messages or both. |
@emontnemery Your explanation confirm my suspicions that enabling disabled entice launch starting HA functions. To check your words I made a few tests and enable some disabled entice (with and without retained or availability) and cause the same effect. After the operation affected was only entices without retention flag.
I think about both.
I send notification to my external system when HA start and the system trigger MQTT discovery messages. But please not focusing on my system, I can easy add retained flag or try build availability msg but creating the issue I'd like focus on Home Assistance system and described problem. From my perspective why touching something in one place (enabling one entice) have impact for all other entices in whole system? Creating the issue my intention was shown that HA have a problem, I was not thinking about enhancement my discovery messages or state messages or my external system because I can do that and soon will do. I also understood that enabling or disabling entices is very rare one-time action comparing to long time operational status. Moreover MQTT discovery messages for disabled entices has been also send with option So summary - I'd like only tell you that from user point, like me, current behavior of system is not perfect and for sure is no logical, in my opinion enabling entice should have impact only for this one entice, not all rest. Nor would I have created an issue if it had been described in the documentation. |
OK, I see. I think this is mostly a documentation problem then, the documentation should explain that external sources which provide Home Assistant entities via MQTT need to listen to the home assistant birth messageand re-publish when that's received.
This is not reliable, you should instead make your external system listen to the birth topic (unless configured differently, |
Yes, general agree. On end I'd like quickly touch below points because was addressee in discussion but not answer word about it.
And new question (related to 3.) |
On a discovery message a retained flag will ensure the mqtt broker replays the last message when MQTT starts up, so it will set up without the need to receive a device config from the device. Else the entity will be unavailable until a discovery message is sent by the device, for example after receiving the birth message, or send in intervals.
A disabled entity will not be loaded until it is enabled. To be able to debug, you must not disable the entity at startup. When you enable an entity, Home Assistant will reload the MQTT config entry. I will make sure the documentation is improved at this point.
This is because the MQTT info only is initialized when the entity is added, but note that you can also enable
You can check the mqtt debug logging. |
The problem
Enabling entice from disabled state cause for all other entities created by MQTT discovery msg with NO retain flag unavailability status. According documentation missing retain flag have only impact for HA restarting, not information that enabling entities have also impact for entices with NO retention flag.
Please note enabling disable entice WITH retention flag have no impact for other entices created by MQTT discovery msg with NO retention flag.
What version of Home Assistant Core has the issue?
core-2024.10.4
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
MQTT
Link to integration documentation on our website
https://www.home-assistant.io/integrations/mqtt/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: