HASwitchPlate / openHASP

HomeAutomation Switchplate based on lvgl for ESP32
https://www.openhasp.com
MIT License
721 stars 185 forks source link

Add retain flag on mqtt message #781

Closed yorulez closed 1 month ago

yorulez commented 2 months ago

Good day. Please add the ability to set a retain flag on the mqtt message.

fvanroie commented 2 months ago

Which messages and why?

Elix-g commented 2 months ago

Hi together, I've added some custom code to my project and implemented an automatic backlight dimming based on the environment light level. The value pairs I've defined for that, can be set from the plate. A function to publish retained messages would allow me to store those values easily on the MQTT broker. Something like _dispatch_state_subtopicretained e.g. Not sure if that is what @yorulez meant, but definitely would be useful for me!

fvanroie commented 2 months ago

I don't think a separate dispatch_state_subtopic_retained function is necessary. I've added a retain flag to mqtt_send_state instead. Retain is a mqtt only option, so I don't think it makes sense to add it to dispatch_state_subtopic as well.

fvanroie commented 2 months ago

@yorulez Could you please explain which messages you want to retain and why?

@Elix-g Does the new mqtt_send_state retain flag work for your use-case?

Elix-g commented 2 months ago

@fvanroie Thanks, very appreciate your swift reaction! The new mqtt_send_state helps a lot for my use-case.

fvanroie commented 1 month ago

Closed due to lack of rely from @yorulez

adorobis commented 2 weeks ago

Could you please explain which messages you want to retain and why?

I have just configured a device with powerrelay, it nicely shows up in HA but after ha restart or config reload the switch is in unknown state until its state changes. This would be fixed if there is the retain flag for output state topic. Or is there other way this could be achieved?