Template Sensor Bounce - Garage Door

Hi, I have a Shelly 1 that I use to open and close the garage door, utilising the Shelly Integration, so the binary sensors and switches were automatically created. The reed switch that is used to monitor the garage door state results in a binary sensor, which reads “on” or “off”, as expected for a binary sensor.

Because I wanted to show the garage door in the Lovelace dashboard as “open” or “closed”, I created template sensor for the garage door state. The problem is that the sensor seems to bounce about 1/3 of the time, so the garage door shows as "open’ then immediately “closed” again although it is in fact still open. Bummer. I understand that I can add a “delay_off” setting for my own binary sensors which might alleviate the bounce scenario, except that the binary sensor is created by the Shelly Integration. How can I modify the template sensor to stop the garage door state from bouncing?

Here’s the existing template.

  - platform: template
    sensors:
      garage_door_state:
        friendly_name: "Garage Door State"
        value_template: >-
          {% if is_state('binary_sensor.shelly_shsw_1_f3a3c3_switch', 'on') %}
            OPEN
          {% else %}
            Closed
          {% endif %}
        icon_template: >-
          {% if is_state('binary_sensor.shelly_shsw_1_f3a3c3_switch', 'on') %}
            mdi:garage-open
          {% else %}
            mdi:garage
          {% endif %}

Thanks.

unless… I create my own template binary sensor, based on the binary_sensor.shelly_shsw_1_f3a3c3_switch sensor and add a “delay_off” to my own sensor, then use my new sensor in my garage door state template? :thinking:

It’s only flip flopping state if the binary_sensor.shelly_shsw_1_f3a3c3_switch is flip flopping state. So is the binary_sensor.shelly_shsw_1_f3a3c3_switch flip flopping state?

yes, that is correct. The same times that template sensor “garage_door_state” showed as “closed” instead of “open” then “closed”, the binary_sensor.shelly_shsw_1_f3a3c3_switch also shows as “off”.

image
image

From what I’ve read in the forums, it’s not unusual for reed switches on garage doors to “bounce”. I had considered using a Wireless Tag for the Garage Door State instead, until I read of a similar issue for those in the forums.