-
-
Notifications
You must be signed in to change notification settings - Fork 495
Expand file tree
/
Copy pathvacuum.yaml
More file actions
executable file
·864 lines (830 loc) · 34.1 KB
/
vacuum.yaml
File metadata and controls
executable file
·864 lines (830 loc) · 34.1 KB
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
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
######################################################################
# @CCOSTAN - Follow Me on X
# For more info visit https://www.vcloudinfo.com/click-here
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# -------------------------------------------------------------------
# Dreame Vacuum Orchestration - Continuous phased sweep/mop with away/on-demand
# Related Issue: 1550, 1553
# Phases: sweep main, sweep baths, mop main, mop baths; notifications + idle auto-start
# -------------------------------------------------------------------
# Notes:
# - `sensor.l10s_vacuum_current_room` can change during transit; require a dwell (`for:`) before dequeuing.
# - Treat 2+ minutes in a room as "being cleaned" and dequeue immediately (queue = remaining rooms).
# - Phase changes happen only after verified completion at dock (`task_status: completed`).
# - Guarded fallback: if docked with empty queue for 10 minutes but no `completed`, advance with `fallback_advance` log.
# - This installed Dreame build still needs native `dreame_vacuum.vacuum_clean_segment`; do not rely on HA `vacuum.clean_area`.
# - Jinja2 loop scoping: use a `namespace` when building lists (otherwise the queue can appear empty and get cleared).
# - If docked+completed still has queue entries, treat queue as stale and clear it before phase advance.
# - Mop phases use `sweeping_and_mopping` instead of mop-only.
# - One-off room clean booleans ignore the queue; they only run when the vacuum is docked/idle.
# - Family-return docking ignores away windows under 20 minutes to avoid short-walk false stops, but docks after 10 minutes home if the family stays put.
# - Formal Dining (room 17/dock) is excluded from phased queues; clean via one-off toggle.
# - Phase advancement no longer depends on a separate "ready" latch.
######################################################################
## 1. Helpers
######################################################################
input_boolean:
l10s_vacuum_on_demand:
name: Dreame Clean (On-Demand)
icon: mdi:robot-vacuum
l10s_vacuum_clean_kitchen:
name: Kitchen Clean
icon: mdi:robot-vacuum
l10s_vacuum_clean_dining_room:
name: Dining Room Clean
icon: mdi:robot-vacuum
l10s_vacuum_clean_living_room:
name: Living Room Clean
icon: mdi:robot-vacuum
l10s_vacuum_clean_master_bedroom:
name: Master Bedroom Clean
icon: mdi:robot-vacuum
l10s_vacuum_clean_foyer:
name: Foyer Clean
icon: mdi:robot-vacuum
l10s_vacuum_clean_stacey_office:
name: Stacey Office Clean
icon: mdi:robot-vacuum
l10s_vacuum_clean_formal_dining:
name: Formal Dining Clean
icon: mdi:robot-vacuum
l10s_vacuum_clean_hallway:
name: Hallway Clean
icon: mdi:robot-vacuum
l10s_vacuum_clean_justin_bedroom:
name: Justin Bedroom Clean
icon: mdi:robot-vacuum
l10s_vacuum_clean_paige_bedroom:
name: Paige Bedroom Clean
icon: mdi:robot-vacuum
l10s_vacuum_clean_master_bathroom:
name: Master Bathroom Clean
icon: mdi:robot-vacuum
l10s_vacuum_clean_office:
name: Office Clean
icon: mdi:robot-vacuum
l10s_vacuum_clean_pool_bath:
name: Pool Bath Clean
icon: mdi:robot-vacuum
l10s_vacuum_clean_kids_bathroom:
name: Kids Bathroom Clean
icon: mdi:robot-vacuum
input_select:
l10s_vacuum_phase:
name: L10s Vacuum Phase
options:
- sweep_main
- sweep_bath
- mop_main
- mop_bath
initial: sweep_main
icon: mdi:playlist-check
input_text:
l10s_vacuum_room_queue:
name: L10s Vacuum Room Queue
# Room order (id:name): 14 Kitchen, 12 Dining, 10 Living, 7 Master Bedroom, 15 Foyer, 9 Stacey Office,
# 13 Hallway, 8 Justin Bedroom, 6 Paige Bedroom, 4 Master Bathroom, 2 Office, 1 Pool Bath, 3 Kids Bathroom.
# Formal Dining (17) is one-off only (dock room).
icon: mdi:format-list-bulleted
max: 255
l10s_vacuum_room_catalog:
name: L10s Vacuum Room Catalog
initial: "6,7,8,9,10,12,13,14,15,2,4,1,3"
icon: mdi:map
max: 255
l10s_vacuum_rooms_cleaned_today:
name: L10s Vacuum Rooms Cleaned Today
icon: mdi:clipboard-check-outline
max: 255
## 2. Script: Start Next Room
######################################################################
script:
l10s_vacuum_start_next_room:
alias: 'Away Vacuum: Start Next Room'
mode: single
sequence:
- variables:
catalog_raw: "{{ states('input_text.l10s_vacuum_room_catalog') | default('', true) | string | replace(' ', '') }}"
catalog_ints: "{{ catalog_raw | regex_findall('[0-9]+') | map('int') | select('gt', 0) | list }}"
bath_ids: [1, 3, 4]
main_ids: "{{ catalog_ints | reject('in', bath_ids) | reject('equalto', 17) | list }}"
phase_order: ['sweep_main', 'sweep_bath', 'mop_main', 'mop_bath']
phase_state: "{{ states('input_select.l10s_vacuum_phase') }}"
phase: "{{ phase_state if phase_state in phase_order else 'sweep_main' }}"
queue_raw: "{{ states('input_text.l10s_vacuum_room_queue') | default('', true) | string | replace(' ', '') }}"
queue_ints: "{{ queue_raw | regex_findall('[0-9]+') | map('int') | select('gt', 0) | list }}"
vac_state: "{{ states('vacuum.l10s_vacuum') | default('', true) | string | lower }}"
vac_is_cleaning: "{{ vac_state == 'cleaning' }}"
cleaning_mode: "{{ 'sweeping_and_mopping' if 'mop_' in phase else 'sweeping' }}"
phase_segments: >
{% if phase == 'sweep_main' %}
{{ main_ids }}
{% elif phase == 'sweep_bath' %}
{{ bath_ids }}
{% elif phase == 'mop_main' %}
{{ main_ids }}
{% else %}
{{ bath_ids }}
{% endif %}
segments_to_clean: "{{ queue_ints if queue_ints | length > 0 else phase_segments }}"
# 0. Reseed the current phase when queue is empty.
- choose:
- conditions:
- condition: template
value_template: "{{ queue_ints | length == 0 }}"
sequence:
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "Queue empty; reseeding phase {{ phase }}."
default: []
# 1. Seed the queue if necessary
- choose:
- conditions:
- condition: template
value_template: "{{ queue_ints | length == 0 and phase_segments | length > 0 }}"
sequence:
- service: input_text.set_value
target:
entity_id: input_text.l10s_vacuum_room_queue
data:
value: "{{ phase_segments | join(',') }}"
default: []
# 2. Check if there is anything to clean and stop if not
- choose:
- conditions:
- condition: template
value_template: "{{ segments_to_clean | length == 0 }}"
sequence:
- stop: 'No rooms left to clean today.'
default: []
# 3. Start cleaning (but don't clobber an active job)
- choose:
- conditions:
- condition: template
value_template: "{{ vac_is_cleaning }}"
sequence:
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "Vacuum is already cleaning; queue/phase updated but not issuing a new segment-clean action."
- stop: "Already cleaning."
default: []
# 4. Start cleaning with the native Dreame segment service.
- service: select.select_option
target:
entity_id: select.l10s_vacuum_cleaning_mode
data:
option: "{{ cleaning_mode }}"
- service: vacuum.set_fan_speed
target:
entity_id: vacuum.l10s_vacuum
data:
fan_speed: Standard
- service: dreame_vacuum.vacuum_clean_segment
target:
entity_id: vacuum.l10s_vacuum
data:
segments: "{{ segments_to_clean }}"
## 3. Automations
######################################################################
automation:
- alias: 'Vacuum: Reset Cleaned List at 5am'
id: 18f7b6d3-c02c-4ec1-88b3-0c3b8b4c6f7b
trigger:
- platform: time
at: '05:00:00'
action:
- service: input_text.set_value
target:
entity_id: input_text.l10s_vacuum_rooms_cleaned_today
data:
value: ""
- alias: 'Vacuum: Auto-Start if Idle 4 Days'
id: c6b3f1e8-9a3f-4098-9b9e-1c7f2d6f1d11
trigger:
- platform: time
at: '17:00:00'
condition:
- condition: template
value_template: >
{% set last = state_attr('script.l10s_vacuum_start_next_room','last_triggered') %}
{{ last is none or (now() - last).days >= 4 }}
action:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.l10s_vacuum_on_demand
- alias: 'Vacuum: One-Off Room Clean (Alexa)'
id: 5e2fd2b1-3f45-4680-ae74-68bb116cf1e8
mode: queued
trigger:
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_kitchen
to: 'on'
id: kitchen
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_dining_room
to: 'on'
id: dining_room
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_living_room
to: 'on'
id: living_room
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_master_bedroom
to: 'on'
id: master_bedroom
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_foyer
to: 'on'
id: foyer
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_stacey_office
to: 'on'
id: stacey_office
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_formal_dining
to: 'on'
id: formal_dining
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_hallway
to: 'on'
id: hallway
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_justin_bedroom
to: 'on'
id: justin_bedroom
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_paige_bedroom
to: 'on'
id: paige_bedroom
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_master_bathroom
to: 'on'
id: master_bathroom
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_office
to: 'on'
id: office
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_pool_bath
to: 'on'
id: pool_bath
- platform: state
entity_id: input_boolean.l10s_vacuum_clean_kids_bathroom
to: 'on'
id: kids_bathroom
variables:
room_map:
kitchen: {segment: 14, name: Kitchen, area: Kitchen}
dining_room: {segment: 12, name: 'Dining Room', area: 'Dining Room'}
living_room: {segment: 10, name: 'Living Room', area: 'Living Room'}
master_bedroom: {segment: 7, name: 'Master Bedroom', area: 'Master Bedroom'}
foyer: {segment: 15, name: Foyer, area: Foyer}
stacey_office: {segment: 9, name: 'Stacey Office', area: 'Stacey Office'}
formal_dining: {segment: 17, name: 'Formal Dining', area: 'Formal Dining'}
hallway: {segment: 13, name: Hallway, area: Hallway}
justin_bedroom: {segment: 8, name: 'Justin Bedroom', area: 'Justin Bedroom'}
paige_bedroom: {segment: 6, name: 'Paige Bedroom', area: 'Paige Bedroom'}
master_bathroom: {segment: 4, name: 'Master Bathroom', area: 'Master Bathroom'}
office: {segment: 2, name: Office, area: Office}
pool_bath: {segment: 1, name: 'Pool Bath', area: 'Pool Bath'}
kids_bathroom: {segment: 3, name: 'Kids Bathroom', area: 'Kids Bathroom'}
room_key: "{{ trigger.id }}"
room_name: "{{ room_map[room_key].name }}"
segment_id: "{{ room_map[room_key].segment | int }}"
vac_state: "{{ states('vacuum.l10s_vacuum') }}"
on_demand: "{{ is_state('input_boolean.l10s_vacuum_on_demand', 'on') }}"
queue_raw: "{{ states('input_text.l10s_vacuum_room_queue') | default('', true) | string | trim }}"
can_start: "{{ vac_state in ['docked', 'idle'] }}"
action:
- choose:
- conditions:
- condition: template
value_template: "{{ can_start and segment_id | int > 0 }}"
sequence:
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "One-off clean: {{ room_name }}."
- continue_on_error: true
service: select.select_option
target:
entity_id: select.l10s_vacuum_cleaning_mode
data:
option: sweeping
- continue_on_error: true
service: vacuum.set_fan_speed
target:
entity_id: vacuum.l10s_vacuum
data:
fan_speed: Standard
- continue_on_error: true
service: dreame_vacuum.vacuum_clean_segment
target:
entity_id: vacuum.l10s_vacuum
data:
segments: "{{ [segment_id] }}"
- delay: "00:00:02"
default:
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "One-off clean blocked: {{ room_name }} (segment={{ segment_id }}, vac={{ vac_state }}, on_demand={{ on_demand }}, queue='{{ queue_raw }}')."
- service: input_boolean.turn_off
data:
entity_id: "{{ trigger.entity_id }}"
- alias: 'Away Vacuum: Start or Resume When we leave or On-Demand'
id: 7f7e0a3c-6452-4f6b-8464-c6c25770a148
trigger:
- platform: state
entity_id: group.family
to: 'not_home'
- platform: state
entity_id: input_boolean.l10s_vacuum_on_demand
to: 'on'
condition:
- condition: state
entity_id: input_boolean.guest_mode
state: 'off'
- condition: template
value_template: "{{ not is_state('vacuum.l10s_vacuum', 'cleaning') }}"
action:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.l10s_vacuum_on_demand
- service: script.l10s_vacuum_start_next_room
- alias: 'Away Vacuum: Dock When Family Returns'
id: 1ef172f2-4b30-4e5b-953d-d4d1ca8701ad
trigger:
- platform: state
entity_id: group.family
to: 'home'
id: family_home
- platform: state
entity_id: group.family
to: 'home'
for: '00:10:00'
id: family_home_stable
- platform: state
entity_id: input_boolean.l10s_vacuum_on_demand
to: 'off'
id: on_demand_off
variables:
family_away_seconds: >
{% if trigger.id == 'family_home'
and trigger.from_state is not none
and trigger.from_state.state == 'not_home'
and trigger.from_state.last_changed is not none %}
{{ (as_timestamp(now()) - as_timestamp(trigger.from_state.last_changed)) | int(0) }}
{% else %}
999999
{% endif %}
condition:
- condition: template
value_template: >
{{ is_state('vacuum.l10s_vacuum', 'cleaning') or is_state('vacuum.l10s_vacuum', 'returning') or is_state('vacuum.l10s_vacuum', 'paused') }}
action:
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.id == 'family_home' and family_away_seconds < 1200 }}"
sequence:
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: >
Family returned after {{ ((family_away_seconds | int(0)) / 60) | round(1) }}
minutes; leaving vacuum running unless we stay home for 10 minutes.
- conditions:
- condition: template
value_template: >
{{ trigger.id == 'family_home_stable' and is_state('input_boolean.l10s_vacuum_on_demand', 'on') }}
sequence:
- service: vacuum.pause
target:
entity_id: vacuum.l10s_vacuum
- delay: 00:00:10
- service: vacuum.return_to_base
target:
entity_id: vacuum.l10s_vacuum
- service: input_boolean.turn_off
target:
entity_id: input_boolean.l10s_vacuum_on_demand
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "Family stayed home for 10 minutes; docking vacuum and disabling On-Demand."
- conditions:
- condition: template
value_template: "{{ trigger.id in ['family_home', 'on_demand_off'] }}"
sequence:
- service: vacuum.pause
target:
entity_id: vacuum.l10s_vacuum
- delay: 00:00:10
- service: vacuum.return_to_base
target:
entity_id: vacuum.l10s_vacuum
- service: input_boolean.turn_off
target:
entity_id: input_boolean.l10s_vacuum_on_demand
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "Family home; docking vacuum and disabling On-Demand."
- alias: 'Away Vacuum: Confirm Room Cleaned'
id: c581c570-55b0-4acd-8b5d-53cfb486cc2a
mode: single
trigger:
- platform: state
entity_id: sensor.l10s_vacuum_current_room
for: '00:02:00'
variables:
room_map: {14: Kitchen, 12: 'Dining Room', 10: 'Living Room', 7: 'Master Bedroom', 15: Foyer, 9: 'Stacey Office', 17: 'Formal Dining', 13: Hallway, 8: 'Justin Bedroom', 6: 'Paige Bedroom', 4: 'Master Bathroom', 2: Office, 1: 'Pool Bath', 3: 'Kids Bathroom'}
queue_raw: "{{ states('input_text.l10s_vacuum_room_queue') | default('', true) | string | replace(' ', '') }}"
queue_ints_raw: "{{ queue_raw | regex_findall('[0-9]+') | map('int') | select('gt', 0) | list | default([], true) }}"
queue_ints: "{{ queue_ints_raw | list }}"
cleaned_room_state: "{{ trigger.to_state.state if trigger.to_state is not none else '' }}"
cleaned_room_id: "{{ (trigger.to_state.attributes.room_id if trigger.to_state is not none else 0) | int(0) }}"
matched_room_id: "{{ cleaned_room_id if cleaned_room_id > 0 and cleaned_room_id in (queue_ints | default([], true)) else 0 }}"
room_name: "{{ room_map.get(matched_room_id, cleaned_room_state) }}"
remaining_list: >
{% set ns = namespace(rem=[]) %}
{% set removed = namespace(done=false) %}
{% for r in queue_ints %}
{% if not removed.done and r == matched_room_id %}
{% set removed.done = true %}
{% else %}
{% set ns.rem = ns.rem + [r] %}
{% endif %}
{% endfor %}
{{ ns.rem }}
remaining_rooms: "{{ remaining_list | join(',') }}"
remaining_count: "{{ remaining_list | length }}"
phase_order: ['sweep_main', 'sweep_bath', 'mop_main', 'mop_bath']
phase_state: "{{ states('input_select.l10s_vacuum_phase') }}"
phase: "{{ phase_state if phase_state in phase_order else 'sweep_main' }}"
phase_index: "{{ phase_order.index(phase) if phase in phase_order else 0 }}"
has_next_phase: "{{ phase_index < (phase_order | length) - 1 }}"
next_phase: "{{ phase_order[phase_index + 1] if has_next_phase else '' }}"
condition:
- condition: template
value_template: >
{{ trigger.from_state is not none and trigger.to_state is not none and trigger.from_state.state != trigger.to_state.state }}
- condition: template
value_template: "{{ queue_ints_raw | length > 0 }}"
- condition: template
value_template: "{{ matched_room_id != 0 }}"
- condition: state
entity_id: vacuum.l10s_vacuum
state: 'cleaning'
- condition: state
entity_id: input_boolean.l10s_vacuum_on_demand
state: 'on'
action:
- variables:
vac_status: "{{ state_attr('vacuum.l10s_vacuum', 'status') | default('', true) | string | lower }}"
vac_charging: "{{ state_attr('vacuum.l10s_vacuum', 'charging') | default(false, true) }}"
- condition: template
value_template: >
{% set is_formal_dining = matched_room_id == 17 %}
{{ not (is_formal_dining and (vac_charging or vac_status in ['charging', 'docked'])) }}
- choose:
- conditions:
- condition: template
value_template: "{{ matched_room_id != 0 }}"
sequence:
- service: input_text.set_value
target:
entity_id: input_text.l10s_vacuum_room_queue
data:
value: "{{ remaining_rooms }}"
- variables:
cleaned_raw: "{{ states('input_text.l10s_vacuum_rooms_cleaned_today') | default('', true) | string }}"
cleaned_parts: "{{ cleaned_raw | regex_findall('[^,]+') | map('trim') | reject('equalto','') | list }}"
updated_cleaned: >
{% set parts = cleaned_parts %}
{% if room_name not in parts %}
{{ (parts + [room_name]) | join(', ') }}
{% else %}
{{ parts | join(', ') }}
{% endif %}
- service: input_text.set_value
target:
entity_id: input_text.l10s_vacuum_rooms_cleaned_today
data:
value: "{{ updated_cleaned }}"
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "{{ room_name }} completed. Phase: {{ phase }}. Remaining: {{ remaining_count }}."
- choose:
- conditions:
- condition: template
value_template: "{{ remaining_count == 0 }}"
sequence:
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "Queue empty for phase {{ phase }}; waiting for completed+docked to advance."
default: []
default: []
- alias: 'Away Vacuum: Advance Phase on Dock After Completion'
id: 6a2d6d8c-3c67-4e3f-9c97-0a2560890d60
mode: single
trigger:
- platform: state
entity_id: vacuum.l10s_vacuum
to: 'docked'
- platform: state
entity_id: sensor.l10s_vacuum_task_status
to: 'completed'
variables:
queue_raw: "{{ states('input_text.l10s_vacuum_room_queue') | default('', true) | trim }}"
queue_ints: "{{ queue_raw | regex_findall('[0-9]+') | map('int') | select('gt', 0) | list }}"
phase_order: ['sweep_main', 'sweep_bath', 'mop_main', 'mop_bath']
phase_state: "{{ states('input_select.l10s_vacuum_phase') }}"
phase: "{{ phase_state if phase_state in phase_order else 'sweep_main' }}"
phase_index: "{{ phase_order.index(phase) if phase in phase_order else 0 }}"
has_next_phase: "{{ phase_index < (phase_order | length) - 1 }}"
next_phase: "{{ phase_order[phase_index + 1] if has_next_phase else '' }}"
condition:
- condition: state
entity_id: input_boolean.l10s_vacuum_on_demand
state: 'on'
- condition: state
entity_id: vacuum.l10s_vacuum
state: 'docked'
- condition: state
entity_id: sensor.l10s_vacuum_task_status
state: 'completed'
action:
- choose:
- conditions:
- condition: template
value_template: "{{ queue_ints | length > 0 }}"
sequence:
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "Completed+docked but queue still had rooms ({{ queue_raw }}); clearing stale queue."
- service: input_text.set_value
target:
entity_id: input_text.l10s_vacuum_room_queue
data:
value: ""
default: []
- choose:
- conditions:
- condition: template
value_template: "{{ has_next_phase }}"
sequence:
- service: input_select.select_option
target:
entity_id: input_select.l10s_vacuum_phase
data:
option: "{{ next_phase }}"
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "Completed phase {{ phase }}; advancing to {{ next_phase }}."
- service: script.l10s_vacuum_start_next_room
- conditions:
- condition: template
value_template: "{{ not has_next_phase }}"
sequence:
- service: input_select.select_option
target:
entity_id: input_select.l10s_vacuum_phase
data:
option: "sweep_main"
- service: input_boolean.turn_off
target:
entity_id: input_boolean.l10s_vacuum_on_demand
- service: input_text.set_value
target:
entity_id: input_text.l10s_vacuum_room_queue
data:
value: ""
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "All phases complete; resetting to sweep_main and disabling On-Demand."
default: []
- alias: 'Away Vacuum: Fallback Advance After Dock Timeout'
id: 0b3db0d9-8a13-4e64-9b2b-8162b64b1e6f
mode: single
trigger:
- platform: template
value_template: >
{{
is_state('input_boolean.l10s_vacuum_on_demand', 'on')
and is_state('vacuum.l10s_vacuum', 'docked')
and (states('input_text.l10s_vacuum_room_queue') | default('', true) | trim == '')
and not is_state('sensor.l10s_vacuum_task_status', 'completed')
}}
for: "00:10:00"
variables:
phase_order: ['sweep_main', 'sweep_bath', 'mop_main', 'mop_bath']
phase_state: "{{ states('input_select.l10s_vacuum_phase') }}"
phase: "{{ phase_state if phase_state in phase_order else 'sweep_main' }}"
phase_index: "{{ phase_order.index(phase) if phase in phase_order else 0 }}"
has_next_phase: "{{ phase_index < (phase_order | length) - 1 }}"
next_phase: "{{ phase_order[phase_index + 1] if has_next_phase else '' }}"
task_status: "{{ states('sensor.l10s_vacuum_task_status') }}"
condition:
- condition: state
entity_id: input_boolean.l10s_vacuum_on_demand
state: 'on'
- condition: state
entity_id: vacuum.l10s_vacuum
state: 'docked'
- condition: template
value_template: "{{ states('input_text.l10s_vacuum_room_queue') | default('', true) | trim == '' }}"
- condition: template
value_template: "{{ task_status != 'completed' }}"
action:
- choose:
- conditions:
- condition: template
value_template: "{{ has_next_phase }}"
sequence:
- service: input_select.select_option
target:
entity_id: input_select.l10s_vacuum_phase
data:
option: "{{ next_phase }}"
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "fallback_advance: docked 10m with empty queue and task_status={{ task_status }}; advancing {{ phase }} -> {{ next_phase }}."
- service: script.l10s_vacuum_start_next_room
- conditions:
- condition: template
value_template: "{{ not has_next_phase }}"
sequence:
- service: input_select.select_option
target:
entity_id: input_select.l10s_vacuum_phase
data:
option: "sweep_main"
- service: input_boolean.turn_off
target:
entity_id: input_boolean.l10s_vacuum_on_demand
- service: input_text.set_value
target:
entity_id: input_text.l10s_vacuum_room_queue
data:
value: ""
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "fallback_advance: final phase timed out docked 10m with empty queue; resetting to sweep_main and disabling On-Demand."
default: []
- alias: 'Away Vacuum: Resume From Dock When Queue Exists'
id: d70ad5a2-6047-4af4-8b4a-6e3b78c19774
mode: single
trigger:
- platform: state
entity_id: vacuum.l10s_vacuum
to: 'docked'
- platform: state
entity_id: input_text.l10s_vacuum_room_queue
for: '00:00:10'
condition:
- condition: state
entity_id: input_boolean.l10s_vacuum_on_demand
state: 'on'
- condition: state
entity_id: vacuum.l10s_vacuum
state: 'docked'
- condition: template
value_template: "{{ states('input_text.l10s_vacuum_room_queue') | default('', true) | trim != '' }}"
action:
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "Docked with queue set; resuming next room without waiting for departure."
- service: script.l10s_vacuum_start_next_room
- alias: 'Vacuum Sensor Cleaning Silencer'
id: 6548de52-a4a4-4df2-9d66-9c2c15577a7f
trigger:
- platform: numeric_state
entity_id: sensor.l10s_vacuum_sensor_dirty_left
below: 10
condition:
- condition: state
entity_id: sensor.l10s_vacuum_task_status
state: 'completed'
action:
- service: button.press
target:
entity_id: button.l10s_vacuum_reset_sensor
- alias: 'Help Vacuum'
id: 6548de52-a4a4-4df2-9d66-9c2c15577a7e
trigger:
- platform: state
entity_id: vacuum.l10s_vacuum
to: 'error'
id: vacuum_state_error
- platform: state
entity_id: sensor.l10s_vacuum_error
id: vacuum_error_state
- platform: event
event_type: event_did_someone_help_vacuum_loop
id: vacuum_error_loop
condition:
- condition: template
value_template: >-
{{
is_state('vacuum.l10s_vacuum', 'error')
or states('sensor.l10s_vacuum_error') not in ['no_error', 'unavailable']
}}
action:
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "{{ states('sensor.l10s_vacuum_error') }} - {{ states('sensor.l10s_vacuum_current_room') }} (phase: {{ states('input_select.l10s_vacuum_phase') }})"
- service: repairs.create
data:
issue_id: "vacuum_error"
title: "Vacuum needs help"
severity: "warning"
persistent: true
description: >-
Vacuum reported an error and needs intervention.
Error: {{ states('sensor.l10s_vacuum_error') }}
Room: {{ states('sensor.l10s_vacuum_current_room') }}
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.id in ['vacuum_state_error', 'vacuum_error_state'] }}"
sequence:
- wait_template: >-
{{
is_state('group.family', 'home')
or is_state('input_boolean.guest_mode', 'on')
or is_state('input_boolean.vacation_mode', 'on')
}}
- service: script.notify_engine
data:
title: 'Help vacuum'
value1: "{{ states('sensor.l10s_vacuum_error') }} - {{ states('sensor.l10s_vacuum_current_room') }}"
who: 'parents'
ios_category: 'camera'
camera_entity: 'camera.l10s_vacuum_map'
content_type: 'jpeg'
group: 'information'
- service: vacuum.locate
entity_id: vacuum.l10s_vacuum
- service: script.speech_engine
data:
value1: >
{{ "Vacuum error: " ~ states('sensor.l10s_vacuum_error') ~ ". Please help the robot." }}
Currently in {{ states('sensor.l10s_vacuum_current_room') }}
- wait_template: "{{ is_state('group.bed', 'off') }}"
- wait_template: "{{ is_state('group.family', 'home') }}"
- delay: 00:03:00
- service: vacuum.locate
entity_id: vacuum.l10s_vacuum
- service: script.speech_engine
data:
value1: >
{{ "Vacuum error: " ~ states('sensor.l10s_vacuum_error') ~ " [ask Residents to help]" }}
Currently in {{states('sensor.l10s_vacuum_current_room')}}
- delay: 00:01:00
- service: vacuum.locate
entity_id: vacuum.l10s_vacuum
- delay: 00:20:00
- event: event_did_someone_help_vacuum_loop
- alias: "Vacuum Error Resolved - Clear Repair Issue"
id: 2a0b3f7f-2f1e-4d2d-8dd4-0f6e4e34b02b
mode: single
trigger:
- platform: state
entity_id: sensor.l10s_vacuum_error
to: 'no_error'
action:
- service: repairs.remove
continue_on_error: true
data:
issue_id: "vacuum_error"
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "Vacuum error cleared (phase: {{ states('input_select.l10s_vacuum_phase') }})."
- alias: "Vacuum Phase Changed"
id: 3e99c6fb-7c4a-4a9f-8f2d-9f1b9a6b4baf
mode: single
trigger:
- platform: state
entity_id: input_select.l10s_vacuum_phase
condition:
- condition: template
value_template: "{{ trigger.from_state is not none and trigger.to_state is not none }}"
action:
- service: script.send_to_logbook
data:
topic: "VACUUM"
message: "Phase changed: {{ trigger.from_state.state }} -> {{ trigger.to_state.state }}."