Make the binary sensor result invertible

Hello Community,

A lot of device classes were added in the last Home Assistant releases. One is the “Problem” device class. It is “Ok” when the sensor is offline (off) and “Problem” when the sensor is on. Its a philosophical question if this is right or wrong.
My Point: In some cases it is necessary the invert the result of a binary sensor. At the moment I resolve this problem by creating an additional template sensor with

state: {{ not is_state('input_boolean.my_sensor','on') }} 

or

state: {{ is_state('input_boolean.my_sensor','off') }} 

I think its only a little bit of an implementation afford to make the result of a binary sensor invertible. But - to be honest - I have not the skills to add this feature on my own and send a pull request.

Kind Regards

Chewy

P.S.: At the moment I try to implement an error system to my home assistant instance (here) (some ping sensors) so that home assistant alerts me if some system is not reachable anymore.

What is the source of the original sensor that needs inverting?

Hi @tom_l,

it could be everything. In my case its a Ping sensor.

1 Like

I created a similar FR some time ago.

The requirement for this has lowered since the new color options were introduced, but still - you might have sensors that are reporting ON while others are reporting OFF in a similar case.

Then, your color schemes may still be broken, since we cannot colorize icons individually without using something like card_mod.

I have a case for this, @tom_l. I’m using a door sensor as a bed occupancy sensor, however, based on how the sensor works, it is “on” when the bed is empty and “off” when the bed is occupied, which makes not useful to use with sensor class “occupancy”, which will make my solution much easier and nicer.
OK, I know the problem is on the fact that door sensors are not bed occupancy sensors and I should have designed better the system, but having an option to simply invert the sensor will make the solution for this much easier.

1 Like

I’m definitely aware there is a legitimate need for this. I was just checking that the integration chewy was using could not be inverted in its config (it can’t in that particular case).

If your door sensor is connected via Zigbee2mqtt it should be able to be inverted in zigbee2mqtt.

I’m reluctant to migrate from ZHA to Z2M… :wink:

Understandable. That’s why I said “if…”