SHARE
TWEET

Untitled

a guest Jul 19th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Integer Lastlight
  2. var Integer Dimmstep = 5
  3. var Timer timer
  4.  
  5. rule "Whz ON"
  6. when
  7.     Item HueDimmerSwitch received update 1002
  8. then
  9.     Whz_licht.sendCommand(ON)
  10.     Lastlight = 0
  11. end
  12. rule "Whz Off"
  13. when
  14.     Item HueDimmerSwitch received update 4002
  15. then
  16.     Whz_licht.sendCommand(OFF)
  17.     Lastlight = 0
  18. end
  19.  
  20. rule "Whz Ambiente ON"
  21. when
  22.     Item HueDimmerSwitch received update 1003
  23. then
  24.     Wohnzimmer_Ambiente.sendCommand(ON)
  25.     Lastlight = 1
  26. end
  27. rule "Whz Ambiente Off"
  28. when
  29.     Item HueDimmerSwitch received update 4003
  30. then
  31.     Wohnzimmer_Ambiente.sendCommand(OFF)
  32.     Lastlight = 1
  33. end
  34.  
  35. rule "Dim Down"
  36. when
  37.     Item HueDimmerSwitch received update 3000
  38. then
  39.     logInfo("Light", "Start Dim Down")
  40.     timer = createTimer(now.plusMillis(800), [|
  41.  
  42.         var dimmstate = (HueDimmerSwitch.state as DecimalType).intValue
  43.         if(Lastlight == 0 && dimmstate == 3001){
  44.             var PercentType currentState = Whz_Dimmer.getStateAs(PercentType)
  45.             var PercentType bright
  46.             if(currentState.intValue > 5 ) {
  47.                 bright = new PercentType(currentState.intValue - Dimmstep)     
  48.             } else if (currentState.intValue < 6 ){
  49.                 bright = new PercentType(1)
  50.             }
  51.  
  52.             sendCommand(Whz_Dimmer, bright as Number)
  53.             logInfo("Light", "Dim Down")
  54.             timer.reschedule(now)
  55.         } else if(Lastlight == 1 && dimmstate == 3001){
  56.             var PercentType currentState = Wohnzimmer_Ambiente.getStateAs(PercentType)
  57.             var PercentType bright
  58.             if(currentState.intValue > 5 ) {
  59.                 bright = new PercentType(currentState.intValue - Dimmstep)     
  60.             }
  61.             else if (currentState.intValue < 6 ){
  62.                 bright = new PercentType(1)
  63.             }
  64.  
  65.             sendCommand(Wohnzimmer_Ambiente, bright as Number)
  66.             logInfo("Light", "Dim Down")
  67.             timer.reschedule(now)  
  68.         } else if(dimmstate == 3000 && timer !== null){
  69.             logInfo("Light", "wait")
  70.             timer.reschedule(now)
  71.         }
  72.     ])
  73. end
  74.  
  75. rule "Dim Up"
  76. when
  77.     Item HueDimmerSwitch received update 2000
  78. then
  79.     logInfo("Light", "Start Dim Up")
  80.     timer = createTimer(now.plusMillis(800), [|
  81.  
  82.         var dimmstate = (HueDimmerSwitch.state as DecimalType).intValue
  83.         if(Lastlight == 0 && dimmstate == 2001){
  84.             var PercentType currentState = Whz_Dimmer.getStateAs(PercentType)
  85.             var PercentType bright
  86.             if(currentState.intValue < 95 ) {
  87.                 bright = new PercentType(currentState.intValue + Dimmstep)     
  88.             } else if (currentState.intValue > 94 ){
  89.                 bright = new PercentType(100)
  90.             }
  91.  
  92.             sendCommand(Whz_Dimmer, bright as Number)
  93.             logInfo("Light", "Dim Up")
  94.             timer.reschedule(now)
  95.         } else if(Lastlight == 1 && dimmstate == 2001){
  96.             var PercentType currentState = Wohnzimmer_Ambiente.getStateAs(PercentType)
  97.             var PercentType bright
  98.             if(currentState.intValue < 95 ) {
  99.                 bright = new PercentType(currentState.intValue + Dimmstep)     
  100.             }
  101.             else if (currentState.intValue > 94 ){
  102.                 bright = new PercentType(100)
  103.             }
  104.  
  105.             sendCommand(Wohnzimmer_Ambiente, bright as Number)
  106.             logInfo("Light", "Dim Up")
  107.             timer.reschedule(now)  
  108.         } else if(dimmstate == 2000 && timer !== null){
  109.             logInfo("Light", "wait")
  110.             timer.reschedule(now)
  111.         }
  112.     ])
  113. end
  114.  
  115. rule "Dim up one step"
  116. when
  117.     Item HueDimmerSwitch received update 2002
  118. then
  119.     logInfo("Light", "Start Dim Up one step")
  120.         if(Lastlight == 0){
  121.             var PercentType currentState = Whz_Dimmer.getStateAs(PercentType)
  122.             var PercentType bright
  123.             if(currentState.intValue < 95 ) {
  124.                 bright = new PercentType(currentState.intValue + Dimmstep)     
  125.             } else if (currentState.intValue > 94 ){
  126.                 bright = new PercentType(100)
  127.             }
  128.  
  129.             sendCommand(Whz_Dimmer, bright as Number)
  130.             logInfo("Light", "Dim Up")
  131.         } else if(Lastlight == 1){
  132.             var PercentType currentState = Wohnzimmer_Ambiente.getStateAs(PercentType)
  133.             var PercentType bright
  134.             if(currentState.intValue < 95 ) {
  135.                 bright = new PercentType(currentState.intValue + Dimmstep)     
  136.             }
  137.             else if (currentState.intValue > 94 ){
  138.                 bright = new PercentType(100)
  139.             }
  140.             sendCommand(Wohnzimmer_Ambiente, bright as Number)
  141.             logInfo("Light", "Dim Up")
  142.         }
  143. end
  144.  
  145. rule "Dim down one step"
  146. when
  147.     Item HueDimmerSwitch received update 3002
  148. then
  149.     logInfo("Light", "Start Dim down one step")
  150.         if(Lastlight == 0){
  151.             var PercentType currentState = Whz_Dimmer.getStateAs(PercentType)
  152.             var PercentType bright
  153.             if(currentState.intValue > 4 ) {
  154.                 bright = new PercentType(currentState.intValue - Dimmstep)     
  155.             } else if (currentState.intValue < 5 ){
  156.                 bright = new PercentType(1)
  157.             }
  158.  
  159.             sendCommand(Whz_Dimmer, bright as Number)
  160.             logInfo("Light", "Dim down")
  161.         } else if(Lastlight == 1){
  162.             var PercentType currentState = Wohnzimmer_Ambiente.getStateAs(PercentType)
  163.             var PercentType bright
  164.             if(currentState.intValue > 4 ) {
  165.                 bright = new PercentType(currentState.intValue - Dimmstep)     
  166.             }
  167.             else if (currentState.intValue < 5 ){
  168.                 bright = new PercentType(1)
  169.             }
  170.             sendCommand(Wohnzimmer_Ambiente, bright as Number)
  171.             logInfo("Light", "Dim down")
  172.         }
  173. end
  174.  
  175. rule "cancel Timer"
  176. when
  177.     Item HueDimmerSwitch received update 2003 or
  178.     Item HueDimmerSwitch received update 2004 or
  179.     Item HueDimmerSwitch received update 3003 or
  180.     Item HueDimmerSwitch received update 3004
  181. then
  182.     timer.cancel
  183.     timer = null
  184. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top