Make threshold helper more flexible

I do like the new threshold helper, however I would love to have it a little bit more flexible.
Currently when I define an upper and a lower threshold, the sensor is on, when the value is in between the thresholds.
It would be great, if there would be an option to have it on, when above the upper threshold and off when below the lower threshold, currently I would need to setup two threshold helpers for that.
Secondly, it would be great to have a timeout option, meaning, that the state only changes, when the value is for more than x seconds/minutes above/below a threshold.
Those options would increase the benefits of this helper.

You can do the first part by using one limit and hysteresis.

This is not a workaround. This is what the hysteresis option is for.

Say you want on at 10 and above, off at 6 and below.

Upper limit = 8
Hysteresis = 2

Say you want on at 3.5 and below, and off at 8.5 and above:

Lower limit = 6
Hysteresis = 2.5

How to calculate,

Use Upper limit if you want the helper to be on above, Lower limit if you want on below.
Limit = average of the two switching point values
Hysteresis = positive (unsigned) difference of average from either one of the values.

Or in algebra,

U = upper switch point
L = lower switch point

Limit = (L+U)/2
Hysteresis = U - Limit (or Limit - L)

The second part you can do in automations by using for: in state triggers using your threshold sensor.

2 Likes

Thanks, that does help, not intuitive but a good solution.
However Integration of a timed delay would make things still easier, as it would eliminate the need for a second step in automations

It’s pretty much how instrumentation and control is done. It’s only unintuitive because you’ve never seen it before.

This one extra option isn’t exactly onerous:

trigger:
  - platform: state
    entity_id: binary_sensor.something
    to: 'on'
    for: 60 #seconds
1 Like

Sure, wanted to say not intuitive to me :wink:

Thank you for this explanation, trying to digest it.

In my case, How do I make a Threshold Helper work for between and Including a high and low limit?

H-Limit = 70
L-Limit = 30

On = a value Between and Including 30 and 70.

So always on?

No,
On = when sensor value is between and including 30 and 70.

Off = when below 30 (29 or lower) or above 70 (71 or higher).

The problem I think I’m having is:

it seems if the sensor value is already between the Limits, and it falls or rises to the limit value the helper stays on.

However if the value is below or above the Limits and if falls or rises to the limit value is stays Off. This is unwanted in my case.

This is not a support topic it is a feature request. Please create a new topic.