After someone is in the house again, I want the temperature to be set to the previous value, for this I either have the variable input_number.old_temp_xxxx which is updated whenever a radiator is set automatically. Or I just say “value: ‘{{ states.climate.thermostat_1.attributes.temperature | float }}’ + 2 degrees”.
I just don’t know how to pass the command to be set down or up two degrees by using the above variable.
(When I open the window of the bathroom, I set the temperature to 7°C and when I close it, I use the variable input_number.old_temp_badezimmer to set the temperature back).
Since this variable, which shows me the currently valid set temperature, exists anyway, I also use it as a setting for an automation when someone arrives back home:
- id: '16xxxx8062611'
alias: Heizung Badezimmer bei Abwesenheit
description: ''
trigger:
- platform: state
entity_id: binary_sensor.people_home
to: 'off'
for: 00:05:00
from: 'on'
condition: []
action:
- service: climate.set_temperature
entity_id: climate.thermostat_2
data:
temperature: '{{ state_attr(''climate.thermostat_2'', ''temperature'') | float
- 2 }}'
mode: single
- id: '1608xxxx306167'
alias: Heizung Wohnzimmer bei ANwesenheit
description: ''
trigger:
- platform: state
entity_id: binary_sensor.people_home
from: 'off'
to: 'on'
condition: []
action:
- service: climate.set_temperature
entity_id: climate.thermostat_2
data:
temperature: '{{ states.input_number.old_temp_badezimmer.state }}'
mode: single
BTW: i set the sensor “binary_sensor.people_home” in my configuration yaml:
- platform: template
sensors:
people_home:
friendly_name: 'Jemand zuhause?'
device_class: presence
value_template: >
{{ is_state('person.joachim_s', 'home') or
is_state('person.joachim_s', 'Zu Hause') or
is_state('person.joachim_s', 'zuhaus') or
is_state('person.angela_m', 'home') or
is_state('person.angela_m', 'Zu Hause') or
is_state('person.angela_m', 'zuhaus') }}
Did I miss this? My templates (defined in configuration.yaml, not in automations) were created just following others’ examples. I’m not sure I even understand what the linked document is trying to say. Here are two templates I use. Is there a better way?
Did you read the warning in the docs I linked? It says that states.xxx can lead to errors on startup and instead use states(…) to access the state of the entity or state_attr(…) to access the state of an attribute of the entity.
Thank you, yes, I got that part. And I’ve seen the errors it mentions. I just wanted to make sure I understood the syntax, since I’m still trying to grasp the underlying meaning of these two different methods.
I tried the “new” notation, and it seems to work great, thank you!
This returns an error when I use Check Configuration:
Error loading /config/configuration.yaml: while parsing a block mapping
in "/config/configuration.yaml", line 133, column 9
expected <block end>, but found '<scalar>'
in "/config/configuration.yaml", line 133, column 41
I verified there are no errant tabs and there are the correct number of spaces. I replaced just the “new” template (between the curly braces) with the “old” one and that checks OK, so it’s got to be just that one part, nothing before or after.
Thank you again for your patience, I’m sure it’s something obvious I’m not seeing.