Question about a rule

I have been trying to get a rule working that unlocks the front door and turns on lights when we both come home.

Here is the rule :

If I remove the required expression, the rule works.

I have been messing with this for too long, and removed the required expression out of lack of other ideas.

When we both come home, our presence sensors (Life360 / iPhone) show we are present.

It is working fine like this, but why does the rule fail to run with the required expression enabled?

I think I've seen others mention behavior like this before as well. IIRC, the required expression gets evaluated immediately after the trigger is observed. So if the trigger is true, then your required expression is necessarily false.

The required part needs to be all not present and the trigger needs to be all arrive. These two contradict themselves and will never fire because of that.

You will need to re evaluate what you want to do, but if I understand where you're going with this rule, I would change the trigger to be either arrive. This way the rule will work only if one of you arrives and that both of you were not present.

1 Like

This required expression will never work because there is a logical problem: it can only trigger if both presence sensors are away, but your trigger event is both sensors coming back. This effectively means the second sensor arriving (just one won't match the trigger unless the other is already present), yet when the first one arrives, the required expression will turn false, preventing triggering regardless of what happens -- until both again leave, repeating this problematic cycle.

Required expressions are effectively evaluated at the moment of or just before triggering, which is to say that the state resulting from a trigger is not taken into effect. One thing they are useful for is capturing specific state transitions. Triggers, however, represent events and not states/conditions, though this particular multi-device trigger does muddy those waters a bit as it will look at both states after an event from either. But triggers don't become "true," as they represent an instant in time, not a state. Two events will not happen at the exact same time.

So, you'll need to re-think what you really want to happen. Two possibilities that might work, depending on what you want: both not present as a requested expression with either arriving as the trigger (will capture the transition resulting from the first person coming home, and only them) -- fairly easy to write -- or one coming home followed by the other within some period of time -- which will require some creativity in your actions but isn't impossible.

6 Likes

That explains it. Thank you. Now I can sleep tonight. :grinning:

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.