I am obviously doing something wrong ;)

cancel
wait
canceling
timer

#1

New to WebCoRE playing around with a few ideas that I thought would be straight-forward.

I have a few ArloPro cameras around the house that are registered and working in ST fine, I have dimmable switches/bulbs that work in ST just fine … so I figured let me see if I can get something working (just fine) :slight_smile:

I created the following piston to turn on the front porch light if any of 3 cameras detect motion, wait 5m and turn light off:

This fires perfectly, motion detected by any of the cameras turns on my front porch light. The problem I have is that I wait 5m assuming the light would turn off after the “Wait” statement, but I must be misunderstanding the logic…


Here are the relevant logs (in case the issue simply doesnt jump right out at you and make you /facepalm).
(New User - can only post 1 image so C&P logs)

Piston Initializing
9/11/2017, 6:58:07 PM +852ms
+2ms ╔Starting piston… (v0.2.0e7.20170906)
+409ms ║╔Subscribing to devices…
+424ms ║║Subscribing to Arlo Cam - Driveway Back.motion…
+437ms ║║Subscribing to Arlo Cam - Front Driveway.motion…
+448ms ║║Subscribing to Arlo Cam - Front of house.motion…
+526ms ║║Subscribing to Front Porch…
+528ms ║╚Finished subscribing (120ms)
+658ms ║Comparison (time) 68288448 is_between (datetime) 1505171880000 … (datetime) 1505126280000 = true (11ms)
+661ms ║Time restriction check passed
+665ms ║Cancelling condition #5’s schedules…
+704ms ╚Piston successfully started (703ms)


Piston Fires - as i walk up driveway
9/11/2017, 7:01:13 PM +293ms
+22ms ╔Received event [Arlo Cam - Driveway Back].motion = active with a delay of 170ms
+152ms ║RunTime Analysis CS > 46ms > PS > 42ms > PE > 63ms > CE
+160ms ║Runtime (36047 bytes) successfully initialized in 42ms (v0.2.0e7.20170906) (136ms)
+162ms ║╔Execution stage started
+201ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
+205ms ║║Cancelling condition #4’s schedules…
+207ms ║║Condition #4 evaluated true (33ms)
+282ms ║║Comparison (time) 68473502 is_between (datetime) 1505171880000 … (datetime) 1505126280000 = true (16ms)
+284ms ║║Time restriction check passed
+288ms ║║Condition #5 evaluated true (79ms)
+289ms ║║Cancelling condition #1’s schedules…
+290ms ║║Condition group #1 evaluated true (state changed) (118ms)
+295ms ║║Cancelling statement #2’s schedules…
+353ms ║║Executed physical command [Front Porch].on() (54ms)
+355ms ║║Executed [Front Porch].on (56ms)
+364ms ║║Executed virtual command [Front Porch].wait (1ms)
+366ms ║║Requesting a wake up for Mon, Sep 11 2017 @ 7:06:13 PM EDT (in 300.0s)
+380ms ║╚Execution stage complete. (219ms)
+383ms ║Setting up scheduled job for Mon, Sep 11 2017 @ 7:06:13 PM EDT (in 299.986s)
+399ms ╚Event processed successfully (398ms)


After motion ends this is in the logs
9/11/2017, 7:01:43 PM +296ms
+1ms ╔Received event [Arlo Cam - Driveway Back].motion = inactive with a delay of 69ms
+135ms ║RunTime Analysis CS > 22ms > PS > 43ms > PE > 70ms > CE
+182ms ║Runtime (36040 bytes) successfully initialized in 43ms (v0.2.0e7.20170906) (179ms)
+184ms ║╔Execution stage started
+220ms ║║Comparison (enum) inactive changes_to (string) active = false (1ms)
+224ms ║║Cancelling condition #4’s schedules…
+225ms ║║Condition #4 evaluated false (28ms)
+227ms ║║Cancelling condition #1’s schedules…
+228ms ║║Condition group #1 evaluated false (state changed) (31ms)
+233ms ║╚Execution stage complete. (50ms)
+241ms ╚Event processed successfully (242ms)


wait 10m to see if light turns off … nope … and no log entry

There must be something I am missing (other than another single malt (Balvenie 16 Triple Cask tonight)


EDIT 20:12 EDT
Hmmm after re-reading What is the optimal design for this simple goal I think I figured out my issue (or at least it works for some reason) Setting “Task Cancellation Policy” to Never Cancel works in my limited testing tonight … so it begs the question - is this the ‘correct’ way to do this?


#2

The issue is that the task get cancelled on condition change. I.e., once the motion stops, the condition evaluates to false and everything that was scheduled (i.e., turning off your lamp) gets cancelled.

If you click the if line when editing the piston and click the little cog wheel icon in the popup, you will see additional options. Change the “Task cancellation policy” to “Never cancel tasks”

Alternatively, you could implement the piston in the following way:


#3

@ahndee thanks! You were posting as I was editing that I found the TCP …so many goodies tucked away waiting to be found :smile:


#4

And because I am anal retentive about closing the loop on threads …

Here is what I did to fix it so that the next guy who asks (which could very well be me again … in the case I forget) can follow & make it work

Open up the Piston for editing and click the Device that you want to have wait and not cancel its action - here it is Dimmer 2

This will bring up another dialog box, click the Gear icon (bottom right) to get to the Advanced Options … Drop down the Task Cancellation Policy, select Never Cancel Tasks, save away and have your piston pump away without dying out because of a pesky change of state :slight_smile:

Hope this helps someone down the line - until then :tumbler_glass:


#5

Added some tags to this post. Seems we are getting this case a lot recently