Generic Thermostat: Using the keep_alive setting to keep MQTT Relays in correct state

Normally I enjoy thought experiments but in this case I think you should simply try it. Be sure to first purge the retained topic (while retain is true, publish an empty-string to the topic). Then set retain to false and start the experiment.


EDIT
I invite you to read this thread starting with my post explaining why only state topics ought to be retained, not command topics.

If you are using Tasmota for the relays, The Hook Up has an informative video explaining the correct use of retain.