Motion Sensor Help


#1

1) Give a description of the problem
My piston is designed to turn on the AC and the light when I come into the room. That works well. They keep turning off while I am in the room

2) What is the expected behaviour?
When a virtual switch is off, the AC and light turn on when I walk into the room. Then, after the sensor doesn’t see motion for 15 minutes, all of the connected devices in the room (fan, lights, AC) will turn off. The virtual switch is there so I can disable the piston by telling Alexa to turn on the virtual switch.

3) What is happening/not happening?
Everything turns on as expected when I walk in the room. Everything keeps turning off even though I am moving about regularly. My desk is against the wall, I am facing the wall, and the sensor is right above the monitors. A turn of my head from monitor to monitor is enough to trigger the sensor.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full

8/4/2020, 11:26:52 PM +191ms
    +1ms ╔Received event [Frog Motion Sensor].motion = active with a delay of 75ms
    +89ms ║RunTime Analysis CS > 23ms > PS > 5ms > PE > 61ms > CE
    +91ms ║Runtime (38053 bytes) successfully initialized in 5ms (v0.3.110.20191009) (89ms)
    +92ms ║╔Execution stage started
    +102ms ║║Comparison (enum) off is (string) off = true (1ms)
    +104ms ║║Condition #1 evaluated true (7ms)
    +104ms ║║Condition group #null evaluated true (state did not change) (9ms)
    +109ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
    +111ms ║║Cancelling condition #3's schedules...
    +113ms ║║Cancelling statement #4's schedules...
    +119ms ║║Skipped execution of physical command [Frog AC].on([]) because it would make no change to the device. (2ms)
    +120ms ║║Executed [Frog AC].on (4ms)
    +134ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (9ms)
    +135ms ║║Executed [Office Light].on (11ms)
    +136ms ║║Condition #3 evaluated true (30ms)
    +137ms ║║Cancelling condition #2's schedules...
    +138ms ║║Condition group #2 evaluated true (state changed) (32ms)
    +140ms ║╚Execution stage complete. (48ms)
    +142ms ║Setting up scheduled job for Tue, Aug 4 2020 @ 11:45:49 PM EDT (in 1136.796s)
    +154ms ╚Event processed successfully (154ms)

    8/4/2020, 11:23:36 PM +944ms
    +1ms ╔Received event [Frog Motion Sensor].motion = inactive with a delay of 72ms
    +78ms ║RunTime Analysis CS > 21ms > PS > 6ms > PE > 50ms > CE
    +80ms ║Runtime (38048 bytes) successfully initialized in 6ms (v0.3.110.20191009) (78ms)
    +81ms ║╔Execution stage started
    +89ms ║║Comparison (enum) off is (string) off = true (1ms)
    +90ms ║║Condition #1 evaluated true (7ms)
    +91ms ║║Condition group #null evaluated true (state did not change) (8ms)
    +95ms ║║Comparison (enum) inactive changes_to (string) active = false (0ms)
    +96ms ║║Cancelling condition #3's schedules...
    +97ms ║║Condition #3 evaluated false (4ms)
    +98ms ║║Cancelling condition #2's schedules...
    +99ms ║║Condition group #2 evaluated false (state changed) (7ms)
    +103ms ║║Comparison (enum) inactive stays (string) inactive = true (1ms)
    +105ms ║║Condition #7 evaluated false (5ms)
    +106ms ║║Condition group #6 evaluated false (state did not change) (6ms)
    +108ms ║╚Execution stage complete. (28ms)
    +109ms ║Setting up scheduled job for Tue, Aug 4 2020 @ 11:45:49 PM EDT (in 1332.075s)
    +144ms ╚Event processed successfully (144ms)

    8/4/2020, 11:22:24 PM +740ms
    +1ms ╔Received event [Frog Motion Sensor].motion = active with a delay of 55ms
    +68ms ║RunTime Analysis CS > 19ms > PS > 4ms > PE > 45ms > CE
    +71ms ║Runtime (38053 bytes) successfully initialized in 4ms (v0.3.110.20191009) (68ms)
    +71ms ║╔Execution stage started
    +79ms ║║Comparison (enum) off is (string) off = true (1ms)
    +81ms ║║Condition #1 evaluated true (7ms)
    +81ms ║║Condition group #null evaluated true (state did not change) (7ms)
    +86ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
    +87ms ║║Cancelling condition #3's schedules...
    +89ms ║║Cancelling statement #4's schedules...
    +95ms ║║Skipped execution of physical command [Frog AC].on([]) because it would make no change to the device. (3ms)
    +96ms ║║Executed [Frog AC].on (4ms)
    +104ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (5ms)
    +104ms ║║Executed [Office Light].on (6ms)
    +106ms ║║Condition #3 evaluated true (22ms)
    +107ms ║║Cancelling condition #2's schedules...
    +107ms ║║Condition group #2 evaluated true (state changed) (24ms)
    +109ms ║╚Execution stage complete. (38ms)
    +111ms ║Setting up scheduled job for Tue, Aug 4 2020 @ 11:45:49 PM EDT (in 1404.278s)
    +131ms ╚Event processed successfully (130ms)

    8/4/2020, 11:22:09 PM +531ms
    +1ms ╔Received event [Frog Motion Sensor].motion = inactive with a delay of 67ms
    +70ms ║RunTime Analysis CS > 17ms > PS > 5ms > PE > 47ms > CE
    +72ms ║Runtime (38048 bytes) successfully initialized in 5ms (v0.3.110.20191009) (70ms)
    +73ms ║╔Execution stage started
    +81ms ║║Comparison (enum) off is (string) off = true (1ms)
    +82ms ║║Condition #1 evaluated true (6ms)
    +83ms ║║Condition group #null evaluated true (state did not change) (8ms)
    +88ms ║║Comparison (enum) inactive changes_to (string) active = false (1ms)
    +89ms ║║Cancelling condition #3's schedules...
    +90ms ║║Condition #3 evaluated false (5ms)
    +91ms ║║Cancelling condition #2's schedules...
    +92ms ║║Condition group #2 evaluated false (state changed) (7ms)
    +97ms ║║Comparison (enum) inactive stays (string) inactive = true (1ms)
    +99ms ║║Condition #7 evaluated false (6ms)
    +100ms ║║Condition group #6 evaluated false (state did not change) (7ms)
    +103ms ║╚Execution stage complete. (29ms)
    +104ms ║Setting up scheduled job for Tue, Aug 4 2020 @ 11:45:49 PM EDT (in 1419.494s)
    +115ms ╚Event processed successfully (115ms)

    8/4/2020, 11:20:37 PM +225ms
    +2ms ╔Received event [Frog Motion Sensor].motion = active with a delay of 73ms
    +74ms ║RunTime Analysis CS > 21ms > PS > 4ms > PE > 48ms > CE
    +76ms ║Runtime (38053 bytes) successfully initialized in 4ms (v0.3.110.20191009) (74ms)
    +77ms ║╔Execution stage started
    +86ms ║║Comparison (enum) off is (string) off = true (1ms)
    +88ms ║║Condition #1 evaluated true (8ms)
    +89ms ║║Condition group #null evaluated true (state did not change) (8ms)
    +94ms ║║Comparison (enum) active changes_to (string) active = true (0ms)
    +95ms ║║Cancelling condition #3's schedules...
    +97ms ║║Cancelling statement #4's schedules...
    +104ms ║║Skipped execution of physical command [Frog AC].on([]) because it would make no change to the device. (3ms)
    +105ms ║║Executed [Frog AC].on (5ms)
    +117ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (8ms)
    +118ms ║║Executed [Office Light].on (9ms)
    +119ms ║║Condition #3 evaluated true (28ms)
    +120ms ║║Cancelling condition #2's schedules...
    +121ms ║║Condition group #2 evaluated true (state changed) (31ms)
    +123ms ║╚Execution stage complete. (46ms)
    +125ms ║Setting up scheduled job for Tue, Aug 4 2020 @ 11:45:49 PM EDT (in 1511.779s)
    +136ms ╚Event processed successfully (136ms)

    8/4/2020, 11:20:00 PM +131ms
    +1ms ╔Received event [Frog Motion Sensor].motion = inactive with a delay of 74ms
    +82ms ║RunTime Analysis CS > 21ms > PS > 5ms > PE > 56ms > CE
    +84ms ║Runtime (38048 bytes) successfully initialized in 5ms (v0.3.110.20191009) (82ms)
    +85ms ║╔Execution stage started
    +93ms ║║Comparison (enum) off is (string) off = true (1ms)
    +94ms ║║Condition #1 evaluated true (6ms)
    +95ms ║║Condition group #null evaluated true (state did not change) (7ms)
    +100ms ║║Comparison (enum) inactive changes_to (string) active = false (0ms)
    +101ms ║║Cancelling condition #3's schedules...
    +102ms ║║Condition #3 evaluated false (4ms)
    +103ms ║║Cancelling condition #2's schedules...
    +103ms ║║Condition group #2 evaluated false (state changed) (6ms)
    +108ms ║║Comparison (enum) inactive stays (string) inactive = true (1ms)
    +110ms ║║Condition #7 evaluated false (6ms)
    +111ms ║║Condition group #6 evaluated false (state did not change) (7ms)
    +113ms ║╚Execution stage complete. (28ms)
    +114ms ║Setting up scheduled job for Tue, Aug 4 2020 @ 11:45:49 PM EDT (in 1548.883s)
    +129ms ╚Event processed successfully (129ms)

    8/4/2020, 11:18:58 PM +90ms
    +1ms ╔Received event [Frog Motion Sensor].motion = active with a delay of 71ms
    +73ms ║RunTime Analysis CS > 21ms > PS > 4ms > PE > 48ms > CE
    +75ms ║Runtime (38053 bytes) successfully initialized in 4ms (v0.3.110.20191009) (73ms)
    +76ms ║╔Execution stage started
    +84ms ║║Comparison (enum) off is (string) off = true (1ms)
    +85ms ║║Condition #1 evaluated true (7ms)
    +86ms ║║Condition group #null evaluated true (state did not change) (8ms)
    +91ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
    +92ms ║║Cancelling condition #3's schedules...
    +94ms ║║Cancelling statement #4's schedules...
    +101ms ║║Skipped execution of physical command [Frog AC].on([]) because it would make no change to the device. (3ms)
    +102ms ║║Executed [Frog AC].on (4ms)
    +114ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (7ms)
    +114ms ║║Executed [Office Light].on (9ms)
    +116ms ║║Condition #3 evaluated true (28ms)
    +117ms ║║Cancelling condition #2's schedules...
    +118ms ║║Condition group #2 evaluated true (state changed) (29ms)
    +120ms ║╚Execution stage complete. (45ms)
    +121ms ║Setting up scheduled job for Tue, Aug 4 2020 @ 11:45:49 PM EDT (in 1610.918s)
    +133ms ╚Event processed successfully (133ms)

    8/4/2020, 11:18:53 PM +759ms
    +2ms ╔Received event [Frog Motion Sensor].motion = inactive with a delay of 80ms
    +80ms ║RunTime Analysis CS > 23ms > PS > 6ms > PE > 50ms > CE
    +82ms ║Runtime (38048 bytes) successfully initialized in 6ms (v0.3.110.20191009) (80ms)
    +83ms ║╔Execution stage started
    +92ms ║║Comparison (enum) off is (string) off = true (1ms)
    +94ms ║║Condition #1 evaluated true (9ms)
    +95ms ║║Condition group #null evaluated true (state did not change) (9ms)
    +99ms ║║Comparison (enum) inactive changes_to (string) active = false (0ms)
    +100ms ║║Cancelling condition #3's schedules...
    +101ms ║║Condition #3 evaluated false (4ms)
    +102ms ║║Cancelling condition #2's schedules...
    +103ms ║║Condition group #2 evaluated false (state changed) (7ms)
    +108ms ║║Comparison (enum) inactive stays (string) inactive = true (2ms)
    +110ms ║║Condition #7 evaluated false (5ms)
    +111ms ║║Condition group #6 evaluated false (state did not change) (6ms)
    +113ms ║╚Execution stage complete. (31ms)
    +114ms ║Setting up scheduled job for Tue, Aug 4 2020 @ 11:45:49 PM EDT (in 1615.255s)
    +126ms ╚Event processed successfully (126ms)

    8/4/2020, 11:15:56 PM +900ms
    +1ms ╔Received event [Frog Motion Sensor].motion = active with a delay of 116ms
    +68ms ║RunTime Analysis CS > 17ms > PS > 5ms > PE > 46ms > CE
    +70ms ║Runtime (38054 bytes) successfully initialized in 5ms (v0.3.110.20191009) (68ms)
    +71ms ║╔Execution stage started
    +80ms ║║Comparison (enum) off is (string) off = true (1ms)
    +81ms ║║Condition #1 evaluated true (8ms)
    +82ms ║║Condition group #null evaluated true (state did not change) (8ms)
    +86ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
    +87ms ║║Cancelling condition #3's schedules...
    +89ms ║║Cancelling statement #4's schedules...
    +239ms ║║Executed physical command [Frog AC].on() (146ms)
    +240ms ║║Executed [Frog AC].on (148ms)
    +252ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (8ms)
    +253ms ║║Executed [Office Light].on (10ms)
    +254ms ║║Condition #3 evaluated true (171ms)
    +255ms ║║Cancelling condition #2's schedules...
    +256ms ║║Condition group #2 evaluated true (state changed) (173ms)
    +258ms ║╚Execution stage complete. (188ms)
    +259ms ║Setting up scheduled job for Tue, Aug 4 2020 @ 11:45:49 PM EDT (in 1791.969s)
    +267ms ╚Event processed successfully (267ms)

    8/4/2020, 11:15:48 PM +992ms
    +1ms ╔Received event [Frog Motion Sensor].motion = inactive with a delay of 86ms
    +106ms ║RunTime Analysis CS > 22ms > PS > 6ms > PE > 79ms > CE
    +109ms ║Runtime (38054 bytes) successfully initialized in 6ms (v0.3.110.20191009) (107ms)
    +110ms ║╔Execution stage started
    +120ms ║║Comparison (enum) off is (string) off = true (1ms)
    +121ms ║║Condition #1 evaluated true (8ms)
    +122ms ║║Condition group #null evaluated true (state did not change) (9ms)
    +126ms ║║Comparison (enum) inactive changes_to (string) active = false (0ms)
    +128ms ║║Condition #3 evaluated false (4ms)
    +129ms ║║Condition group #2 evaluated false (state did not change) (5ms)
    +133ms ║║Comparison (enum) inactive stays (string) inactive = true (1ms)
    +135ms ║║Adding a timed trigger schedule for condition 7
    +137ms ║║Condition #7 evaluated false (7ms)
    +138ms ║║Condition group #6 evaluated false (state did not change) (9ms)
    +140ms ║╚Execution stage complete. (30ms)
    +141ms ║Setting up scheduled job for Tue, Aug 4 2020 @ 11:45:49 PM EDT (in 1799.995s)
    +155ms ╚Event processed successfully (155ms)

    8/4/2020, 11:15:14 PM +634ms
    +1ms ╔Starting piston... (v0.3.110.20191009)
    +424ms ║╔Subscribing to devices...
    +462ms ║║Subscribing to Frog Motion Sensor.motion...
    +520ms ║║Subscribing to Sleep Over...
    +522ms ║║Subscribing to Frog AC...
    +523ms ║║Subscribing to Frog Fan...
    +524ms ║║Subscribing to Frog Fan Light1...
    +525ms ║║Subscribing to Frog Fan Light2...
    +526ms ║║Subscribing to Frog Lamp...
    +527ms ║║Subscribing to Office Light...
    +528ms ║╚Finished subscribing (111ms)
    +550ms ║Comparison (enum) off is (string) off = true (2ms)
    +559ms ║Cancelling condition #3's schedules...
    +565ms ║Cancelling condition #2's schedules...
    +574ms ║Comparison (enum) active stays (string) inactive = false (2ms)
    +576ms ║Cancelling condition #7's schedules...
    +577ms ║Cancelling condition #6's schedules...
    +589ms ╚Piston successfully started (588ms)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

I tidied up your log a bit to make it easier to read… and deleted all of the old logs.

For future reference, once you edit a piston, the logs below are instantly old & outdated…
(Please Clear the logs after editing a piston to start fresh)


#3

… and as irony would have it, the remaining log shows no indication of lights turning off. :grin:

Don’t sweat it. We will catch it on the next go around.


Although, here is some food for thought, that may solve your issue.

I would recommend dropping the ELSE IF,
and moving that last trigger into a separate independent IF block.

My logic is, we WANT that 30 min timer to reset each time the door changes to inactive.
(and from the log above, it is not doing that)


Pro Tip:

When moving that last block, there is no need for the extra 5 minute WAIT.
Just increase the STAYS INACTIVE for 35 minutes, if that is your goal.


#4

what @WCmore talking about is here with a couple of examples.
This is one of the best and most reliable ways to do that…


#5

I suspect the problem is, as @WCmore suggested, that the ‘stays’ has been nested. It probably needs to be evaluated when the motion is inactive in order to cancel the ‘timed trigger’ it set up.

When pistons evaluate conditional statements they compare the result with the one they got the last time they did it. If it has changed, their default behaviour is to cancel any scheduled tasks (typically wake ups after long waits) that were set up by code the piston ran previously when the condition evaluated differently. The ‘stays’ comparison is a bit of a one-off though, so although it sets up a timer, I suspect it doesn’t get recognised as a scheduled task in the same way.


#6

Thanks for the help. I have made the changes you suggested and we’ll see how the day progresses. If it does it again, I’ll copy the log right away and post.

I am sort of new to Webcore and know just enough to not know anything at all. Perfect example it not realizing you could add a whole other set of if’s after the initial if without the else if. Go figure, something new every day and whatnot.

Thanks again for the help!


#7

What I wound up doing was making two pistons. One to turn on the light and AC when I come in the room. Another that runs every 5 minutes to see if the motion sensor has been inactive for at least 15 minutes and if so, it turns the room off. Bingo. Nothing turned off all day.

Thanks for the input everyone. Thank you!


#8

Working code is the best playground. I started my first motion sensor piston over the weekend. The first 5 iterations behaved kind of wonky before I worked out the kinks. Since then, I have made perhaps 5 more iterations of tweaking, simplifying logic, adding functionality.


#9

In my opinion… The truly “smart” home, will never be 100% complete.
(without growing & evolving, one becomes stagnate)