Closed apauly closed 1 year ago
Hey! Thanks for your addition. The obvious reason why it's not implemented this way is the chance of old outdated values on the broker. Not it has been some time since I last worked with the code, I know that there are expiry settings and lwt messages... How does the setup work for inactive sensors?
For my personal use case, the only way a sensor could get inactive is by running out of battery - so I'd rather have the latest value than no value. But I see that there might be other use cases where this might be different.
What do you think about a configurable option so that the default behaviour would not change?
Hey! Had another look at this. I agree that the current behavior is annoying, the new behavior would be too carefree. I would like numbers right after restart too, but super old readings should not be shown indefinitely when one sensor was eaten by the dog.
Maybe the solution is simple: Could you try adding an expiry time the config of all sensors? You can choose a high one, just so we are safeguarded from values that are super old https://www.home-assistant.io/integrations/sensor.mqtt/#expire_after Be sure to exclude the battery sensor ;)
Did you test the alternative approach?
@ThomDietrich Most probably I'm missing some details here but why having retain=true
set, for example for wirenboard-mqtt
and mqtt-smarthome
is not a problem but for Home Assistant it is?
Retain is a MQTT feature which would behave the same for wirenboard and mqtt-smarthome. It is not Home Assistant specific. I don't see how it is going to be "too carefree" for Home Assistant.
My concern is with outdated sensor reading retained forever. However, with lwt and the expire_after
setting added recently, the retain flag should be a meaningful improvement without the issue of outdated sensors. All good!
I've added the retain flag for publications for home assistant. This will make sure that the latest values are present after a reboot when HA initially subscribes to the topics.
Please let me know if there's anything missing