diff --git a/esphome/esp-downstloungeentry.yaml b/esphome/esp-downstloungeentry.yaml index b6d5013..18d412e 100644 --- a/esphome/esp-downstloungeentry.yaml +++ b/esphome/esp-downstloungeentry.yaml @@ -163,6 +163,15 @@ logger: # This adds device-specific MQTT command triggers to the common MQTT configuration. #:########################################################################################:# mqtt: + # Republish current mirror state whenever MQTT reconnects so the remote device + # knows our view of the state. + on_connect: + - mqtt.publish: + topic: "${mqtt_remote_status_topic}" + payload: !lambda |- + return id(Relay_1).state ? "${mqtt_remote_device_command_on}" : "${mqtt_remote_device_command_off}"; + retain: true + on_message: # Mirror remote state onto Relay_1 (only toggle if a change is needed) - topic: "${mqtt_remote_status_topic}"