diff --git a/esphome/esp-officeduallights.yaml b/esphome/esp-officeduallights.yaml index 54c2ee7..11de242 100644 --- a/esphome/esp-officeduallights.yaml +++ b/esphome/esp-officeduallights.yaml @@ -6,6 +6,8 @@ # https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-officeduallights.yaml #:########################################################################################:# # VERSIONS: +# V3.0 2026-09-12 Makes HA the primary Office synchronizer. Direct MQTT peer synchronization +# runs only while HA's native API state subscription is disconnected. # V2.9 2026-08-16 Makes this physical relay the sole overhead status authority. Removes the # bidirectional shared retained-status topic that could chatter during reconnects. # V2.8 2026-07-25 Added 2-way MQTT sync with esp-officelights (office main lightswitch). @@ -93,7 +95,7 @@ substitutions: # Project Naming project_name: "Sonoff Technologies.Sonoff Dual R1" - project_version: "v2.9" + project_version: "v3.0" # Passwords and Secrets api_key: !secret esp-api_key @@ -311,16 +313,19 @@ mqtt: id(relay_2_timer_script)->execute(timer_seconds * 1000); - # Mirror remote bunker command from esp-officelights onto light_1, but only if a real - # state change is needed. Do not republish the command from here. Relay status is - # published by the relay callback below. + # MQTT peer synchronization is the HA-down fallback. When HA is connected it is the + # sole synchronizer, so remote MQTT commands must not change either physical relay. - topic: "${mqtt_mainlight_command_bunker}" payload: "${mqtt_command_on}" then: - script.stop: relay_1_timer_script - if: condition: - lambda: "return !id(relay_1).state;" + and: + - not: + api.connected: + state_subscription_only: true + - lambda: "return !id(relay_1).state;" then: - light.turn_on: light_1 @@ -330,19 +335,25 @@ mqtt: - script.stop: relay_1_timer_script - if: condition: - lambda: "return id(relay_1).state;" + and: + - not: + api.connected: + state_subscription_only: true + - lambda: "return id(relay_1).state;" then: - light.turn_off: light_1 - # Mirror remote overhead command from esp-officelights onto light_2, but only if a real - # state change is needed. - topic: "${mqtt_mainlight_command_overhead}" payload: "${mqtt_command_on}" then: - script.stop: relay_2_timer_script - if: condition: - lambda: "return !id(relay_2).state;" + and: + - not: + api.connected: + state_subscription_only: true + - lambda: "return !id(relay_2).state;" then: - light.turn_on: light_2 @@ -352,7 +363,11 @@ mqtt: - script.stop: relay_2_timer_script - if: condition: - lambda: "return id(relay_2).state;" + and: + - not: + api.connected: + state_subscription_only: true + - lambda: "return id(relay_2).state;" then: - light.turn_off: light_2