I use this smartapp. It works better with a separate sensor. In my case, I have a tilt sensor.
But with groovy being phased out… who knows what will happen.