Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Integer Lastlight
- var Integer Dimmstep = 5
- var Timer timer
- rule "Whz ON"
- when
- Item HueDimmerSwitch received update 1002
- then
- Whz_licht.sendCommand(ON)
- Lastlight = 0
- end
- rule "Whz Off"
- when
- Item HueDimmerSwitch received update 4002
- then
- Whz_licht.sendCommand(OFF)
- Lastlight = 0
- end
- rule "Whz Ambiente ON"
- when
- Item HueDimmerSwitch received update 1003
- then
- Wohnzimmer_Ambiente.sendCommand(ON)
- Lastlight = 1
- end
- rule "Whz Ambiente Off"
- when
- Item HueDimmerSwitch received update 4003
- then
- Wohnzimmer_Ambiente.sendCommand(OFF)
- Lastlight = 1
- end
- rule "Dim Down"
- when
- Item HueDimmerSwitch received update 3000
- then
- logInfo("Light", "Start Dim Down")
- timer = createTimer(now.plusMillis(800), [|
- var dimmstate = (HueDimmerSwitch.state as DecimalType).intValue
- if(Lastlight == 0 && dimmstate == 3001){
- var PercentType currentState = Whz_Dimmer.getStateAs(PercentType)
- var PercentType bright
- if(currentState.intValue > 5 ) {
- bright = new PercentType(currentState.intValue - Dimmstep)
- } else if (currentState.intValue < 6 ){
- bright = new PercentType(1)
- }
- sendCommand(Whz_Dimmer, bright as Number)
- logInfo("Light", "Dim Down")
- timer.reschedule(now)
- } else if(Lastlight == 1 && dimmstate == 3001){
- var PercentType currentState = Wohnzimmer_Ambiente.getStateAs(PercentType)
- var PercentType bright
- if(currentState.intValue > 5 ) {
- bright = new PercentType(currentState.intValue - Dimmstep)
- }
- else if (currentState.intValue < 6 ){
- bright = new PercentType(1)
- }
- sendCommand(Wohnzimmer_Ambiente, bright as Number)
- logInfo("Light", "Dim Down")
- timer.reschedule(now)
- } else if(dimmstate == 3000 && timer !== null){
- logInfo("Light", "wait")
- timer.reschedule(now)
- }
- ])
- end
- rule "Dim Up"
- when
- Item HueDimmerSwitch received update 2000
- then
- logInfo("Light", "Start Dim Up")
- timer = createTimer(now.plusMillis(800), [|
- var dimmstate = (HueDimmerSwitch.state as DecimalType).intValue
- if(Lastlight == 0 && dimmstate == 2001){
- var PercentType currentState = Whz_Dimmer.getStateAs(PercentType)
- var PercentType bright
- if(currentState.intValue < 95 ) {
- bright = new PercentType(currentState.intValue + Dimmstep)
- } else if (currentState.intValue > 94 ){
- bright = new PercentType(100)
- }
- sendCommand(Whz_Dimmer, bright as Number)
- logInfo("Light", "Dim Up")
- timer.reschedule(now)
- } else if(Lastlight == 1 && dimmstate == 2001){
- var PercentType currentState = Wohnzimmer_Ambiente.getStateAs(PercentType)
- var PercentType bright
- if(currentState.intValue < 95 ) {
- bright = new PercentType(currentState.intValue + Dimmstep)
- }
- else if (currentState.intValue > 94 ){
- bright = new PercentType(100)
- }
- sendCommand(Wohnzimmer_Ambiente, bright as Number)
- logInfo("Light", "Dim Up")
- timer.reschedule(now)
- } else if(dimmstate == 2000 && timer !== null){
- logInfo("Light", "wait")
- timer.reschedule(now)
- }
- ])
- end
- rule "Dim up one step"
- when
- Item HueDimmerSwitch received update 2002
- then
- logInfo("Light", "Start Dim Up one step")
- if(Lastlight == 0){
- var PercentType currentState = Whz_Dimmer.getStateAs(PercentType)
- var PercentType bright
- if(currentState.intValue < 95 ) {
- bright = new PercentType(currentState.intValue + Dimmstep)
- } else if (currentState.intValue > 94 ){
- bright = new PercentType(100)
- }
- sendCommand(Whz_Dimmer, bright as Number)
- logInfo("Light", "Dim Up")
- } else if(Lastlight == 1){
- var PercentType currentState = Wohnzimmer_Ambiente.getStateAs(PercentType)
- var PercentType bright
- if(currentState.intValue < 95 ) {
- bright = new PercentType(currentState.intValue + Dimmstep)
- }
- else if (currentState.intValue > 94 ){
- bright = new PercentType(100)
- }
- sendCommand(Wohnzimmer_Ambiente, bright as Number)
- logInfo("Light", "Dim Up")
- }
- end
- rule "Dim down one step"
- when
- Item HueDimmerSwitch received update 3002
- then
- logInfo("Light", "Start Dim down one step")
- if(Lastlight == 0){
- var PercentType currentState = Whz_Dimmer.getStateAs(PercentType)
- var PercentType bright
- if(currentState.intValue > 4 ) {
- bright = new PercentType(currentState.intValue - Dimmstep)
- } else if (currentState.intValue < 5 ){
- bright = new PercentType(1)
- }
- sendCommand(Whz_Dimmer, bright as Number)
- logInfo("Light", "Dim down")
- } else if(Lastlight == 1){
- var PercentType currentState = Wohnzimmer_Ambiente.getStateAs(PercentType)
- var PercentType bright
- if(currentState.intValue > 4 ) {
- bright = new PercentType(currentState.intValue - Dimmstep)
- }
- else if (currentState.intValue < 5 ){
- bright = new PercentType(1)
- }
- sendCommand(Wohnzimmer_Ambiente, bright as Number)
- logInfo("Light", "Dim down")
- }
- end
- rule "cancel Timer"
- when
- Item HueDimmerSwitch received update 2003 or
- Item HueDimmerSwitch received update 2004 or
- Item HueDimmerSwitch received update 3003 or
- Item HueDimmerSwitch received update 3004
- then
- timer.cancel
- timer = null
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement