Help with rule for motion and open/close sensor

Since it may be awhile before the piston code is tested and available as it’s still early in the design phase, I did just want to mention that there is a way to solve this problem without using any custom code if you’re willing to use transitional modes. Several of us Have been doing this for about a year, using various different devices.

This approach doesn’t use a timer, which can be tricky anyway because of the mesh network. Instead, it works by knowing where you started, which is based on the use of transitional modes.

So say you’re coming in from outside. The initial mode is away. So you use a routine that only runs in away mode. That routine says when the mode is away, if the motion sensor reports activity, change the mode to arriving and turn on the stair lights.

The second routine only runs in arriving mode. It says when the mode is arriving, if the door sensor opens, turn on the living room lights. It also changes the mode to whatever your usual i’m home mode would be.

That takes care of the direction where you are coming in from outside.

Now for the direction where you are starting in the living room.

A third routine says when the mode is anything except arriving (that is, it doesn’t run in arriving mode), when you open the front door, turn on the stair lights. That way the living room lights are not going to come on.

The structure may be more or less complicated depending on exactly what you are doing. You might need two transitional modes (one for leaving and one for arriving) and multiple routines, based on the number of other modes you have already. You may even include virtual switches in routines to trigger smart lighting or other smart apps so that you can do things that aren’t available in basic routines.

But the point is that it gives you a way to recognize the sequence in which devices are triggered. No custom code required.

The following thread show some of the different ways that I’ve used it, and some of the different devices I’ve used it with. The basic idea came from a different community member, and That’s also mentioned in the thread. In my case, I wanted to limit presence detection to A smaller area than even the arrival sensor covered, so using two devices allowed me to do that.

Anyway, this is a solution with a lot of different pieces, even if each piece is pretty simple. So you might prefer to wait until there are more complex custom code methods available. But I did just want to mention that you can do it now just with the existing official features. :sunglasses:

1 Like