mirror of
https://github.com/brianhanifin/esphome-config.git
synced 2026-07-28 04:05:55 +00:00
57 lines
1.4 KiB
YAML
57 lines
1.4 KiB
YAML
---
|
|
# Shelly 1 Power Module
|
|
# Location: Dining Room Light Switch
|
|
#
|
|
substitutions:
|
|
project: Dining Room Light Switch
|
|
id: switchdining
|
|
|
|
hass_light: light.dining_room
|
|
|
|
<<: !include common/substitutions/gpio/shelly1.yaml
|
|
|
|
<<: !include common/esphome/esp8266.yaml
|
|
<<: !include common/common.yaml
|
|
|
|
script:
|
|
- id: hass_light_toggle
|
|
then:
|
|
if:
|
|
condition:
|
|
api.connected:
|
|
then:
|
|
- if:
|
|
condition:
|
|
switch.is_off: relay
|
|
then:
|
|
# Turn the relay back on and turn on the light.
|
|
- switch.turn_on: relay
|
|
|
|
- homeassistant.service:
|
|
service: light.turn_on
|
|
data:
|
|
entity_id: $hass_light
|
|
else:
|
|
# Have Home Assistant toggle the light.
|
|
- homeassistant.service:
|
|
service: light.toggle
|
|
data:
|
|
entity_id: $hass_light
|
|
else:
|
|
# When HA is unavailable, toggle the relay.
|
|
- switch.toggle: relay
|
|
|
|
binary_sensor:
|
|
- platform: gpio
|
|
pin:
|
|
number: $button_gpio
|
|
name: $project Wall Switch
|
|
id: button
|
|
filters:
|
|
- delayed_on: 10ms
|
|
- delayed_off: 10ms
|
|
on_state:
|
|
- script.execute: hass_light_toggle
|
|
|
|
switch:
|
|
<<: !include common/switches/relay_always_on_internal.yaml |