New smart app to link the virtual/simulated garage door device with two actual devices

Wondering if there should be something in the smartapp code statements for “opening” or “closing” states. Since you have if statements for “open” and “close” but sometimes it seems it gets stuck in the “opening” state or “closing” state occasionally. Need a failsafe I think to have it go back and check to see if the state is stuck in opening / closing maybe?

I’m an experienced programmer but have little experience working with this system but I might be able to help out.

Also, trying to think if there is a way we can put a manual refresh button on the Virtual Device if it gets jammed up.
No matter what happens, if I manually toggle the garage from the physical switch on the wall a couple of times it stays stuck in “opening”.

Guessing I’ll have to delete everything and re-add it if it doesn’t go away.