From 9831f3150e06174f164f8e93d3556bf926a62186 Mon Sep 17 00:00:00 2001 From: Carlo Costanzo Date: Wed, 17 Dec 2025 10:57:55 -0500 Subject: [PATCH] Finally got the Vacuum scheduler working! Update HA version to 2025.12.3 and refine vacuum automation logic by adjusting room dequeue timing to 2 minutes and improving Jinja2 loop scoping for better list handling. --- config/.HA_VERSION | 2 +- config/packages/vacuum.yaml | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/config/.HA_VERSION b/config/.HA_VERSION index 74e4adb6..6e7e5869 100755 --- a/config/.HA_VERSION +++ b/config/.HA_VERSION @@ -1 +1 @@ -2025.12.2 \ No newline at end of file +2025.12.3 \ No newline at end of file diff --git a/config/packages/vacuum.yaml b/config/packages/vacuum.yaml index 8c2e870b..6bfdb3e5 100755 --- a/config/packages/vacuum.yaml +++ b/config/packages/vacuum.yaml @@ -12,6 +12,7 @@ # - Treat 3+ minutes in a room as "being cleaned" and dequeue immediately (queue = remaining rooms). # - Phase changes are driven by `sensor.l10s_vacuum_task_status: completed` and an empty queue to avoid skipping ahead on false room transitions. # - Avoid reissuing `dreame_vacuum.vacuum_clean_segment` while already cleaning; only send a new segment job when starting/resuming or switching phases. +# - Jinja2 loop scoping: use a `namespace` when building lists (otherwise the queue can appear empty and get cleared). ###################################################################### ## 1. Helpers @@ -207,26 +208,26 @@ automation: trigger: - platform: state entity_id: sensor.l10s_vacuum_current_room - for: '00:03:00' + for: '00:02:30' 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'} + 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: "{{ queue_raw | regex_findall('[0-9]+') | map('int') | list | default([], true) }}" + queue_ints: "{{ queue_raw | regex_findall('[0-9]+') | map('int') | select('gt', 0) | list | default([], true) }}" 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 rem = [] %} + {% 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 rem = rem + [r] %} + {% set ns.rem = ns.rem + [r] %} {% endif %} {% endfor %} - {{ rem }} + {{ ns.rem }} remaining_rooms: "{{ remaining_list | join(',') }}" remaining_count: "{{ remaining_list | length }}" phase_order: ['sweep_main', 'sweep_bath', 'mop_main', 'mop_bath']