Change type of State of a Sensor

Hi there,

I have some sensors with impractical state.
For example some Sensors of the ViCare implementation. There is a binary sensor which switches between “detected” and “normal”.
But “on” and “off” would be way more useful.

Is there a solution to change this?

Cheers

this depends on the Device_class of the binary sensor.

there are different solutions:
The author of the Integration could change the device class of the sensor itself, to acheive this
or you could create a template sensor - which get the state of the ViCare Sensor, but is using its own device class.

here’s an example - I’ve created a default binary_sensor template which gets the status from the “Betriebsstundenzähler” - another binary_sensor, but with a different device_class…

image

  - binary_sensor:
      - name: "Test Sensor"
        unique_id: "my_test_sensor"
        state: >
          {{ states('binary_sensor.betriebsstundenzahler_t1') }}

To be precise, the actual state of a binary sensor will always be on or off.
Depending on the device_class of the sensor, the frontend will display on/off as, e.g., “detected” and “normal”