Azuria

Openhab rule for timers

Dec 20th, 2018
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.39 KB | None | 0 0
  1. var Timer timer
  2. rule "Taend vindmølle"
  3.         when
  4.                 //Time cron "0 0/1 * * * ?"   // every minute
  5.                 Item Voltage received update
  6.                 //Item VoltageTime changed
  7.         then
  8.         logInfo("voltage.rules", "Timestate: " + VoltageTime.state)
  9.         logInfo("voltage.rules", "on off mode: ", WindRelayControl.state)
  10.                 logInfo("voltage.rules", "Voltage changed" )
  11.         if (WindRelayControl.state.toString == "2"){
  12.                         if (Voltage.state <= 56.5){
  13.                         sendCommand(WindRelay, ON)
  14.                         if(timer!=null) {
  15.                         timer.cancel
  16.                         timer = null
  17.                         }
  18.                         timer = createTimer(now.plusSeconds(70)) [|
  19.                                 //{
  20.                                 {sendCommand(WindRelay, OFF)}
  21.                                 //logInfo("voltage.rules", "Relay turned off due to timeout")
  22.                                 //}
  23.                         ]
  24.                         }else{
  25.                         sendCommand(WindRelay, OFF)
  26.                         }
  27.                 }else if (WindRelayControl.state.toString == "1") {
  28.                 sendCommand(WindRelay, ON)
  29.                 }else if (WindRelayControl.state.toString == "0") {
  30.                 sendCommand(WindRelay, OFF)
  31.                 }
  32. end
Advertisement
Add Comment
Please, Sign In to add comment