-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshelly-bathroom.yaml_old
244 lines (233 loc) · 6.89 KB
/
shelly-bathroom.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
substitutions:
shelly_id: "Bathroom"
device_name: "Shelly ${shelly_id}"
channel_1: Mirror Light
channel_2: Spotlights
max_power: "2000.0" # watt
max_temp: "80.0" # °C
esphome:
name: shelly-bathroom
platform: ESP8266
board: esp01_1m
on_boot:
priority: 100
then:
- binary_sensor.template.publish:
id: switch_clicker_1
state: OFF
- binary_sensor.template.publish:
id: switch_clicker_2
state: OFF
packages:
wifi: !include /config/esphome/common/wifi.yaml
network_diagnostics: !include /config/esphome/common/network_diagnostics.yaml
base_config: !include /config/esphome/common/base_config.yaml
i2c:
sda: GPIO12
scl: GPIO14
# Sensors with general information.
sensor:
# 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
- platform: ade7953_i2c
voltage:
name: ${device_name} voltage
current_a:
name: ${channel_2} current
internal: true
current_b:
name: ${channel_1} current
internal: true
active_power_a:
name: ${channel_2} power
id: power_channel_2
filters:
- multiply: 1
on_value_range:
- above: ${max_power}
then:
- switch.turn_off: shelly_relay_2
- homeassistant.service:
service: persistent_notification.create
data:
title: Message from ${device_name}
data_template:
message: Switch turned off because power exceeded ${max_power}W
active_power_b:
name: ${channel_1} power
id: power_channel_1
filters:
- multiply: -1
on_value_range:
- above: ${max_power}
then:
- switch.turn_off: shelly_relay_1
- homeassistant.service:
service: persistent_notification.create
data:
title: Message from ${device_name}
data_template:
message: Switch turned off because power exceeded ${max_power}W
update_interval: 30s
# NTC Temperature
- platform: ntc
sensor: temp_resistance_reading
name: ${device_name} temperature
unit_of_measurement: "°C"
accuracy_decimals: 1
icon: "mdi:thermometer"
calibration:
b_constant: 3350
reference_resistance: 10kOhm
reference_temperature: 298.15K
on_value_range:
- above: ${max_temp}
then:
- switch.turn_off: shelly_relay_1
- switch.turn_off: shelly_relay_2
- homeassistant.service:
service: persistent_notification.create
data:
title: Message from ${device_name}
data_template:
message: Switch turned off because temperature exceeded ${max_temp}°C
- platform: resistance
id: temp_resistance_reading
sensor: temp_analog_reading
configuration: DOWNSTREAM
resistor: 32kOhm
- platform: adc
id: temp_analog_reading
pin: A0
status_led:
pin:
number: GPIO0
inverted: yes
switch:
- platform: gpio # Mirror Light
name: ${device_name} Relay 1
pin: GPIO4
id: shelly_relay_1
# After reboot, restore default or turn off
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio # Spotlights
name: ${device_name} Relay 2
pin: GPIO15
id: shelly_relay_2
# After reboot, restore to ON
restore_mode: RESTORE_DEFAULT_ON
binary_sensor:
- platform: gpio
name: ${device_name} Input 1
pin:
number: GPIO13
# 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_1
state: ON
- delay: 100ms
- binary_sensor.template.publish:
id: switch_clicker_1
state: OFF
id: button_1
- platform: template
name: ${device_name} Momentary Switch 1
id: switch_clicker_1
on_click:
- switch.toggle: shelly_relay_1
- platform: gpio
name: ${device_name} Input 2
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_2
state: ON
- delay: 100ms
- binary_sensor.template.publish:
id: switch_clicker_2
state: OFF
id: button_2
- platform: template
name: ${device_name} Momentary Switch 2
id: switch_clicker_2
on_multi_click:
# triple click
- timing:
- ON for at most 1s
- OFF for at most 1s
- ON for at most 1s
- OFF for at most 1s
- ON for at most 1s
- OFF for at least 0.2s
then:
- homeassistant.event:
event: esphome.button_pressed
data:
title: ${device_name} triple click
device_name: ${device_name}
channel: ${channel_2}
click_type: triple
click_count: "3"
# 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_2
then:
- homeassistant.event:
event: esphome.button_pressed
data:
title: ${device_name} double click
device_name: ${device_name}
channel: ${channel_2}
click_type: double
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_2
# 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}
channel: ${channel_2}
click_type: single
click_count: "1"
# toggle relay in case either wifi or api are not connected
else:
- switch.toggle: shelly_relay_2