Check if there was motion before contact open

conditions
motion

#1

1) Give a description of the problem
I can’t work out which condition I need to use to check if a motion sensor was active before a contact sensor changed to open. I want to check if the motion sensor was activated at least 1 second before the contact changed to open.

I have a contact sensor on my front door and a motion sensor inside the house behind said door. So, when the door opens the contact changes to open and the motion sensor changes to active.

2) What is the expected behaviour?
I want to chime my siren if the door opens from outside but not from inside.

3) What is happening/not happening?
Chime either always goes off, or never goes off.


#2

Can you give us a green shot of your piston and the full log of an execution with trace turned on?


#3

I can, but I don’t think it will help as I don’t know what the right condition is to use. Obviously I have a trigger on the contact sensor opening, but I need to know which condition checks that the motion sensor inside was inactive beforehand.


#4

Just an observation…You might have difficulty programming a 1 second difference between your sensors. Sensor and network latency could easily be longer than 1 second and randomly change.


#5

Is there a way to check that it was inactive for at least a set period before the contact sensor opened?

i.e. Contact opens, and motion was inactive for 30 seconds beforehand?


#6

You might try using age([motionSensor1 : motion]), which is reported in milliseconds.

EDIT : You could also try STAYS INACTIVE for the second sensor.

IF Contact sensor opens
Then
  IF motion sensor stays inactive for 30 seconds
    Then
      Do Stuff
  END IF
END IF

Another way may be…

IF Contact sensor opens
  Then
    IF age([motion sensor : motion]) is greater than 1000 (1 second)
      Then
        Do Stuff
    END IF
END IF

#7

I am giving this a go, as logically it appears it would do as I wanted.

This is what I had before, but it isn’t working: