-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshelly_template.yaml_old
140 lines (125 loc) · 3.49 KB
/
shelly_template.yaml_old
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
substitutions:
shelly_id: "ROOMNAME"
device_name: "Shelly ${shelly_id}"
esphome:
name: shelly-ROOMNAME
platform: ESP8266
board: esp01_1m
on_boot:
priority: 100
then:
- binary_sensor.template.publish:
id: switch_clicker
state: OFF
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ${device_name} Hotspot
password: !secret esphome_fallback_pass
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
# Enable OTA updates
ota:
# Enable Web server (optional).
web_server:
port: 80
# Text sensors with general information.
text_sensor:
- platform: wifi_info
ip_address:
name: ${device_name} IP
# Sensors with general information.
sensor:
# Uptime sensor.
- platform: uptime
name: ${device_name} Uptime
# WiFi Signal sensor.
- platform: wifi_signal
name: ${device_name} WiFi Signal
update_interval: 60s
# Home assistant adaptive lighting
- platform: homeassistant
id: colortemperature
entity_id: switch.adaptive_lighting_adaptive_lighting
attribute: color_temp_kelvin
- platform: homeassistant
id: brightness
entity_id: switch.adaptive_lighting_adaptive_lighting
attribute: brightness_pct
# Shelly 1 detached switch config with fallback in case of wifi or api fail
switch:
- platform: gpio
name: ${device_name}
pin: GPIO4
id: shelly_relay
# After reboot, restore to ON
restore_mode: ALWAYS_ON
binary_sensor:
- platform: gpio
name: ${device_name} Input
pin:
number: GPIO5
# small delay to prevent debouncing
filters:
- delayed_on_off: 50ms
# config for state change of input button
on_state:
then:
- binary_sensor.template.publish:
id: switch_clicker
state: ON
- delay: 100ms
- binary_sensor.template.publish:
id: switch_clicker
state: OFF
id: button
- platform: template
name: ${device_name} Momentary Switch
id: switch_clicker
on_multi_click:
# double click
- timing:
- ON for at most 1s
- OFF for at most 1s
- ON for at most 1s
- OFF for at least 0.2s
then:
- if:
condition:
and:
- wifi.connected:
- api.connected:
- switch.is_on: shelly_relay
then:
- homeassistant.event:
event: esphome.button_pressed
data:
title: ${device_name} double click
device_name: ${device_name}
click_count: "2"
- timing:
- ON for at most 1s
- OFF for at least 0.5s
then:
- if:
condition:
and:
- wifi.connected:
- api.connected:
- switch.is_on: shelly_relay
# send single click event in case wifi and api are conncected
then:
- homeassistant.event:
event: esphome.button_pressed
data:
title: ${device_name} short click
device_name: ${device_name}
click_count: "1"
# toggle relay in case either wifi or api are not connected
else:
- switch.toggle: shelly_relay