Garage door running time

I am wondering if anyone can help me.
I have a properly working LoraTap GDC311ZBQ1 (Tuya) garage door mechanism in HA with zigbee2mqtt. I have in customize.yaml (enabled in configuration.yaml) cover (cover.garaz_brama_trigger)


cover.garaz_brama:
  device_class: garage
  friendly_name: "Garaż Brama"

so that the switch is seen as a gate.

The LoraTap mechanism is equipped with a contact sensor (binary_sensor.garaz_brama_garage_door_contact) and it too reports the closed or open state correctly.
All of this is passed to HomeKit via a bridge (but that doesn’t matter in the problem) to be visible in CarPlay.

The gate opens or closes about 15 seconds - but the HA (and HK) basically show Open or Closed as soon as the button is pressed (where maybe for less than a second it blinks Opening / Closing).

Is there any way to add a time to open / close the gate and only then show that it is OPEN or CLOSE?

I use a triggered template to determine the state of the garage door

- trigger:
  - entity_id: button.porte_garage
    platform: state
    id: trig_button
  - entity_id: binary_sensor.tuya_contact_01_opening
    platform: state
    id: trig_state
  - entity_id: sensor.garage_cover_state
    platform: state
    id: tm_opening
    to: "opening"
    for: 30
  - entity_id: sensor.garage_cover_state
    platform: state
    id: tm_closing
    to: "closing"
    for: 60
  - platform: event
    event_type: event_template_reloaded

  sensor:
    - name: "Garage cover state"
      unique_id: "garage_cover_state"
      state: >
        {% if trigger.id == "tm_opening"  %}
          open
        {% elif trigger.id == "tm_closing"  %}
          open
        {% elif trigger.id == "trig_state" and trigger.from_state.state == "off"  %}
          opening
        {% elif trigger.id == "trig_button" and is_state("binary_sensor.tuya_contact_01_opening", "on")  %}
          closing
        {% elif trigger.id == "trig_state" and trigger.to_state.state == "off"  %}
          closed
        {% else %}
          {{ "open" if is_state("binary_sensor.tuya_contact_01_opening", "on") else "closed" }}
        {% endif %}

The door contact is binary_sensor.tuya_contact_01_opening and goes “on” as soon as I start opening the garage. I put the state on “opening”, then, and to “opened” after 30seconds. Similar when closing, based upon the closing button being pushed.

I then use a cover template to put all together

- platform: template
  covers:
    garage_door:
      unique_id: garage_door_01
      device_class: garage
      friendly_name: "Porte garage"
      value_template: '{{ states("sensor.garage_cover_state") }}'
      availability_template : '{{ has_value("sensor.garage_cover_state") }}'
      open_cover:
        service: button.press
        data:
          entity_id: button.porte_garage
      close_cover:
        service: button.press
        data:
          entity_id: button.porte_garage
1 Like

I am total noob in HA so excuse me… my configuration.yaml:


template:
  - trigger:
      - entity_id: button.garaz_brama_trigger1
        platform: state
        id: trig_button
      - entity_id: binary_sensor.garaz_brama_garage_door_contact
        platform: state
        id: trig_state
      - entity_id: sensor.garaz_cover_state
        platform: state
        id: tm_opening
        to: "opening"
        for: 5
      - entity_id: sensor.garaz_cover_state
        platform: state
        id: tm_closing
        to: "closing"
        for: 10
      - platform: event
        event_type: event_template_reloaded

    sensor:
      - name: "Garage Brama Stan"
        unique_id: "garaz_cover_state"
        state: >
          {% if trigger.id == "tm_opening"  %}
            open
          {% elif trigger.id == "tm_closing"  %}
            open
          {% elif trigger.id == "trig_state" and trigger.from_state.state == "off"  %}
            opening
          {% elif trigger.id == "trig_button" and is_state("binary_sensor.garaz_brama_garage_door_contact", "on")  %}
            closing
          {% elif trigger.id == "trig_state" and trigger.to_state.state == "off"  %}
            closed
          {% else %}
            {{ "open" if is_state("binary_sensor.garaz_brama_garage_door_contact", "on") else "closed" }}           
          {% endif %}

cover:
  - platform: template
    covers:
      garage_door:
        unique_id: garaz_brama_trigger1
        device_class: garage
        friendly_name: "Brama Garazowa"
        value_template: '{{ states("sensor.garaz_cover_state") }}'
        availability_template: '{{ has_value("sensor.garaz_cover_state") }}'
        open_cover:
          service: button.press
          data:
            entity_id: button.garaz_brama_trigger1
        close_cover:
          service: button.press
          data:
            entity_id: button.garaz_brama_trigger1

My contact sensor is binary_sensor.garaz_brama_garage_door_contact. I have no idea what is wrong with this?