Closed Anto79-ops closed 1 year ago
Not sure why this happens to you. I have restarted lots of times, and just very rarely I have gotten a "_2" entity or two, but more than 99% of the times, all the entities are retained.
It could be somwthing with your MQTT settings maybe?
thanks, yes, exactly, sometimes its just a few sensors, sometimes its 50% of the sensors...maybe if I check with MQTT Explorer, if the actually sensor name on the MQTT is the same or if HASS does something to it.
Hi, I just wanted to follow up on this, is the code using asyncio-mqtt?
if so, then retaining the mqtt entities (after restart) can be achieved by simply placing retain=True
to any client.publish
calls.
It is using paho https://github.com/Olen/solar-monitor/blob/c263d350b23f44f2278b1cd90ccb5a07050e95af/datalogger.py#L6
And retain is set https://github.com/Olen/solar-monitor/blob/c263d350b23f44f2278b1cd90ccb5a07050e95af/datalogger.py#L64
You can also enable debug-logging to see what it receives from the MQTT-server https://github.com/Olen/solar-monitor/blob/c263d350b23f44f2278b1cd90ccb5a07050e95af/datalogger.py#L154
its interesting that the retain is set to true already, now I'm wondering if this has anything to do with HASS discovery.
I'll have to confirm that with the debug-logging
hey I'm wondering if this PR will solve this issue here:
https://github.com/home-assistant/core/pull/90801
according to the devs comment:
"...This will prevent an extra async call if for each discovery update that has not changed."
This should be in 2023.5
This is not an issue anymore since the update above.
Hey, not sure if this a code related or HASS discovery related, but every time I have to restart my RPi for updates and resume the script, the entities get all changed up in HASS, for example it may add or remove a suffix like "_2" at the end of the entity, and it kind of messes up my automations.
How can the names be retained on restart? thanks