-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimmersion-gordon.yaml
289 lines (265 loc) · 6.59 KB
/
immersion-gordon.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: immersion-gordon
friendly_name: "Gordon House Immersion"
device_description: "Sonoff POW Elite 20A"
update_interval: 20s
# https://devices.esphome.io/devices/Sonoff-POW-Elite-20a
esphome:
name: $device_name
friendly_name: $friendly_name
on_boot: # Set the initial state of the template switch to the actual relay state. This will NOT change the state.
priority: 250.0 # Wait until WiFi is connected to allow the sensor some time to settle
then:
- if:
condition:
lambda: 'return id(v_sensor).state > 10;'
then:
- switch.turn_on: relay_1
else:
- switch.turn_off: relay_1
esp32:
board: nodemcu-32s
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 172.23.23.11
gateway: 172.23.23.1
subnet: 255.255.255.0
ap:
ssid: $device_name
password: !secret hotspot_wifi_password
captive_portal:
web_server:
port: 80
include_internal: true
logger:
level: INFO
api:
encryption:
key: !secret api_enc
ota:
- platform: esphome
password: !secret ota_pwd
uart:
rx_pin: GPIO16
baud_rate: 4800
parity: EVEN
time:
- platform: homeassistant
id: homeassistant_time
timezone: Europe/London
sensor:
- platform: cse7766
current:
name: Current
id: a_sensor
filters:
- throttle_average: ${update_interval}
voltage:
name: Voltage
id: v_sensor
filters:
- throttle_average: ${update_interval}
power:
name: Power
id: w_sensor
on_value_range:
- above: 4.0
then:
- light.turn_on: switch_led
- below: 3.0
then:
- light.turn_off: switch_led
filters:
- throttle_average: ${update_interval}
energy:
name: Energy
id: wh_sensor
filters:
- throttle_average: ${update_interval}
apparent_power:
name: Apparent Power
filters:
- throttle_average: ${update_interval}
power_factor:
name: Power Factor
filters:
- throttle_average: ${update_interval}
- platform: total_daily_energy
name: Daily Energy
power_id: w_sensor
filters:
- multiply: 0.001
unit_of_measurement: kWh
- platform: wifi_signal
name: Wifi RSSI
update_interval: 60s
- platform: uptime
id: uptime_sensor
internal: True
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? to_string(days) + "d " : "") +
(hours ? to_string(hours) + "h " : "") +
(minutes ? to_string(minutes) + "m " : "") +
(to_string(seconds) + "s")
).c_str();
- platform: template
name: ESP32 Internal Temp
device_class: temperature
unit_of_measurement: °C
id: esp32_temp
lambda: return temperatureRead();
- platform: template
name: Power Factor
device_class: power_factor
id: power_factor
lambda: return id(w_sensor).state / id(v_sensor).state / id(a_sensor).state;
- platform: esp32_hall
name: ESP32 Hall Sensor
update_interval: 60s
binary_sensor:
- platform: gpio
pin: GPIO00
id: reset
internal: true
filters:
- invert:
- delayed_off: 10ms
on_click:
- max_length: 350ms # short press to toggle the relay
then:
switch.toggle: relay_1
- min_length: 360ms # long press to cycle display info
max_length: 3s
then:
- if:
condition:
binary_sensor.is_on: page
then:
binary_sensor.template.publish:
id: page
state: OFF
else:
binary_sensor.template.publish:
id: page
state: ON
- platform: template # this is a fake sensor to tell the screen which info to show on display
id: page
publish_initial_state: true
internal: true
- platform: template
name: Load
id: load_on
lambda: |-
if (isnan(id(w_sensor).state)) {
return {};
} else if (id(w_sensor).state > 4) {
// Running
return true;
} else {
// Not running
return false;
}
display:
platform: tm1621
id: tm1621_display
cs_pin: GPIO25
data_pin: GPIO14
read_pin: GPIO26
write_pin: GPIO27
lambda: |-
if (id(page).state) {
it.display_voltage(true);
it.display_kwh(false);
it.printf(0, "%.1f", id(v_sensor).state);
it.printf(1, "%.1f", id(a_sensor).state);
} else {
it.display_voltage(false);
it.display_kwh(true);
it.printf(0, "%.1f", id(wh_sensor).state);
it.printf(1, "%.1f", id(w_sensor).state);
}
output:
- platform: ledc
id: led
pin:
number: GPIO18
inverted: True
switch:
- platform: template
name: Switch
icon: mdi:water-boiler
optimistic: true
id: relay_1
turn_off_action:
- switch.turn_on: relay_off
turn_on_action:
- switch.turn_on: relay_on
- platform: gpio
restore_mode: ALWAYS_OFF
internal: true
id: relay_off
pin: GPIO04
on_turn_on:
- delay: 500ms
- switch.turn_off: relay_off # bi-stable relay so no need to keep on
- light.turn_off: switch_led
interlock: [relay_on]
- platform: gpio
restore_mode: ALWAYS_OFF
internal: true
id: relay_on
pin: GPIO02
on_turn_on:
- delay: 500ms
- switch.turn_off: relay_on # bi-stable relay so no need to keep on
- light.turn_on: switch_led
interlock: [relay_off]
- platform: restart
name: Restart
text_sensor:
- platform: template
name: Uptime
id: uptime_human
icon: mdi:clock-start
- platform: wifi_info
ip_address:
name: IP
ssid:
name: SSID
bssid:
name: BSSID
light:
- platform: monochromatic
id: switch_led
output: led
internal: True
- platform: status_led
id: wifi_status_led
internal: True
pin:
number: GPIO05
inverted: True
interval:
- interval: 30s
then:
if:
condition:
wifi.connected:
then:
- light.turn_on: wifi_status_led
else:
- light.turn_off: wifi_status_led