Motion Based Light EXCEPT when Manually turned On



@Levahj I don’t think the second IF will mature unless you set TCP to never in the WITH.
The tasks will stop after around 10 seconds as the ‘changes to’ becomes false again, which it will as it needs to start looking for ‘Changes to’ again.
Hope this makes sense.


@bobbles You just confirmed my level of WebCore inaptitude! (is that even a word?) LOL. Can you explain one more time for me? Not sure what you mean by TCP? should I just take out ’ and switch 7 switch is on’ in the second IF?

I just want to clean it up for @CoZ. Obviously I did not test it :grimacing:


TCP means Task Cancellation Policy.
The default settings for TCP is to cancel tasks on condition state change.
So in your piston above in your IF you have a ‘changes to’ inactive.
When this happens i.e. the sensor changes to inactive, the statement becomes true and the tasks in the THEN will start.
The timer starts to count down.
After around 10 seconds the ‘changes to’ inactive will change to false as this is a trigger and it needs to start looking again for the sensor to change to inactive again.
At this point the tasks will cancel because it is set to default, cancel on condition state change.
If you open the WITH for switch 7 wait and turn off, click on the settings cog at the bottom, you can change TCP to never.
This means that when the statement ‘change to’ becomes false, the tasks will not cancel and the timer will mature and the turn off will happen.
Hope this all makes sense.


Thanks for all the input all. Sorry about coming on to this thread and asking for something entirely different than what was the subject. I was just hoping to try and import this piston and maybe massage it a bit for my own needs. I wasn’t asking for someone to create a new piston for me. I apologize if you thought I came in here begging for help and cluttered up the thread and being selfish.

I tried to create my own from scratch. It worked but not at night… the light came on during the day only for whatever reason. Of course in my frustration, I just deleted the whole thing like an idiot. LoL

@Levahj thanks for taking the time out to create an entirely new piston for my needs. I saw the reply from @bobbles though following. So I’m not sure if the one you posted works or not? He started talking about TCP and then my eyes just kind of glazed over… lol


Hey @CoZ . Dont apologize. Its all good… I have way too much time on my hands these past few months and this WebCore/SmartThings home automation thing has taken over my life :slight_smile:

I just adjusted the new Piston I created per @bobbles suggestion. These TCP (task cancellation policy) rules always seem to get me in WebCore. Just when I think I figured it out!.. Here it is below with the changes. You will notice the circled ‘N’ after the ‘with’ in the last IF statement. This should work though I did not test it. You can change the time of day or make additions - whatever. Hope this helps you get started in the wonderful world of times black hole we call WebCore/SmartThings home automation :grimacing:


@bobbles - Have a question. As I am trying to get more comfortable building Pistons within WebCore, the two more difficult things to get my arms around are ‘Conditions vs. Triggers’ and the Task Cancellation Policy (TCP).

The Q&A you guys put together on Conditions vs. Triggers and have as a main tab on this site is very helpful. I recommend you do the same for TCP. But I have a question regarding TCP. Shouldn’t the correct verbiage be ‘Cancel tasks on Trigger state change’ and not 'Cancel tasks on Condition state change? Seems like it would follow the logic of Conditions & Triggers a bit better as Triggers always are subscribed to and Conditions are not unless there is no Trigger. In that case the Conditions become Triggers.

Just seems like for newbies like me it would be much more descriptive of how the TCP works? Kind of a small thing, but taken it from a Newbie’s perspective it could make things easier to get your arms around.

My 2 cents for whatever that worth!


Sorry in advance, I’m very new to this and trying to figure this stuff out.

I Imported this piston as it does everything I’ve been looking to do (use motion sensor to turn on my front porch light via a smart switch/dumb bulb if it is 30 min before sunset or 30 min before sunrise for X amount of time upon motion detection, unless the light was turned on manually by the switch).

I only have one smart switch in this system tho, when I import the code it assigns a null value to the un-used switch value which I cannot remove from the code later (well, I can’t figure out how to remove it, at least).

Also, How would I tell it to turn off the porch light at 30 min after sunrise if it was manually turned on?


Ok, I figured out how to remove the second switch. Everything appears to be right/working. I guess I’ll know in a few days if it’s correct.

FWIW, I originally had this controlled via smart things but wanted to understand webcore better so I’m trying to replicate it here.


Sorry for the newbie question, but am I supposed to click on and enter anything for “Programmatic” and “ViaMotion”?


if this is for piston code nc4jh no need to add anything for those variables.


Thank you!


Is there a reason my lights are ignoring sunrise?


just a thought but if sunrise is being reported at 6:25 then the time would never be between 6:25 and sunrise it would end up being either or.


Sunrise is 8:14 at the moment so there’s something else wrong with the code.


please share a green snapshot of the piston.



thanks but don’t see a reference to this partial snippet you posted earlier?


Sorry that one doesn’t work either and that’s the one I used the wizard for.

This is the one from the snippet:


That’s where the time is on the very first post in this thread so I copied that.


right but that is so the light can always come on but at different levels during different times of the day.

for what you seem to want you should do what @rsmith179 suggested above.