I’d like to execute a rule based on the items state before it received the command
here is how i set my rule up
rule "Cinema scene Level selection"
when
Item Scene_Cinema received command
then
//logInfo("TEST ", "Cinema scene previous state WAS " + Scene_Cinema.previousState)
switch(receivedCommand) {
case 0 : return false //no selection
case 1 : { //Level I
sendCommand(D2, DOWN)
}
case 2 : { //Level II
sendCommand(D0, DOWN)
}
case 3 : { //Level III
sendCommand(D0, DOWN)
sendCommand(K1, DOWN)
}
case 4 : { //Level IV
sendCommand(D0, DOWN)
sendCommand(K0, DOWN)
}
case 5 : if (Scene_Cinema.previousState == 1) {
sendCommand(D2, UP)
postUpdate(Scene_Cinema, 0)
}
else if (Scene_Cinema.previousState == 2) {
sendCommand(D0, UP)
postUpdate(Scene_Cinema, 0)
}
else if (Scene_Cinema.previousState == 3) {
sendCommand(D0, UP)
sendCommand(K1, UP)
postUpdate(Scene_Cinema, 0)
}
else if (Scene_Cinema.previousState == 4) {
sendCommand(D0, UP)
sendCommand(K0, UP)
postUpdate(Scene_Cinema, 0)
}
else {
sendCommand(D0, UP)
sendCommand(K0, UP)
postUpdate(Scene_Cinema, 0)
}
}
end`
What i’d like is to execute a rule in case 5 according to what the previous state of the item was, before the command was issued. However i can’t seem to get the .previousState working.
Can anyone suggest a solution?