/
power_plugs.yaml
executable file
·539 lines (498 loc) · 18 KB
/
power_plugs.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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
################################################
## Packages / Power Plugs
################################################
homeassistant:
customize:
switch.wasmachine:
friendly_name: Wasmachine
switch.tuin:
friendly_name: Tuinverlichting
switch.droger:
friendly_name: Droger
switch.meterkast:
friendly_name: Meterkast
switch.tv_woonkamer:
friendly_name: TV Woonkamer
switch.tv_woonkamer_verlichting:
friendly_name: TV Woonkamer Verlichting
switch.tv_slaapkamer:
friendly_name: TV Slaapkamer
switch.boris:
friendly_name: Verlichting Boris
sensor.wasmachine_watts:
friendly_name: Huidig verbruik wasmachine
icon: mdi:washing-machine
sensor.droger_watts:
friendly_name: Huidig verbruik droger
icon: mdi:tumble-dryer
sensor.wasmachine_status_time:
friendly_name: Wasmachine draaitijd
icon: mdi:washing-machine
sensor.wasmachine_status_value:
friendly_name: Wasmachine status
icon: mdi:washing-machine
sensor.droger_status_time:
friendly_name: Droger draaitijd
icon: mdi:tumble-dryer
sensor.droger_status_value:
friendly_name: Droger status
icon: mdi:tumble-dryer
sensor.wasmachine_this_week:
friendly_name: Weekly Wasmachine Running Hours
icon: mdi:washing-machine
sensor.wasmachine_this_month:
friendly_name: Monthly Wasmachine Running Hours
icon: mdi:washing-machine
sensor.droger_this_week:
friendly_name: Weekly Droger Running Hours
icon: mdi:tumble-dryer
sensor.droger_this_month:
friendly_name: Monthly Droger Running Hours
icon: mdi:tumble-dryer
sensor.percent_wasmachine_weekly:
friendly_name: Weekly Wasmachine
icon: mdi:washing-machine
sensor.percent_wasmachine_monthly:
friendly_name: Monthly Wasmachine
icon: mdi:washing-machine
sensor.percent_droger_weekly:
friendly_name: Weekly Droger
icon: mdi:tumble-dryer
sensor.percent_droger_monthly:
friendly_name: Monthly Droger
icon: mdi:tumble-dryer
################################################
## TP-Link
################################################
tplink:
discovery: false
switch:
- host: 192.168.1.171
- host: 192.168.1.172
- host: 192.168.1.173
- host: 192.168.1.174
- host: 192.168.1.175
- host: 192.168.1.176
- host: 192.168.1.177
- host: 192.168.1.178
- host: 192.168.1.179
################################################
## Group
################################################
group:
hometracking:
name: Household Tracking
view: no
entities:
- device_tracker.taipan5g
- device_tracker.lieke_iphone
################################################
## Inputs
################################################
input_boolean:
wasmachine:
name: Wasmachine status
initial: off
icon: mdi:washing-machine
droger:
name: Droger status
initial: off
icon: mdi:tumble-dryer
input_number:
wasmachine_start:
name: Wasmachine start
min: 0
max: 999999999
wasmachine_stop:
name: Wasmachine stop
min: 0
max: 999999999
droger_start:
name: Droger start
min: 0
max: 999999999
droger_stop:
name: Droger stop
min: 0
max: 999999999
################################################
## Sensor
################################################
binary_sensor:
- platform: ping
host: !secret lgwebostv_host_1
name: TV Ping Woonkamer
scan_interval: 10
count: 3
- platform: ping
host: !secret lgwebostv_host_2
name: TV Ping Slaapkamer
scan_interval: 10
count: 3
sensor:
# VAATWASSER
- platform: template
sensors:
meterkast_watts:
friendly_name: "Huidig verbruik Meterkast"
value_template: '{{ states.switch.meterkast.attributes["current_power_w"] | replace(" W", "") | float }}'
unit_of_measurement: 'W'
meterkast_kw:
friendly_name: "Current KiloWatts"
value_template: '{{ states.switch.meterkast.attributes["total_energy_kwh"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kWh'
meterkast_amps:
friendly_name: "Amps"
value_template: '{{ states.switch.meterkast.attributes["current_a"] | replace(" A", "") | float }}'
unit_of_measurement: 'A'
meterkast_kw_today:
friendly_name: "Today's KiloWatts"
value_template: '{{ states.switch.meterkast.attributes["today_energy_kwh"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kWh'
meterkast_volts:
friendly_name: "Current Voltage"
value_template: '{{ states.switch.meterkast.attributes["voltage"] | replace(" V", "") | float }}'
unit_of_measurement: 'V'
- platform: statistics
name: Meterkast statistics
entity_id: sensor.meterkast_watts
# TUIN
- platform: template
sensors:
tuin_watts:
friendly_name: "Huidig verbruik tuin"
value_template: '{{ states.switch.tuin.attributes["current_power_w"] | replace(" W", "") | float }}'
unit_of_measurement: 'W'
tuin_kw:
friendly_name: "Current KiloWatts"
value_template: '{{ states.switch.tuin.attributes["total_energy_kwh"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kWh'
tuin_amps:
friendly_name: "Amps"
value_template: '{{ states.switch.tuin.attributes["current_a"] | replace(" A", "") | float }}'
unit_of_measurement: 'A'
tuin_kw_today:
friendly_name: "Today's KiloWatts"
value_template: '{{ states.switch.tuin.attributes["today_energy_kwh"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kWh'
tuin_volts:
friendly_name: "Current Voltage"
value_template: '{{ states.switch.tuin.attributes["voltage"] | replace(" V", "") | float }}'
unit_of_measurement: 'V'
- platform: statistics
name: Tuin statistics
entity_id: sensor.tuin_watts
# TV
- platform: template
sensors:
tv_woonkamer_watts:
friendly_name: "Huidig verbruik TV kast"
value_template: '{{ states.switch.tv_woonkamer.attributes["current_power_w"] | replace(" W", "") | float }}'
unit_of_measurement: 'W'
tv_woonkamer_kw:
friendly_name: "Current KiloWatts"
value_template: '{{ states.switch.tv_woonkamer.attributes["total_energy_kwh"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kWh'
tv_woonkamer_amps:
friendly_name: "Amps"
value_template: '{{ states.switch.tv_woonkamer.attributes["current_a"] | replace(" A", "") | float }}'
unit_of_measurement: 'A'
tv_woonkamer_kw_today:
friendly_name: "Today's KiloWatts"
value_template: '{{ states.switch.tv_woonkamer.attributes["today_energy_kwh"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kWh'
tv_woonkamer_volts:
friendly_name: "Current Voltage"
value_template: '{{ states.switch.tv_woonkamer.attributes["voltage"] | replace(" V", "") | float }}'
unit_of_measurement: 'V'
- platform: statistics
name: TV kast statistics
entity_id: sensor.tv_woonkamer_watts
# WASMACHINE
- platform: template
sensors:
wasmachine_watts:
friendly_name: "Huidig verbruik wasmachine"
value_template: '{{ states.switch.wasmachine.attributes["current_power_w"] | replace(" W", "") | float }}'
unit_of_measurement: 'W'
wasmachine_kw_today:
friendly_name: "Today's KiloWatts"
value_template: '{{ states.switch.wasmachine.attributes["today_energy_kwh"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kWh'
wasmachine_amps:
friendly_name: "Amps"
value_template: '{{ states.switch.wasmachine.attributes["current_a"] | replace(" A", "") | float }}'
unit_of_measurement: 'A'
wasmachine_kw:
friendly_name: "Current KiloWatts"
value_template: '{{ states.switch.wasmachine.attributes["total_energy_kwh"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kWh'
wasmachine_volts:
friendly_name: "Current Voltage"
value_template: '{{ states.switch.wasmachine.attributes["voltage"] | replace(" V", "") | float }}'
unit_of_measurement: 'V'
- platform: template
sensors:
wasmachine_verbruik:
friendly_name: "Wasmachine verbruik"
value_template: '{{ (float(states("input_number.wasmachine_stop")) - float(states("input_number.wasmachine_start"))) | round(3) }}'
unit_of_measurement: 'kWh'
- platform: template
sensors:
wasmachine_status_time:
friendly_name: "Wasmachine draaitijd"
unit_of_measurement: 'minuten'
value_template: >
{% if is_state("input_boolean.wasmachine", "on") -%}
{{ ((as_timestamp(now())-as_timestamp(states.input_boolean.wasmachine.last_changed))/60) | round | int }}
{% else %}
0
{% endif %}
entity_id: sensor.time
wasmachine_status_value:
friendly_name: "Wasmachine status"
value_template: >-
{%- if is_state('input_boolean.wasmachine', 'on') -%} Aan
{%- else -%} Uit
{%- endif -%}
- platform: statistics
name: Wasmachine statistics
entity_id: sensor.wasmachine_watts
- platform: template
sensors:
wasmachine_statistics_mean:
friendly_name: Wasmachine statistics Mean
value_template: "{{ state_attr('sensor.wasmachine_statistics','mean') }}"
# DROGER
- platform: template
sensors:
droger_watts:
friendly_name: "Huidig verbruik droger"
value_template: '{{ states.switch.droger.attributes["current_power_w"] | replace(" W", "") | float }}'
unit_of_measurement: 'W'
droger_kw:
friendly_name: "Current KiloWatts"
value_template: '{{ states.switch.droger.attributes["total_energy_kwh"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kWh'
droger_amps:
friendly_name: "Amps"
value_template: '{{ states.switch.droger.attributes["current_a"] | replace(" A", "") | float }}'
unit_of_measurement: 'A'
droger_kw_today:
friendly_name: "Today's KiloWatts"
value_template: '{{ states.switch.droger.attributes["today_energy_kwh"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kWh'
droger_volts:
friendly_name: "Current Voltage"
value_template: '{{ states.switch.droger.attributes["voltage"] | replace(" V", "") | float }}'
unit_of_measurement: 'V'
- platform: template
sensors:
droger_verbruik:
friendly_name: "Droger verbruik"
value_template: '{{ (float(states("input_number.droger_stop")) - float(states("input_number.droger_start"))) | round(3) }}'
unit_of_measurement: 'kWh'
- platform: template
sensors:
droger_status_time:
friendly_name: "Droger draaitijd"
unit_of_measurement: 'minuten'
value_template: >
{% if is_state("input_boolean.droger", "on") -%}
{{ ((as_timestamp(now())-as_timestamp(states.input_boolean.droger.last_changed))/60) | round | int }}
{% else %}
0
{% endif %}
entity_id: sensor.time
droger_status_value:
friendly_name: "Droger status"
value_template: >-
{%- if is_state('input_boolean.droger', 'on') -%} Aan
{%- else -%} Uit
{%- endif -%}
- platform: statistics
name: Droger statistics
entity_id: sensor.droger_watts
- platform: template
sensors:
droger_statistics_mean:
friendly_name: Droger statistics Mean
value_template: "{{ state_attr('sensor.droger_statistics','mean') }}"
################################################
## Automation
################################################
automation:
# WASMACHINE
- alias: Action - Set wasmachine/droger to running
trigger:
- platform: numeric_state
entity_id: sensor.wasmachine_statistics_mean
above: 5
for:
minutes: 5
- platform: numeric_state
entity_id: sensor.droger_statistics_mean
above: 5
for:
minutes: 5
condition: []
action:
- service: homeassistant.turn_on
data_template:
entity_id: >-
input_boolean.
{%- if trigger.entity_id == 'sensor.wasmachine_statistics_mean' -%}wasmachine
{%- elif trigger.entity_id == 'sensor.droger_statistics_mean' -%}droger
{%- endif -%}
- service: input_number.set_value
data_template:
entity_id: >-
input_number.
{%- if trigger.entity_id == 'sensor.wasmachine_statistics_mean' -%}wasmachine_start
{%- elif trigger.entity_id == 'sensor.droger_statistics_mean' -%}droger_start
{%- endif -%}
value: >-
{%- if trigger.entity_id == 'sensor.wasmachine_statistics_mean' -%}
{{ states.sensor.wasmachine_kw_today.state }}
{%- elif trigger.entity_id == 'sensor.droger_statistics_mean' -%}
{{ states.sensor.droger_kw_today.state }}
{%- endif -%}
- service: notify.family
data_template:
title: "Waskamer:"
message: >-
{%- if trigger.entity_id == 'sensor.wasmachine_statistics_mean' -%}
Wasprogramma gestart.
{%- elif trigger.entity_id == 'sensor.droger_statistics_mean' -%}
Droger gestart.
{%- endif -%}
- alias: Action - Set wasmachine/droger as finished
trigger:
- platform: numeric_state
entity_id: sensor.wasmachine_statistics_mean
below: 5
for:
minutes: 1
- platform: numeric_state
entity_id: sensor.droger_statistics_mean
below: 5
for:
minutes: 1
condition:
- condition: state
entity_id: input_boolean.wasmachine
state: 'on'
- condition: state
entity_id: input_boolean.droger
state: 'on'
action:
- service: input_number.set_value
data_template:
entity_id: >-
input_number.
{%- if trigger.entity_id == 'sensor.wasmachine_statistics_mean' -%}wasmachine_stop
{%- elif trigger.entity_id == 'sensor.droger_statistics_mean' -%}droger_stop
{%- endif -%}
value: >-
{%- if trigger.entity_id == 'sensor.wasmachine_statistics_mean' -%}
{{ states.sensor.wasmachine_kw_today.state }}
{%- elif trigger.entity_id == 'sensor.droger_statistics_mean' -%}
{{ states.sensor.droger_kw_today.state }}
{%- endif -%}
- service: notify.family
data_template:
title: "Waskamer:"
message: >-
{%- if trigger.entity_id == 'sensor.wasmachine_statistics_mean' -%}
Wasprogramma gereed. Doorlooptijd: {{ ((as_timestamp(now())-as_timestamp(states.input_boolean.wasmachine.last_changed))/60) | round | int }} minuten. Verbruik: {{ states('sensor.wasmachine_verbruik') }} kWh.
{%- elif trigger.entity_id == 'sensor.droger_statistics_mean' -%}
Droger gereed. Doorlooptijd: {{ ((as_timestamp(now())-as_timestamp(states.input_boolean.droger.last_changed))/60) | round | int }} minuten. Verbruik: {{ states('sensor.droger_verbruik') }} kWh.
{%- endif -%}
# GENERAL
- alias: "General powerplugs On/Off"
trigger:
- platform: time_pattern
minutes: '/10'
seconds: 00
- platform: state
entity_id: sensor.hal_motion
to: 'True'
- platform: state
entity_id: sensor.woonkamer_motion
to: 'True'
condition:
- condition: state
entity_id: input_boolean.automation_mode
state: 'off'
action:
- service: script.turn_on
data_template:
entity_id: >-
{%- if is_state('sensor.woonkamer_motion', 'True') and is_state('switch.tv_woonkamer', 'off') and states('sensor.time_of_day_short') in ['daytime','early evening','evening'] -%}
script.woonkamer_switch_on
{%- else -%}
script.noop
{%- endif -%}
# - service: script.turn_on
# data_template:
# entity_id: >-
# {%- if is_state('sensor.woonkamer_motion', 'False') and is_state('switch.tv_woonkamer', 'on') and is_state('binary_sensor.tv_ping_woonkamer', 'off') and is_state('media_player.livingroom_tv', 'off') and states('sensor.time_of_day_short') in ['night'] -%}
# script.woonkamer_switch_off
# {%- else -%}
# script.noop
# {%- endif -%}
- service: script.turn_on
data_template:
entity_id: >-
{%- if is_state('media_player.bedroom_tv', 'off') and is_state('switch.tv_slaapkamer', 'on') and is_state('binary_sensor.tv_ping_slaapkamer', 'off') -%}
script.slaapkamer_switch_off
{%- else -%}
script.noop
{%- endif -%}
- alias: "TV Kast switch Off"
trigger:
- platform: state
entity_id: sensor.woonkamer_motion
to: 'False'
for:
hours: 4
minutes: 00
condition:
- condition: state
entity_id: input_boolean.automation_mode
state: 'off'
- condition: time
after: '08:30:00'
before: '16:00:00'
action:
- service: script.turn_on
entity_id: script.woonkamer_switch_off
################################################
## Script
################################################
script:
# woonkamer_switch:
# sequence:
# - service_template: >-
# {%- if states('sensor.time_of_day_short') in ['daytime','evening','night'] -%}homeassistant.turn_on
# {%- elif states('sensor.time_of_day_short') in ['evening','night'] -%}homeassistant.turn_off
# entity_id: switch.tv_woonkamer
noop:
sequence:
- delay: '00:00:00'
woonkamer_switch_on:
sequence:
- service: homeassistant.turn_on
entity_id: switch.tv_woonkamer
woonkamer_switch_off:
sequence:
- service: homeassistant.turn_off
entity_id: switch.tv_woonkamer
slaapkamer_switch_on:
sequence:
- service: homeassistant.turn_on
entity_id: switch.tv_slaapkamer
slaapkamer_switch_off:
sequence:
- service: homeassistant.turn_off
entity_id: switch.tv_slaapkamer