From 812e5c123f0f77ee2ba40f4db11ea55208e40fb1 Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 5 Dec 2025 11:51:59 +0100 Subject: [PATCH] Update ha-smart-thermostat-control.yaml adjusted triggers --- ha-smart-thermostat-control.yaml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ha-smart-thermostat-control.yaml b/ha-smart-thermostat-control.yaml index 454d7eb..16ba81f 100644 --- a/ha-smart-thermostat-control.yaml +++ b/ha-smart-thermostat-control.yaml @@ -205,12 +205,18 @@ trigger: variables: thermostat_entities: !input thermostat triggered_thermostat: "{{ trigger.entity_id | default('none') }}" - # FIX: Safely retrieve state objects for non-state triggers (e.g., calendar, numeric_state) - safe_to_state: "{{ trigger.to_state | default({}) }}" - safe_from_state: "{{ trigger.from_state | default({}) }}" - # Use the safe state objects to get temperatures - new_temperature: "{{ safe_to_state.attributes.temperature | float(0) }}" - old_temperature: "{{ safe_from_state.attributes.temperature | float(0) }}" + # Access temperature safely: + # 1. Get the 'to_state', defaulting to a simple object/dict if missing. + # 2. Get the 'attributes' from that object, defaulting to a dict if missing. + # 3. Get the 'temperature' from the attributes, defaulting to 0, then convert to float. + new_temperature: > + {{ trigger.to_state.attributes.temperature | default(0) | float(0) + if trigger.to_state is defined and trigger.to_state.attributes is defined + else 0 }} + old_temperature: > + {{ trigger.from_state.attributes.temperature | default(0) | float(0) + if trigger.from_state is defined and trigger.from_state.attributes is defined + else 0 }} override_helper: !input manual_override_helper day_temp_input: !input day_temp night_temp_input: !input night_temp