Hello. I have got two switches (named ARollerUp and ARollerDown) as items and they must never be in the same state, so possible is only ARollerUp = ON && ARollerDown = OFF and vice versa. I tried the following 2 rules for realising that:
rule "ARollerUp"
when
Item ARollerUp received command
then
lock.lock()
try{
if(receivedCommand==OFF){
sendCommand(ARollerDown, ON)
}
if(receivedCommand==ON){
sendCommand(ARollerDown, OFF)
}
}
finally{ lock.unlock()}
end
rule "ARollerDown"
when
Item ARollerDown received command
then
lock.lock()
try{
if(receivedCommand==OFF){
sendCommand(ARollerUp, ON)
}
if(receivedCommand==ON){
sendCommand(ARollerUp, OFF)
}
}
finally{ lock.unlock()}
end
The problem ist: when I change one state, both states start toggling infinitively. They start switching from one state to the other without any end. I think the action of one rule always triggers the other rule. How can I avoid that? E.g. when I switch ARollerUp to OFF, I only want ARollerDown to switch to ON and so on.