Wait random time not working (or prob user error)


#1

1) Give a description of the problem
Light is not turning off randomly between 5 and 8 minutes

2) What is the expected behavior?
Lights turn off after waiting between 5 and 8 minutes

3) What is happening/not happening?
Lights turn on as expected, but not turn off. Nothing happens, after “Turn ON”

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach any logs (From ST IDE and by turning logging level to Full)

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


#2

Let’s see some logs :slight_smile:


#3
+1ms ╔Received event [Front Screen Door].contact = open with a delay of 115ms
+137ms ║RunTime Analysis CS > 17ms > PS > 40ms > PE > 80ms > CE
+140ms ║Runtime (41371 bytes) successfully initialized in 40ms (v0.3.104.20180323) (137ms)
+140ms ║╔Execution stage started
+149ms ║║Comparison (string) PM is (string) PM = true (1ms)
+150ms ║║Condition #7 evaluated true (5ms)
+159ms ║║Comparison (enum) open stays (string) open = true (2ms)
+161ms ║║Comparison (enum) open stays (string) open = true (2ms)
+163ms ║║Adding a timed trigger schedule for device :2ef4b2844ab94dd1a7c744ee846254a7: for condition 5
+165ms ║║Adding a timed trigger schedule for device :8ee4c3775f72ed567e87e57c26c33edb: for condition 5
+167ms ║║Cancelling condition #5’s schedules…
+167ms ║║Condition #5 evaluated false (16ms)
+168ms ║║Cancelling condition #8’s schedules…
+169ms ║║Condition group #8 evaluated false (state changed) (24ms)
+173ms ║║Comparison (string) PM is (string) AM = false (1ms)
+175ms ║║Condition #10 evaluated false (4ms)
+175ms ║║Condition group #9 evaluated false (state did not change) (5ms)
+176ms ║║Cancelling condition #1’s schedules…
+177ms ║║Condition group #1 evaluated false (state changed) (32ms)
+180ms ║║Fast executing schedules, waiting for 83ms to sync up
+269ms ║║Cancelling condition #5’s schedules…
+270ms ║║Condition #5 evaluated true (1ms)
+303ms ║║Calculating (decimal) 0.0 - (decimal) 20.0 >> (decimal) -20.0
+306ms ║║Comparison (datetime) 1522398894301 is_after (datetime) 1522395300000 = true (1ms)
+308ms ║║Condition #13 evaluated true (36ms)
+308ms ║║Cancelling condition #8’s schedules…
+309ms ║║Condition group #8 evaluated true (state changed) (41ms)
+310ms ║║Cancelling condition #1’s schedules…
+311ms ║║Condition group #1 evaluated true (state changed) (43ms)
+313ms ║║Cancelling statement #3’s schedules…
+318ms ║║Skipped execution of physical command [Front Lights].on([]) because it would make no change to the device. (3ms)
+319ms ║║Executed [Front Lights].on (4ms)
+323ms ║║Executed virtual command [Front Lights].waitRandom (0ms)
+324ms ║║Requesting a wake up for Fri, Mar 30 2018 @ 7:41:35 PM AEDT (in 401.196s)
+334ms ║║Condition #5 evaluated true (0ms)
+340ms ║║Calculating (decimal) 0.0 - (decimal) 20.0 >> (decimal) -20.0
+343ms ║║Comparison (datetime) 1522398894365 is_after (datetime) 1522395300000 = true (2ms)
+344ms ║║Condition #13 evaluated true (10ms)
+345ms ║║Condition group #8 evaluated true (state did not change) (13ms)
+346ms ║║Condition group #1 evaluated true (state did not change) (14ms)
+348ms ║║Cancelling statement #3’s schedules…
+352ms ║║Skipped execution of physical command [Front Lights].on([]) because it would make no change to the device. (2ms)
+353ms ║║Executed [Front Lights].on (3ms)
+357ms ║║Executed virtual command [Front Lights].waitRandom (1ms)
+358ms ║║Requesting a wake up for Fri, Mar 30 2018 @ 7:41:14 PM AEDT (in 380.426s)
+362ms ║╚Execution stage complete. (222ms)
+363ms ║Setting up scheduled job for Fri, Mar 30 2018 @ 7:41:14 PM AEDT (in 380.421s), with 1 more job pending
+373ms ╚Event processed successfully (373ms)

#4

Nothing happens at the wakeup time. Light is still on. And it’s 20 mins later. Here are the logs for the wakeup

+1ms ╔Received event [EU Location].time = 1522399335595 with a delay of -1437ms
+172ms ║RunTime Analysis CS > 20ms > PS > 54ms > PE > 98ms > CE
+175ms ║Runtime (41381 bytes) successfully initialized in 54ms (v0.3.104.20180323) (174ms)
+176ms ║╔Execution stage started
+177ms ║╚Execution stage complete. (1ms)
+179ms ╚Event processed successfully (179ms)

#5

I would suggest creating a toned down version of that piston. Start with Contact Sensor changes to open, turn on, wait randomly between X and XX seconds, turn off. Just to test.


#6

So I tried your suggestion, and the piston works as you would expect if the door remains open, but if the door shuts, then the piston is cancelled.

I’ve tried “changes to open” and a few others, but each time the door shuts, the piston is cancelled and doesnt run the turn off command.

Thoughts?__


#7

In the With, click the cog icon and set the task cancellation policy to never.


#8

Thanks, that did it. I was on the right track, but I was doing it with the first IF statement, not the WITH statement.