Skip to content

Instantly share code, notes, and snippets.

@dawithers
Created July 28, 2017 20:12
Show Gist options
  • Save dawithers/e20dfe9782a5056e1a5e7f875952cc2b to your computer and use it in GitHub Desktop.
Save dawithers/e20dfe9782a5056e1a5e7f875952cc2b to your computer and use it in GitHub Desktop.
Chamberlain/LiftMaster MyQ openhab timer rule
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