IF THEN - ELSE IF Help, Kind of

Good to know, thanks for the heads up.

I guess I can use the app that @cjkeenan suggested, but the mode change is the first action; that should alleviate multiple running of the first part.. the likelihood that 2 people enter the geofence at the exact same time is very low and, worst case, it just runs twice?

@cjkeenan do you know enough about that app to give me advice? Like... if I set this up in this instance, it looks like I should be using the boolean OR option?

It may not matter in this particular rule; I just wanted you to be aware of this. Some rules might have concurrency issues, though.

Since this is a good example how would i alleviate it in this case?

One way is to have a Variable to be tested as the first step, with a wait until false or exit rule, as appropriate, then set the semaphore variable, do your stuff, then clear the lock variable and exit. Difficult to debug and test.

There are atomic state operators in Groovy that can be used, and some concurrent operations may have to be written that way.

Yeah for combining multiple people I use the boolean OR option. For a combining multiple presence detections for a single person, I use the standard combiner.

I don't get what advantage this has. I'm still doing an OR operator on multiple presence sensors, which could also fire off the rule again?

Well this is handled outside of the rule, changing another virtual presence sensor that the rule sees and acts on so unless RM sees and triggers based off multiple changes to the same state, that is present, then changing to present again and RM triggering twice, which I do not think it does, this should handle the multiple trigger situation.

1 Like

i believe your rule was fine as written. the concurrency shouldnt matter as only one should change the mode.

I think it will matter because it will trigger the Home mode actions multiple times, yes it may trigger the away mode ones once but then the other two, worst case, would trigger the home ones. Also in that case a race condition is effectively there, if all arrive at the same time, albeit that is not really relevant here as they all have more or less the same path.

no i have a similiar rule that triggers home mode when any door unlocks and a rule that unlocks a 2nd door when the first one does.. it never has caused an issue.

maybe add an extra if that says if garage door is closed open otherwise the reset of the actions even if triggered more than once wont matter. even that wont matter if it is a zwave garage door opener . if it is a relay it may . stop or reverse the already opening door.

Nevermind, when looking at your rule again, you likely do not want to combine them because then you will not be able to retrigger when a new person arrives which I believe you want to do. Honestly as people are saying yes, you may get a retrigger, but there are not really any practical downsides to that other than negligible hub load.

That being said, I still recommend that app, just not for this specific case, as it makes presence more reliable since you can combine multiple sources, including free ones like wifi-tracking, and also makes handling presence based rules a lot easier.

1 Like

i have written my rules this way.

when a door unlocks by code or a garage door opens change mode to home. (if away).
another rule that does stuff on mode change like unlock other doors turn on lights etc.

another rule that opens each individual garage door when a vehicle arrives. and turns on garage lights.

rule that arms away when a vehicle leaves and all vehicles are gone.

etc.

I think it is easier to break up rules into separate.

1 Like

Very interesting, I would love to get to a state of trust where I could arm, disarm, lock and unlock based on presence but it just isn't there yet.

i also get an alert /text on mode change so i know if it is failing. but havent had the issue.. I use smartthings presence sensors and a tesla integration for my car.. Haven't had any issues. on our empty house i disable some stuff so the house doesn't accidentially disarm when we are away from that location.. I leave the lock disarm so i can open the lock for someone or put a code in there for maintenance people. And it is actually when a door is unlocked by CODE so manually using the lock doesnt affect it.

1 Like