Edit esp-officelights.yaml
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-officelights.yaml
|
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-officelights.yaml
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# VERSIONS:
|
# VERSIONS:
|
||||||
|
# v3.2 2026-09-12 Makes HA the primary Office synchronizer. Direct MQTT peer synchronization
|
||||||
|
# runs only while HA's native API state subscription is disconnected.
|
||||||
# v3.1 2026-08-16 Makes the Sonoff Dual the sole overhead status authority. Removes the
|
# v3.1 2026-08-16 Makes the Sonoff Dual the sole overhead status authority. Removes the
|
||||||
# bidirectional shared retained-status topic that could chatter during reconnects.
|
# bidirectional shared retained-status topic that could chatter during reconnects.
|
||||||
# v3.0 2026-07-25 Refactored MQTT sync to use template HA switch actions; physical button and
|
# v3.0 2026-07-25 Refactored MQTT sync to use template HA switch actions; physical button and
|
||||||
@@ -81,7 +83,7 @@ substitutions:
|
|||||||
|
|
||||||
# Project Naming
|
# Project Naming
|
||||||
project_name: "Zemismart Technologies.KS-811 Triple"
|
project_name: "Zemismart Technologies.KS-811 Triple"
|
||||||
project_version: "v3.1"
|
project_version: "v3.2"
|
||||||
|
|
||||||
# Passwords & Secrets
|
# Passwords & Secrets
|
||||||
api_key: !secret esp-api_key
|
api_key: !secret esp-api_key
|
||||||
@@ -215,15 +217,18 @@ mqtt:
|
|||||||
retain: true
|
retain: true
|
||||||
|
|
||||||
on_message:
|
on_message:
|
||||||
# Mirror remote overhead command onto virtual Relay_2, but only if a real state change
|
# MQTT peer synchronization is the HA-down fallback. When HA is connected it is the
|
||||||
# is needed. Do not republish the command from here. Relay status is published by the
|
# sole synchronizer, so remote MQTT state must not change this mirror.
|
||||||
# relay callback below.
|
|
||||||
- topic: "${mqtt_this_device_command_topic_overhead}"
|
- topic: "${mqtt_this_device_command_topic_overhead}"
|
||||||
payload: "${mqtt_command_on}"
|
payload: "${mqtt_command_on}"
|
||||||
then:
|
then:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: "return !id(Relay_2).state;"
|
and:
|
||||||
|
- not:
|
||||||
|
api.connected:
|
||||||
|
state_subscription_only: true
|
||||||
|
- lambda: "return !id(Relay_2).state;"
|
||||||
then:
|
then:
|
||||||
- switch.turn_on: Relay_2
|
- switch.turn_on: Relay_2
|
||||||
|
|
||||||
@@ -232,7 +237,11 @@ mqtt:
|
|||||||
then:
|
then:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: "return id(Relay_2).state;"
|
and:
|
||||||
|
- not:
|
||||||
|
api.connected:
|
||||||
|
state_subscription_only: true
|
||||||
|
- lambda: "return id(Relay_2).state;"
|
||||||
then:
|
then:
|
||||||
- switch.turn_off: Relay_2
|
- switch.turn_off: Relay_2
|
||||||
|
|
||||||
@@ -244,7 +253,11 @@ mqtt:
|
|||||||
then:
|
then:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: "return !id(Relay_2).state;"
|
and:
|
||||||
|
- not:
|
||||||
|
api.connected:
|
||||||
|
state_subscription_only: true
|
||||||
|
- lambda: "return !id(Relay_2).state;"
|
||||||
then:
|
then:
|
||||||
- switch.turn_on: Relay_2
|
- switch.turn_on: Relay_2
|
||||||
|
|
||||||
@@ -253,7 +266,11 @@ mqtt:
|
|||||||
then:
|
then:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: "return id(Relay_2).state;"
|
and:
|
||||||
|
- not:
|
||||||
|
api.connected:
|
||||||
|
state_subscription_only: true
|
||||||
|
- lambda: "return id(Relay_2).state;"
|
||||||
then:
|
then:
|
||||||
- switch.turn_off: Relay_2
|
- switch.turn_off: Relay_2
|
||||||
|
|
||||||
@@ -265,7 +282,11 @@ mqtt:
|
|||||||
then:
|
then:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: "return !id(Relay_1).state;"
|
and:
|
||||||
|
- not:
|
||||||
|
api.connected:
|
||||||
|
state_subscription_only: true
|
||||||
|
- lambda: "return !id(Relay_1).state;"
|
||||||
then:
|
then:
|
||||||
- switch.turn_on: Relay_1
|
- switch.turn_on: Relay_1
|
||||||
|
|
||||||
@@ -274,7 +295,11 @@ mqtt:
|
|||||||
then:
|
then:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: "return id(Relay_1).state;"
|
and:
|
||||||
|
- not:
|
||||||
|
api.connected:
|
||||||
|
state_subscription_only: true
|
||||||
|
- lambda: "return id(Relay_1).state;"
|
||||||
then:
|
then:
|
||||||
- switch.turn_off: Relay_1
|
- switch.turn_off: Relay_1
|
||||||
|
|
||||||
@@ -341,10 +366,16 @@ script:
|
|||||||
lambda: "return !id(Relay_1).state;"
|
lambda: "return !id(Relay_1).state;"
|
||||||
then:
|
then:
|
||||||
- switch.turn_on: Relay_1
|
- switch.turn_on: Relay_1
|
||||||
- mqtt.publish:
|
- if:
|
||||||
topic: "${mqtt_this_device_command_topic_bunker}"
|
condition:
|
||||||
payload: "${mqtt_command_on}"
|
not:
|
||||||
retain: false
|
api.connected:
|
||||||
|
state_subscription_only: true
|
||||||
|
then:
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_this_device_command_topic_bunker}"
|
||||||
|
payload: "${mqtt_command_on}"
|
||||||
|
retain: false
|
||||||
|
|
||||||
# Local/HA requested OFF for Bunker Lights.
|
# Local/HA requested OFF for Bunker Lights.
|
||||||
- id: office_bunker_off
|
- id: office_bunker_off
|
||||||
@@ -355,10 +386,16 @@ script:
|
|||||||
lambda: "return id(Relay_1).state;"
|
lambda: "return id(Relay_1).state;"
|
||||||
then:
|
then:
|
||||||
- switch.turn_off: Relay_1
|
- switch.turn_off: Relay_1
|
||||||
- mqtt.publish:
|
- if:
|
||||||
topic: "${mqtt_this_device_command_topic_bunker}"
|
condition:
|
||||||
payload: "${mqtt_command_off}"
|
not:
|
||||||
retain: false
|
api.connected:
|
||||||
|
state_subscription_only: true
|
||||||
|
then:
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_this_device_command_topic_bunker}"
|
||||||
|
payload: "${mqtt_command_off}"
|
||||||
|
retain: false
|
||||||
|
|
||||||
# Physical Button 1 toggle logic for Bunker Lights. This is the only place that decides
|
# Physical Button 1 toggle logic for Bunker Lights. This is the only place that decides
|
||||||
# ON vs OFF for the bunker.
|
# ON vs OFF for the bunker.
|
||||||
@@ -383,10 +420,16 @@ script:
|
|||||||
lambda: "return !id(Relay_2).state;"
|
lambda: "return !id(Relay_2).state;"
|
||||||
then:
|
then:
|
||||||
- switch.turn_on: Relay_2
|
- switch.turn_on: Relay_2
|
||||||
- mqtt.publish:
|
- if:
|
||||||
topic: "${mqtt_this_device_command_topic_overhead}"
|
condition:
|
||||||
payload: "${mqtt_command_on}"
|
not:
|
||||||
retain: false
|
api.connected:
|
||||||
|
state_subscription_only: true
|
||||||
|
then:
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_this_device_command_topic_overhead}"
|
||||||
|
payload: "${mqtt_command_on}"
|
||||||
|
retain: false
|
||||||
|
|
||||||
# Local/HA requested OFF for Overhead Lights.
|
# Local/HA requested OFF for Overhead Lights.
|
||||||
- id: office_overhead_off
|
- id: office_overhead_off
|
||||||
@@ -397,10 +440,16 @@ script:
|
|||||||
lambda: "return id(Relay_2).state;"
|
lambda: "return id(Relay_2).state;"
|
||||||
then:
|
then:
|
||||||
- switch.turn_off: Relay_2
|
- switch.turn_off: Relay_2
|
||||||
- mqtt.publish:
|
- if:
|
||||||
topic: "${mqtt_this_device_command_topic_overhead}"
|
condition:
|
||||||
payload: "${mqtt_command_off}"
|
not:
|
||||||
retain: false
|
api.connected:
|
||||||
|
state_subscription_only: true
|
||||||
|
then:
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_this_device_command_topic_overhead}"
|
||||||
|
payload: "${mqtt_command_off}"
|
||||||
|
retain: false
|
||||||
|
|
||||||
# Physical Button 2 toggle logic for Overhead Lights.
|
# Physical Button 2 toggle logic for Overhead Lights.
|
||||||
- id: office_overhead_toggle
|
- id: office_overhead_toggle
|
||||||
|
|||||||
Reference in New Issue
Block a user