Presence sensor from contact and motion

Hi,
I want to create a virtual presence sensor for the basement. The basement has a door with a contact sensor, and two motion sensors.

The idea I have is:
If the door is closed and new motion is detected => present (that's easy)
If the door opens, then closed, then motion is detected =` present
If motion is detected, then the door opens, closes, and no motion is detected => absent

Any one has written rules like such ? In particular, I can't figure out how to chain events like that as triggers ?

I can't quite work out how that'll work:

That confuses me, how would the motion trigger without you going through the door in the first instance?

If you have two motion sensors already could you not just use both of those in your rule?

Required Expression:
Private Boolean True

Triggers:
Motion detector A active
Motion detector B active

Actions:
Set Private Boolean False
Virtual Presence Sensor 'Present'
Wait for event Motion detector A and Motion detector B report 'inactive' and stay that way for x seconds
Virtual Presence Sensor 'Not Present'
Set Private Boolean True

Though if you wanted the door in the rule you could add that as a trigger as well. I think that'd work but might need tweaking.

I agree with John. If everything is dependent on motion, then the contact sensor isn't even needed. Additionally, there are apps that will let you group the motion sensors together as a virtual sensor so that if either detects motion, the virtual will go active, and if both go inactive the virtual will as well. There's the built in Zone Motion Controller app or you can take mine for a spin that lets you group most sensor types with some extra functions:

1 Like

The thing is I don't have motion sensors that cover all rooms of the basement. Motion sensor going off does not mean there's nobody in the basement, it just means there's nobody moving around that sensor. Therefore, I aim to track "people enter" and "people exit" event, which really are a chain of event that involves the contact sensor on the door.

The first rule (motion detected while door is closed) is simply to correct for possible missed events with the door (i.e. if motion is detected, then someone is there, and if the door remains closed, then that someone is still there even if motion stops).

Ok, I think that with the clues above, I managed to do it with 3 rules.
For the arrival in the basement:


For the departure from the basement:

Safe-guard in case the other ones failed.

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