Rule changing/setting a switch is ignored

Hi Dirk,

Autoupdate is not causing your problems (yet!). If you do some testing by putting a call to logInfo in your rule but outside of the if statements, I think you’ll find that your rule is running, it’s just not triggering either of the if statements. That has to do with what you are testing.

CubicPing is an item and as such will never equal ON or OFF (which are states) but is an object with many properties and methods of which state is only one. You want to know if the state of CubicPing is ON or OFF

if (CubicPing.state == OFF)

Once your if statements are formatted correctly, then you might start to see some unusual behavior from the rule due to autoupdate, and you can get around that either by setting autoupdate for CubicPing to false or by using the implicit variables available to you in rules.

receivedCommand is the variable that you would want to use here, so that instead of relying on the timing of CubicPig actually changing state, your if statements can react to what the eventual state of CubicPing will be whenever it gets around to updating.

On a stylistic note: it will be easier for everyone to read your posts and help you if you use code fences on all your logs and configuration text.

1 Like