Skip to content

fix: do not publish sensor updates with RETAIN#229

Open
Suxsem wants to merge 1 commit intoLaxilef:masterfrom
Suxsem:antifreeze_boot_fix
Open

fix: do not publish sensor updates with RETAIN#229
Suxsem wants to merge 1 commit intoLaxilef:masterfrom
Suxsem:antifreeze_boot_fix

Conversation

@Suxsem
Copy link
Copy Markdown

@Suxsem Suxsem commented Mar 21, 2026

Background and motivation

I have some sensors configured as manual (update via API/MQTT) in OTGateway and recently I found a boring issue: after booting OTGateway always reported a strange sensor value in dashboard and the sensor was considered as connected despite no updates where pushed via API/MQTT. After some digging I found that I had a retained value in the sensor mqtt topic that on boot would trick the gateway into thinking that a new update was pushed.

I deleted that retained message and restarted the board but after a few seconds the retained message came back. I then discovered that OTGateway is publishing sensor values with the retain flag set. In my option this is not correct and should only be used for configuration values and not for real-time ones.

The change

This PR simply changes sensor publishing function in MqttTask to publish update messages without the retain flag set.

I'm testing the change for a couple of days not without any side effect.
I hope this could be useful for others!

@Laxilef
Copy link
Copy Markdown
Owner

Laxilef commented Apr 5, 2026

Hi @Suxsem,

Thank you for your contribution! Indeed, I've noticed something similar and I think I've already made the appropriate changes to the async branch. Can you test it?

Removing the RETAIN flag is not entirely correct, because after restarting the MQTT broker there will be no data, and this will cause parsing errors in HA.

@Suxsem
Copy link
Copy Markdown
Author

Suxsem commented Apr 7, 2026

hi @Laxilef,
I will test your changes as soon as possible, but I would like to further discuss on the removal of the retain flag. HA provides various ways to handle this scenarios (https://www.home-assistant.io/integrations/mqtt/#using-availability-topics) and I still think that using old values for realtime sensors is not a good idea. What do you think?

@Suxsem
Copy link
Copy Markdown
Author

Suxsem commented Apr 9, 2026

@Laxilef
I have noticed another strange things: if temperature drops below zero the boiler turns on as expected (due to the antifreeze feature) but if the temperature rises back up the boiler doesn't turn off automatically. is this the expected behaviour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants