sgaluf
(sasa)
June 20, 2019, 5:45pm
1
I’m trying to set the value of some slider/input_number using voice command from snips. This is my intent_script:
lightsOnOff:
action:
- service: input_number.set_value
data_template:
entity_id: input_number.living_room_light
value: "100"
this works and the slider is set to 100. also this works:
- service: script.turn_on
data_template:
entity_id: >
{% if (brightness == "on" ) %}
script.lights_100
{% endif %}
However, if I want to set the slider using template, it doesn’t work:
- service: input_number.set_value
data_template:
entity_id: input_number.living_room_light
value: >
{% if (brightness == "on" ) %}
"100"
{% endif %}
How to correctly set the value of an input_number using template?
petro
(Petro)
June 20, 2019, 5:50pm
2
remove the quotes around the 100.
- service: input_number.set_value
data_template:
entity_id: input_number.living_room_light
value: >
{% if (brightness == "on" ) %}
100
{% endif %}
sgaluf
(sasa)
June 20, 2019, 6:02pm
3
Thanks, it’s working now.
What about if I want to decrease the slider value by 10 (e.g. dim the lights)?
petro
(Petro)
June 20, 2019, 6:55pm
4
I guess that depends on your intent. What are you passing through?
sgaluf
(sasa)
June 20, 2019, 7:11pm
5
something like this:
- service: input_number.set_value
data_template:
entity_id: input_number.living_room_light
value: >
{% if (brightness == "dim" ) %}
//decrease the value of the input_number.living_room_light by 10....
{% endif %}
petro
(Petro)
June 20, 2019, 7:16pm
6
- service: input_number.set_value
data_template:
entity_id: input_number.living_room_light
value: >
{% if (brightness == "dim" ) %}
{% set next = states('input_number.living_room_light') | int - 10 %}
{% set min = state_attr('input_number.living_room_light', 'min') %}
{{ min if next < min else next }}
{% endif %}
sgaluf
(sasa)
June 21, 2019, 2:04pm
7
nope, not working. but no problem, important that the direct change is working.
krovachek
(Krisztian Borsi)
December 18, 2019, 7:34am
8
How can I put an input number template to instead of number in Node Red get template node?
{{ (now().timestamp() + 10*60)|timestamp_custom("%H:%M") == states.sensor.alarm_time.state }}
I would like to change the value of 10 to an input number value at “10*60”.
If I use separately this:
{{ states('input_number.fade_minutes')|int * 60 }}
then I get the right value.
If this template is inserted in the full template then I get “Error get-template: Request failed with status code 400”
{{ (now().timestamp() + {{ states('input_number.fade_minutes')|int * 60 }})|timestamp_custom("%H:%M") == states.sensor.alarm_time.state }}
petro
(Petro)
December 18, 2019, 12:52pm
9
you can’t put a template in a tempate. YOu’re trying to do {{ }} inside a {{ }}. When you specify a template with {% %} or {{ }} you don’t need more {{}} or {%%}. Just put the whole equation in it.
{{ (now().timestamp() + states('input_number.fade_minutes')|int * 60 )|timestamp_custom("%H:%M") == states.sensor.alarm_time.state }}
krovachek
(Krisztian Borsi)
December 18, 2019, 12:55pm
10
Yes I know it, I found the mistake with the HA templating page. Thank you!