diff --git a/esphome/esp-officeduallights.yaml b/esphome/esp-officeduallights.yaml index 47035be..8648c5a 100644 --- a/esphome/esp-officeduallights.yaml +++ b/esphome/esp-officeduallights.yaml @@ -365,6 +365,28 @@ mqtt: then: - light.turn_off: light_2 + # Mirror shared overhead status from esp-officelights onto light_2. This handles the + # case where the main lightswitch's overhead timer finishes and turns off the overhead. + # State guards prevent ping-pong with the command topic handlers above. + - topic: "${mqtt_shared_overhead_status_topic}" + payload: "${mqtt_command_on}" + then: + - if: + condition: + lambda: "return !id(relay_2).state;" + then: + - light.turn_on: light_2 + + - topic: "${mqtt_shared_overhead_status_topic}" + payload: "${mqtt_command_off}" + then: + - script.stop: relay_2_timer_script + - if: + condition: + lambda: "return id(relay_2).state;" + then: + - light.turn_off: light_2 + #:########################################################################################:# # SCRIPT COMPONENT: # Independent per-relay timer scripts