This works fine for manually changing from 2 to 3…
I also have a template sensor that uses the value of this state togeter with other values to decide what to do. I would like to change the input_number.statesw in this template, I have added a # where I want it to happen… is this possible??
template:
sensor:
- name: "switchstate"
state: >
{%set AA=states('sensor.current_l1') | float %}
{%set Maxvalue=states('input_number.slider1') | float%}
{%set BB=(Maxvalue-AA)%}
{%if AA<20 and states('input_number.statesw')|int== or states('input_number.start_ladd')|int==22%}
3
#Here I want my slider to change to 3 !!!
{% else %}
2
{% endif %}
Where did you get the idea that it’s possible to do what you tried to do?
There’s not a single example of that anywhere in the documentation or in this community forum. Why not? Because that’s not how you set an entity’s value.
The value of an entity like an input_number can be set using a service call like input_number.set_value.
A service call is part of Home Assistant’s scripting language, not Jinja2’s templating language.
Im new to home assistant so Im really confused at the moment
It felt (from a c++ backgground (simple stuff…)) reasonable that after a couple of if statements its possible to do more than setting swithstate to 3 in this case.
Not sure why you would assume that what’s possible in C++ is also possible in a templating language like Jinja2.
Have you reviewed the Templating documentation? If you haven’t, I recommend that you set aside some time to study it and learn how Home Assistant employs Jinja2.
Perhaps what you want is to create an automation that detects when the value of sensor.switchstate changes to 3 then sets the input_number to 3. Does that meet your requirements?