Garage Door State Help

I have a template sensor to represent the state of my garage door. It relies on a reed switch wired into my Shelly device and a z-wave tilt sensor to determine the different states. However for the life of me, I can’t figure out how to get the “Closing” state to work. It’s always “Opening”, “Open”, or “Closed”. I feel like there’s a simple logic problem with my template that I just can’t see.

  - sensor:
      - name: Garage State
        state: >
          {% set open_on = is_state('binary_sensor.garage_door_input','on') %}
          {% set close_on = is_state('binary_sensor.garage_tilt_sensor', 'off') %}
          {% if open_on and not close_on %}
            open
          {% elif not open_on and close_on %}
            closed
          {% elif open_on and close_on %}
            sensor error
          {% else %}
            {% if is_state('sensor.garage_state', 'open') %}
              closing
            {% else %}
              opening
            {% endif %}
          {% endif %}

First of all, I an not sure whether it is a good idea to make the sensor’s status dependent on the sensors status:

{% if is_state('sensor.garage_state', 'open') %}

You can try to to set a helper with the final state of the door once it is completely closed or opened to get around that.

Secondly, if works to check the sensor from the inside, you are missing the opening and closing states in the above if-clause.

Isnt closing and opening the same? Difference being that opening can only occur after close and closing occurs only after open? Other than that they both represent a state of not Open or close.