ChristianKuehnel / plantgateway

Bluetooth to mqtt gateway for Xiaomi Mi plant sensors
Apache License 2.0
276 stars 43 forks source link

How to set retain flag #28

Closed h4nc closed 5 years ago

h4nc commented 5 years ago

When I restart home assistant the initial values of my plant sensors are unknown.

This first paragraph here https://www.home-assistant.io/components/sensor.mqtt/

If messages in this state_topic are published with RETAIN flag, the sensor will receive an instant update with last known value.

tells us that the retain flag has to be set to avoid this.

Is it possible to set the retain flag in the configuration file?

h4nc commented 5 years ago

Retain flag is already set, has to be an issue with my config in ha.

xbmcnut commented 4 years ago

@h4nc Did you resolve your issue as I've just come across this today too?

h4nc commented 4 years ago

Yes, my values show up after a ha restart but to be honest I don't remember what solved this.

I think adding force_update: true to my mqtt sensor configuration fixed it for me. Please let me know if this solves your issue too.

xbmcnut commented 4 years ago

Ah yes, force_update. That's the one! Thank you.