diff --git a/esphome/esp-centralstairs-bottom.yaml b/esphome/esp-centralstairs-bottom.yaml index 0ec9d32..67d974b 100644 --- a/esphome/esp-centralstairs-bottom.yaml +++ b/esphome/esp-centralstairs-bottom.yaml @@ -6,6 +6,7 @@ # https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-centralstairs-bottom.yaml #:########################################################################################:# # VERSIONS: +# V3.9 2026-07-21 Added retained MQTT status mirroring for HA-independent two-way switching # V3.8 2026-06-09 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_1).state;' + lambda: "return id(Relay_1).state;" then: - mqtt.publish: topic: "${mqtt_status_topic_1}" payload: "${mqtt_command_ON}" - qos: 0 - retain: false + qos: 1 + retain: true else: - mqtt.publish: topic: "${mqtt_status_topic_1}" 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 2 is a mirror of the remote physical Stair Footer Lights relay. + - topic: "${mqtt_status_topic_2}" + payload: "${mqtt_command_ON}" + then: + - if: + condition: + not: + - switch.is_on: Relay_2 + then: + - switch.turn_on: Relay_2 + + - topic: "${mqtt_status_topic_2}" + payload: "${mqtt_command_OFF}" + then: + - if: + condition: + - switch.is_on: Relay_2 + then: + - switch.turn_off: Relay_2 + #:########################################################################################:# # STATUS LED: # https://esphome.io/components/status_led.html @@ -298,7 +319,7 @@ binary_sensor: # Toggle the remote Footer Lights via COMMAND topic, based on our mirrored state - if: condition: - lambda: 'return id(Relay_2).state;' + lambda: "return id(Relay_2).state;" then: - mqtt.publish: topic: "${mqtt_command_topic_2}" @@ -332,15 +353,17 @@ switch: - mqtt.publish: topic: "${mqtt_status_topic_1}" payload: "${mqtt_command_ON}" - retain: false + qos: 1 + retain: true on_turn_off: - mqtt.publish: topic: "${mqtt_status_topic_1}" payload: "${mqtt_command_OFF}" - retain: false + qos: 1 + retain: true - platform: gpio name: "Relay 2: ${switch_2_name}" pin: GPIO12 id: Relay_2 - # No mqtt.publish here (this is a mirror only) \ No newline at end of file + # No mqtt.publish here (this is a mirror only)