mqtt discovery on every update bug
Hey!
I'm currently in HA core beta, and was looking for other bugs but ended up noticing that hass.agent does something that's not very efficient on the home assistant side, it sends the discovery payload on every update for every sensor which cost CPU time on HA.
For example
I reported the exact same thing for another integration and you may want to read this here:
https://github.com/bachya/ecowitt2mqtt/issues/704
This will definitely lower the burden on HA when it does mqtt processing.
I'm running 2.0.1. Sorry if this was already fixed in beta or even reported already
GitHub
update of sensor entities also floods HA mqtt discovery Ā· Issue #70...
Describe the bug Working with @bdraco, we were hunting down what is causing some extra overhead on my system (RPi4 4Gb/HAOS) and discovered that ecowitt2mqtt seems to be flooding HA with MQTT disco...
27 Replies
Help us Help Others!
To help others find answers, you can mark your question as solved via
Right click solution message -> Apps -> ā
Mark Solution
Help us Help You!
Please don't delete messages or posts because it makes it impossible to understand what happened. If you don't want your messages to be seen then don't post here.
Make sure to provide detailed reports of bugs.
Please include error log uploads and info about the bug.
@Amadeo
That is interesting
I had in my head that the discovery is sent only when entities are recreated/HASS.Agent restarts
I'll take a look at this
Yeah discovery should only be sent if:
* HA Restarts(subscribe to the topic as it will tell you if it went off)
* HassAgent restarts
* Entities are recreated
now it got more interesting
it got sent only once
does this log require debug option to be enabled or is it generated by default?
Yes, need this
ok, I'll add this and see
could you please also check on your side with mqtt exploer if the messages are really being sent more than once?
You should see home assistant saying "already discovered" on every update
I can't recall any changes between 2.0.1 and the betas that could cause it but everything is possible
ok, got it I think
but I'll double check and leave if running for a while
and then find the root cause š
yup, confirmed
š
I'll work on it today
I'll see if I can confirm it on explorer too
I am a dum dum but I just woke up at the time
You can also just use the retain flag and you should only need to ever re-send it in case something changes, same for payload values
we can't trust users
and/or mqtt servers
š
I have the poc ready, it's sent only once per run and when config changes
need to replicate it for satellite and do some basic tests
Solution
will be part of 2.1.0-beta1
quite a "sizable" update that will be <insert yoda noises>
Awesome that was fast!
I haven't been able to connect to my machine to confirm things on mqtt Explorer
But if you confirmed the issue and issued a fix for it, that's great!
yup, got it replicated to satellite (and made me realize how much some parts of the code need rewrite xD) and now letting it run for some time just to make sure
Yeah, using the retain flag for the discovery payload is a dumb idea. HA retains everything anyways.
not quite, restarting mosquitto while HASS.Agent is offline will make all the entities dissapear from HA
but as always, "configurable by user" is the right answer š
looks like the fix is ready
Wait what? It looses them if you restart the BROKER? How stupid is that???
by design
that's the way to get rid of mqtt discovered entities
other way would be for HA to manage the retained topics itself or have some kind of deletion method like it is for discovery now
it's simpler this way, discovery payload exists = entity exists
mqtt is such a useful technology
Hm. I retract my previous statement. The device reconnects to the broker and when doing so, it publishes the discovery again, resulting in that all entities are back.
I had issues with auto discovery devices remaining in HA that I no longer use, just because they used retain. Only way to delete them is to manually send a null payload to the auto discovery topic using an MQTT GUI client.
Just tell a noob that is what he needs to do.... š¬