Manually set sensor value based on input

Hi there,

twimc: Like some users here before, I was searching for a way to manually override a helper sensor value based on an input and didn’t find any help. I am very new to HA (some days only), but when I created my first sensors and inputs I simply tested some code in the developer tools and figured out how to override the sensor values:
numbers:
I just created a input_number.sliderand after that a sensor and pasted the template as follows: {{states('input_number.slider')}} and thats it.
binary:
I just created a input_boolean.switch and after that a binary sensor and pasted the template as follows: {{ is_state('input_boolean.switch', 'on') }} and thats it.
If I know change the value of the slider or flip the switch, the corresponding sensor will take the appropriate value.

Have a nice day

Why do you even need to create a Template Sensor, or Template Binary Sensor, if you already have an Input Number or Input Boolean? Seems redundant.

I just wanted to test some automations which are explicitly based on sensor values and I knew I would replace those with real sensors later on.

If you are interested, you can create a binary_sensor entity using a Trigger-based Template Binary Sensor and then you don’t need an Input Boolean. The same principle can be used for a Trigger-based Template Sensor. The concept well suited for permanent or temporary use (as in your case).

Example

The entity’s value is set by posting an event (easy way is via Developer Tools > Events).