-
Notifications
You must be signed in to change notification settings - Fork 0
/
window-shutter-direct.yaml
289 lines (263 loc) · 6.56 KB
/
window-shutter-direct.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
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
substitutions:
device_name: "window-shutter"
device_verbose_name: "Window Shutter"
device_class: "shutter"
pin_led1: GPIO0
pin_button1: GPIO2
pin_relay1: GPIO4
pin_switch2n: GPIO5
pin_sda: GPIO12
pin_switch1n: GPIO13
pin_scl: GPIO14
pin_relay2: GPIO15
pin_ade7953: GPIO16
pin_temp: A0
open_duration: 30s
close_duration: 30s
ota_password:
fallback_hotspot_password:
wifi1_ssid:
wifi1_password:
esphome:
name: "${device_name}"
platform: ESP8266
board: modwifi
# Enable logging
logger:
level: INFO
# Enable Home Assistant API
api:
services:
- service: calibrate_lower_endstop
then:
- delay: 1s
- switch.turn_on: relay1
- delay: 1s
- switch.turn_off: relay1
- delay: 1s
- switch.turn_on: relay1
- delay: 1s
- switch.turn_off: relay1
- service: calibrate_upper_endstop
then:
- delay: 1s
- switch.turn_on: relay2
- delay: 1s
- switch.turn_off: relay2
- delay: 0.8s
- switch.turn_on: relay2
- delay: 1s
- switch.turn_off: relay2
- service: reset_endstops
then:
- switch.turn_on: relay1
- delay: 1s
- switch.turn_off: relay1
- delay: 1s
- switch.turn_on: relay2
- delay: 1s
- switch.turn_off: relay2
- delay: 1s
- switch.turn_on: relay2
- delay: 1s
- switch.turn_off: relay2
- delay: 1s
- switch.turn_on: relay1
- delay: 1s
- switch.turn_off: relay1
- delay: 1s
- switch.turn_on: relay2
- delay: 1s
- switch.turn_off: relay2
- delay: 1s
- switch.turn_on: relay1
- delay: 1s
- switch.turn_off: relay1
- delay: 1s
- switch.turn_on: relay1
- delay: 1s
- switch.turn_off: relay1
ota:
safe_mode: true
id: my_ota
password: "${ota_password}"
wifi:
ssid: ${wifi1_ssid}
password: ${wifi1_password}
power_save_mode: none
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${device_name}"
password: ${fallback_hotspot_password}
captive_portal:
time:
- platform: sntp
servers:
- 10.80.80.1
# Enable Web server (optional).
web_server:
port: 80
# Text sensors with general information.
text_sensor:
- platform: wifi_info
ip_address:
name: ${device_verbose_name} IP
i2c:
sda: GPIO12
scl: GPIO14
# Sensors with general information.
sensor:
# Uptime sensor.
#- platform: uptime
# name: ${device_verbose_name} Uptime
# WiFi Signal sensor.
#- platform: wifi_signal
# name: ${device_verbose_name} WiFi Signal
# update_interval: 60s
- platform: ade7953
irq_pin: ${pin_ade7953} # Prevent overheating by setting this
#voltage:
# name: ${device_verbose_name} Voltage
# filters:
# - throttle: 5s
# On the Shelly 2.5 channels are mixed ch1=B ch2=A
current_a:
name: ${device_verbose_name} Close Current
id: close_current
internal: true
current_b:
name: ${device_verbose_name} Open Current
id: open_current
internal: true
active_power_a:
name: ${device_verbose_name} Active Power Close
id: close_power
internal: true
filters:
- lambda: if (x < 2) return 0; else return x;
# active_power_a is normal, so don't multiply by -1
active_power_b:
name: ${device_verbose_name} Active Power Open
id: open_power
internal: true
# active_power_b is inverted, so multiply by -1
filters:
- multiply: -1
- lambda: if (x < 2) return 0; else return x;
update_interval: 0.5s
- platform: ntc
sensor: temp_resistance_reading
name: ${device_verbose_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: 90
then: # Security shutdown by overheating
- switch.turn_on: _shutdown
- platform: resistance
id: temp_resistance_reading
sensor: temp_analog_reading
configuration: DOWNSTREAM
resistor: 32kOhm
internal: true
- platform: adc
id: temp_analog_reading
pin: A0
update_interval: 30s
internal: true
- platform: template
name: ${device_verbose_name} Active Power
id: total_active_power
unit_of_measurement: W
lambda: return (id(open_power).state + id(close_power).state);
filters:
multiply: 0.1
update_interval: 1s
- platform: total_daily_energy
name: ${device_verbose_name} Daily Energy
power_id: total_active_power
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kWh
status_led:
pin:
number: GPIO0
inverted: yes
binary_sensor:
- platform: gpio
pin: ${pin_switch2n}
name: "Switch #2"
internal: true
id: switch2
filters:
- delayed_on: 10ms
- delayed_off: 10ms
on_press:
then:
- switch.turn_on: relay2
on_release:
then:
- switch.turn_off: relay2
- platform: gpio
pin: ${pin_switch1n}
name: "Switch #1"
internal: true
id: switch1
filters:
- delayed_on: 10ms
- delayed_off: 10ms
on_press:
then:
- switch.turn_on: relay1
on_release:
then:
- switch.turn_off: relay1
switch:
- platform: shutdown
id: _shutdown
internal: true
name: ${device_verbose_name} Shelly 2.5 Shutdown
- platform: gpio
pin: ${pin_relay1}
name: "Relay #1"
internal: true
id: relay1
interlock: &interlock_group [relay1, relay2]
interlock_wait_time: 500ms
- platform: gpio
pin: ${pin_relay2}
name: "Relay #2"
internal: true
id: relay2
interlock: *interlock_group
interlock_wait_time: 500ms
cover:
- platform: current_based
device_class: ${device_class}
name: "${device_verbose_name} Shutter"
id: shutter
open_sensor: open_current
open_moving_current_threshold: 0.5
open_duration: ${open_duration}
open_action:
- switch.turn_on: relay1
close_sensor: close_current
close_moving_current_threshold: 0.5
close_duration: ${close_duration}
close_action:
- switch.turn_on: relay2
stop_action:
- switch.turn_off: relay1
- switch.turn_off: relay2
obstacle_rollback: 30%
start_sensing_delay: 0.8s
malfunction_detection: true
malfunction_action:
then:
- logger.log: "Malfunction detected. Relay welded."