Help with motion trigger


#1

1) Give a description of the problem
I’d like to have my toilet fan turn on when someone is using the toilet for longer than a few minutes. The issue is even when someone is sitting on it, the motion goes to active then 2 mins later will go inactive and then go active again.
2) What is the expected behaviour?
I’ve used the followed by feature, but the grap of within 5 mins is too large and i don’t want to miss an event.

Is there a way to only make the motion event trigger if the motion changed any number of times for example the following scenarios would result in the triggering piston:

  1. Motion goes to active and stays active for 5 mins
  2. Motion goes to active, 2 mins later inactive, 2 minutes later active
  3. Motion goes to active, 4 mins later inactive, 1 minutes later active

The following would not trigger the piston:

  1. Motion goes to active then 4 minutes later goes in active. then stays inactive for 1 more minute
  2. Motion goes to active 2 mins later inactive. then stays inactive for 3 more minutes

3) What is happening/not happening?
The trigger is not firing many times when I want it to as above rules. for example it still turns on if there is motion for 1 minute. then inactive, then motion within 1 minute.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full


#2

Untested, but here is what I am thinking:

IF Motion changes to active
Then
    With Bathroom lights  (TCP set to Never)
    Turn on etc
    Wait 5 minutes
        IF Motion is active
        Then
            With Fan  (TCP set to Never)
            Turn on
            Wait 10 minutes
            Turn off
        ELSE 
            With Bathroom Lights
            Turn off
        END IF
END IF

With this structure, as long as the motion is active at the 5 minute mark, the fan will kick on for 10 minutes.


Note:
The only logic not accounted for above is when to turn off the bathroom lights in the longer sessions.
(the easiest solution is to insert it right below the wait 10 minutes line)