Motion Trigger with restrictions


#1

1) Give a description of the problem
This piston was working but stopped and cant figure out why. The motion sensor uses a BI camera via BI fusion. ST shows the motion status changing correctly but light switch is not turning on. I’ve tested with a simple ST automation and works, but need the inactive restriction in place.

2) What is the expected behaviour?
light switch turn on with motion, then off when motion is inactive for 15 minutes. will not trigger unless motion is inactive for 5 seconds; otherwise the IR lights on the camera triggers motion creating cycle loop

3) What is happening/not happening?
per the logs, the motion event is detected but the lights are not switching on

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full

11/15/2020, 12:16:09 AM +464ms
+2ms ╔Received event [Driveway].motion = active with a delay of 86ms
+155ms ║RunTime Analysis CS > 18ms > PS > 89ms > PE > 47ms > CE
+157ms ║Runtime (39427 bytes) successfully initialized in 89ms (v0.3.110.20191009) (155ms)
+158ms ║╔Execution stage started
+197ms ║║Comparison (time) 969626 is_between (time) 1605482640000 … (time) 1605445020000 = true (9ms)
+198ms ║║Time restriction check passed
+199ms ║║Condition #1 evaluated true (37ms)
+416ms ║║Comparison (enum) active was (string) inactive = false (212ms)
+418ms ║║Condition #2 evaluated false (217ms)
+418ms ║║Condition group #3 evaluated false (state did not change) (257ms)
+426ms ║║Comparison (enum) active stays (string) inactive = false (1ms)
+427ms ║║Cancelling any timed trigger schedules for condition 8
+428ms ║║Cancelling statement #8’s schedules…
+429ms ║║Condition #8 evaluated false (8ms)
+430ms ║║Condition group #7 evaluated false (state did not change) (10ms)
+432ms ║╚Execution stage complete. (273ms)
+432ms ╚Event processed successfully (432ms)


#2

In your logs, line 25 was false, so line 32 should not execute.

Comparison (Motion Sensor) was inactive = false
Condition #2 evaluated false

This makes sense to me because if the piston is running, it means that the Sensor’s motion has just changed… Hence, the trigger on line 27 will always find line 25 to be false.


#3

Thank you. I agree with the logic; however, it was working before with the same restriction. not sure when it stopped working. could have been when I migrated smartthings or upgraded to BI v5 from v4. both occurred around the same time. I believe I copied this piston from another user for the same use case. Previously without the inactive restriction, when the 15 minutes of inactive motion was reached and the light would turn off, the BI camera’s IR lights would come on thus triggering another motion event and turning the lights back on resulting in a continuous loop. For now, i have removed the inactive restriction and the IR lights are not triggering another motion event. We will see how it goes. do you have any suggestions to accomplish what i have described? Thank again!


#4

I would do it without using ONLY WHEN or WAS INACTIVE…

Maybe something like this:

define
   boolean {recent} = (no value set)
end define

IF Sensor 3's motion changes to active
Then
   IF Time is NOT between Sunrise and Sunset
      and
      Variable {recent} is not true
   Then
      Turn on Switch 8
   END IF
END IF

IF Sensor 3's motion stays inactive for 15 minutes
Then
   With Switch 8 (TCP set to Never)
      Set variable {recent} = true
      WAIT 1 seconds  <-- Might not need this line
      Turn off
      WAIT 5 seconds
      Set variable {recent} = false
END IF

Note: I inverted your times so as not to span midnight.

Also, there is no way to prevent the piston from running each time the motion sensor changes… but hopefully the variable gets set in time to prevent any action from taking place.


#5

Thank you very much. i will give that a shot