-
Notifications
You must be signed in to change notification settings - Fork 20
/
switch-dining.yaml
62 lines (55 loc) · 1.51 KB
/
switch-dining.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
# 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