forked from brianhanifin/esphome-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshelly1_01.yaml
57 lines (50 loc) · 1.39 KB
/
shelly1_01.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
---
# 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