Helpers: Negate Binary Entities (problem class for threshold)

Hi!
It would be extremely helpful if binary entities of/inside of helpers had a negate option (group and threshold).

Let me give you a few examples:

  • The water pressure of my central heating should be between 1,1bar and 1,8bar. The threshold helper creates a binary sensor with is false if the pressure is out of the expected range. The device_class "problem" however expects it to be true.
  • I have several other sensors from my central heating which directly report problems (matching the problem device classes’ semantics). Because of how the threshold helper works, I cannot join the water pressure threshold sensor with these problem sensors
  • In general I’d like to be able to join boolean entities with different semantics like above with the group helper

So it would be very helpful if the group helper allowed for negation of the grouped binary sensors and if the threshold sensor would have an option to negate its state.

Does this make sense?

The threshold sensor is for simple situations. If you want a more complex sensor use a template instead:

template:
  - binary_sensor:
      - name: Central Heating Pressure Problem
        state: "{{ states('sensor.pressure')|float(0) > 1.8 or states('sensor.pressure')|float(0) < 1.1 }}"
        availability: "{{ states('sensor.pressure')|is_number }}"
        device_class: problem

I’m aware of templates but I’d still argue this feature would be an important improvement, as it makes the threshold helper applicable to so many more situations:

First of all, interpreting ‘being inside the thresholds’ as ‘ok’ and ‘being outside’ as ‘problem’ is the obvious interpretation for a lot of situations (like controlling/checking pressure, temperatues, voltage, luminous intensity and so on).
Thresholds with upper and lower bounds allow you to assign the problem device_class but the result is counter-intuitive to say the least. So by adding this feature you’ll enable a super-easy solution for lots of real-life usecases.

Second, the threshold helper can apply hysteresis, which is a great feature and a must-have if you have to cope with real-life fluctuating data (a feature that is still missing from grafanas alerting btw). This would also have to be implemented in the template and I’m not sure about how easy this is in a singe template.

So probably the only workaround at the moment is to use a threshold helper combined with a template sensor negating its output.