How can I make Alexa detect a sensor status and carry out an action based on it? (Garage Door use case)

Thanks.

I already have this working. I’m using an LFM-20 relay switch, set as a Virtual Momentary Switch in the ST IDE. So, when it triggers, it turns on and off again. This opens the garage door. The next time it triggers it turns on and off again. This closes the door. Have the exact thing you suggested also set up in Alexa.

However, I want it to work where the door will only open/close after checking the door’s position. I have a contact switch on the garage door which will tell me if it’s open or closed. I want to set it where I can arrive home, for instance, and if the door is closed, it will open. If it’s already open, it does nothing.

Currently, if I arrived home, the door will simply change states.

This Ridiculously Simple Virtual Garage Door purports to do exactly what I’m wanting, but I"m having trouble setting it up. Any help?