Problems First Time Using Loops

loops

#1

1) Give a description of the problem
The piston completes the first section and enters the loop. However, it never stops looping based on the conditions chosen, it just loops over and over…

2) What is the expected behaviour?
At 9pm, if the dog hasn’t been fed within the prior hour, remind me it’s time to feed the took (is a specific way). If the dog food food hasn’t been picked up in the next 5 minutes, enter a loop combined of light flashes and Alexa reminder. Repeat this loop every 5 minutes until either the dog food bowl is picked up (I.e. god has been fed), or it reaches a specific time, to prevent unnecessary repeats if I’m on vacation with the dog or something.

3) What is happening/not happening?
Introduction works, but once it enters the loop it won’t stop, regardless of any actions done to the dod food bowl (which is what the Samsung Smartthings multipurpose sensor it stuck on to)

I’m hoping the use of “orientation” is the issue. Nothing else provided as great results such as acceleration. I was able to integrate it into an

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
NOTE: I changed the 9pm triggering time to 12:40am to be able to get these logs without waiting until 9pm tomorrow.

7/30/2020, 12:51:08 AM +153ms
+0ms ╔Received event [River Ranch].time = 1596095469353 with a delay of -1200ms
+104ms ║RunTime Analysis CS > 21ms > PS > 41ms > PE > 42ms > CE
+107ms ║Runtime (43047 bytes) successfully initialized in 41ms (v0.3.110.20191009) (106ms)
+108ms ║╔Execution stage started
+711ms ║║Executed physical command [Kitchen Light].off() (600ms)
+713ms ║║Fast executing schedules, waiting for 490ms to sync up
+1226ms ║║Cancelling statement #41's schedules...
+1560ms ║║Executed physical command [Echo - Bedroom Echo Dot].playText([Reminder... Don't forget, it's time to feed Joey!]) (326ms)
+1562ms ║║Executed [Echo - Bedroom Echo Dot].playText (329ms)
+1780ms ║║Executed physical command [Echo - Living Room Echo].playText([Reminder... Don't forget, it's time to feed Joey!]) (212ms)
+1781ms ║║Executed [Echo - Living Room Echo].playText (214ms)
+1789ms ║║Condition #35 evaluated false (7ms)
+1797ms ║║Comparison (time) 3069943 is_after (time) 85800000 = false (5ms)
+1798ms ║║Condition #36 evaluated false (8ms)
+1799ms ║║Condition group #34 evaluated false (state did not change) (17ms)
+1802ms ║║Cancelling statement #37's schedules...
+1805ms ║║Executed virtual command wait (1ms)
+1806ms ║║Requesting a wake up for Thu, Jul 30 2020 @ 12:56:09 AM PDT (in 300.0s)
+1819ms ║╚Execution stage complete. (1711ms)
+1821ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:56:09 AM PDT (in 299.987s), with 1 more job pending
+1829ms ╚Event processed successfully (1829ms)
7/30/2020, 12:51:05 AM +312ms
+0ms ╔Received event [River Ranch].time = 1596095466253 with a delay of -941ms
+96ms ║RunTime Analysis CS > 23ms > PS > 37ms > PE > 35ms > CE
+98ms ║Runtime (43045 bytes) successfully initialized in 37ms (v0.3.110.20191009) (97ms)
+99ms ║╔Execution stage started
+120ms ║║Executed physical command [Kitchen Light].off() (16ms)
+121ms ║╚Execution stage complete. (22ms)
+123ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:51:09 AM PDT (in 3.918s), with 2 more jobs pending
+131ms ╚Event processed successfully (131ms)
7/30/2020, 12:51:01 AM +80ms
+0ms ╔Received event [River Ranch].time = 1596095462253 with a delay of -1174ms
+123ms ║RunTime Analysis CS > 32ms > PS > 50ms > PE > 42ms > CE
+126ms ║Runtime (43047 bytes) successfully initialized in 50ms (v0.3.110.20191009) (125ms)
+127ms ║╔Execution stage started
+474ms ║║Executed physical command [Kitchen Light].on() (342ms)
+476ms ║╚Execution stage complete. (348ms)
+478ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:51:06 AM PDT (in 4.696s), with 3 more jobs pending
+486ms ╚Event processed successfully (487ms)
7/30/2020, 12:50:58 AM +140ms
+0ms ╔Received event [River Ranch].time = 1596095459252 with a delay of -1112ms
+110ms ║RunTime Analysis CS > 21ms > PS > 46ms > PE > 43ms > CE
+113ms ║Runtime (43047 bytes) successfully initialized in 46ms (v0.3.110.20191009) (112ms)
+114ms ║╔Execution stage started
+150ms ║║Executed physical command [Kitchen Light].off() (30ms)
+152ms ║╚Execution stage complete. (38ms)
+156ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:51:02 AM PDT (in 3.958s), with 4 more jobs pending
+165ms ╚Event processed successfully (165ms)
7/30/2020, 12:50:54 AM +177ms
+0ms ╔Received event [River Ranch].time = 1596095455252 with a delay of -1076ms
+92ms ║RunTime Analysis CS > 21ms > PS > 35ms > PE > 37ms > CE
+96ms ║Runtime (43046 bytes) successfully initialized in 35ms (v0.3.110.20191009) (94ms)
+97ms ║╔Execution stage started
+537ms ║║Executed physical command [Kitchen Light].on() (435ms)
+540ms ║╚Execution stage complete. (442ms)
+543ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:50:59 AM PDT (in 4.532s), with 5 more jobs pending
+551ms ╚Event processed successfully (551ms)
7/30/2020, 12:50:51 AM +145ms
+1ms ╔Received event [River Ranch].time = 1596095452251 with a delay of -1106ms
+96ms ║RunTime Analysis CS > 19ms > PS > 41ms > PE > 36ms > CE
+99ms ║Runtime (43046 bytes) successfully initialized in 41ms (v0.3.110.20191009) (97ms)
+99ms ║╔Execution stage started
+783ms ║║Executed physical command [Kitchen Light].off() (679ms)
+785ms ║╚Execution stage complete. (686ms)
+788ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:50:55 AM PDT (in 3.32s), with 6 more jobs pending
+797ms ╚Event processed successfully (797ms)
7/30/2020, 12:50:48 AM +67ms
+0ms ╔Received event [River Ranch].time = 1596095449180 with a delay of -1113ms
+88ms ║RunTime Analysis CS > 16ms > PS > 36ms > PE > 35ms > CE
+90ms ║Runtime (43046 bytes) successfully initialized in 36ms (v0.3.110.20191009) (89ms)
+91ms ║╔Execution stage started
+127ms ║║Cancelling statement #39's schedules...
+152ms ║║Executed physical command [Kitchen Light].on() (15ms)
+187ms ║║Executed virtual command [Kitchen Light].flash (55ms)
+189ms ║║Requesting a wake up for Thu, Jul 30 2020 @ 12:51:09 AM PDT (in 21.1s)
+234ms ║╚Execution stage complete. (142ms)
+237ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:50:52 AM PDT (in 3.948s), with 7 more jobs pending
+246ms ╚Event processed successfully (246ms)
7/30/2020, 12:45:48 AM +179ms
+1ms ╔Received event [River Ranch].time = 1596095148523 with a delay of -344ms
+94ms ║RunTime Analysis CS > 16ms > PS > 37ms > PE > 41ms > CE
+97ms ║Runtime (43045 bytes) successfully initialized in 37ms (v0.3.110.20191009) (96ms)
+98ms ║╔Execution stage started
+241ms ║║Executed physical command [Kitchen Light].off() (139ms)
+243ms ║║Fast executing schedules, waiting for 104ms to sync up
+380ms ║║Cancelling statement #41's schedules...
+781ms ║║Executed physical command [Echo - Bedroom Echo Dot].playText([Reminder... Don't forget, it's time to feed Joey!]) (393ms)
+782ms ║║Executed [Echo - Bedroom Echo Dot].playText (396ms)
+976ms ║║Executed physical command [Echo - Living Room Echo].playText([Reminder... Don't forget, it's time to feed Joey!]) (191ms)
+977ms ║║Executed [Echo - Living Room Echo].playText (192ms)
+985ms ║║Condition #35 evaluated false (5ms)
+992ms ║║Comparison (time) 2749165 is_after (time) 85800000 = false (5ms)
+993ms ║║Condition #36 evaluated false (8ms)
+994ms ║║Condition group #34 evaluated false (state did not change) (16ms)
+996ms ║║Cancelling statement #37's schedules...
+999ms ║║Executed virtual command wait (1ms)
+1000ms ║║Requesting a wake up for Thu, Jul 30 2020 @ 12:50:49 AM PDT (in 300.0s)
+1017ms ║╚Execution stage complete. (918ms)
+1018ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:50:49 AM PDT (in 299.983s), with 1 more job pending
+1031ms ╚Event processed successfully (1031ms)
7/30/2020, 12:45:45 AM +142ms
+1ms ╔Received event [River Ranch].time = 1596095145423 with a delay of -281ms
+89ms ║RunTime Analysis CS > 18ms > PS > 37ms > PE > 34ms > CE
+92ms ║Runtime (43045 bytes) successfully initialized in 37ms (v0.3.110.20191009) (90ms)
+92ms ║╔Execution stage started
+176ms ║║Executed physical command [Kitchen Light].off() (80ms)
+178ms ║╚Execution stage complete. (86ms)
+180ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:45:48 AM PDT (in 3.202s), with 2 more jobs pending
+189ms ╚Event processed successfully (189ms)
7/30/2020, 12:45:42 AM +80ms
+1ms ╔Received event [River Ranch].time = 1596095141422 with a delay of 658ms
+100ms ║RunTime Analysis CS > 17ms > PS > 45ms > PE > 38ms > CE
+102ms ║Runtime (43045 bytes) successfully initialized in 45ms (v0.3.110.20191009) (101ms)
+103ms ║╔Execution stage started
+131ms ║║Executed physical command [Kitchen Light].on() (24ms)
+133ms ║╚Execution stage complete. (30ms)
+135ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:45:45 AM PDT (in 3.208s), with 3 more jobs pending
+144ms ╚Event processed successfully (144ms)
7/30/2020, 12:45:38 AM +255ms
+1ms ╔Received event [River Ranch].time = 1596095138422 with a delay of -168ms
+114ms ║RunTime Analysis CS > 19ms > PS > 42ms > PE > 53ms > CE
+118ms ║Runtime (43046 bytes) successfully initialized in 42ms (v0.3.110.20191009) (116ms)
+120ms ║╔Execution stage started
+830ms ║║Executed physical command [Kitchen Light].off() (703ms)
+832ms ║╚Execution stage complete. (713ms)
+835ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:45:41 AM PDT (in 2.333s), with 4 more jobs pending
+843ms ╚Event processed successfully (843ms)
7/30/2020, 12:45:34 AM +150ms
+1ms ╔Received event [River Ranch].time = 1596095134421 with a delay of -271ms
+89ms ║RunTime Analysis CS > 16ms > PS > 34ms > PE > 39ms > CE
+92ms ║Runtime (43045 bytes) successfully initialized in 34ms (v0.3.110.20191009) (89ms)
+93ms ║╔Execution stage started
+118ms ║║Executed physical command [Kitchen Light].on() (22ms)
+120ms ║╚Execution stage complete. (28ms)
+122ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:45:38 AM PDT (in 4.15s), with 5 more jobs pending
+131ms ╚Event processed successfully (130ms)
7/30/2020, 12:45:30 AM +136ms
+1ms ╔Received event [River Ranch].time = 1596095131421 with a delay of -1285ms
+94ms ║RunTime Analysis CS > 17ms > PS > 37ms > PE > 39ms > CE
+96ms ║Runtime (43046 bytes) successfully initialized in 37ms (v0.3.110.20191009) (95ms)
+97ms ║╔Execution stage started
+177ms ║║Executed physical command [Kitchen Light].off() (76ms)
+180ms ║╚Execution stage complete. (84ms)
+182ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:45:34 AM PDT (in 4.103s), with 6 more jobs pending
+190ms ╚Event processed successfully (190ms)
7/30/2020, 12:45:27 AM +211ms
+0ms ╔Received event [River Ranch].time = 1596095127255 with a delay of -44ms
+82ms ║RunTime Analysis CS > 16ms > PS > 34ms > PE > 32ms > CE
+85ms ║Runtime (43044 bytes) successfully initialized in 34ms (v0.3.110.20191009) (83ms)
+85ms ║╔Execution stage started
+104ms ║║Cancelling statement #39's schedules...
+195ms ║║Executed physical command [Kitchen Light].on() (81ms)
+213ms ║║Executed virtual command [Kitchen Light].flash (104ms)
+215ms ║║Requesting a wake up for Thu, Jul 30 2020 @ 12:45:48 AM PDT (in 21.1s)
+237ms ║╚Execution stage complete. (151ms)
+240ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:45:31 AM PDT (in 3.971s), with 7 more jobs pending
+248ms ╚Event processed successfully (248ms)
7/30/2020, 12:45:24 AM +99ms
+0ms ╔Received event [River Ranch].time = 1596095125193 with a delay of -1095ms
+81ms ║RunTime Analysis CS > 16ms > PS > 34ms > PE > 32ms > CE
+83ms ║Runtime (43046 bytes) successfully initialized in 34ms (v0.3.110.20191009) (82ms)
+84ms ║╔Execution stage started
+111ms ║║Cancelling statement #39's schedules...
+136ms ║║Executed physical command [Kitchen Light].off() (15ms)
+159ms ║║Executed virtual command [Kitchen Light].flash (42ms)
+166ms ║║Requesting a wake up for Thu, Jul 30 2020 @ 12:45:45 AM PDT (in 21.1s)
+184ms ║╚Execution stage complete. (100ms)
+187ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:45:27 AM PDT (in 2.97s), with 7 more jobs pending
+195ms ╚Event processed successfully (195ms)
7/30/2020, 12:40:25 AM +71ms
+0ms ╔Received event [River Ranch].time = 1596094825200 with a delay of -130ms
+87ms ║RunTime Analysis CS > 17ms > PS > 33ms > PE > 37ms > CE
+89ms ║Runtime (43045 bytes) successfully initialized in 33ms (v0.3.110.20191009) (88ms)
+91ms ║╔Execution stage started
+117ms ║║Cancelling statement #37's schedules...
+120ms ║║Executed virtual command wait (1ms)
+121ms ║║Requesting a wake up for Thu, Jul 30 2020 @ 12:45:25 AM PDT (in 300.0s)
+137ms ║╚Execution stage complete. (47ms)
+139ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:45:25 AM PDT (in 299.984s), with 1 more job pending
+148ms ╚Event processed successfully (148ms)
7/30/2020, 12:40:21 AM +160ms
+1ms ╔Received event [River Ranch].time = 1596094821116 with a delay of 44ms
+87ms ║RunTime Analysis CS > 18ms > PS > 35ms > PE > 33ms > CE
+90ms ║Runtime (43043 bytes) successfully initialized in 35ms (v0.3.110.20191009) (88ms)
+91ms ║╔Execution stage started
+114ms ║║Executed physical command [Kitchen Light].on() (18ms)
+149ms ║║Cancelling statement #29's schedules...
+1037ms ║║Executed virtual command [Laundry Room, Main Bedroom Light, Office Main, Upper Left TV].lifxBreathe (875ms)
+1039ms ║║Requesting a wake up for Thu, Jul 30 2020 @ 12:40:25 AM PDT (in 3.0s)
+1103ms ║╚Execution stage complete. (1013ms)
+1106ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:40:25 AM PDT (in 2.934s), with 1 more job pending
+1116ms ╚Event processed successfully (1115ms)
7/30/2020, 12:40:13 AM +151ms
+0ms ╔Received event [River Ranch].time = 1596094814016 with a delay of -866ms
+156ms ║RunTime Analysis CS > 47ms > PS > 75ms > PE > 35ms > CE
+159ms ║Runtime (43046 bytes) successfully initialized in 75ms (v0.3.110.20191009) (158ms)
+161ms ║╔Execution stage started
+2143ms ║║Executed physical command [Kitchen Light].off() (1975ms)
+2145ms ║║Fast executing schedules, waiting for 1720ms to sync up
+3883ms ║║Executed physical command [Kitchen Light].on() (15ms)
+3886ms ║╚Execution stage complete. (3726ms)
+3890ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:40:21 AM PDT (in 4.076s), with 2 more jobs pending
+3905ms ╚Event processed successfully (3905ms)
7/30/2020, 12:40:09 AM +83ms
+0ms ╔Received event [River Ranch].time = 1596094810015 with a delay of -933ms
+104ms ║RunTime Analysis CS > 21ms > PS > 47ms > PE > 37ms > CE
+107ms ║Runtime (43046 bytes) successfully initialized in 47ms (v0.3.110.20191009) (106ms)
+108ms ║╔Execution stage started
+686ms ║║Executed physical command [Kitchen Light].on() (572ms)
+688ms ║╚Execution stage complete. (581ms)
+691ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:40:14 AM PDT (in 4.242s), with 4 more jobs pending
+699ms ╚Event processed successfully (699ms)
7/30/2020, 12:40:06 AM +172ms
+1ms ╔Received event [River Ranch].time = 1596094807015 with a delay of -843ms
+113ms ║RunTime Analysis CS > 26ms > PS > 48ms > PE > 39ms > CE
+116ms ║Runtime (43046 bytes) successfully initialized in 48ms (v0.3.110.20191009) (115ms)
+117ms ║╔Execution stage started
+137ms ║║Executed physical command [Kitchen Light].off() (16ms)
+140ms ║╚Execution stage complete. (22ms)
+142ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:40:10 AM PDT (in 3.702s), with 5 more jobs pending
+273ms ╚Event processed successfully (273ms)
7/30/2020, 12:40:03 AM +100ms
+1ms ╔Received event [River Ranch].time = 1596094803015 with a delay of 85ms
+140ms ║RunTime Analysis CS > 41ms > PS > 66ms > PE > 32ms > CE
+142ms ║Runtime (43044 bytes) successfully initialized in 66ms (v0.3.110.20191009) (140ms)
+144ms ║╔Execution stage started
+176ms ║║Executed physical command [Kitchen Light].on() (27ms)
+179ms ║╚Execution stage complete. (36ms)
+182ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:40:07 AM PDT (in 3.734s), with 6 more jobs pending
+190ms ╚Event processed successfully (190ms)
7/30/2020, 12:39:59 AM +114ms
+1ms ╔Received event [River Ranch].time = 1596094800000 with a delay of -886ms
+245ms ║RunTime Analysis CS > 21ms > PS > 172ms > PE > 51ms > CE
+247ms ║Runtime (43048 bytes) successfully initialized in 172ms (v0.3.110.20191009) (246ms)
+248ms ║╔Execution stage started
+310ms ║║Comparison (enum) right side up did_not_change = true (38ms)
+312ms ║║Condition #3 evaluated true (49ms)
+313ms ║║Condition group #2 evaluated true (state did not change) (51ms)
+315ms ║║Cancelling statement #4's schedules...
+633ms ║║Executed physical command [Echo - Bedroom Echo Dot].playTextAndRestore([It's time to feed Joey his dinner]) (313ms)
+634ms ║║Executed [Echo - Bedroom Echo Dot].playTextAndRestore (315ms)
+839ms ║║Executed physical command [Echo - Living Room Echo].playTextAndRestore([It's time to feed Joey his dinner]) (202ms)
+840ms ║║Executed [Echo - Living Room Echo].playTextAndRestore (203ms)
+843ms ║║Cancelling statement #27's schedules...
+881ms ║║Executed physical command [Kitchen Light].off() (28ms)
+903ms ║║Executed virtual command [Kitchen Light].flash (53ms)
+905ms ║║Requesting a wake up for Thu, Jul 30 2020 @ 12:40:21 AM PDT (in 21.1s)
+912ms ║╚Execution stage complete. (664ms)
+915ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:40:03 AM PDT (in 2.987s), with 7 more jobs pending
+975ms ╚Event processed successfully (974ms)
7/30/2020, 12:35:06 AM +855ms
+1ms ╔Starting piston... (v0.3.110.20191009)
+896ms ║╔Subscribing to devices...
+1023ms ║║Subscribing to Echo - Bedroom Echo Dot...
+1024ms ║║Subscribing to Echo - Living Room Echo...
+1025ms ║║Subscribing to Kitchen Light...
+1026ms ║║Subscribing to Laundry Room...
+1027ms ║║Subscribing to Main Bedroom Light...
+1028ms ║║Subscribing to Office Main...
+1030ms ║║Subscribing to Upper Left TV...
+1030ms ║╚Finished subscribing (142ms)
+1101ms ║Comparison (enum) right side up did_not_change = true (31ms)
+1135ms ║Comparison (time) 2107982 is_after (time) 85800000 = false (6ms)
+1147ms ║Setting up scheduled job for Thu, Jul 30 2020 @ 12:40:00 AM PDT (in 291.999s)
+1178ms ╚Piston successfully started (1177ms)

Thanks all!


#2

Just had a quick look. Try changing line 52 to a condition rather than a trigger


#3

In addition to @Paul1964’s tip, the condition:
IF X did not change in the last Y
is unfinished code. (and should be avoided)

In my quick test, it looped every two seconds, and returned true when it should return false.


If this were my piston, I would make the initial trigger:

IF orientation changes
    Then set variable to $now
END IF

… and then below that block:

Every day at 9pm
do
    IF ($now - variable) is greater than 1 hour
         Then speak
    END IF
END EVERY

#4

I figured it out - User Error.

I realize now that with loops the condition is only checked upon each iteration of the loop: a single point in time. I was under the impression the piston was constantly checking my condition throughout the loop, and would cease looping once the condition was met.

Is there a way to achieve such functionality?

The act of picking up the dog food bowl (orientation change) to feed the dog, only takes 15~20 seconds. Once the bowl is set back down it returns to the original “right side up” orientation. So I’m guessing unless the loop is realllly short, there’s a high probability it’ll miss the condition being met.


#5

You could consider the following. This piston alerts me to take the bin out, whenever there is motion in the room where the speaker is, but only once an hour. It uses a virtual switch set from another piston, but you could use a global variable.


#6

The problem is I’ve found no other way to reliably track the action of picking up the dog bowl, filling it, and returning it to its position. I’ve tried many other sensors and events, but orientation seems to work the best.

I just can’t figure out how to create a loop that constantly watches for an orientation change, and when recognized ceases the looping. I’ve stripped the piston down to just the loop to remove any potential conflicts, but I’m still getting a never ending loop.


#7

pls share the lastest piston you have.


#8

Here is a piston I use for something similar.
Mine is a fish tank with open/close sensor attached to it.
It starts sending me hourly messages if I forget to feed the fish.
Once I open the lid and feed the fish it resets it self and the next day same rouite starts.

There are many different ways of doing the same task, I didn’t use a loop for mine.