From 6dc9b56ff7ed13356af605e2807372f7d18b9bbb Mon Sep 17 00:00:00 2001 From: ESPHome Device Builder Date: Tue, 21 Jul 2026 18:28:33 +1200 Subject: [PATCH] Edit esp-centralstairs-top.yaml --- esphome/esp-centralstairs-top.yaml | 41 +++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/esphome/esp-centralstairs-top.yaml b/esphome/esp-centralstairs-top.yaml index 14230e2..b3bddab 100644 --- a/esphome/esp-centralstairs-top.yaml +++ b/esphome/esp-centralstairs-top.yaml @@ -6,6 +6,7 @@ # https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-centralstairs-top.yaml #:########################################################################################:# # VERSIONS: +# V3.9 2026-07-21 Added retained MQTT status mirroring for HA-independent two-way switching # V3.8 2026-04-26 Added Downstairs Lights Bulk Activation virtual switch toggled by Button 1 double-click # V3.7 2025-09-24 Upload to this device # V3.5 2025-07-24 YAML tidyups @@ -83,7 +84,7 @@ substitutions: # Project Naming project_name: "Zemismart Technologies.KS-811 Double" # Project Details - project_version: "v2.1" # Project V denotes release of yaml file, allowing checking of deployed vs latest version + project_version: "v3.9" # Project V denotes release of yaml file, allowing checking of deployed vs latest version # MQTT Controls mqtt_command_main_topic: !secret mqtt_command_main_topic @@ -184,19 +185,19 @@ mqtt: then: - if: condition: - lambda: 'return id(Relay_2).state;' + lambda: "return id(Relay_2).state;" then: - mqtt.publish: topic: "${mqtt_status_topic_2}" payload: "${mqtt_command_ON}" - qos: 0 - retain: false + qos: 1 + retain: true else: - mqtt.publish: topic: "${mqtt_status_topic_2}" payload: "${mqtt_command_OFF}" - qos: 0 - retain: false + qos: 1 + retain: true on_message: # Relay 1: only turn ON if currently OFF @@ -241,6 +242,26 @@ mqtt: then: - switch.turn_off: Relay_2 + # Relay 1 is a mirror of the remote physical Main Stair Lights relay. + - topic: "${mqtt_status_topic_1}" + payload: "${mqtt_command_ON}" + then: + - if: + condition: + not: + - switch.is_on: Relay_1 + then: + - switch.turn_on: Relay_1 + + - topic: "${mqtt_status_topic_1}" + payload: "${mqtt_command_OFF}" + then: + - if: + condition: + - switch.is_on: Relay_1 + then: + - switch.turn_off: Relay_1 + #:########################################################################################:# # STATUS LED: # https://esphome.io/components/status_led.html @@ -286,7 +307,7 @@ binary_sensor: then: - if: condition: - lambda: 'return id(Relay_1).state;' + lambda: "return id(Relay_1).state;" then: - mqtt.publish: topic: "${mqtt_command_topic_1}" @@ -338,9 +359,11 @@ switch: - mqtt.publish: topic: "${mqtt_status_topic_2}" payload: "${mqtt_command_ON}" - retain: false + qos: 1 + retain: true on_turn_off: - mqtt.publish: topic: "${mqtt_status_topic_2}" payload: "${mqtt_command_OFF}" - retain: false \ No newline at end of file + qos: 1 + retain: true