Skip to content

Instantly share code, notes, and snippets.

@rwestergren
Created February 13, 2019 21:12
Show Gist options
  • Save rwestergren/216193d4eb1dd83bebcad7680001307d to your computer and use it in GitHub Desktop.
Save rwestergren/216193d4eb1dd83bebcad7680001307d to your computer and use it in GitHub Desktop.
import org.openhab.model.script.actions.Timer
var Timer timer = null
var boolean washerStarted = false
var float washerPowerThreshold = 3.0
var int washerFinishedTimeout = 60
rule "Send notification when washer is finished"
when
Item HS110_Power changed
then
if(washerStarted) {
if(HS110_Power.state<washerPowerThreshold) {
timer = createTimer(now.plusSeconds(washerFinishedTimeout)) [|
washerStarted = false
// Send notification
logInfo("washer", "Finished, send notification")
sendNotification("[email protected]", "Washer has finished!")
timer.cancel
timer = null
]
}else {
if(timer!==null) {
timer.cancel
timer = null
}
}
}
else if(HS110_Power.state>=washerPowerThreshold) {
logInfo("washer", HS110_Power.state.toString)
logInfo("washer", "started")
washerStarted = true
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment