Hello rossko57,
now I have a working program that stores the commands “UP”/“DOWN”/“STOP” in “number items” and passes them to the shutter control “rule”, which implements the interlock query and control.
In the next step, I will try to save the percentage setting as well and pass it to the control rule.
Do you have a suggestion or tip for me?
Perhaps someone would like to make an effort and check my code for possible areas of improvement. It could be that I could better implement the proper use of the timers.
Many thanks in advance for this and below is the code:
ITEMS:
Rollershutter Rollladen_Gaestezimmer "Gaestezimmer" (gGaestezimmer, Rolllaeden, gSpeichern)
Rollershutter Rollladen_Schlafzimmer "Schlafzimmer" (gSchlafzimmer, Rolllaeden, gSpeichern)
Rollershutter Rollladen_Buero "Buero" (gBuero, Rolllaeden, gSpeichern)
Number GZ_Rollladen_UP
Number GZ_Rollladen_DOWN
Number GZ_Rollladen_STOP
Number SZ_Rollladen_UP
Number SZ_Rollladen_DOWN
Number SZ_Rollladen_STOP
Number Buero_Rollladen_UP
Number Buero_Rollladen_DOWN
Number Buero_Rollladen_STOP
______________________________________________
RULE:
rule "Rollladen Gästezimmer HOCH/RUNTER/STOP"
when
Item Rollladen_Gaestezimmer received command
then
switch(receivedCommand.toString.toUpperCase){
case "UP": {
GZ_Rollladen_UP.postUpdate(1)
}
case "STOP": {
GZ_Rollladen_UP.postUpdate(0)
GZ_Rollladen_DOWN.postUpdate(0)
sendCommand (Arduino , "<Rollladen_GZ_STOP,>".toString)
GZ_Rollladen_STOP.postUpdate(1)
}
case "DOWN": {
GZ_Rollladen_DOWN.postUpdate(1)
}
}
end
rule "Rollladen Schlafzimmer HOCH/RUNTER/STOP"
when
Item Rollladen_Schlafzimmer received command
then
switch(receivedCommand.toString.toUpperCase){
case "UP": {
SZ_Rollladen_UP.postUpdate(1)
}
case "STOP": {
SZ_Rollladen_UP.postUpdate(0)
SZ_Rollladen_DOWN.postUpdate(0)
sendCommand (Arduino , "<Rollladen_SZ_STOP,>".toString)
SZ_Rollladen_STOP.postUpdate(1)
}
case "DOWN": {
SZ_Rollladen_DOWN.postUpdate(1)
}
}
end
rule "Rollladen Buero HOCH/RUNTER/STOP"
when
Item Rollladen_Buero received command
then
switch(receivedCommand.toString.toUpperCase){
case "UP": {
Buero_Rollladen_UP.postUpdate(1)
}
case "STOP": {
Buero_Rollladen_UP.postUpdate(0)
Buero_Rollladen_DOWN.postUpdate(0)
sendCommand (Arduino , "<Rollladen_Buero_STOP,>".toString)
Buero_Rollladen_STOP.postUpdate(1)
}
case "DOWN": {
Buero_Rollladen_DOWN.postUpdate(1)
}
}
end
_______________________________________________
rule "Steuerung Rolllaeden HOCH"
when
Item GZ_Rollladen_UP received update or
Item GZ_Rollladen_UP changed or
Item SZ_Rollladen_UP received update or
Item SZ_Rollladen_UP changed or
Item Buero_Rollladen_UP received update or
Item Buero_Rollladen_UP changed or
Time cron "0 0/1 * 1/1 * ? *" //every Minute
then
if (GZ_Rollladen_UP.state == 1 && GZ_Rollladen_STOP.state == 1 && SZ_Rollladen_STOP.state == 1 && Buero_Rollladen_STOP.state == 1){
GZ_Rollladen_STOP.postUpdate(0)
sendCommand (Arduino , "<Rollladen_GZ_UP,>".toString)
createTimer(now.plusSeconds(40)) [|
GZ_Rollladen_UP.postUpdate(0)
sendCommand(Rollladen_Gaestezimmer, STOP)
]
}
createTimer(now.plusSeconds(2)) [|
if (SZ_Rollladen_UP.state == 1 && GZ_Rollladen_STOP.state == 1 && SZ_Rollladen_STOP.state == 1 && Buero_Rollladen_STOP.state == 1){
SZ_Rollladen_STOP.postUpdate(0)
sendCommand (Arduino , "<Rollladen_SZ_UP,>".toString)
createTimer(now.plusSeconds(40)) [|
SZ_Rollladen_UP.postUpdate(0)
sendCommand(Rollladen_Schlafzimmer, STOP)
]
}]
createTimer(now.plusSeconds(4)) [|
if (Buero_Rollladen_UP.state == 1 && GZ_Rollladen_STOP.state == 1 && SZ_Rollladen_STOP.state == 1 && Buero_Rollladen_STOP.state == 1){
Buero_Rollladen_STOP.postUpdate(0)
sendCommand (Arduino , "<Rollladen_Buero_UP,>".toString)
createTimer(now.plusSeconds(40)) [|
Buero_Rollladen_UP.postUpdate(0)
sendCommand(Rollladen_Buero, STOP)
]
}]
end
rule "Steuerung Rolllaeden RUNTER"
when
Item GZ_Rollladen_DOWN received update or
Item GZ_Rollladen_DOWN changed or
Item SZ_Rollladen_DOWN received update or
Item SZ_Rollladen_DOWN changed or
Item Buero_Rollladen_DOWN received update or
Item Buero_Rollladen_DOWN changed or
Time cron "0 0/2 * 1/1 * ? *" //every 2 Minute
then
if (GZ_Rollladen_DOWN.state == 1 && GZ_Rollladen_STOP.state == 1 && SZ_Rollladen_STOP.state == 1 && Buero_Rollladen_STOP.state == 1){
GZ_Rollladen_STOP.postUpdate(0)
sendCommand (Arduino , "<Rollladen_GZ_DOWN,>".toString)
createTimer(now.plusSeconds(40)) [|
GZ_Rollladen_DOWN.postUpdate(0)
sendCommand(Rollladen_Gaestezimmer, STOP)
]
}
createTimer(now.plusSeconds(2)) [|
if (SZ_Rollladen_DOWN.state == 1 && GZ_Rollladen_STOP.state == 1 && SZ_Rollladen_STOP.state == 1 && Buero_Rollladen_STOP.state == 1){
SZ_Rollladen_STOP.postUpdate(0)
sendCommand (Arduino , "<Rollladen_SZ_DOWN,>".toString)
createTimer(now.plusSeconds(40)) [|
SZ_Rollladen_DOWN.postUpdate(0)
sendCommand(Rollladen_Schlafzimmer, STOP)
]
} ]
createTimer(now.plusSeconds(4)) [|
if (Buero_Rollladen_DOWN.state == 1 && GZ_Rollladen_STOP.state == 1 && SZ_Rollladen_STOP.state == 1 && Buero_Rollladen_STOP.state == 1){
Buero_Rollladen_STOP.postUpdate(0)
sendCommand (Arduino , "<Rollladen_Buero_DOWN,>".toString)
createTimer(now.plusSeconds(40)) [|
Buero_Rollladen_DOWN.postUpdate(0)
sendCommand(Rollladen_Buero, STOP)
]
}]
end
Greetings
Tobi