Switch off after wait doesn't work


#1

Whilst migrating my pistons over from CoRE I have a few that are identical (except different devices) and the structure has worked flawlessly in CoRE for months but fails to switch off in webCoRE. I’m struggling to understand why - I can get it working by adding another if for when motion changes to inactive but surely this is less efficient as it is subscribing to two events instead of one.

The switch should turn off 2 minutes after being turned on

In actual fact the wwitch doesn’t turn off at all as Line 29 does not seem to execute


#2

Set Task Cancellation Policy (TCP) to never in your with.
You will find it when you click on the settings cog at the bottom of the page when you click on the WITH.


#3

Ah superb thank you.

Am I correct in my assumption that it is more efficient to not have multiple subscriptions or would I be better to have a second if that checks for motion to go inactive?


#4

Actually thinking about it, if I change the If from “is active” to “changes to active” that would be better wouldn’t it?

In my thinking “is active” causes the state to change (and the tasks to be cancelled) whereas changes to active won’t cause the state to change when movement stops.


#5

To be honest I don’t think it makes much difference.
The method you are using is my preference for simple pistons and you will find other people that use the method you have suggested.
At the end of the day it’s what ever works for you and you are happy with it.
Have fun. :smile:


#6

Cheers,

Just checking :slight_smile:
Thanks for the help


#7

The problem with this is that when it changes to active the statement becomes true. As it needs to monitor the state as you are using changes to, after about 10 seconds the statement will change to false so the tasks will stop if you don’t change TCP to never.
Swings and roundabouts.