Skip to content

Commit c8d8423

Browse files
committed
Refine vacuum automation logic by improving room dequeue conditions and adding safeguards against premature completion. Enhance logbook entries for better tracking of cleaning state and room revisits.
1 parent 7310f24 commit c8d8423

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

config/packages/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Live collection of plug-and-play Home Assistant packages. Each YAML file in this
6363
### Dreame vacuum automations
6464
- Logic lives in [vacuum.yaml](vacuum.yaml): continuous four-phase loop (sweep main, sweep baths, mop main, mop baths) driven by `input_select.l10s_vacuum_phase` and `input_text.l10s_vacuum_room_queue`, with per-room notifications and automatic reseeding between phases.
6565
- Uses the Dreame HACS integration with segment IDs to enforce bathrooms last in each sweep/mop pass, dock on arrival, and auto-run if idle for 3+ days.
66+
- Room queue advances conservatively (dwell + leave + no quick revisit) so an interrupted/docked run doesn’t mark rooms complete early.
6667
![Dreame Automations](../www/custom_ui/floorplan/images/branding/Dreame%20Automations.png)
6768

6869
### Blog & video deep dives

config/packages/vacuum.yaml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# -------------------------------------------------------------------
1010
# Notes:
1111
# - `sensor.l10s_vacuum_current_room` can change during transit; require a dwell (`for:`) and then wait for the vacuum to leave before dequeue/phase advance.
12+
# - Only dequeue a room after it leaves and does not return shortly; prevents boundary "bouncing" and avoids marking a room done if we interrupt and dock.
1213
# - Avoid reissuing `dreame_vacuum.vacuum_clean_segment` while already cleaning; only send a new segment job when starting/resuming or switching phases.
1314
######################################################################
1415

@@ -212,6 +213,7 @@ automation:
212213
cleaned_room_state: "{{ trigger.to_state.state if trigger.to_state is not none else '' }}"
213214
cleaned_room_id: "{{ (trigger.to_state.attributes.room_id if trigger.to_state is not none else 0) | int(0) }}"
214215
matched_room_id: "{{ cleaned_room_id if cleaned_room_id > 0 and cleaned_room_id in (queue_ints | default([], true)) else 0 }}"
216+
room_name: "{{ room_map.get(matched_room_id, cleaned_room_state) }}"
215217
remaining_list: >
216218
{% set rem = [] %}
217219
{% set removed = namespace(done=false) %}
@@ -251,6 +253,58 @@ automation:
251253
- wait_template: "{{ states('sensor.l10s_vacuum_current_room') != cleaned_room_state }}"
252254
timeout: '02:00:00'
253255
continue_on_timeout: false
256+
257+
# Do not mark a room "done" if we simply crossed a boundary, or if we are about to be interrupted and dock.
258+
- delay: '00:00:20'
259+
- choose:
260+
- conditions:
261+
- condition: state
262+
entity_id: vacuum.l10s_vacuum
263+
state: 'cleaning'
264+
- condition: state
265+
entity_id: input_boolean.l10s_vacuum_on_demand
266+
state: 'on'
267+
- condition: state
268+
entity_id: group.family
269+
state: 'not_home'
270+
sequence:
271+
- wait_template: "{{ states('sensor.l10s_vacuum_current_room') == cleaned_room_state }}"
272+
timeout: '00:12:00'
273+
continue_on_timeout: true
274+
- choose:
275+
- conditions:
276+
- condition: template
277+
value_template: "{{ wait.completed }}"
278+
sequence:
279+
- service: script.send_to_logbook
280+
data:
281+
topic: "VACUUM"
282+
message: "{{ room_name }} revisit detected; keeping it queued."
283+
- stop: "Vacuum returned to the same room; not dequeuing."
284+
default: []
285+
286+
- choose:
287+
- conditions:
288+
- condition: state
289+
entity_id: vacuum.l10s_vacuum
290+
state: 'cleaning'
291+
- condition: state
292+
entity_id: group.family
293+
state: 'not_home'
294+
sequence: []
295+
default:
296+
- service: script.send_to_logbook
297+
data:
298+
topic: "VACUUM"
299+
message: "{{ room_name }} not dequeued (vacuum state: {{ states('vacuum.l10s_vacuum') }}, family: {{ states('group.family') }})."
300+
- stop: "Vacuum no longer cleaning / family returned; not dequeuing."
301+
default:
302+
- service: script.send_to_logbook
303+
data:
304+
topic: "VACUUM"
305+
message: "{{ room_name }} not dequeued (vacuum state: {{ states('vacuum.l10s_vacuum') }}, family: {{ states('group.family') }})."
306+
- stop: "Not in away-cleaning conditions; not dequeuing."
307+
254308
- service: input_text.set_value
255309
target:
256310
entity_id: input_text.l10s_vacuum_room_queue
@@ -259,7 +313,6 @@ automation:
259313
- variables:
260314
cleaned_raw: "{{ states('input_text.l10s_vacuum_rooms_cleaned_today') | default('', true) | string }}"
261315
cleaned_parts: "{{ cleaned_raw | regex_findall('[^,]+') | map('trim') | reject('equalto','') | list }}"
262-
room_name: "{{ room_map.get(matched_room_id, cleaned_room_state) }}"
263316
updated_cleaned: >
264317
{% set parts = cleaned_parts %}
265318
{% if room_name not in parts %}

0 commit comments

Comments
 (0)