Edit esp-downstloungemain.yaml

This commit is contained in:
ESPHome Device Builder
2026-07-25 20:49:10 +12:00
parent ed17c41764
commit 4dea67f941
+20 -3
View File
@@ -164,16 +164,33 @@ logger:
# This adds device-specific MQTT command triggers to the common MQTT configuration. # This adds device-specific MQTT command triggers to the common MQTT configuration.
#:########################################################################################:# #:########################################################################################:#
mqtt: mqtt:
# Republish current relay states whenever MQTT reconnects so retained status stays accurate
# for subscribers that reconnect later.
on_connect:
- mqtt.publish:
topic: "${mqtt_local_status_topic}"
payload: !lambda |-
return id(relay_1).state ? "On" : "Off";
retain: true
on_message: on_message:
# Main Lights control (Relay 1) # Main Lights control (Relay 1) — state guard prevents ping-pong
- topic: "${mqtt_local_command_topic}" - topic: "${mqtt_local_command_topic}"
payload: "On" payload: "On"
then: then:
- switch.turn_on: relay_1 - if:
condition:
lambda: "return !id(relay_1).state;"
then:
- switch.turn_on: relay_1
- topic: "${mqtt_local_command_topic}" - topic: "${mqtt_local_command_topic}"
payload: "Off" payload: "Off"
then: then:
- switch.turn_off: relay_1 - if:
condition:
lambda: "return id(relay_1).state;"
then:
- switch.turn_off: relay_1
#:########################################################################################:# #:########################################################################################:#
# STATUS LED # STATUS LED