Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This rule checks if the washing machine. If it is done washing it sends notifications via my.openhab.com
- //import is needed for the timer
- import org.openhab.model.script.actions.Timer
- var Timer timer = null
- var boolean resetTimer = false
- var boolean isWamaActivated = false
- var int CHECKTIMEMIN = 2
- var int POWERLEVEL = 2
- rule "checkWamaStatus"
- when
- Item WamaPlugPower changed
- then
- //reset the timer if it has been started and no Wama is active
- if( timer != null &&
- resetTimer)
- {
- timer.cancel
- timer = null
- resetTimer = false
- }
- //check if the wama has been activated
- //it uses a lot of power if this is the case
- if(WamaPlugPower.state >= POWERLEVEL)
- {
- if(!isWamaActivated)
- {
- sendNotification("MY.OPENHAB.COM LOGIN", "Waschmaschine ist gestartet!")
- isWamaActivated = true
- }
- }
- //check if the power went down below POWERLEVEL after the wama has been started
- if( isWamaActivated &&
- timer == null &&
- WamaPlugPower.state < POWERLEVEL)
- {
- //start a timer that checks again in a few minutes if the power is still down
- //if the wama is disabled for a few minutes it means that it is done and not just pausing, send a notification than
- timer = createTimer(now.plusMinutes(CHECKTIMEMIN + 1))
- [|
- if(WamaPlugPower.averageSince(now.minusMinutes(CHECKTIMEMIN), "mysql") < POWERLEVEL)
- {
- isWamaActivated = false
- resetTimer = true
- sendNotification("MY.OPENHAB.COM LOGIN", "Waschmaschine ist fertig!")
- }
- else
- {
- resetTimer = true
- }
- ]
- }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement