Created
February 13, 2019 21:12
-
-
Save rwestergren/216193d4eb1dd83bebcad7680001307d to your computer and use it in GitHub Desktop.
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 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