Skip to content

Commit fc36c9a

Browse files
committed
Use Dreame segment cleaning services in vacuum automations
1 parent 1791afa commit fc36c9a

1 file changed

Lines changed: 10 additions & 48 deletions

File tree

config/packages/vacuum.yaml

Lines changed: 10 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
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-
# - Use `vacuum.clean_area` (HA 2026.3+) and keep room->area mappings aligned with Home Assistant Areas.
15+
# - Use `dreame_vacuum.vacuum_clean_segment` with the integration's segment ids.
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,30 +133,7 @@ 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 }}
136+
segment_ids: "{{ segments_to_clean | list }}"
160137

161138
# 0. Reseed the current phase when queue is empty.
162139
- choose:
@@ -192,19 +169,6 @@ script:
192169
- stop: 'No rooms left to clean today.'
193170
default: []
194171

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-
208172
# 3. Start cleaning (but don't clobber an active job)
209173
- choose:
210174
- conditions:
@@ -214,7 +178,7 @@ script:
214178
- service: script.send_to_logbook
215179
data:
216180
topic: "VACUUM"
217-
message: "Vacuum is already cleaning; queue/phase updated but not issuing a new clean_area action."
181+
message: "Vacuum is already cleaning; queue/phase updated but not issuing a new segment clean action."
218182
- stop: "Already cleaning."
219183
default: []
220184

@@ -229,12 +193,12 @@ script:
229193
entity_id: vacuum.l10s_vacuum
230194
data:
231195
fan_speed: Standard
232-
- service: vacuum.clean_area
196+
- service: dreame_vacuum.vacuum_clean_segment
233197
target:
234198
entity_id: vacuum.l10s_vacuum
235199
data:
236-
# Clean mapped Home Assistant areas for this phase queue.
237-
cleaning_area_id: "{{ cleaning_area_ids }}"
200+
# Clean the queued room segments directly.
201+
segments: "{{ segment_ids }}"
238202

239203

240204
## 3. Automations
@@ -347,8 +311,6 @@ automation:
347311
kids_bathroom: {segment: 3, name: 'Kids Bathroom', area: 'Kids Bathroom'}
348312
room_key: "{{ trigger.id }}"
349313
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 }}"
352314
segment_id: "{{ room_map[room_key].segment | int }}"
353315
vac_state: "{{ states('vacuum.l10s_vacuum') }}"
354316
on_demand: "{{ is_state('input_boolean.l10s_vacuum_on_demand', 'on') }}"
@@ -358,7 +320,7 @@ automation:
358320
- choose:
359321
- conditions:
360322
- condition: template
361-
value_template: "{{ can_start and area_id_value is not none }}"
323+
value_template: "{{ can_start and segment_id | int > 0 }}"
362324
sequence:
363325
- service: script.send_to_logbook
364326
data:
@@ -377,17 +339,17 @@ automation:
377339
data:
378340
fan_speed: Standard
379341
- continue_on_error: true
380-
service: vacuum.clean_area
342+
service: dreame_vacuum.vacuum_clean_segment
381343
target:
382344
entity_id: vacuum.l10s_vacuum
383345
data:
384-
cleaning_area_id: "{{ [area_id_value] }}"
346+
segments: "{{ [segment_id] }}"
385347
- delay: "00:00:02"
386348
default:
387349
- service: script.send_to_logbook
388350
data:
389351
topic: "VACUUM"
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 }}')."
352+
message: "One-off clean blocked: {{ room_name }} (segment={{ segment_id }}, vac={{ vac_state }}, on_demand={{ on_demand }}, queue='{{ queue_raw }}')."
391353
- service: input_boolean.turn_off
392354
data:
393355
entity_id: "{{ trigger.entity_id }}"

0 commit comments

Comments
 (0)