Threshold sensor with a variable?

I was wondering if it’s possible to have a variable in a binary sensor?
So the objective is I have a number of temperature sensors that then drive binary sensors (virtual room thermostats). All of this works great to call for heat etc.

I would like to have a single bias value that I can set (hopefully in the GUI) somewhere and that it’s value will be added to all the binary sensors that I have.

So something like Lower Limit : 18.0 + $tweak

Then somewhere in GUI I set $tweak=0

In the summer I might set $tweak=-2.0
And in winder I might set $tweak=1.5
Basically I can increase or decrease all my virtual thermostats in the entire house with a single base value.

Anyone know if something like that is possible and if so what helper I might use to achive that?

R

Then your $tweak is:

{{ states('input_number.YOUR_ENTITY_ID')|float }}

The float is needed because states (even in input_numbers) are strings and need casting to a number before using in arithmetic.

Thanks, the Input helper will work, but I see in the documentation that it’s to be used in Automations.
I cant work out how I would use the input helper in another helper (binary sensor)?

Share the correctly-formatted code for one of your binary sensors; or if it’s a template binary sensor created via the UI, paste the state template here.

I hope I copied if from the right place as it wont show be the code for the binary sensor, so I got this from the developer tools>states:

entity_id: sensor.main_temp1_temperature
hysteresis: 0.2
lower: 17.7
position: below
sensor_value: 16.3
type: lower
upper: null
icon: mdi:thermostat
friendly_name: Thermostat_BedroomMain

I created a number helper “input_number.temp_bias” with values -2 and 2.

So if possible I would like set “lower: 17.7 + input_number.temp_bias”

OK, so that’s a Threshold sensor. You can’t do the arithmetic within it.

The solution would be to create a template sensor with the “corrected” temperature as its state, then use that in the threshold sensor rather than the actual temperature.

Under Helpers, create a template sensor with name “Corrected Temperature”, state template:

{{ states('sensor.main_temp1_temperature')|float + states('input_number.temp_bias')|float }}

device class of Temperature and unit of °C.

Then edit the threshold sensor to use sensor.corrected_temperature instead.