I am trying to make a simple script that:
- stores the current mode and temperature of a smart thermostat
- then changes those to "auto" and 24 degrees
- after an amount of time, returns them to their previous state.
I have the following script:
sequence:
- variables:
previous_mode: "{{ state_attr('climate.office', 'hvac_mode') }}"
previous_temperature: "{{ state_attr('climate.office', 'temperature') }}"
- target:
entity_id: climate.office
data:
hvac_mode: heat
action: climate.set_hvac_mode
- target:
entity_id: climate.office
data:
temperature: 24
action: climate.set_temperature
- delay: "00:01:00"
- target:
entity_id: climate.office
data:
hvac_mode: previous_mode
action: climate.set_hvac_mode
- target:
entity_id: climate.office
data:
temperature: previous_temperature
action: climate.set_temperature```
But when running, the actions after the delay do not happen. Looking at the trace, there is the error:
`Error: expected HVACMode or one of 'off', 'heat', 'cool', 'heat_cool', 'auto', 'dry', 'fan_only' for dictionary value @ data['hvac_mode']`
I don't quite follow what this error means. My understanding was that `previous_mode: "{{ state_attr('climate.office', 'hvac_mods') }}"` should store previous mode as (usually) `auto` or `off` and then give that mode back to the script. But it seems not to be happening here?