Cancel Scheduled/Pending Task


#1

1) Give a description of the problem
I’m trying to have a task wait 30 minutes before executing, and have the task not execute if the condition changes while waiting the 30 minutes. I realize this is basic functionality; I thought that the default task cancellation policy would automatically cause the scheduled task to be cancelled, but it isn’t. Help appreciated, thanks!

2) What is the expected behavior?
The wait 30 minute and then disarm alarm task would be cancelled if the alarm system state is no longer armedStay.

3) What is happening/not happening?
The wait 30 minute task is not cancelled; the alarm always disarms after 30 minutes regardless of its system value at that time.

**4) Post a Green Snapshot of the piston!


#2

I made a change to use '…stays armedStaty for 30 minutes…". Will see if that works.


#3

Anyone have any comment?


#4

did it work? :smile:


#5

Your second post is not going work either me thinks…

There is something very odd in just simply how both your examples read, with specific reference to the Motion Sensor 1 bit:
===> Motion Sensor 1’s system stays…

I wasn’t aware a motion sensor could have a “system” value

When I tried importing your piston, all devices “translate” OK, except for Motion Sensor 1; in my pic below you can see I get no motions sensors to list from.

image

I suspect either a corrupt piston, or a faulty motion sensor.

J


#6

@bangali It didn’t work, no.

@GatVlieg It’s not a motion sensor, it’s an alarm. It displays correctly in the webcore editor, see below screenshot. I don’t know why it displays as a motion sensor in the snapshot, that is odd. I don’t think the piston is corrupt, as it still runs fine and it does disarm the alarm. The only thing that it doesn’t do as expected is to cancel the scheduled alarm disarm if the alarm system state changes away from armedStay in the 30 minute wait period.

Any ideas?

27 PM


#7

i havent looked thru the logic but the if with stays instead of nesting it under the other if, if you pulled it out to the top level would the piston logic still work? if yes, unnest that if and put it at the top level.


#8

Thanks, but that won’t work. The top-level IF is the trigger that starts the whole piston. The IF for the alarm should only be evaluated if the conditions that start the piston are true.

I don’t understand how Task Execution Policy works, perhaps I can use that? Or perhaps a Wait?


#9

ok. remove the if stays, insert a 30 min wait then check if motion sensor 1 was ‘armedStay’ for 30 minutes then disarm?

would that work?


#10

I was thinking the same thing. In fact, the check after 30 minutes is simply ‘is alarm system current state armedStay’, then disarm if it is. Does this look right?


#11

yes this is fine if you only care about the alarm system state after 30 minutes and not what it was during the last 30 minutes.


#12

Yep that is all I care about. OK thanks for your help, will see if this works tomorrow morning.