forked from gio-dot/Washing-Machine-Sonoff-Pow-R2-Esphome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sonoff_pow_r2_w_machine.yaml
253 lines (231 loc) · 6.88 KB
/
sonoff_pow_r2_w_machine.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
esphome:
name: sonoff_pow_r2_lavatrice
platform: ESP8266
board: esp01_1m
# esp8266_restore_from_flash: true
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pw
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Sonoff Pow R2 Lavatrice"
password: "BaOG47iOIGPC"
captive_portal:
# Enable logging
logger:
baud_rate: 0
uart:
rx_pin: RX
baud_rate: 4800
# Enable Home Assistant API
api:
ota:
time:
- platform: sntp
id: my_time
################################################################################
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Sonoff POW Button"
internal: true
on_press:
- switch.toggle: relay
################################################################################
# Machine running #
################################################################################
- platform: template
name: "RUN"
id: machine_running
filters:
- delayed_on: 60s # MINIMUM TIME TO AVOID FALSE POSITIVES
- delayed_off: 300s
lambda: |-
if (isnan(id(power).state)) {
return {};
} else if (id(power).state > 4) {
// Running
return true;
} else {
// Not running
return false;
}
on_press:
then: # at cycle start i reset all binary sensors
- lambda: |-
{
id(machine_end).publish_state(false);
id(minimum_working_time).publish_state(false);
id(cycle_centrifughe).publish_state(false);
id(cycle_drain).publish_state(false);
}
- light.turn_on: led
on_release:
then: # at the end of cycle turn on end cycle
- lambda: |-
{
id(machine_end).publish_state(true);
}
################################################################################
# Minimum duration cycle #
################################################################################
- platform: template
name: "Washing Machine Minimum time"
internal: true # minimum working time 30m
id: minimum_working_time
filters:
- delayed_on: 30min
- delayed_off: 180s
lambda: |-
if (isnan(id(power).state)) {
return {};
} else if (id(power).state > 4) {
// Running
return true;
} else {
// Not running (le due graffe significa che non fa nulla)
return {};
}
################################################################################
# Centrifuge #
################################################################################
- platform: template
name: "CENTRIFUGE"
id: cycle_centrifughe
filters:
- delayed_on: 60s
# >< 90W-400W for 60s (centrifuge) 010520 changed threshold to 100W
lambda: |-
if (isnan(id(power).state)) {
return {};
} else if ( (id(power).state > 100)&&(id(power).state < 400)&&(id(minimum_working_time).state) ){
// Running
return true;
} else {
// Not running (le due graffe significa che non fa nulla)
return {};
}
################################################################################
# Water drain #
################################################################################
- platform: template
name: "DRAIN"
id: cycle_drain
filters:
- delayed_on: 60s
# >< 15W-50W for 60s (drain pump)
lambda: |-
if (isnan(id(power).state)) {
return {};
} else if ( (id(power).state > 15) && (id(power).state < 60) && (id(cycle_centrifughe).state) ){
// Running
return true;
} else {
// Not running (le due graffe significa che non fa nulla)
return {};
}
################################################################################
# Machine end #
################################################################################
- platform: template
name: "END"
id: machine_end
on_press:
- light.turn_off: led
################################################################################
switch:
- platform: gpio
id: relay
pin: GPIO12
name: "Sonoff POW Relay"
restore_mode: ALWAYS_ON
output:
- platform: esp8266_pwm
id: pow_blue_led
pin:
number: GPIO13
inverted: True
light:
- platform: monochromatic
name: "Sonoff POW Blue LED"
internal: true
output: pow_blue_led
id: led
sensor:
- platform: wifi_signal
name: "Sonoff POW WiFi Signal"
update_interval: 60s
- platform: uptime
name: "Sonoff POW Uptime"
- platform: cse7766
update_interval: 2s
current:
name: "Sonoff POW Current"
id: curr
internal: true
voltage:
name: "Sonoff POW Voltage"
id: volt
internal: true
power:
name: "Sonoff POW Power"
id: power
internal: true
# on_value_range:
# - above: 4.0
# then:
# - light.turn_on: led
# - below: 3.0
# then:
# - delay: 60s
# - light.turn_off: led
- platform: total_daily_energy ############################
name: "Sonoff POW R2 Total Daily Energy"
power_id: power
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kWh
accuracy_decimals: 1
################################################################################
# Slow sensors for Home assistant #
################################################################################
- platform: template #########################
name: "Sonoff Pow Current Slow"
lambda: |-
if (id(curr).state) {
return (id(curr).state);
} else {
return 0;
}
unit_of_measurement: A
icon: "mdi:alpha-a-circle"
update_interval: 90s
- platform: template #########################
name: "Sonoff Pow Voltage Slow"
lambda: |-
if (id(volt).state) {
return (id(volt).state);
} else {
return 0;
}
unit_of_measurement: V
icon: "mdi:alpha-v-circle"
update_interval: 90s
- platform: template #########################
name: "Sonoff Pow Power Slow"
lambda: |-
if (id(power).state) {
return (id(power).state);
} else {
return 0;
}
unit_of_measurement: W
icon: "mdi:alpha-w-circle"
update_interval: 90s
text_sensor:
- platform: version
name: "Sonoff POW ESPHome Version"