Garage Door Opening-Closing Help

I am trying to create a template to to show “opening” and “closing” state for my garage door. I have combination tilt and vibration sensor. These are the various states, i am trying to figure out the best template:

  • If binary_sensor.garage_door_tilt is “on” and binary_sensor.garage_door_vibration is “off” then OPEN

  • If binary_sensor.garage_door_tilt is “off” and binary_sensor.garage_door_vibration is “off” then CLOSED

Then it gets tough: For OPENING the door will start closed (tilt off) and vibration will be on for 4 secs. For CLOSING the the door with start open (tilt on) and vibration will be on for 4 secs.

I can do the templates for OPEN and CLOSE. Does anyone see a way to pull off OPENING and CLOSING?