Update ha-smart-thermostat-control.yaml
adjusted triggers
This commit is contained in:
parent
66ddee0043
commit
812e5c123f
1 changed files with 12 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue