Stuck in Infinite Loop


#1

1) Give a description of the problem
I have a webCoRE set to turn on my front lights upon detecting motion from my Ring Doorbell. After three minutes of no activity, it will turn the lights off. With that said, I’ve run into a bit of an issue. When the lights turn off, the doorbell thinks it senses motion again and the lights turn back on. It’s a constant infinite loop.

2) What is the expected behavior?
The lights should turn off after 3 minutes of no motion.

3) What is happening/not happening?
It’s detecting “motion” when the light is turned off… therefore turning the light back on.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
(1/13/2018, 8:19:39 PM +370ms +1ms ╔Received event [Front Doorbell].motion = active with a delay of 69ms +124ms ║Runtime (37012 bytes) successfully initialized in 39ms (v0.2.101.20171227) (122ms) +125ms ║╔Execution stage started +246ms ║║Executed [Front Door Dimmer].on (72ms) +266ms ║║Executed [Front Door Dimmer].setLevel (16ms) +268ms ║╚Execution stage complete. (143ms) +269ms ╚Event processed successfully (269ms) 1/13/2018, 8:19:34 PM +392ms +1ms ╔Received event [Home].time = 1515892775353 with a delay of -961ms +150ms ║Runtime (37009 bytes) successfully initialized in 52ms (v0.2.101.20171227) (148ms) +151ms ║╔Execution stage started +268ms ║║Executed [Front Door Dimmer].off (101ms) +271ms ║╚Execution stage complete. (120ms) +273ms ╚Event processed successfully (273ms) 1/13/2018, 8:16:35 PM +213ms +1ms ╔Received event [Front Doorbell].motion = inactive with a delay of 80ms +125ms ║Runtime (37007 bytes) successfully initialized in 40ms (v0.2.101.20171227) (122ms) +125ms ║╔Execution stage started +139ms ║║Executed virtual command [Front Door Dimmer].wait (0ms) +139ms ║║Requesting a wake up for Sat, Jan 13 2018 @ 8:19:35 PM EST (in 180.0s) +143ms ║╚Execution stage complete. (18ms) +144ms ║Setting up scheduled job for Sat, Jan 13 2018 @ 8:19:35 PM EST (in 179.996s) +153ms ╚Event processed successfully (152ms) 1/13/2018, 8:16:05 PM +209ms +1ms ╔Received event [Front Doorbell].motion = active with a delay of 76ms +124ms ║Runtime (37012 bytes) successfully initialized in 40ms (v0.2.101.20171227) (122ms) +125ms ║╔Execution stage started +197ms ║║Executed [Front Door Dimmer].on (27ms) +217ms ║║Executed [Front Door Dimmer].setLevel (18ms) +219ms ║╚Execution stage complete. (95ms) +220ms ╚Event processed successfully (220ms) 1/13/2018, 8:16:00 PM +237ms +1ms ╔Received event [Home].time = 1515892561319 with a delay of -1082ms +113ms ║Runtime (37010 bytes) successfully initialized in 31ms (v0.2.101.20171227) (110ms) +114ms ║╔Execution stage started +243ms ║║Executed [Front Door Dimmer].off (114ms) +246ms ║╚Execution stage complete. (133ms) +247ms ╚Event processed successfully (247ms) 1/13/2018, 8:13:01 PM +185ms +1ms ╔Received event [Front Doorbell].motion = inactive with a delay of 145ms +119ms ║Runtime (37008 bytes) successfully initialized in 32ms (v0.2.101.20171227) (117ms) +120ms ║╔Execution stage started +133ms ║║Executed virtual command [Front Door Dimmer].wait (1ms) +134ms ║║Requesting a wake up for Sat, Jan 13 2018 @ 8:16:01 PM EST (in 180.0s) +138ms ║╚Execution stage complete. (19ms) +139ms ║Setting up scheduled job for Sat, Jan 13 2018 @ 8:16:01 PM EST (in 179.995s) +146ms ╚Event processed successfully (146ms) 1/13/2018, 8:12:31 PM +719ms +1ms ╔Received event [Front Doorbell].motion = active with a delay of 46ms +114ms ║Runtime (37012 bytes) successfully initialized in 27ms (v0.2.101.20171227) (112ms) +115ms ║╔Execution stage started +226ms ║║Executed [Front Door Dimmer].on (67ms) +244ms ║║Executed [Front Door Dimmer].setLevel (16ms) +246ms ║╚Execution stage complete. (132ms) +247ms ╚Event processed successfully (247ms))


Help with ring doorbell motion light loop
#2

You can add a variable in the mix so that when it’s on, the piston won’t trigger until it is reset back to off.

If motion is active
and
motionTriggered is off
do
set variable motionTriggered = on
turn on
wait 4 minutes (modify this to your liking)
set variable motionTriggered = off


#3

Thank you, eibyer! I do have a question though. I want the light to stay on if motion is constantly detected. My assumption was that if motion kept triggering, the 3 minutes would keep restarting until motion stopped. If I set a variable to not trigger again, would that effectively set the light to be on for a static 3 minutes?

Thanks again for your help!


#4

That would be a static 3 minutes, you’re right until the variable reset. Hmmm, good Saturday night puzzle :slight_smile:


#5

Haha… it’s been a LONG time since I did any coding. So my brain is filled with cobwebs on this stuff. I’m glad to hear it’s not just me that’s temporarily stumped on this. I do appreciate your willingness to help with this!


#6

Hmm one more idea. How about a condition that the light has been off for X number of seconds?


#7

That’s not a bad thought. Let me mess around to try to figure out how to implement that. Thanks for the idea!


#8

I’m a bit stuck on this implementation. If I set a condition to only execute if the light is off (for any given amount of time), it will only ever be on for a static 3 minutes again. Am I looking at this wrong?


#9

It’s giving me a headache… need more :beer: I want to try and simulate the turning off the light and the camera sensing it as motion, that is a little tricky.

I tried this with simulated devices, see how it works on your actual devices. Adjust the times pls.


#10

try this:


#11

Ok… I feel like a moron… I am trying to implement your solutions, but I am having trouble finding the spot to “set variable”. I have “show variables” checked. When I go to add an action, it gives me a drop down for devices… which lists virtual devices, physical devices, and system variables. I never see local variables. FWIW, I see local variables when I choose an IF statement, but not when choosing an action. I tried doing a search in the forum and I went to the “your first piston” guide, but still no luck. What dumb thing am I missing lol?


#12

when adding action click with location then you will see a list of actions including set variable that you can select from in the drop down.

you can also restore this piston using the orange button after clicking create new piston and putting in the piston code at the top of the piston image. that way you don’t have to type everything in.


#13

See… that’s what I thought too. Here is what I see though…


#14

Click Add Task, in the absence of a device, location is default


#15

Wow… I feel like an idiot. I always thought I had to add something to each screen before moving forward! Thank you for clarifying that, eibyer! I’ll let you guys know how each of the codes makes out (likely within the next day or two). Thank you to you both for your help!!


#16

Just an update here. Eibyer, with your solution, it produced the same result as what originally was occurring. Bangali, we are close with your solution, but it failed when turning off the lights DIDN’T produce a motion alert. Therefore, it ignored the next motion (which was usually a valid motion alert). So, I’ve combined your ideas. Eibyer, you suggested that I code it so that the light only recognized motion after the light has been off for a few seconds. I added that thought into Bangali’s solution. It looks like this:

I’m going to try it tonight, but I’ve run though every scenario in my head and I think this works. If so, this was another example of great teamwork! Thank you to you both!

P.S. I did add another switch since the original code was posted. That switch controls my garage lights. This new code includes turning on the porch and garage lights at the same time.


#17

Well… here was my first attempt. I set the motion sensor off and the lights went on (as predicted). After about 3 mintues, the lights went off. About 15 seconds after the light went off, I went back outside and set the motion sensor off again… however, the lights remained off. I attempted again, and it worked as predicted. Thoughts?

Here is the log:

1/16/2018, 4:42:56 PM +80ms +1ms ╔Received event [Front Doorbell].motion = inactive with a delay of 49ms +106ms ║RunTime Analysis CS > 10ms > PS > 24ms > PE > 72ms > CE +108ms ║Runtime (39276 bytes) successfully initialized in 24ms (v0.2.101.20171227) (107ms) +109ms ║╔Execution stage started +117ms ║║Comparison (enum) inactive is (string) active = false (1ms) +118ms ║║Cancelling condition #9's schedules... +119ms ║║Condition #9 evaluated false (5ms) +120ms ║║Cancelling condition #1's schedules... +120ms ║║Condition group #1 evaluated false (state changed) (7ms) +129ms ║║Comparison (enum) on is (string) on = true (2ms) +130ms ║║Cancelling condition #12's schedules... +131ms ║║Condition #12 evaluated true (9ms) +132ms ║║Cancelling condition #10's schedules... +132ms ║║Condition group #10 evaluated true (state changed) (10ms) +134ms ║║Cancelling statement #2's schedules... +138ms ║║Executed virtual command [Garage Lights, Porch Light].wait (1ms) +139ms ║║Requesting a wake up for Tue, Jan 16 2018 @ 4:45:56 PM EST (in 180.0s) +143ms ║╚Execution stage complete. (34ms) +145ms ║Setting up scheduled job for Tue, Jan 16 2018 @ 4:45:56 PM EST (in 179.995s) +151ms ╚Event processed successfully (151ms) 1/16/2018, 4:42:27 PM +717ms +2ms ╔Received event [Porch Light].switch = on with a delay of 101ms +140ms ║RunTime Analysis CS > 20ms > PS > 42ms > PE > 77ms > CE +142ms ║Runtime (39268 bytes) successfully initialized in 42ms (v0.2.101.20171227) (140ms) +143ms ║╔Execution stage started +156ms ║║Comparison (enum) active is (string) active = true (1ms) +157ms ║║Condition #9 evaluated true (9ms) +158ms ║║Condition group #1 evaluated true (state did not change) (11ms) +163ms ║║Comparison (boolean) false is (boolean) true = false (1ms) +164ms ║║Condition #16 evaluated false (4ms) +165ms ║║Condition group #13 evaluated false (state did not change) (5ms) +206ms ║║Comparison (time) 60147884 is_between (time) 1516140120000 .. (time) 1516105380000 = true (8ms) +207ms ║║Time restriction check passed +208ms ║║Condition #8 evaluated true (41ms) +209ms ║║Condition group #5 evaluated true (state did not change) (42ms) +210ms ║║Cancelling statement #5's schedules... +244ms ║║Executed physical command [Garage Lights].on() (30ms) +245ms ║║Executed [Garage Lights].on (32ms) +249ms ║║Skipped execution of physical command [Porch Light].on([]) because it would make no change to the device. (0ms) +249ms ║║Executed [Porch Light].on (2ms) +267ms ║║Executed physical command [Garage Lights].setLevel([100]) (15ms) +268ms ║║Executed [Garage Lights].setLevel (16ms) +423ms ║║Executed physical command [Porch Light].setLevel([100]) (153ms) +423ms ║║Executed [Porch Light].setLevel (155ms) +426ms ║╚Execution stage complete. (283ms) +427ms ╚Event processed successfully (427ms) 1/16/2018, 4:42:26 PM +701ms +0ms ╔Received event [Front Doorbell].motion = active with a delay of 43ms +103ms ║RunTime Analysis CS > 11ms > PS > 25ms > PE > 67ms > CE +105ms ║Runtime (39278 bytes) successfully initialized in 25ms (v0.2.101.20171227) (104ms) +106ms ║╔Execution stage started +114ms ║║Comparison (enum) active is (string) active = true (1ms) +116ms ║║Cancelling condition #9's schedules... +117ms ║║Condition #9 evaluated true (5ms) +117ms ║║Cancelling condition #1's schedules... +118ms ║║Condition group #1 evaluated true (state changed) (8ms) +124ms ║║Comparison (boolean) false is (boolean) true = false (1ms) +125ms ║║Cancelling condition #16's schedules... +126ms ║║Condition #16 evaluated false (5ms) +126ms ║║Cancelling condition #13's schedules... +127ms ║║Condition group #13 evaluated false (state changed) (7ms) +303ms ║║Comparison (time) 60146831 is_between (time) 1516140120000 .. (time) 1516105380000 = true (7ms) +304ms ║║Time restriction check passed +305ms ║║Condition #8 evaluated true (176ms) +306ms ║║Condition group #5 evaluated true (state did not change) (177ms) +307ms ║║Cancelling statement #5's schedules... +331ms ║║Executed physical command [Garage Lights].on() (21ms) +332ms ║║Executed [Garage Lights].on (23ms) +350ms ║║Executed physical command [Porch Light].on() (16ms) +351ms ║║Executed [Porch Light].on (18ms) +369ms ║║Executed physical command [Garage Lights].setLevel([100]) (15ms) +370ms ║║Executed [Garage Lights].setLevel (16ms) +384ms ║║Executed physical command [Porch Light].setLevel([100]) (13ms) +385ms ║║Executed [Porch Light].setLevel (15ms) +387ms ║╚Execution stage complete. (281ms) +389ms ╚Event processed successfully (388ms) 1/16/2018, 4:37:23 PM +196ms +1ms ╔Received event [Front Doorbell].motion = inactive with a delay of 68ms +109ms ║RunTime Analysis CS > 15ms > PS > 25ms > PE > 68ms > CE +111ms ║Runtime (39273 bytes) successfully initialized in 25ms (v0.2.101.20171227) (109ms) +112ms ║╔Execution stage started +120ms ║║Comparison (enum) inactive is (string) active = false (1ms) +122ms ║║Cancelling condition #9's schedules... +123ms ║║Condition #9 evaluated false (5ms) +123ms ║║Cancelling condition #1's schedules... +124ms ║║Condition group #1 evaluated false (state changed) (8ms) +133ms ║║Comparison (enum) off is (string) on = false (1ms) +134ms ║║Condition #12 evaluated false (8ms) +135ms ║║Condition group #10 evaluated false (state did not change) (9ms) +138ms ║╚Execution stage complete. (25ms) +139ms ╚Event processed successfully (138ms) 1/16/2018, 4:36:53 PM +855ms +2ms ╔Received event [Front Doorbell].motion = active with a delay of 100ms +142ms ║RunTime Analysis CS > 20ms > PS > 46ms > PE > 75ms > CE +144ms ║Runtime (39281 bytes) successfully initialized in 46ms (v0.2.101.20171227) (141ms) +145ms ║╔Execution stage started +154ms ║║Comparison (enum) active is (string) active = true (2ms) +155ms ║║Cancelling condition #9's schedules... +156ms ║║Condition #9 evaluated true (6ms) +157ms ║║Cancelling condition #1's schedules... +158ms ║║Condition group #1 evaluated true (state changed) (7ms) +163ms ║║Comparison (boolean) true is (boolean) true = true (2ms) +164ms ║║Cancelling condition #16's schedules... +165ms ║║Condition #16 evaluated true (5ms) +166ms ║║Cancelling condition #13's schedules... +166ms ║║Condition group #13 evaluated true (state changed) (7ms) +169ms ║║Cancelling statement #14's schedules... +174ms ║║Executed virtual command setVariable (3ms) +177ms ║╚Execution stage complete. (32ms) +178ms ╚Event processed successfully (178ms) 1/16/2018, 4:36:32 PM +407ms +0ms ╔Received event [Home].time = 1516138593668 with a delay of -1262ms +170ms ║RunTime Analysis CS > 42ms > PS > 37ms > PE > 92ms > CE +173ms ║Runtime (39278 bytes) successfully initialized in 37ms (v0.2.101.20171227) (156ms) +175ms ║╔Execution stage started +176ms ║╚Execution stage complete. (2ms) +179ms ╚Event processed successfully (179ms) 1/16/2018, 4:36:27 PM +187ms +1ms ╔Received event [Porch Light].switch = off with a delay of 88ms +114ms ║RunTime Analysis CS > 15ms > PS > 27ms > PE > 72ms > CE +116ms ║Runtime (39271 bytes) successfully initialized in 27ms (v0.2.101.20171227) (115ms) +117ms ║╔Execution stage started +129ms ║║Comparison (enum) inactive is (string) active = false (2ms) +130ms ║║Condition #9 evaluated false (8ms) +131ms ║║Condition group #1 evaluated false (state did not change) (9ms) +137ms ║║Comparison (enum) off is (string) on = false (1ms) +138ms ║║Cancelling condition #12's schedules... +139ms ║║Condition #12 evaluated false (6ms) +140ms ║║Cancelling condition #10's schedules... +141ms ║║Condition group #10 evaluated false (state changed) (8ms) +143ms ║╚Execution stage complete. (26ms) +144ms ╚Event processed successfully (144ms) 1/16/2018, 4:36:26 PM +362ms +1ms ╔Received event [Home].time = 1516138587459 with a delay of -1097ms +163ms ║RunTime Analysis CS > 20ms > PS > 46ms > PE > 96ms > CE +165ms ║Runtime (39276 bytes) successfully initialized in 46ms (v0.2.101.20171227) (163ms) +166ms ║╔Execution stage started +271ms ║║Executed physical command [Garage Lights].off() (82ms) +272ms ║║Executed [Garage Lights].off (85ms) +293ms ║║Executed physical command [Porch Light].off() (18ms) +294ms ║║Executed [Porch Light].off (20ms) +300ms ║║Executed virtual command [Garage Lights, Porch Light].setVariable (2ms) +304ms ║║Executed virtual command [Garage Lights, Porch Light].wait (0ms) +305ms ║║Requesting a wake up for Tue, Jan 16 2018 @ 4:36:33 PM EST (in 7.0s) +312ms ║╚Execution stage complete. (146ms) +314ms ║Setting up scheduled job for Tue, Jan 16 2018 @ 4:36:33 PM EST (in 6.992s) +322ms ╚Event processed successfully (322ms) 1/16/2018, 4:33:27 PM +284ms +1ms ╔Received event [Front Doorbell].motion = inactive with a delay of 88ms +139ms ║RunTime Analysis CS > 21ms > PS > 44ms > PE > 74ms > CE +141ms ║Runtime (39276 bytes) successfully initialized in 44ms (v0.2.101.20171227) (139ms) +142ms ║╔Execution stage started +150ms ║║Comparison (enum) inactive is (string) active = false (1ms) +152ms ║║Cancelling condition #9's schedules... +153ms ║║Condition #9 evaluated false (5ms) +154ms ║║Cancelling condition #1's schedules... +154ms ║║Condition group #1 evaluated false (state changed) (8ms) +163ms ║║Comparison (enum) on is (string) on = true (2ms) +164ms ║║Cancelling condition #12's schedules... +165ms ║║Condition #12 evaluated true (9ms) +166ms ║║Cancelling condition #10's schedules... +166ms ║║Condition group #10 evaluated true (state changed) (10ms) +169ms ║║Cancelling statement #2's schedules... +173ms ║║Executed virtual command [Garage Lights, Porch Light].wait (0ms) +174ms ║║Requesting a wake up for Tue, Jan 16 2018 @ 4:36:27 PM EST (in 180.0s) +179ms ║╚Execution stage complete. (37ms) +181ms ║Setting up scheduled job for Tue, Jan 16 2018 @ 4:36:27 PM EST (in 179.995s) +186ms ╚Event processed successfully (186ms) 1/16/2018, 4:33:00 PM +142ms +2ms ╔Received event [Porch Light].switch = on with a delay of 104ms +141ms ║RunTime Analysis CS > 22ms > PS > 41ms > PE > 78ms > CE +144ms ║Runtime (39268 bytes) successfully initialized in 41ms (v0.2.101.20171227) (142ms) +145ms ║╔Execution stage started +156ms ║║Comparison (enum) active is (string) active = true (1ms) +157ms ║║Condition #9 evaluated true (8ms) +158ms ║║Condition group #1 evaluated true (state did not change) (9ms) +163ms ║║Comparison (boolean) false is (boolean) true = false (1ms) +164ms ║║Condition #16 evaluated false (4ms) +165ms ║║Condition group #13 evaluated false (state did not change) (5ms) +205ms ║║Comparison (time) 59580309 is_between (time) 1516140120000 .. (time) 1516105380000 = true (7ms) +206ms ║║Time restriction check passed +207ms ║║Condition #8 evaluated true (40ms) +208ms ║║Condition group #5 evaluated true (state did not change) (41ms) +209ms ║║Cancelling statement #5's schedules... +246ms ║║Executed physical command [Garage Lights].on() (34ms) +247ms ║║Executed [Garage Lights].on (36ms) +250ms ║║Skipped execution of physical command [Porch Light].on([]) because it would make no change to the device. (1ms) +250ms ║║Executed [Porch Light].on (1ms) +523ms ║║Executed physical command [Garage Lights].setLevel([100]) (270ms) +524ms ║║Executed [Garage Lights].setLevel (271ms) +544ms ║║Executed physical command [Porch Light].setLevel([100]) (19ms) +544ms ║║Executed [Porch Light].setLevel (20ms) +547ms ║╚Execution stage complete. (403ms) +548ms ╚Event processed successfully (548ms) 1/16/2018, 4:32:57 PM +782ms +2ms ╔Received event [Front Doorbell].motion = active with a delay of 98ms +144ms ║RunTime Analysis CS > 19ms > PS > 53ms > PE > 71ms > CE +146ms ║Runtime (39283 bytes) successfully initialized in 53ms (v0.2.101.20171227) (144ms) +147ms ║╔Execution stage started +155ms ║║Comparison (enum) active is (string) active = true (1ms) +157ms ║║Cancelling condition #9's schedules... +157ms ║║Condition #9 evaluated true (5ms) +158ms ║║Cancelling condition #1's schedules... +159ms ║║Condition group #1 evaluated true (state changed) (8ms) +164ms ║║Comparison (boolean) false is (boolean) true = false (1ms) +165ms ║║Condition #16 evaluated false (4ms) +166ms ║║Condition group #13 evaluated false (state did not change) (5ms) +205ms ║║Comparison (time) 59577950 is_between (time) 1516140120000 .. (time) 1516105380000 = true (8ms) +206ms ║║Time restriction check passed +207ms ║║Cancelling condition #8's schedules... +208ms ║║Condition #8 evaluated true (40ms) +209ms ║║Cancelling condition #5's schedules... +209ms ║║Condition group #5 evaluated true (state changed) (41ms) +210ms ║║Cancelling statement #5's schedules... +233ms ║║Executed physical command [Garage Lights].on() (19ms) +234ms ║║Executed [Garage Lights].on (21ms) +255ms ║║Executed physical command [Porch Light].on() (19ms) +256ms ║║Executed [Porch Light].on (20ms) +272ms ║║Executed physical command [Garage Lights].setLevel([100]) (13ms) +273ms ║║Executed [Garage Lights].setLevel (13ms) +286ms ║║Executed physical command [Porch Light].setLevel([100]) (12ms) +287ms ║║Executed [Porch Light].setLevel (14ms) +290ms ║╚Execution stage complete. (143ms) +291ms ╚Event processed successfully (291ms)