mirror of
https://github.com/brianhanifin/esphome-config.git
synced 2026-07-27 19:55:41 +00:00
63 lines
1.5 KiB
YAML
63 lines
1.5 KiB
YAML
---
|
|
# Shelly 1
|
|
# Location: Dining room light wall switch
|
|
#
|
|
substitutions:
|
|
friendly_name: Dining room light wall switch
|
|
id: switch_dining
|
|
hostname: switch-dining
|
|
#ip: 10.0.20.9
|
|
|
|
light_entity: light.dining_room
|
|
|
|
<<: !include common/substitutions/gpio/shelly1.yaml
|
|
|
|
<<: !include common/esphome/esp8266.yaml
|
|
<<: !include common/common.yaml
|
|
|
|
script:
|
|
- id: light_entity_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: $light_entity
|
|
else:
|
|
# Have Home Assistant toggle the light.
|
|
- homeassistant.service:
|
|
service: light.toggle
|
|
data:
|
|
entity_id: $light_entity
|
|
else:
|
|
# When HA is unavailable, toggle the relay.
|
|
- switch.toggle: relay
|
|
|
|
binary_sensor:
|
|
- platform: gpio
|
|
pin:
|
|
number: $button_gpio
|
|
#name: $friendly_name
|
|
id: button
|
|
internal: true
|
|
#disabled_by_default: true
|
|
#entity_category: diagnostic
|
|
filters:
|
|
- delayed_on: 10ms
|
|
- delayed_off: 10ms
|
|
on_state:
|
|
- script.execute: light_entity_toggle
|
|
|
|
switch:
|
|
<<: !include common/switches/relay_always_on_internal.yaml
|