1212# - Treat 2+ minutes in a room as "being cleaned" and dequeue immediately (queue = remaining rooms).
1313# - Phase changes happen only after verified completion at dock (`task_status: completed`).
1414# - Guarded fallback: if docked with empty queue for 10 minutes but no `completed`, advance with `fallback_advance` log.
15- # - Avoid reissuing `dreame_vacuum.vacuum_clean_segment` while already cleaning; only send a new segment job when starting/resuming or switching phases .
15+ # - Use `vacuum.clean_area` (HA 2026.3+) and keep room->area mappings aligned with Home Assistant Areas .
1616# - Jinja2 loop scoping: use a `namespace` when building lists (otherwise the queue can appear empty and get cleared).
1717# - If docked+completed still has queue entries, treat queue as stale and clear it before phase advance.
1818# - Mop phases use `sweeping_and_mopping` instead of mop-only.
@@ -133,6 +133,30 @@ script:
133133 {{ bath_ids }}
134134 {% endif %}
135135 segments_to_clean : " {{ queue_ints if queue_ints | length > 0 else phase_segments }}"
136+ segment_area_name_map :
137+ 14 : Kitchen
138+ 12 : " Dining Room"
139+ 10 : " Living Room"
140+ 7 : " Master Bedroom"
141+ 15 : Foyer
142+ 9 : " Stacey Office"
143+ 13 : Hallway
144+ 8 : " Justin Bedroom"
145+ 6 : " Paige Bedroom"
146+ 4 : " Master Bathroom"
147+ 2 : Office
148+ 1 : " Pool Bath"
149+ 3 : " Kids Bathroom"
150+ cleaning_area_ids : >
151+ {% set ns = namespace(ids=[]) %}
152+ {% for seg in segments_to_clean %}
153+ {% set area_name = segment_area_name_map.get(seg) %}
154+ {% set aid = area_id(area_name) if area_name else none %}
155+ {% if aid %}
156+ {% set ns.ids = ns.ids + [aid] %}
157+ {% endif %}
158+ {% endfor %}
159+ {{ ns.ids }}
136160
137161 # 0. Reseed the current phase when queue is empty.
138162 - choose :
@@ -168,6 +192,19 @@ script:
168192 - stop : ' No rooms left to clean today.'
169193 default : []
170194
195+ # 2b. Clean-area needs a mapped Home Assistant area ID for every segment
196+ - choose :
197+ - conditions :
198+ - condition : template
199+ value_template : " {{ cleaning_area_ids | length != segments_to_clean | length }}"
200+ sequence :
201+ - service : script.send_to_logbook
202+ data :
203+ topic : " VACUUM"
204+ message : " Missing area mappings for one or more segments {{ segments_to_clean }}; skipping clean_area."
205+ - stop : " Incomplete Home Assistant area mappings."
206+ default : []
207+
171208 # 3. Start cleaning (but don't clobber an active job)
172209 - choose :
173210 - conditions :
@@ -177,7 +214,7 @@ script:
177214 - service : script.send_to_logbook
178215 data :
179216 topic : " VACUUM"
180- message : " Vacuum is already cleaning; queue/phase updated but not issuing a new segment job ."
217+ message : " Vacuum is already cleaning; queue/phase updated but not issuing a new clean_area action ."
181218 - stop : " Already cleaning."
182219 default : []
183220
@@ -192,12 +229,12 @@ script:
192229 entity_id : vacuum.l10s_vacuum
193230 data :
194231 fan_speed : Standard
195- - service : dreame_vacuum.vacuum_clean_segment
232+ - service : vacuum.clean_area
196233 target :
197234 entity_id : vacuum.l10s_vacuum
198235 data :
199- # Clean the non-bathrooms if any, otherwise clean the bathrooms
200- segments : " {{ segments_to_clean }}"
236+ # Clean mapped Home Assistant areas for this phase queue.
237+ cleaning_area_id : " {{ cleaning_area_ids }}"
201238
202239
203240# # 3. Automations
@@ -294,22 +331,24 @@ automation:
294331 id : kids_bathroom
295332 variables :
296333 room_map :
297- kitchen : {segment: 14, name: Kitchen}
298- dining_room : {segment: 12, name: 'Dining Room'}
299- living_room : {segment: 10, name: 'Living Room'}
300- master_bedroom : {segment: 7, name: 'Master Bedroom'}
301- foyer : {segment: 15, name: Foyer}
302- stacey_office : {segment: 9, name: 'Stacey Office'}
303- formal_dining : {segment: 17, name: 'Formal Dining'}
304- hallway : {segment: 13, name: Hallway}
305- justin_bedroom : {segment: 8, name: 'Justin Bedroom'}
306- paige_bedroom : {segment: 6, name: 'Paige Bedroom'}
307- master_bathroom : {segment: 4, name: 'Master Bathroom'}
308- office : {segment: 2, name: Office}
309- pool_bath : {segment: 1, name: 'Pool Bath'}
310- kids_bathroom : {segment: 3, name: 'Kids Bathroom'}
334+ kitchen : {segment: 14, name: Kitchen, area: Kitchen }
335+ dining_room : {segment: 12, name: 'Dining Room', area: 'Dining Room' }
336+ living_room : {segment: 10, name: 'Living Room', area: 'Living Room' }
337+ master_bedroom : {segment: 7, name: 'Master Bedroom', area: 'Master Bedroom' }
338+ foyer : {segment: 15, name: Foyer, area: Foyer }
339+ stacey_office : {segment: 9, name: 'Stacey Office', area: 'Stacey Office' }
340+ formal_dining : {segment: 17, name: 'Formal Dining', area: 'Formal Dining' }
341+ hallway : {segment: 13, name: Hallway, area: Hallway }
342+ justin_bedroom : {segment: 8, name: 'Justin Bedroom', area: 'Justin Bedroom' }
343+ paige_bedroom : {segment: 6, name: 'Paige Bedroom', area: 'Paige Bedroom' }
344+ master_bathroom : {segment: 4, name: 'Master Bathroom', area: 'Master Bathroom' }
345+ office : {segment: 2, name: Office, area: Office }
346+ pool_bath : {segment: 1, name: 'Pool Bath', area: 'Pool Bath' }
347+ kids_bathroom : {segment: 3, name: 'Kids Bathroom', area: 'Kids Bathroom' }
311348 room_key : " {{ trigger.id }}"
312349 room_name : " {{ room_map[room_key].name }}"
350+ area_name : " {{ room_map[room_key].area }}"
351+ area_id_value : " {{ area_id(area_name) if area_name else none }}"
313352 segment_id : " {{ room_map[room_key].segment | int }}"
314353 vac_state : " {{ states('vacuum.l10s_vacuum') }}"
315354 on_demand : " {{ is_state('input_boolean.l10s_vacuum_on_demand', 'on') }}"
@@ -319,7 +358,7 @@ automation:
319358 - choose :
320359 - conditions :
321360 - condition : template
322- value_template : " {{ can_start }}"
361+ value_template : " {{ can_start and area_id_value is not none }}"
323362 sequence :
324363 - service : script.send_to_logbook
325364 data :
@@ -338,17 +377,17 @@ automation:
338377 data :
339378 fan_speed : Standard
340379 - continue_on_error : true
341- service : dreame_vacuum.vacuum_clean_segment
380+ service : vacuum.clean_area
342381 target :
343382 entity_id : vacuum.l10s_vacuum
344383 data :
345- segments : " {{ [segment_id ] }}"
384+ cleaning_area_id : " {{ [area_id_value ] }}"
346385 - delay : " 00:00:02"
347386 default :
348387 - service : script.send_to_logbook
349388 data :
350389 topic : " VACUUM"
351- message : " One-off clean blocked: {{ room_name }} (vac={{ vac_state }}, on_demand={{ on_demand }}, queue='{{ queue_raw }}')."
390+ message : " One-off clean blocked: {{ room_name }} (area={{ area_name }}, area_id={{ area_id_value }}, vac={{ vac_state }}, on_demand={{ on_demand }}, queue='{{ queue_raw }}')."
352391 - service : input_boolean.turn_off
353392 data :
354393 entity_id : " {{ trigger.entity_id }}"
0 commit comments