Hello
i want to setup an automation, where if the door opens, my heater goes to lower temperature (or off) and then goes back to the one before the door was opened. So i need to store the temperature value. I’ve been reading that you can store a value in an input_slider or input_number, so i created an input_number entity for it. Here is the automation code i put together:
- id: '1616159174740'
alias: test
description: ''
trigger:
- platform: state
entity_id: binary_sensor.fk_kuche_state
from: 'off'
to: 'on'
condition: []
action:
- service: input_number.set_value
target:
entity_id: input_number.prev_temp_kuche
data:
value: "{{states.climate.hz_regler_kuche.attributes.temperature}}"
Sadly, this does not work. If i input that template into the test window under developer options it returns the correct value:
i also tried using (and also the first one without the “target and data” part but with data_template instead)
action:
- service: input_number.set_value
data_template:
entity_id: input_number.temperatur
value: '{{ state_attr("climate.hz_regler_kuche", "temperature") | int }}'
This does not work either. Maybe you have guessed it, i just started today with Home assisstant, i implemented my Homematic and it works great so far, in homematic i had a rule where exactly what i described worked, so i thought “Well it should be easy here then”. Oh how i was mistaken, i looked to solve this for the last couple hours ^^
Maybe if someone could help me clear up my mistake or maybe explain how to do the Aim another way, that would be awesome. I tried similar topics results but they did not work or were to unrealated.
Hi,There are some issues with the syntax, please try this.
action:
- service: input_number.set_value
data_template:
entity_id: input_number.temperatur
value: '{{ state_attr(''climate.hz_regler_kuche'', ''temperature'') | int }}'
thanks for the reply, sadly it did not work
this should work:
action:
- service: input_number.set_value
data:
entity_id: input_number.temperatur
value: >
{{ state_attr('climate.hz_regler_kuche','temperature')|int }}
provided the template:
{{ state_attr('climate.hz_regler_kuche','temperature')|int }}
is valid in your system, its a bit difficult (impossible) to read with these new template editor colors
but, please be precise: what did not work? no trigger, no action, an error in the log?
the template you gave me worked in the developer options window, but it did not change the input_number.
For what precisly is not working i think it is the action, if i change the action to set a fixed value to the input_number (like value: 12) it works like a charm, but with the templates it does not
Have you made a bare test automation to try in operation? Or did you only try in developer tools.
If you did write the automation please post here. The templates should work, it’s how we record our nightly energy consumption daily …
I first used the automation UI to create this:
- id: '1616177177460'
alias: test
description: ''
trigger:
- platform: state
entity_id: binary_sensor.fk_kuche_state
from: 'off'
to: 'on'
condition: []
action:
- service: input_number.set_value
target:
entity_id: input_number.prev_temp_kuche
data:
value: 12
mode: single
the value is set to 12 as a fixed number, this works
so now i changed the action part with your code so it looks like this:
- id: '1616177177460'
alias: test
description: ''
trigger:
- platform: state
entity_id: binary_sensor.fk_kuche_state
from: 'off'
to: 'on'
condition: []
action:
- service: input_number.set_value
data:
entity_id: input_number.temperatur
value: >
{{ state_attr('climate.hz_regler_kuche','temperature')|int }}
mode: single
this is not working, i do not get an error in the log, it says the test has triggered but nothing about the input_number changing because it does not
i went back to using the function build into the homematic, wich works, still interested in knowing why this does not work ^^
You could just set the climate to an away mode
What’s the definition of the input number? Just thinking it’s the |int maybe causing a type conflict ?
Input number being a float