Created
July 28, 2017 20:12
-
-
Save dawithers/e20dfe9782a5056e1a5e7f875952cc2b to your computer and use it in GitHub Desktop.
Chamberlain/LiftMaster MyQ openhab timer rule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.openhab.model.script.actions.Timer | |
var Timer timer = null | |
var minutes = 60 | |
rule "Garage Open Timer" | |
when | |
Item GarageDoorString changed | |
then | |
if(GarageDoorString.state == "Open") { | |
logInfo( "garage", "Open. Starting Timer." ); | |
timer = createTimer(now.plusMinutes(minutes)) [| | |
logInfo( "garage", "Timer expired. Closing." ); | |
sendCommand(GarageDoorSwitch, OFF) | |
] | |
} else { | |
logInfo( "garage", "!Open." ); | |
if(timer != null) { | |
logInfo( "garage", "Resetting timer." ); | |
timer.cancel | |
timer = null | |
} | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment