Filter sensor values

Hi all, I have a binary sensor called “binary_sensor.treppenhaus_briefkasten”. This sensor can assume two states, vibration detected and no vibration detected. I would like to show only the “vibration detected” value in a logbook in Lovelace. Therefore I read that I need to create a new sensor which takes the filtered value from the original sensor. But I have no clue how. :frowning: Can anyone help me?


What should it show when vibration is not detected?

A binary_sensor’s two states are reported in Logbook.

If you only want to show one of a binary_sensor’s two states in Logbook, I’m unaware of a way to do that. Logbook shows whatever is recorded by the recorder integration. You can exclude entities from recorder but then they will not be shown in Logbook at all. Recorder doesn’t let you control which one of an entity’s states are recorded.

Although I can show you how to do that, I don’t think it will help you get what you want. The Template Sensor you create still has to report two states:

  • when vibration is detected
  • when vibration is not detected

Both states will be displayed in Logbook, even if you make one state “Detected” and the other one blank (an empty string). Recorder will still record the empty string and Logbook will display it.

I was hoping that only the “vibration is detected” could be “written” to the newly created sensor. And then I connect this one to Logbook. But maybe this is just a wish :smiley:

It can but what should it report when vibration is not detected? It has to report something otherwise it will always show “vibration is detected”, even when there is no vibration detected.

You could have a “vibration last detected” trigger-based template sensor.

  - trigger:
      - platform: state
        entity_id: binary_sensor.treppenhaus_briefkasten
        from: 'off'
        to: 'on'
      - name: Last motion
        state: '{{ now() }}'