This is a custom written app in Groovy that you load into your hub.
You can see pictures of my setup here. I am using a Zooz Zen17 to control my garage door as well as the contact sensor for the beam sensor. When the garage door opens, I turn on the beam sensor and when it is closed, it turns it off. In the Zen17 setup I am using "motion" instead of contact because I have yet another automation that manages my overhead lights and will turn them on if motion is detected when the LUX of my outdoor sensor is below a certain threshold - no point in turning on the lights if it is light in there.