Edit esp-downstloungemain.yaml
This commit is contained in:
@@ -201,6 +201,52 @@ status_led:
|
|||||||
number: GPIO2
|
number: GPIO2
|
||||||
inverted: true
|
inverted: true
|
||||||
|
|
||||||
|
#:########################################################################################:#
|
||||||
|
# SCRIPTS
|
||||||
|
# https://esphome.io/components/script.html
|
||||||
|
#:########################################################################################:#
|
||||||
|
script:
|
||||||
|
# Local/HA requested ON for Main Lights. Change the local relay immediately, then
|
||||||
|
# publish a non-retained command so any linked switch follows.
|
||||||
|
- id: mainlights_on
|
||||||
|
mode: restart
|
||||||
|
then:
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
lambda: "return !id(relay_1).state;"
|
||||||
|
then:
|
||||||
|
- switch.turn_on: relay_1
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_local_command_topic}"
|
||||||
|
payload: "On"
|
||||||
|
retain: false
|
||||||
|
|
||||||
|
# Local/HA requested OFF for Main Lights.
|
||||||
|
- id: mainlights_off
|
||||||
|
mode: restart
|
||||||
|
then:
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
lambda: "return id(relay_1).state;"
|
||||||
|
then:
|
||||||
|
- switch.turn_off: relay_1
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_local_command_topic}"
|
||||||
|
payload: "Off"
|
||||||
|
retain: false
|
||||||
|
|
||||||
|
# Physical Button 1 toggle logic.
|
||||||
|
- id: mainlights_toggle
|
||||||
|
mode: restart
|
||||||
|
then:
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
lambda: "return id(relay_1).state;"
|
||||||
|
then:
|
||||||
|
- script.execute: mainlights_off
|
||||||
|
else:
|
||||||
|
- script.execute: mainlights_on
|
||||||
|
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# BINARY SENSORS
|
# BINARY SENSORS
|
||||||
# https://esphome.io/components/binary_sensor/
|
# https://esphome.io/components/binary_sensor/
|
||||||
@@ -214,8 +260,11 @@ binary_sensor:
|
|||||||
inverted: true
|
inverted: true
|
||||||
use_interrupt: false
|
use_interrupt: false
|
||||||
name: "Button 1: ${switch_1_name}"
|
name: "Button 1: ${switch_1_name}"
|
||||||
|
filters:
|
||||||
|
- delayed_on: 10ms
|
||||||
|
- delayed_off: 10ms
|
||||||
on_press:
|
on_press:
|
||||||
- switch.toggle: relay_1
|
- script.execute: mainlights_toggle
|
||||||
|
|
||||||
# Button 2 (GPIO05)
|
# Button 2 (GPIO05)
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
@@ -224,16 +273,22 @@ binary_sensor:
|
|||||||
mode: INPUT
|
mode: INPUT
|
||||||
inverted: true
|
inverted: true
|
||||||
name: "Button 2: ${switch_2_name}"
|
name: "Button 2: ${switch_2_name}"
|
||||||
|
filters:
|
||||||
|
- delayed_on: 10ms
|
||||||
|
- delayed_off: 10ms
|
||||||
on_press:
|
on_press:
|
||||||
- switch.toggle: relay_2
|
- switch.toggle: relay_2
|
||||||
|
|
||||||
# Button 3 (GPIO04)
|
# Button 3 (GPIO04)
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
pin:
|
pin:
|
||||||
number: GPIO4
|
number: GPIO04
|
||||||
mode: INPUT
|
mode: INPUT
|
||||||
inverted: true
|
inverted: true
|
||||||
name: "Button 3: ${switch_3_name}"
|
name: "Button 3: ${switch_3_name}"
|
||||||
|
filters:
|
||||||
|
- delayed_on: 10ms
|
||||||
|
- delayed_off: 10ms
|
||||||
on_press:
|
on_press:
|
||||||
- switch.toggle: relay_3
|
- switch.toggle: relay_3
|
||||||
|
|
||||||
@@ -242,19 +297,36 @@ binary_sensor:
|
|||||||
# https://esphome.io/components/switch/
|
# https://esphome.io/components/switch/
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
switch:
|
switch:
|
||||||
# Relay 1 (GPIO13) + publish MQTT status
|
# Exposed Home Assistant control for Main Lights. This controls the local relay and
|
||||||
- platform: gpio
|
# publishes the matching command so linked switches follow.
|
||||||
|
- platform: template
|
||||||
name: "Relay 1: ${switch_1_name}"
|
name: "Relay 1: ${switch_1_name}"
|
||||||
|
id: relay_1_ha
|
||||||
|
lambda: |-
|
||||||
|
return id(relay_1).state;
|
||||||
|
turn_on_action:
|
||||||
|
- script.execute: mainlights_on
|
||||||
|
turn_off_action:
|
||||||
|
- script.execute: mainlights_off
|
||||||
|
|
||||||
|
# Physical Relay 1. Kept internal so HA uses the template switch above.
|
||||||
|
# Relay callbacks publish retained status only, not commands.
|
||||||
|
- platform: gpio
|
||||||
|
name: "Internal Relay 1: ${switch_1_name}"
|
||||||
|
internal: true
|
||||||
pin: GPIO13
|
pin: GPIO13
|
||||||
id: relay_1
|
id: relay_1
|
||||||
|
restore_mode: ${relay_restore_mode}
|
||||||
on_turn_on:
|
on_turn_on:
|
||||||
- mqtt.publish:
|
- mqtt.publish:
|
||||||
topic: "${mqtt_local_status_topic}"
|
topic: "${mqtt_local_status_topic}"
|
||||||
payload: "On"
|
payload: "On"
|
||||||
|
retain: true
|
||||||
on_turn_off:
|
on_turn_off:
|
||||||
- mqtt.publish:
|
- mqtt.publish:
|
||||||
topic: "${mqtt_local_status_topic}"
|
topic: "${mqtt_local_status_topic}"
|
||||||
payload: "Off"
|
payload: "Off"
|
||||||
|
retain: true
|
||||||
|
|
||||||
# Relay 2 (GPIO12)
|
# Relay 2 (GPIO12)
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
|
|||||||
Reference in New Issue
Block a user