-
Notifications
You must be signed in to change notification settings - Fork 0
/
pc_cop.yaml
417 lines (379 loc) · 9.14 KB
/
pc_cop.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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
esphome:
name: cop
globals:
- id: screen_timeout
type: int
restore_value: no
initial_value: '60'
- id: fade_time
type: int
restore_value: no
initial_value: '10'
output:
- platform: ledc
pin: 25
id: backlight_pwm
light:
- platform: monochromatic
output: backlight_pwm
name: "ILI9341 Display Backlight"
id: back_light
restore_mode: ALWAYS_OFF
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "********************************************"
ota:
password: "********************************"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Cop Fallback Hotspot"
password: "************"
captive_portal:
uart:
rx_pin: 16
tx_pin: 17
baud_rate: 9600
modbus:
spi:
clk_pin: 18
mosi_pin: 23
dallas:
pin: 22
update_interval: 60s
sensor:
- platform: pzemac
id: pzemac_1
current:
name: "PZEM-004T V3 Current"
id: pc_current
voltage:
name: "PZEM-004T V3 Voltage"
energy:
name: "PZEM-004T V3 Energy (Total)"
id: el_energy_total
state_class: total_increasing
device_class: energy
filters:
offset: 0.0
power:
name: "PZEM-004T V3 Power"
id: el_power
frequency:
name: "PZEM-004T V3 Frequency"
power_factor:
name: "PZEM-004T V3 Power Factor"
update_interval: 60s
- platform: dallas
address: 0x510b228144cf6928
name: T1
id: pc_T1
- platform: dallas
address: 0xcc0b22811f6bc128
name: T2
id: pc_T2
# PC power sensors
# heating
- platform: template
name: "PC Power (Heating)"
id: pc_power_heating
device_class: "power"
unit_of_measurement: "W"
state_class: measurement
update_interval: 60s
lambda: |-
if ((id(el_power).state > 100) && (id(pc_T1).state > id(pc_T2).state)) {
return 0.02*4.2*997*(id(pc_T1).state-id(pc_T2).state)*0.01666666*1000;
}
else
{ return 0.0;
}
# cooling
- platform: template
name: "PC Power (Cooling)"
id: pc_power_cooling
device_class: "power"
unit_of_measurement: "W"
state_class: measurement
update_interval: 60s
lambda: |-
if ((id(el_power).state > 100) && (id(pc_T2).state > id(pc_T1).state)) {
return 0.02*4.2*997*(id(pc_T2).state-id(pc_T1).state)*0.01666666*1000;
}
else
{ return 0.0;
}
# total
- platform: template
name: "PC Power (Total)"
id: pc_power_total
device_class: "power"
unit_of_measurement: "W"
state_class: measurement
update_interval: 60s
lambda: |-
return id(pc_power_heating).state+id(pc_power_cooling).state;
# Electric power sensors
# heating
- platform: template
name: "Electric Power (Heating)"
id: el_power_heating
device_class: "power"
unit_of_measurement: "W"
state_class: measurement
update_interval: 60s
lambda: |-
if (id(pc_T2).state < id(pc_T1).state) {
return id(el_power).state;
}
else
{ return 0.0;
}
# cooling
- platform: template
name: "Electric Power (Cooling)"
id: el_power_cooling
device_class: "power"
unit_of_measurement: "W"
state_class: measurement
update_interval: 60s
lambda: |-
if (id(pc_T2).state > id(pc_T1).state) {
return id(el_power).state;
}
else
{ return 0.0;
}
# total is el_power
# PC energy counters
# heating
- platform: integration
sensor: pc_power_heating
time_unit: h
name: "PC Energy (heating)"
id: pc_energy_heating
state_class: total
device_class: energy
restore: true
filters:
- offset: 0.0
# cooling
- platform: integration
sensor: pc_power_cooling
time_unit: h
name: "PC Energy (cooling)"
id: pc_energy_cooling
state_class: total
device_class: energy
restore: true
# total
- platform: integration
sensor: pc_power_total
time_unit: h
name: "PC Energy (total)"
id: pc_energy_total
state_class: total
device_class: energy
restore: true
filters:
- offset: 0.0
# EL energy counters
# heating
- platform: integration
sensor: el_power_heating
time_unit: h
name: "Electric Energy Heating"
id: el_energy_heating
state_class: total
device_class: energy
restore: true
filters:
- offset: 0.0
# cooling
- platform: integration
sensor: el_power_cooling
time_unit: h
name: "Electric Energy Cooling"
id: el_energy_cooling
state_class: total
device_class: energy
restore: true
filters:
- offset: 0.0
# daily PC energy
- platform: total_daily_energy
name: "Total Daily PC Energy"
power_id: pc_power_total
id: pc_energy_daily
# daily EN Energy
- platform: total_daily_energy
name: "Total Daily Electric Energy"
power_id: el_power
id: el_energy_daily
# COP'S
# daily
- platform: template
name: "_COP Daily"
id: pc_cop_daily
update_interval: 60s
lambda: |-
if (id(el_energy_daily).state != 0.0)
return id(pc_energy_daily).state/id(el_energy_daily).state;
else
return 0.0;
- platform: template
name: "_COP (heating)"
id: pc_cop_heating
update_interval: 60s
lambda: |-
if (id(el_energy_heating).state != 0.0)
return id(pc_energy_heating).state/id(el_energy_heating).state;
else
return 0.0;
- platform: template
name: "_COP (cooling)"
id: pc_cop_cooling
update_interval: 60s
lambda: |-
if (id(el_energy_heating).state != 0.0)
return id(pc_energy_cooling).state/id(el_energy_cooling).state;
else
return 0.0;
- platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
name: "WiFi Signal dB"
id: wifi_signal_db
update_interval: 60s
entity_category: "diagnostic"
- platform: copy # Reports the WiFi signal strength in %
source_id: wifi_signal_db
name: "WiFi Signal Percent"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "Signal %"
entity_category: "diagnostic"
font:
- file: "arial.ttf"
id: arial
size: 20
- file: "gfonts://Roboto"
id: roboto20
size: 20
- file: "gfonts://Roboto"
id: roboto30
size: 30
- file: "gfonts://Roboto"
id: roboto40
size: 40
display:
- platform: ili9341
model: TFT 2.4
cs_pin: 5
dc_pin: 27
# led_pin: 25 ### see note below ###
reset_pin: 26
update_interval: 5s
rotation: 270
id: ili
pages:
- id: page_1
lambda: |-
it.printf(0, 0, id(roboto20), "El power: %.1fW", id(el_power).state);
it.printf(0, 21, id(roboto20), "PC power: %.1fW", id(pc_power_total).state);
it.graph(0,45,id(pc_power_graph),my_green);
- id: page_2
lambda: |-
it.printf(0, 0, id(roboto40), "COP heat: %.2f", id(pc_cop_heating).state);
it.printf(0, 41, id(roboto40), "COP Cooling: %.2f", id(pc_cop_cooling).state);
it.printf(0, 82, id(roboto40), "COP Daily: %.2f",id(pc_cop_daily).state);
- id: page_3
lambda: |-
it.printf(0, 0, id(roboto30), "T1: %.2f , T2: %.2f ", id(pc_T1).state, id(pc_T2).state);
it.graph(0,45,id(pc_temp_graph),my_green);
graph:
- id: pc_power_graph
width: 300
height: 177
duration: 1h
traces:
- sensor: pc_power_total
line_thickness: 1
line_type: SOLID
color: my_lt_green
- sensor: el_power
line_thickness: 1
line_type: SOLID
color: my_lt_blue
- id: pc_temp_graph
width: 300
height: 177
duration: 1h
traces:
- sensor: pc_T1
line_thickness: 1
line_type: SOLID
color: my_lt_green
- sensor: pc_T2
line_thickness: 1
line_type: SOLID
color: my_lt_blue
color:
- id: my_lt_green
red: 33%
green: 100%
blue: 33%
- id: my_lt_blue
red: 33%
green: 33%
blue: 100%
- id: my_green
red: 0%
green: 100%
blue: 0%
touchscreen:
platform: xpt2046
id: tcreen
cs_pin: 15
update_interval: 50ms
report_interval: 1s
threshold: 400
calibration_x_min: 3860
calibration_x_max: 280
calibration_y_min: 340
calibration_y_max: 3860
swap_x_y: false
on_touch:
- lambda: |-
ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
id(tcreen).x,
id(tcreen).y,
id(tcreen).x_raw,
id(tcreen).y_raw
);
ESP_LOGI("ts", "Turning on");
auto call = id(back_light).turn_on();
call.set_brightness(0.77);
call.perform();
ESP_LOGI("ts", "Waiting 60s");
- delay: 60s
- lambda: |-
ESP_LOGI("ts", "Fading 10s");
auto call = id(back_light).turn_off();
call.set_transition_length(60*1000);
call.perform();
interval:
- interval: 5s
then:
- display.page.show_next: ili
- component.update: ili
time:
- platform: homeassistant
id: homeassistant_time