Advertisement
Guest User

Untitled

a guest
Dec 30th, 2015
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. //This rule checks if the washing machine. If it is done washing it sends notifications via my.openhab.com
  2.  
  3. //import is needed for the timer
  4. import org.openhab.model.script.actions.Timer
  5.  
  6. var Timer timer = null
  7. var boolean resetTimer = false
  8. var boolean isWamaActivated = false
  9. var int CHECKTIMEMIN = 2
  10. var int POWERLEVEL = 2
  11.  
  12. rule "checkWamaStatus"
  13. when
  14. Item WamaPlugPower changed
  15. then
  16. //reset the timer if it has been started and no Wama is active
  17. if( timer != null &&
  18. resetTimer)
  19. {
  20. timer.cancel
  21. timer = null
  22. resetTimer = false
  23. }
  24.  
  25. //check if the wama has been activated
  26. //it uses a lot of power if this is the case
  27. if(WamaPlugPower.state >= POWERLEVEL)
  28. {
  29. if(!isWamaActivated)
  30. {
  31. sendNotification("MY.OPENHAB.COM LOGIN", "Waschmaschine ist gestartet!")
  32. isWamaActivated = true
  33. }
  34. }
  35.  
  36. //check if the power went down below POWERLEVEL after the wama has been started
  37. if( isWamaActivated &&
  38. timer == null &&
  39. WamaPlugPower.state < POWERLEVEL)
  40. {
  41. //start a timer that checks again in a few minutes if the power is still down
  42. //if the wama is disabled for a few minutes it means that it is done and not just pausing, send a notification than
  43. timer = createTimer(now.plusMinutes(CHECKTIMEMIN + 1))
  44. [|
  45. if(WamaPlugPower.averageSince(now.minusMinutes(CHECKTIMEMIN), "mysql") < POWERLEVEL)
  46. {
  47. isWamaActivated = false
  48. resetTimer = true
  49. sendNotification("MY.OPENHAB.COM LOGIN", "Waschmaschine ist fertig!")
  50. }
  51. else
  52. {
  53. resetTimer = true
  54. }
  55. ]
  56. }
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement