Template binary sensor and Availability

So I have a MQTT binary_sensor coming from my alarm system that reports motion with a 5 minute timeout. Only issue is that it reports “Triggered” and then “off” immediately. It’s called “binary_sensor.panel_motion”.

To circumvent this, I created a template binary_sensor called “binary_sensor.iqpanel_motion” which “holds” the Triggered status for 5 minutes and that works fine using the following code:

template:
  - binary_sensor:
      - name: "IQPanel Motion"
        delay_off:
          minutes: 5
        state: >
          {{ states('binary_sensor.panel_motion') }}

This works exactly as designed, except for the sensor availability. I want the template binary_sensor to become Unavailable (not off) if the original one is unavailable. I can’t figure it out using the availability template fields… anyone know how I can achieve this?

template:
  - binary_sensor:
      - name: "IQPanel Motion"
        delay_off:
          minutes: 5
        state: >
          {{ states('binary_sensor.panel_motion') }}
        availability: >
          {{ states('binary_sensor.panel_motion') != 'unavailable' }}
1 Like