Binary sensor threshold with variable threshold

Hi. I’m testing the threshold binary sensor but I cannot modify the threshold value by means of the interface with an input_number entity because there is not a service to change this value.
For example, with the climate platform I have an automation that can modify the thermostat (service set_temperature). Also, the generic thermostat has a user interface to modify it manually.
Is there any way I can modify the threshold that does not imply to reconfigure HA?

If it’s not then I would make some automations with templates to solve this.

Thank you.

Could anyone write the code of a service that modifies the threshold of a threshold binary_sensor?

I think it’s easy if we copy, for example, the code of the service input_number.set_value.

Hi all,

Has anyone asked if the limits of a threshold binary sensor could be changed without restarting HA?

I’m going to reformulate the feature request in a way I think it could be more easy to implement and much more useful. Imagine a config like this:

# Example configuration.yaml entry
input_number:
  humidity_threshold:
    min: 10
    max: 100
    step: 5
    icon: mdi:water-percent
binary_sensor:
  - platform: threshold
    entity_id: sensor.high_humidity
    upper_entity: input_number.humidity_threshold
    hysteresis: 0.5
    device_class: moisture

If you could specify an upper or lower with an entity, instead of a fixed value, in the threshold you could modify it very easily with an input_number. This saves a lot of template programing for doing a very common task.

Please, vote if you think this is useful.

Thanks HA community!

8 Likes

Please, vote on the title if you think it’s useful.

done :wink:

if it’s still WTH month, you could file it there too, dev’s are on the templating race as we speak, maybe this could be added?

1 Like

I think it’s still valid the feature request. Up!

I have a use case for that which I don’t find any simple alternative.

The electricity price is different every hour. I’d like to configure some maximum cutoff price for some electric heaters. This price should come from input_number which can be easily changed by user compared with threshold sensor configuration.

Automation should be simple: compare electricity price with cutoff price and if it goes higher, then save current state of the switches to the temporary scene and switch heaters off. When it comes back below the cutoff price then restore switches using the saved scene.

You can’t use cutoff price sensor (number) directly in automation because automation must cycle always between save/restore state. This will be very simple task if you can use the threshold (i.e binary) sensor for the automation trigger. Can be done in one or two autotamtions (save scene + switch off and restore).

I second this FR.

I would like to know, if it is warm at home or not, and take appropriate actions (heating/cooling).

However, the definition of what is hot or cold changes throughout the seasons.
So it would be really great to at least be able to template upper, lower and hysteresis.

Even the example in the docs is about temperature.

1 Like

Thresholds are among the most useful sensors, but not being able to use an input helper makes that less so.

2 Likes

There is a template sensor while you wait :grin:

2 Likes

Thanks, I know. Template sensors can pretty much do anything any other sensor can do, and I have a few of them for this purpose. But the threshold sensors have a nice simplicity to them, and this could be a quick win to make HA more user friendly.

3 Likes

I have the same need.
I’m controlling my heating pumps with this. If all the rooms are warm enough. I want to switch off the heating pumps for each circuit. Actual, I’m using fixed values. But If I could use the setup temperature from the thermostat. I could easily change this without manual editing each threshold.

I set up for each room a threshold. And group this for each floor. So that the 1. floor heating is switched off if all rooms in the first floor are warm. And the same for the second floor.

It would be nice as well If all the values of the threshold helper could be a number or an entity. This allows maximum flexibility.

@all thank you so much!