Piston being cancelled by device state change


#1

1) Give a description of the problem
Trying to figure out why some of my pistons exit before they complete.

2) What is the expected behavior?
I have a motion sensor that I only want to notify me upon the first instance of motion (changes to active) and wait 5 minutes before they notify me if triggered again.

3) What is happening/not happening?
I determined that the piston is being cancelled when the motion sensor changes from active to inactive. This was working as expected in core, but in webCore I can see the piston exit early. In the example, I can see the Do loop start to execute and the first 2 minute wait begins, but after several seconds the piston is terminated, I’ve tried setting the Task Cancellation Policy to Never for both the IF and With statements with no change in behavior. I thought I understood triggers vs conditions, but maybe not??? It acts as though the IF statement is a condition that’s changing and causing the piston to terminate?

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

5) Attach any logs (From ST IDE and by turning logging level to Full)
(1/17/2018, 10:59:24 PM +228ms
+2ms ╔Received event [Front Porch Motion Sensor].motion = inactive with a delay of 279ms
+84ms ║RunTime Analysis CS > 16ms > PS > 49ms > PE > 19ms > CE
+86ms ║Runtime (37295 bytes) successfully initialized in 49ms (v0.2.102.20180116) (83ms)
+87ms ║╔Execution stage started
+96ms ║║Comparison (enum) inactive changes_to (string) active = false (0ms)
+97ms ║║Cancelling condition #6’s schedules…
+98ms ║║Condition #6 evaluated false (6ms)
+99ms ║║Cancelling condition #1’s schedules…
+99ms ║║Condition group #1 evaluated false (state changed) (7ms)
+102ms ║╚Execution stage complete. (15ms)
+104ms ║Setting up scheduled job for Wed, Jan 17 2018 @ 11:01:06 PM MST (in 102.224s)
+149ms ╚Event processed successfully (149ms)
1/17/2018, 10:59:06 PM +467ms
+1ms ╔Received event [Front Porch Motion Sensor].motion = active with a delay of 269ms
+64ms ║RunTime Analysis CS > 13ms > PS > 36ms > PE > 14ms > CE
+66ms ║Runtime (37300 bytes) successfully initialized in 36ms (v0.2.102.20180116) (64ms)
+67ms ║╔Execution stage started
+76ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
+77ms ║║Cancelling condition #6’s schedules…
+78ms ║║Condition #6 evaluated true (6ms)
+79ms ║║Cancelling condition #1’s schedules…
+80ms ║║Condition group #1 evaluated true (state changed) (8ms)
+82ms ║║Cancelling statement #2’s schedules…
+87ms ║║Executed virtual command [Family Room - Lamp 2].wait (1ms)
+88ms ║║Requesting a wake up for Wed, Jan 17 2018 @ 11:01:06 PM MST (in 120.0s)
+92ms ║╚Execution stage complete. (25ms)
+94ms ║Setting up scheduled job for Wed, Jan 17 2018 @ 11:01:06 PM MST (in 119.995s)
+102ms ╚Event processed successfully (102ms))


#2

Try getting rid of the never against the IF. Use the default option.
I think it should only be against the DO.


#3

I removed the Never Cancel on the If and left it on the Do, but I get the same results - about 30 seconds into the first 2 minute Wait it terminates, apparently due to the motion sensor changing from Active to Inactive. I have the same basic code in a Core piston and it works as expected (screenshot below) I have many Core pistons I’m trying to convert to webCore so hopefully this is something that can be resolved.
Thanks!

Log:
webCoRE
Home \ webCoRE (v0.2.102)
Test2
Status
This piston is currently active and humming happily.

Pause »
Piston category

My Pistons
Quick facts
Piston state: false

Last executed: 1/18/2018, 11:38:47 AM

Next scheduled: 1/18/2018, 11:40:32 AM

Subscriptions: 1 event, 1 control

Devices used: 2

Memory used: 7% (7207 bytes)

External URL: (click to open/execute)

Automatic backup
You do not have automatic backup enabled for this piston.

Enable automatic backup »
Script (hide)
//
/* Test2 */
/
/
/* Author : me /
/
Created : 1/17/2018, 10:05:20 PM /
/
Modified : 1/18/2018, 11:16:30 AM /
/
Build : 13 /
/
UI version : v0.2.102.20180116 */
/**************************************************************/

+0msstart
/* Trace started on 1/18/2018, 11:38:47 AM (about 1 minute ago) */

execute
+75ms9ms
if /* #1 /
+75ms5ms
Front Porch Motion Sensor’s motion changes to active /
#6 /
then
with /
#2 /
Family Room - Lamp 2
do
Wait 2 minutes; /
#3 /
Flash on 1 seconds / off 1 seconds for 1 times; /
#4 /
Wait 2 minutes; /
#5 */
end with;
end if;
+84msdone
end execute;

+105msstop
/* Trace ended on 1/18/2018, 11:38:47 AM */
Edit » Test TraceTrace Delete »
Logs
1/18/2018, 11:38:47 AM +610ms
+1ms ╔Received event [Front Porch Motion Sensor].motion = inactive with a delay of 361ms
+67ms ║RunTime Analysis CS > 14ms > PS > 36ms > PE > 17ms > CE
+69ms ║Runtime (37302 bytes) successfully initialized in 36ms (v0.2.102.20180116) (67ms)
+70ms ║╔Execution stage started
+79ms ║║Comparison (enum) inactive changes_to (string) active = false (1ms)
+80ms ║║Cancelling condition #6’s schedules…
+81ms ║║Condition #6 evaluated false (6ms)
+82ms ║║Cancelling condition #1’s schedules…
+83ms ║║Condition group #1 evaluated false (state changed) (8ms)
+86ms ║╚Execution stage complete. (17ms)
+87ms ║Setting up scheduled job for Thu, Jan 18 2018 @ 11:40:32 AM MST (in 104.997s)
+97ms ╚Event processed successfully (97ms)
1/18/2018, 11:38:32 AM +598ms
+1ms ╔Received event [Front Porch Motion Sensor].motion = active with a delay of 369ms
+72ms ║RunTime Analysis CS > 13ms > PS > 36ms > PE > 23ms > CE
+74ms ║Runtime (37307 bytes) successfully initialized in 36ms (v0.2.102.20180116) (72ms)
+75ms ║╔Execution stage started
+84ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
+85ms ║║Cancelling condition #6’s schedules…
+86ms ║║Condition #6 evaluated true (5ms)
+87ms ║║Cancelling condition #1’s schedules…
+88ms ║║Condition group #1 evaluated true (state changed) (8ms)
+90ms ║║Cancelling statement #2’s schedules…
+95ms ║║Executed virtual command [Family Room - Lamp 2].wait (0ms)
+96ms ║║Requesting a wake up for Thu, Jan 18 2018 @ 11:40:32 AM MST (in 120.0s)
+100ms ║╚Execution stage complete. (25ms)
+102ms ║Setting up scheduled job for Thu, Jan 18 2018 @ 11:40:32 AM MST (in 119.995s)
+111ms ╚Event processed successfully (111ms)

Core piston that works as expected:
IMG_2888


#4

Hmm.
Very strange. This works for me.
If there is no motion for 2 minutes the light flashes on and off.
I agree that when motion becomes inactive it evaluates to false, but the turn off task is still scheduled.
18/01/2018, 19:50:53 +507ms
+1ms ╔Received event [Lounge - Xiaomi Motion 1].motion = inactive with a delay of 154ms
+90ms ║RunTime Analysis CS > 20ms > PS > 52ms > PE > 19ms > CE
+93ms ║Runtime (40597 bytes) successfully initialized in 52ms (v0.2.102.20180116) (91ms)
+94ms ║╔Execution stage started
+101ms ║║Comparison (enum) inactive changes_to (string) active = false (1ms)
+102ms ║║Cancelling condition #6’s schedules…
+103ms ║║Condition #6 evaluated false (5ms)
+104ms ║║Cancelling condition #1’s schedules…
+105ms ║║Condition group #1 evaluated false (state changed) (6ms)
+107ms ║╚Execution stage complete. (14ms)
+108ms ║Setting up scheduled job for Thu, Jan 18 2018 @ 7:52:23 PM GMT (in 90.35s)
+118ms ╚Event processed successfully (118ms)

Then it does the deed.
18/01/2018, 19:52:23 +992ms
+0ms ╔Received event [Home].time = 1516305143965 with a delay of 26ms
+141ms ║RunTime Analysis CS > 25ms > PS > 89ms > PE > 29ms > CE
+145ms ║Runtime (40587 bytes) successfully initialized in 89ms (v0.2.102.20180116) (143ms)
+146ms ║╔Execution stage started
+323ms ║║Executed physical command [Dining Room - Main Light].off() (141ms)
+328ms ║║Executed physical command [Dining Room - Main Light].on([delay: 1000]) (4ms)
+333ms ║║Executed physical command [Dining Room - Main Light].on([delay: 2099]) (4ms)
+335ms ║║Executed virtual command [Dining Room - Main Light].flash (165ms)
+336ms ║║Waiting for 2100ms
+2442ms ║║Executed virtual command [Dining Room - Main Light].wait (1ms)
+2444ms ║║Requesting a wake up for Thu, Jan 18 2018 @ 7:54:26 PM GMT (in 120.0s)
+2450ms ║╚Execution stage complete. (2303ms)
+2452ms ║Setting up scheduled job for Thu, Jan 18 2018 @ 7:54:26 PM GMT (in 119.993s)
+2458ms ╚Event processed successfully (2458ms)


#5

So you are seeing the first 2 minute countdown complete even as the motion sensor changes from Active to Inactive? I only get about 30 seconds into it before the motion changes to Inactive and the piston is cancelled. This is a Smartthings Smartsense motion detector, and I’m assuming that it’s default is to change to Inactive after 30 seconds of no activity. I’ve searched the forum and haven’t found any references to others having this issue. As I said, this works as expected in Core, so I’m wondering if I’ve somehow tweaked some obscure setting in webCoRE as ive been learning that’s causing this. Are there any hidden settings related to event subscriptions I’m missing here?
Thanks,
Dave