Garage door cover opening and closing states with button and binary sensor

I have a zwave tilt sensor on my garage doors. I have a switch on each door to trigger it to open or close.

I’m currently only able to get “open” and “closed” states on my doors, but I’d like it to show “opening” and “closing” states as well. I’m thinking I need to update the value template with some kind of logic to check if the previous state was closed and the switch was pressed then show “opening”, and the opposite for the “closing” state.

I’ve never done anything like this in a template and it seems like it would be some fairly complex logic. Is there a way to check previous states like this or is there a simpler way to try and get what I want?

My existing value template looks like this:

- platform: template
  covers:
    dual_bay_garage_door:
      device_class: garage
      friendly_name: Dual Bay Garage Door
      value_template: "{{ is_state('binary_sensor.garage_dual_bay_door_tilt_sensor_any', 'on') }}"
  • id: ‘1627225410558’(I’m new at this what number goes in here?)
    alias: ‘Garage door tag is scanned (closed)’
    description: ‘’
    trigger:

    • platform: tag
      tag_id:
      condition:
    • condition: device
      device_id:
      domain: cover
      entity_id: cover.garage_door
      type: is_closed
      action:
    • device_id:
      domain: cover
      entity_id: cover.garage_door
      type: open
      mode: single
  • id: ‘1627225442700’ (where does this number come from?)
    alias: ‘Garage door tag is scanned (open)’
    description: ‘’
    trigger:

    • platform: tag
      tag_id:
      condition:
    • condition: device
      device_id:
      domain: cover
      entity_id: cover.garage_door
      type: is_open
      action:
    • device_id:
      domain: cover
      entity_id: cover.garage_door
      type: close
      mode: single

this is what i use if its any help, would you by chance know what id number is in top line.

Thanks, I will take a look next time I am at my PC.

As for the IDs question, it just has to be a unique number for each automation. If you use the Home Assistant GUI to create the automation, it will generate the numbers for you.