Edit esp-officelights.yaml
This commit is contained in:
@@ -34,17 +34,19 @@
|
|||||||
# MQTT COMMANDS:
|
# MQTT COMMANDS:
|
||||||
# Bunker Lights (Button 1):
|
# Bunker Lights (Button 1):
|
||||||
# - Command topic: ${mqtt_this_device_command_topic_bunker}
|
# - Command topic: ${mqtt_this_device_command_topic_bunker}
|
||||||
# Payloads: ${mqtt_command_on}, ${mqtt_command_off}
|
# Payloads: ${mqtt_command_on}, ${mqtt_command_off}, or 1 to 3600 (timer seconds)
|
||||||
# - Status topic: ${mqtt_this_device_status_topic_bunker}
|
# - Status topic: ${mqtt_this_device_status_topic_bunker}
|
||||||
# Payloads mirror the actual bunker relay state and are published retained.
|
# Payloads mirror the actual bunker relay state and are published retained.
|
||||||
#
|
#
|
||||||
# Overhead Lights (Button 2):
|
# Overhead Lights (Button 2):
|
||||||
# - Command topic: ${mqtt_this_device_command_topic_overhead}
|
# - Command topic: ${mqtt_this_device_command_topic_overhead}
|
||||||
# Payloads: ${mqtt_command_on}, ${mqtt_command_off}
|
# Payloads: ${mqtt_command_on}, ${mqtt_command_off}, or 1 to 3600 (timer seconds)
|
||||||
# - Status topic: ${mqtt_this_device_status_topic_overhead}
|
# - Status topic: ${mqtt_this_device_status_topic_overhead}
|
||||||
# Payloads mirror the overhead virtual relay state and are published retained.
|
# Payloads mirror the overhead virtual relay state and are published retained.
|
||||||
#
|
#
|
||||||
# This device subscribes to status topics from esp-officeduallights to mirror remote state.
|
# This device subscribes to status topics from esp-officeduallights to mirror remote state.
|
||||||
|
# Timer values from esp-occupancyoffice are handled locally (countdown runs on this device).
|
||||||
|
# Physical button presses cancel any active timer before toggling.
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# OFFLINE NOTES:
|
# OFFLINE NOTES:
|
||||||
# - a) Home Assistant offline (network and MQTT online):
|
# - a) Home Assistant offline (network and MQTT online):
|
||||||
@@ -118,6 +120,12 @@ substitutions:
|
|||||||
mqtt_command_on: "On"
|
mqtt_command_on: "On"
|
||||||
mqtt_command_off: "Off"
|
mqtt_command_off: "Off"
|
||||||
|
|
||||||
|
# MQTT Overhead Status - shared topic for overhead state sync
|
||||||
|
# Both this device and esp-officeduallights publish and subscribe to this topic so
|
||||||
|
# whichever device's timer finishes first keeps the other in sync.
|
||||||
|
mqtt_shared_overhead_status_function: "office-overhead-status"
|
||||||
|
mqtt_shared_overhead_status_topic: "${mqtt_status_main_topic}/${mqtt_shared_overhead_status_function}"
|
||||||
|
|
||||||
# Switch/Relay/Button Naming
|
# Switch/Relay/Button Naming
|
||||||
switch_1_name: "Bunker Lights" # Physical relay (GPIO13) connected to bunker light load
|
switch_1_name: "Bunker Lights" # Physical relay (GPIO13) connected to bunker light load
|
||||||
switch_2_name: "Overhead Lights" # Virtual mirror of esp-officeduallights overhead state
|
switch_2_name: "Overhead Lights" # Virtual mirror of esp-officeduallights overhead state
|
||||||
@@ -214,6 +222,11 @@ mqtt:
|
|||||||
payload: !lambda |-
|
payload: !lambda |-
|
||||||
return id(Relay_2).state ? "${mqtt_command_on}" : "${mqtt_command_off}";
|
return id(Relay_2).state ? "${mqtt_command_on}" : "${mqtt_command_off}";
|
||||||
retain: true
|
retain: true
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_shared_overhead_status_topic}"
|
||||||
|
payload: !lambda |-
|
||||||
|
return id(Relay_2).state ? "${mqtt_command_on}" : "${mqtt_command_off}";
|
||||||
|
retain: true
|
||||||
|
|
||||||
on_message:
|
on_message:
|
||||||
# Mirror remote overhead command onto virtual Relay_2, but only if a real state change
|
# Mirror remote overhead command onto virtual Relay_2, but only if a real state change
|
||||||
@@ -265,6 +278,28 @@ mqtt:
|
|||||||
|
|
||||||
id(overhead_timer_script)->execute(timer_seconds * 1000);
|
id(overhead_timer_script)->execute(timer_seconds * 1000);
|
||||||
|
|
||||||
|
# Mirror shared overhead status from esp-officeduallights onto virtual Relay_2.
|
||||||
|
# This handles the case where the dual lights' overhead timer finishes and turns off
|
||||||
|
# the overhead — the main lightswitch mirrors the state so its virtual relay stays
|
||||||
|
# in sync. 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:
|
||||||
|
- switch.turn_on: Relay_2
|
||||||
|
|
||||||
|
- topic: "${mqtt_shared_overhead_status_topic}"
|
||||||
|
payload: "${mqtt_command_off}"
|
||||||
|
then:
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
lambda: "return id(Relay_2).state;"
|
||||||
|
then:
|
||||||
|
- switch.turn_off: Relay_2
|
||||||
|
|
||||||
# Mirror remote bunker command onto Relay_1, but only if a real state change is needed.
|
# Mirror remote bunker command onto Relay_1, but only if a real state change is needed.
|
||||||
# This handles commands from esp-officeduallights when its local button toggles the
|
# This handles commands from esp-officeduallights when its local button toggles the
|
||||||
# physical bunker light and publishes status.
|
# physical bunker light and publishes status.
|
||||||
@@ -544,11 +579,19 @@ switch:
|
|||||||
topic: "${mqtt_this_device_status_topic_overhead}"
|
topic: "${mqtt_this_device_status_topic_overhead}"
|
||||||
payload: "${mqtt_command_on}"
|
payload: "${mqtt_command_on}"
|
||||||
retain: true
|
retain: true
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_shared_overhead_status_topic}"
|
||||||
|
payload: "${mqtt_command_on}"
|
||||||
|
retain: true
|
||||||
on_turn_off:
|
on_turn_off:
|
||||||
- mqtt.publish:
|
- mqtt.publish:
|
||||||
topic: "${mqtt_this_device_status_topic_overhead}"
|
topic: "${mqtt_this_device_status_topic_overhead}"
|
||||||
payload: "${mqtt_command_off}"
|
payload: "${mqtt_command_off}"
|
||||||
retain: true
|
retain: true
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_shared_overhead_status_topic}"
|
||||||
|
payload: "${mqtt_command_off}"
|
||||||
|
retain: true
|
||||||
|
|
||||||
# Relay 3 (Spare) - no function assigned
|
# Relay 3 (Spare) - no function assigned
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
|
|||||||
Reference in New Issue
Block a user