-
Notifications
You must be signed in to change notification settings - Fork 42
/
vacuum.yaml
809 lines (778 loc) · 26.7 KB
/
vacuum.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
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
###################################
# iRobot Vacuum Package
###################################
###################################
# Sensor
###################################
sensor:
# Roomba via Rest980 Docker Image
- platform: rest
name: rest980
json_attributes:
- batPct
- bin
- cleanMissionStatus
- dock
- pose
- signal
- bbmssn
- bbrun
- name
- pmaps
- vacHigh
- openOnly
- twoPass
- noAutoPasses
- softwareVer
- runtimeStats
resource: !secret vacuum_state
value_template: 'OK'
scan_interval: 10
- platform: template
sensors:
vacuum:
friendly_name_template: >-
{{ state_attr('sensor.rest980', 'name') }}
value_template: >-
{% if state_attr('sensor.rest980', 'cleanMissionStatus')['cycle'] == 'none' and state_attr('sensor.rest980', 'cleanMissionStatus')['notReady'] == 39 %}
Pending
{% elif state_attr('sensor.rest980', 'cleanMissionStatus')['notReady'] > 0 %}
Not Ready
{% else %}
{% set mapper = {
'clean' : 'Clean',
'quick' : 'Clean',
'spot' : 'Spot',
'evac' : 'Empty',
'dock' : 'Dock',
'train' : 'Train',
'none' : 'Ready' } %}
{% set state = state_attr('sensor.rest980', 'cleanMissionStatus')['cycle'] %}
{{ mapper[state] if state in mapper else state }}
{% endif %}
icon_template: mdi:robot-vacuum
attribute_templates:
notready_msg: >-
{% set mapper = {
0 : 'n-a',
2 : 'Uneven Ground',
15 : 'Low Battery',
39 : 'Pending',
48 : 'Path Blocked' } %}
{% set state = state_attr('sensor.rest980', 'cleanMissionStatus')['notReady'] %}
{{ mapper[state] if state in mapper else state }}
error_msg: >-
{% set mapper = {
0 : 'n-a',
15 : 'Reboot Required',
18 : 'Docking Issue'} %}
{% set state = state_attr('sensor.rest980', 'cleanMissionStatus')['error'] %}
{{ mapper[state] if state in mapper else state }}
battery: >-
{{ state_attr('sensor.rest980', 'batPct') }} %
software_ver: >-
{% if state_attr('sensor.rest980', 'softwareVer') is defined %}
{% set version = state_attr('sensor.rest980', 'softwareVer') %}
{% if '+' in version %}
{{ version.split('+')[1] }}
{% else %}
{{ version }}
{% endif %}
{% else %}
n-a
{% endif %}
phase: >-
{% if state_attr('sensor.rest980', 'cleanMissionStatus')['phase'] == 'charge' and state_attr('sensor.rest980', 'batPct') == 100 %}
Idle
{% elif state_attr('sensor.rest980', 'cleanMissionStatus')['cycle'] == 'none' and state_attr('sensor.rest980', 'cleanMissionStatus')['phase'] == 'stop' %}
Stopped
{% else %}
{% set mapper = {
'charge' : 'Charge',
'run' : 'Run',
'evac' : 'Empty',
'stop' : 'Paused',
'stuck' : 'Stuck',
'hmUsrDock' : 'Sent Home',
'hmMidMsn' : 'Mid Dock',
'hmPostMsn' : 'Final Dock' } %}
{% set state = state_attr('sensor.rest980', 'cleanMissionStatus')['phase'] %}
{{ mapper[state] if state in mapper else state }}
{% endif %}
bin: >-
{% set mapper = {
true : 'Full',
false : 'Not Full' } %}
{% set state = state_attr('sensor.rest980', 'bin')['full'] %}
{{ mapper[state] if state in mapper else state }}
bin_present: >-
{% set mapper = {
true : 'Yes',
false : 'No' } %}
{% set state = state_attr('sensor.rest980', 'bin')['present'] %}
{{ mapper[state] if state in mapper else state }}
clean_base: >-
{% if state_attr('sensor.rest980', 'dock')['state'] is defined %}
{% set mapper = {
300 : 'Ready',
301 : 'Ready',
302 : 'Empty',
303 : 'Empty',
350 : 'Bag Missing',
351 : 'Clogged',
352 : 'Sealing Problem',
353 : 'Bag Full',
360 : 'Comms Problem' } %}
{% set state = state_attr('sensor.rest980', 'dock')['state'] %}
{{ mapper[state] if state in mapper else state }}
{% else %}
n-a
{% endif %}
location: >-
{% if state_attr('sensor.rest980', 'pose')['theta'] is defined %}
({{ state_attr('sensor.rest980', 'pose')['point']['x'] }}, {{ state_attr('sensor.rest980', 'pose')['point']['y'] }}, {{ state_attr('sensor.rest980', 'pose')['theta'] }})
{% else %}
n-a
{% endif %}
rssi: >-
{% if state_attr('sensor.rest980', 'signal')['rssi'] is defined %}
{{ state_attr('sensor.rest980', 'signal')['rssi'] }}
{% else %}
n-a
{% endif %}
total_area: >-
{% if state_attr('sensor.rest980', 'runtimeStats')['sqft'] is defined %}
{{ (state_attr('sensor.rest980', 'runtimeStats')['sqft'] / 10.764 * 100)| round() }}m²
{% else %}
n-a
{% endif %}
# {{ (state_attr('sensor.rest980', 'runtimeStats')['sqft'] }}ft²
total_time: >-
{% if state_attr('sensor.rest980', 'runtimeStats')['hr'] is defined %}
{{ state_attr('sensor.rest980', 'runtimeStats')['hr'] }}h {{ state_attr('sensor.rest980', 'runtimeStats')['min'] }}m
{% else %}
n-a
{% endif %}
total_jobs: >-
{% if state_attr('sensor.rest980', 'bbmssn')['nMssn'] is defined %}
{{ state_attr('sensor.rest980', 'bbmssn')['nMssn'] }}
{% else %}
n-a
{% endif %}
dirt_events: >-
{% if state_attr('sensor.rest980', 'bbrun')['nScrubs'] is defined %}
{{ state_attr('sensor.rest980', 'bbrun')['nScrubs'] }}
{% else %}
n-a
{% endif %}
# evac_events I7+/S9+ Models (Clean Base)
evac_events: >-
{% if state_attr('sensor.rest980', 'bbrun')['nEvacs'] is defined %}
{{ state_attr('sensor.rest980', 'bbrun')['nEvacs'] }}
{% else %}
n-a
{% endif %}
job_initiator: >-
{% set mapper = {
'schedule' : 'Scheduler',
'rmtApp' : 'App',
'manual' : 'Robot',
'localApp' : 'HA' } %}
{% set state = state_attr('sensor.rest980', 'cleanMissionStatus')['initiator'] %}
{{ mapper[state] if state in mapper else state }}
job_time: >-
{% if state_attr('sensor.rest980', 'cleanMissionStatus')['mssnStrtTm'] is defined %}
{% if state_attr('sensor.rest980', 'cleanMissionStatus')['mssnStrtTm'] != 0 %}
{% set time = state_attr('sensor.rest980', 'cleanMissionStatus')['mssnStrtTm'] | timestamp_local %}
{% set elapsed = ((as_timestamp(now()) - as_timestamp(time)) / 60) | round(0) %}
{% if elapsed > 60 %}
{{ elapsed // 60 }}h {{ '{:0>2d}'.format(elapsed%60) }}m
{% else %}
{{elapsed}}m
{% endif %}
{% else %}
n-a
{% endif %}
{% else %}
n-a
{% endif %}
job_recharge: >-
{% if state_attr('sensor.rest980', 'cleanMissionStatus')['rechrgTm'] is defined %}
{% if state_attr('sensor.rest980', 'cleanMissionStatus')['rechrgTm'] != 0 %}
{% set time = state_attr('sensor.rest980', 'cleanMissionStatus')['rechrgTm'] | timestamp_local %}
{% set resume = ((as_timestamp(time) - as_timestamp(now())) / 60) | round(0) %}
{% if resume > 60 %}
{{ resume // 60 }}h {{ '{:0>2d}'.format(resume%60) }}m
{% else %}
{{resume}}m
{% endif %}
{% else %}
n-a
{% endif %}
{% else %}
n-a
{% endif %}
job_expires: >-
{% if state_attr('sensor.rest980', 'cleanMissionStatus')['expireTm'] is defined %}
{% if state_attr('sensor.rest980', 'cleanMissionStatus')['expireTm'] != 0 %}
{% set time = state_attr('sensor.rest980', 'cleanMissionStatus')['expireTm'] | timestamp_local %}
{% set resume = ((as_timestamp(time) - as_timestamp(now())) / 60) | round(0) %}
{% if resume > 60 %}
{{ resume // 60 }}h {{ '{:0>2d}'.format(resume%60) }}m
{% else %}
{{resume}}m
{% endif %}
{% else %}
n-a
{% endif %}
{% else %}
n-a
{% endif %}
clean_mode: >-
{% if state_attr('sensor.rest980', 'noAutoPasses') is defined and state_attr('sensor.rest980', 'twoPass') is defined %}
{% if state_attr('sensor.rest980', 'noAutoPasses') == true and state_attr('sensor.rest980', 'twoPass') == false %}
One
{% elif state_attr('sensor.rest980', 'noAutoPasses') == true and state_attr('sensor.rest980', 'twoPass') == true %}
Two
{% else %}
Auto
{% endif %}
{% else %}
n-a
{% endif %}
carpet_boost: >-
{% if state_attr('sensor.rest980', 'vacHigh') is defined %}
{% if state_attr('sensor.rest980', 'vacHigh') == false and state_attr('sensor.rest980', 'carpetBoost') == false %}
Eco
{% elif state_attr('sensor.rest980', 'vacHigh') == true and state_attr('sensor.rest980', 'carpetBoost') == false %}
Performance
{% else %}
Auto
{% endif %}
{% else %}
n-a
{% endif %}
clean_edges: >-
{% if state_attr('sensor.rest980', 'openOnly') is defined %}
{% if state_attr('sensor.rest980', 'openOnly') == true %}
False
{% else %}
True
{% endif %}
{% else %}
n-a
{% endif %}
maint_due: >-
{% if is_state('input_boolean.vacuum_maint_due', 'on') %}
True
{% else %}
False
{% endif %}
# pmap0_id I7/S9 Models
pmap0_id: >-
{% if state_attr('sensor.rest980', 'pmaps')[0] is defined %}
{{ state_attr('sensor.rest980', 'pmaps')[0] | regex_findall_index("{'([\w\-]+)': '\w+'}") }}
{% else %}
n-a
{% endif %}
vacuum_location:
friendly_name_template: >-
{{ state_attr('sensor.rest980', 'name') }} Location
value_template: >-
{{ state_attr('sensor.vacuum', 'location') }}
icon_template: mdi:home-map-marker
###################################
# Rest Command
###################################
rest_command:
vacuum_action:
url: >-
{{ states('input_text.vacuum_action') }}{{ command }}
verify_ssl: !secret vacuum_verify_ssl
method: 'get'
timeout: 20
vacuum_clean:
url: >-
{{ states('input_text.vacuum_action') }}cleanRoom
verify_ssl: !secret vacuum_verify_ssl
method: POST
content_type: 'application/json'
payload: '{{ payload }}'
###################################
# Input Boolean
###################################
input_boolean:
vacuum_clean_kitchen:
name: Kitchen
icon: mdi:silverware-fork-knife
vacuum_clean_zone_fridge:
name: Fridge Zone
icon: mdi:fridge
vacuum_clean_entry:
name: Entry
icon: mdi:coat-rack
vacuum_clean_hall:
name: Hall
icon: mdi:ceiling-light
vacuum_clean_living_room:
name: Living Room
icon: mdi:sofa
vacuum_clean_bathroom:
name: Bathroom
icon: mdi:shower
vacuum_clean_bedroom:
name: Bedroom
icon: mdi:bed-empty
vacuum_clean_wardrobe:
name: Wardrobe
icon: mdi:wardrobe-outline
vacuum_clean_master_ensuite:
name: Master Ensuite
icon: mdi:shower
vacuum_clean_master_bedroom:
name: Master Bedroom
icon: mdi:bed-empty
vacuum_clean_master_passage:
name: Master Passage
icon: mdi:ceiling-light
vacuum_clean_table:
name: Table
icon: mdi:room-service
vacuum_maint_due:
name: Vacuum Maintenance
icon: mdi:wrench
vacuum_schedule_1:
name: Vacuum Schedule 1
icon: mdi:timetable
vacuum_schedule_2:
name: Vacuum Schedule 2
icon: mdi:timetable
###################################
# Input Text
###################################
input_text:
vacuum_action:
name: Vacuum Action URL
initial: !secret vacuum_action
vacuum_map:
name: Vacuum Map URL
initial: !secret vacuum_map
vacuum_log:
name: Vacuum Log Path
initial: !secret vacuum_log
vacuum_dir:
name: Vacuum Dir Path
initial: !secret vacuum_dir
vacuum_rooms:
name: Vacuum Rooms
max: 255
vacuum_clean_kitchen:
name: Kitchen
initial: !secret vacuum_kitchen
vacuum_clean_zone_fridge:
name: Fridge Zone
initial: !secret vacuum_clean_zone_fridge
vacuum_clean_entry:
name: Entry
initial: !secret vacuum_entry
vacuum_clean_hall:
name: Hall
initial: !secret vacuum_hall
vacuum_clean_living_room:
name: Living Room
initial: !secret vacuum_living_room
vacuum_clean_bathroom:
name: Bathroom
initial: !secret vacuum_bathroom
vacuum_clean_bedroom:
name: Bedroom
initial: !secret vacuum_bedroom
vacuum_clean_wardrobe:
name: Wardrobe
initial: !secret vacuum_wardrobe
vacuum_clean_master_ensuite:
name: Master Ensuite
initial: !secret vacuum_master_ensuite
vacuum_clean_master_bedroom:
name: Master Bedroom
initial: !secret vacuum_master_bedroom
vacuum_clean_master_passage:
name: Master Passage
initial: !secret vacuum_master_passage
vacuum_clean_table:
name: Table
initial: !secret vacuum_table
###################################
# Group
###################################
group:
vacuum_rooms:
entities:
- input_boolean.vacuum_clean_kitchen
- input_boolean.vacuum_clean_zone_fridge
- input_boolean.vacuum_clean_entry
- input_boolean.vacuum_clean_hall
- input_boolean.vacuum_clean_living_room
- input_boolean.vacuum_clean_bathroom
- input_boolean.vacuum_clean_bedroom
- input_boolean.vacuum_clean_wardrobe
- input_boolean.vacuum_clean_master_ensuite
- input_boolean.vacuum_clean_master_bedroom
- input_boolean.vacuum_clean_master_passage
- input_boolean.vacuum_clean_table
###################################
# Automation
###################################
automation:
# Initiate Selective Room Clean
- alias: Vacuum Clean Rooms
trigger:
- platform: event
event_type: initiate_vacuum_clean
condition:
condition: not
conditions:
- condition: state
entity_id: input_text.vacuum_rooms
state: ''
action:
- service: rest_command.vacuum_clean
data_template:
payload: >
{% set rooms = states('input_text.vacuum_rooms') %}
{% if rooms[-1:] == ',' %}
{% set rooms = rooms[:-1] %}
{% endif %}
{% set rooms = rooms.split(",") %}
{
"ordered": 1,
"pmap_id": "{{ state_attr('sensor.vacuum', 'pmap0_id') | string }}",
"regions": [{% for id in rooms %}
{% set room = 'input_text.vacuum_clean_' + id %} {{ states(room) | string }} {%- if not loop.last %},{%- endif %}
{%- endfor %}
]
}
- service: input_text.set_value
data:
entity_id: input_text.vacuum_rooms
value: ''
- service: input_boolean.turn_off
data:
entity_id: group.vacuum_rooms
# Update Vacuum REST Sensor for Location Details
- alias: Vacuum Update Location
initial_state: true
trigger:
- platform: time_pattern
seconds: /2
- platform: event
event_type: call_service
event_data:
domain: rest_command
service: vacuum_clean
condition:
condition: or
conditions:
- condition: template
value_template: "{{ is_state_attr('sensor.vacuum', 'phase', 'Run') }}"
- condition: template
value_template: "{{ is_state_attr('sensor.vacuum', 'phase', 'Sent Home') }}"
- condition: template
value_template: "{{ is_state_attr('sensor.vacuum', 'phase', 'Mid Dock') }}"
- condition: template
value_template: "{{ is_state_attr('sensor.vacuum', 'phase', 'Final Dock') }}"
action:
- service: homeassistant.update_entity
entity_id: sensor.rest980
# Log Vacuum Location to File
- alias: Vacuum Log Position
initial_state: true
trigger:
platform: state
entity_id: sensor.vacuum_location
condition:
condition: or
conditions:
- condition: state
entity_id: sensor.vacuum
state: 'Clean'
- condition: state
entity_id: sensor.vacuum
state: 'Train'
action:
- service: notify.vacuumfile
data_template:
message: "{{ states('sensor.vacuum_location') }}"
# Initialize Blank Vacuum Log File
- alias: Vacuum Clean Log
initial_state: true
trigger:
- platform: state
entity_id: sensor.vacuum
from: 'Ready'
to: 'Clean'
- platform: state
entity_id: sensor.vacuum
from: 'Ready'
to: 'Train'
action:
- service: shell_command.vacuum_clear_log
- service: shell_command.vacuum_clear_image
# Update Vacuum Log File with Finished Status
- alias: Vacuum Notify on Finished Cleaning
initial_state: true
trigger:
- platform: state
entity_id: sensor.vacuum
from: 'Clean'
to: 'Ready'
- platform: state
entity_id: sensor.vacuum
from: 'Train'
to: 'Ready'
- platform: state
entity_id: sensor.vacuum
from: 'Pending'
to: 'Ready'
action:
- service: notify.vacuumfile
data_template:
message: "Finished"
# Update Vacuum Log File with Stuck Status
- alias: Vacuum Notify on Stuck Status
initial_state: true
trigger:
platform: template
value_template: "{{ is_state_attr('sensor.vacuum', 'phase', 'Stuck') }}"
action:
- service: notify.vacuumfile
data_template:
message: "Stuck"
# DELETE BELOW SECTION IF YOU DONT WANT NOTIFICATIONS
- delay: 5
- service: !secret vacuum_notify
data_template:
title: "{{ state_attr('sensor.rest980', 'name') }} requires your attention"
message: "{{ state_attr('sensor.rest980', 'name') }} is stuck."
# =============
# NOTICE THIS SECTION IS VALID FOR IOS USERS ONLY!
data:
attachment:
content-type: jpeg
push:
category: camera
entity_id: camera.roomba
# =============
# Generate Complete Vacuum Map
- alias: Vacuum Generate Image after Cleaning
initial_state: true
trigger:
- platform: state
entity_id: sensor.vacuum
from: 'Clean'
to: 'Ready'
for:
seconds: 10
- platform: state
entity_id: sensor.vacuum
from: 'Train'
to: 'Ready'
for:
seconds: 10
- platform: state
entity_id: sensor.vacuum
from: 'Pending'
to: 'Ready'
for:
seconds: 10
action:
- service: shell_command.vacuum_generate_image
# DELETE BELOW SECTION IF YOU DONT WANT NOTIFICATIONS
- delay: 5
- service: !secret vacuum_notify
data_template:
title: "{{ state_attr('sensor.rest980', 'name') }}"
message: "{{ state_attr('sensor.rest980', 'name') }} successfully completed a job!"
# =============
# NOTICE THIS SECTION IS VALID FOR IOS USERS ONLY!
data:
attachment:
content-type: jpeg
push:
category: camera
entity_id: camera.roomba
# =============
# Maintenance Check
- alias: Vacuum Maintenance Check
initial_state: true
trigger:
- platform: time_pattern
minutes: /15
- platform: state
entity_id: [
'sensor.vacuum_maint_clean_brushes',
'sensor.vacuum_maint_clean_contacts',
'sensor.vacuum_maint_clean_filter',
'sensor.vacuum_maint_clean_wheel',
'sensor.vacuum_maint_clean_bin',
'sensor.vacuum_maint_replace_brushes',
'sensor.vacuum_maint_replace_filter',
'sensor.vacuum_maint_replace_wheel'
]
action:
- service: >-
{% set ns = namespace(count = 0) %}
{% for item in states.sensor if 'sensor.vacuum_maint' in item.entity_id and (state_attr(item.entity_id, 'timeout_timestamp') < as_timestamp(now())) %}
{% set ns.count = loop.index %}
{% endfor %}
{% if ns.count > 0 %}
input_boolean.turn_on
{% else %}
input_boolean.turn_off
{% endif %}
entity_id: input_boolean.vacuum_maint_due
# Add Rooms for Ordered Cleaning
- alias: Vacuum Add Rooms for Cleaning
initial_state: true
trigger:
platform: state
entity_id: [
'input_boolean.vacuum_clean_kitchen',
'input_boolean.vacuum_clean_zone_fridge',
'input_boolean.vacuum_clean_entry',
'input_boolean.vacuum_clean_hall',
'input_boolean.vacuum_clean_living_room',
'input_boolean.vacuum_clean_bathroom',
'input_boolean.vacuum_clean_bedroom',
'input_boolean.vacuum_clean_wardrobe',
'input_boolean.vacuum_clean_master_ensuite',
'input_boolean.vacuum_clean_master_bedroom',
'input_boolean.vacuum_clean_master_passage',
'input_boolean.vacuum_clean_table'
]
to: 'on'
action:
service: input_text.set_value
data_template:
entity_id: input_text.vacuum_rooms
value: |
{% set room = trigger.entity_id %}
{% set room = room.replace("input_boolean.vacuum_clean_","") %}
{% if ((states('input_text.vacuum_rooms') == "unknown") or (states('input_text.vacuum_rooms') == "")) %}
{{ room }},
{% else %}
{{ states('input_text.vacuum_rooms') }}{{ room }},
{% endif %}
# Remove Rooms for Ordered Cleaning
- alias: Vacuum Remove Rooms for Cleaning
initial_state: true
trigger:
platform: state
entity_id: [
'input_boolean.vacuum_clean_kitchen',
'input_boolean.vacuum_clean_zone_fridge',
'input_boolean.vacuum_clean_entry',
'input_boolean.vacuum_clean_hall',
'input_boolean.vacuum_clean_living_room',
'input_boolean.vacuum_clean_bathroom',
'input_boolean.vacuum_clean_bedroom',
'input_boolean.vacuum_clean_wardrobe',
'input_boolean.vacuum_clean_master_ensuite',
'input_boolean.vacuum_clean_master_bedroom',
'input_boolean.vacuum_clean_master_passage',
'input_boolean.vacuum_clean_table'
]
to: 'off'
action:
service: input_text.set_value
data_template:
entity_id: input_text.vacuum_rooms
value: |
{% set room = trigger.entity_id %}
{% set room = room.replace("input_boolean.vacuum_clean_","") %}
{% set result = states('input_text.vacuum_rooms') %}
{% set result = result.replace(room + ",","") %}
{{ result }}
# Vacuum Cleaning Schedule 1
- alias: Vacuum Cleaning Schedule 1
initial_state: true
trigger:
platform: time_pattern
hours: "6"
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.vacuum_schedule_1
state: 'on'
- condition: state
entity_id: input_boolean.vacation
state: 'off'
action:
- service: input_text.set_value
entity_id: input_text.vacuum_rooms
data_template:
entity_id: input_text.vacuum_rooms
value: "kitchen"
- service: automation.trigger
entity_id: automation.vacuum_clean_rooms
# Vacuum Cleaning Schedule 2
- alias: Vacuum Cleaning Schedule 2
initial_state: true
trigger:
platform: time_pattern
hours: "10"
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.vacuum_schedule_2
state: 'on'
- condition: state
entity_id: input_boolean.vacation
state: 'off'
- condition: time
weekday:
- mon
- wed
- fri
action:
- service: input_text.set_value
entity_id: input_text.vacuum_rooms
data_template:
entity_id: input_text.vacuum_rooms
value: "kitchen,entry,hall,living_room,bathroom,bedroom,wardrobe,master_ensuite,master_passage"
- service: automation.trigger
entity_id: automation.vacuum_clean_rooms
# Delete Old Vacuum Image Files
- alias: Vacuum Delete Images
initial_state: true
trigger:
platform: time_pattern
hours: "00"
action:
- service: shell_command.vacuum_delete_images
###################################
# Notify
###################################
notify:
- name: VacuumFile
platform: file
filename: !secret vacuum_log
###################################
# Camera
###################################
camera:
- platform: generic
still_image_url: >-
{{ states('input_text.vacuum_map') }}
content_type: image/png
name: Roomba
###################################
# Shell Command
###################################
shell_command:
vacuum_clear_log: cp /dev/null {{ states('input_text.vacuum_log') }}
vacuum_clear_image: curl -X GET -s -O /dev/null '{{ states("input_text.vacuum_map") }}?clear=true'
vacuum_generate_image: curl -X GET -s -O /dev/null '{{ states("input_text.vacuum_map") }}?last=true'
vacuum_delete_images: find {{ states('input_text.vacuum_dir') }} -regex ".*[0-9]\.png" -type f -mtime +20 -exec rm -f {} \;