Unexpected behavior from states

Hi

I am getting some unexpected behavior in my security PLEG, in relation to a change I just made to transition to using the state capabilities of PLEG. It seems to work elsewhere, so I am not quite sure why this one thing occurs. It relates to the following condition, which sets my alarm when the timer runs out, but should only do so when the home state is in one of the conditions defined in AlarmState. For some reason though, this is showing true, even though the state is reported as being set as HomeAwake and none of the other valid states are true.

I left the timings in in case they provide any clues, but I am at a loss. Any advice appreciated.

SetAlarm No AlarmState AND (AlarmState;!AlarmTimer) true 2014-09-01 22:06:47.166 2014-09-01 22:00:02.472
AlarmState No State$HomeAsleep OR State$Away false 2014-09-01 22:01:46.324 2014-09-01 22:08:12.817

State Variables
Name Value Last Change Previous Change
State HomeAwake 2014-09-01 22:08:12.708 2014-09-01 22:06:47.308

SetAlarm became true at 22:06:47.166. AlarmState was true at this time - it was true between 22:01:46.324 and 22:08:12.817.

You may need to consider the order of your Conditions. They are evaluated from the top down.

Thanks… However I am not sure the order is the issue. I have also noticed similarly unpredictable behaviour for this one:

AwayState No State$Away OR State$AwayArmed OR State$Vacation false 2014-09-01 11:36:07.693 2014-09-01 19:52:28.152

State$HomeAwake No Home AND Awake true 2014-09-02 15:00:58.701 2014-09-02 13:29:21.514
State$Vacation No Vacation false 2014-08-29 11:54:40.434 2014-08-29 11:54:56.876
State$Away No Away AND !State$Vacation false 2014-09-02 13:29:21.363 2014-09-02 15:00:13.902

As you can see, the condition did not evaluate as true, despite the state changing to one of the target conditions. The thing is, this condition was placed BEFORE the states themselves, the previous one (AlarmState) was placed AFTER the states, so I would have thought if ordering was the issue, then at least one of them should be working? Is there something I am missing about the behaviour of the states, in terms of when they are evaluated in a condition, for example?

Thanks

Deleted the conditions and recreated and seems ok now (conditions at the end). Not sure what went wrong.

Cheers

One thing to note: When you use a term like State$Away in an expression, you are testing the state of the Condition of that name. This is not the same as testing whether State contains Away. Once the Condition State$Away has fired and set the State Variable State to Away, it may become false. The value of State will not necessarily change, though, unless another State$xxxx Condition fires.

If you want to test the contents of State, use this form: (State eq “Away”)

Ah, I was not aware of that. Could well be the problem. Thanks as always RexBeckett!