From 4b285770d233a300e8e8d080890ab84a0c8aeef2 Mon Sep 17 00:00:00 2001 From: John Ogle Date: Sun, 21 Dec 2025 15:35:23 -0800 Subject: [PATCH] Fix presence_mode_reset blueprint variable scoping issue Move condition check into action sequence after variables are defined. Previously, the condition tried to use 'occupancy_sensors' before it was defined, causing UndefinedError during automation execution. --- blueprints/automation/presence_mode_reset.yaml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/blueprints/automation/presence_mode_reset.yaml b/blueprints/automation/presence_mode_reset.yaml index 5870991..e3dcceb 100644 --- a/blueprints/automation/presence_mode_reset.yaml +++ b/blueprints/automation/presence_mode_reset.yaml @@ -78,7 +78,13 @@ trigger: for: minutes: !input empty_delay -condition: +action: + - variables: + occupancy_sensors: !input occupancy_sensors + al_switch: !input adaptive_lighting_switch + mode_select: !input mode_input_select + default_mode: !input default_mode + # Ensure ALL sensors are off (room is truly empty) - condition: template value_template: >- @@ -88,13 +94,6 @@ condition: list | count == 0 }} -action: - - variables: - occupancy_sensors: !input occupancy_sensors - al_switch: !input adaptive_lighting_switch - mode_select: !input mode_input_select - default_mode: !input default_mode - # Reset manual control if AL switch provided - if: - condition: template