Motion Based Light EXCEPT when Manually turned On

manual
except
off
light
motion

#161

Wanted to share my version of this Motion Based Light Except when Manually turned on. The issue into my garage is that opening the door would not trigger the PIR Motion as PIR requires temp change and the door swinging does not provide this. Only until I was physically in the garage and the PIR sensor saw me would it trigger the light. Since there is an ~1 sec delay or so before the light turns on, my wife (and I as well) were complaining we would be 3-4 feet into the garage before the light comes on. Anyone else with this frustration on motion based triggering?

So I added a door contact sensor as well that would turn the light on when the door opens. I still wanted the motion to kick in too and wanted the motion to override the door contact if I closed the door and stayed in the garage for some time or walked in through the actual garage door. Sounds relatively easy but it took a couple of days of playing with the piston to get it right. And what if someone opened the door, changed their mind, and closed it again without entering the garage and without triggering the motion? wanted it to shut the light off in this case immediately. This essentially covers any scenario and triggers the light initially by the door so that there is light when we step into the garage but also keeps it on if the door shuts and we spend time in there.


#162

I’m like new, REALLY really really new to this. Just discovered WebCORE a few weeks ago and made some little pistons. I came here hoping someone would have a piston with a light and motion already done so I could look at it and try to figure out how to get a little better with the whole programming thing. Heck, I haven’t even figured out how to import these pistons you all are making into my WebCORE. Told you I was new.

I’m just trying to figure out how to get a motion sensor to turn on a light, only at night and then turn off 5 minutes after the motion event turns on the light, regardless of physical button press,etc.

I looked at his one and then promptly “drowned” in it…


#163

I know how you feel, this thread has got out of hand.
I feel like everyone has joined webcore purely to fix this lighting issue.

To import the original code on this, login to your webcore on a browser, click ‘add a new piston’ then select create from backup code. Type in edsh2 which you’ll see in big letters on the first post in this thread. It’ll ask you which lights you want to control etc and then it’s ready to go, just save it.

You can click on the times in the code to change the times that it operates too.


#164

and i thought “drowned” was a happy context as in immersed in webcore. obviously not … sorry about that :grimacing:

thanks @jameswillo :slight_smile:


#165

@bangali That drowned vs. immersed comment had me howling :laughing:

@CoZ I get it. We are all on different levels of WebCore aptitude. I am frankly not much ahead of you. I just copy Piston designs such as the edsh2 at the beginning of the thread and spend HOURS playing with it. Helps me learn how to get around WebCore a bit but not without a lot of frustrations. That what the community is for, really. I just posted my Piston because of my frustration with the delay many times motion has with turning on lights, especially gong through a door. Thought others could benefit from it. It got way more complex than I ever imagined but works flawlessly. Thats kind of the cool feature of WebCore is that it can get from simple to hightly complex. Certainly this Piston is a bit too complex for what you require.

Since I believe even that first Piston is way too complex for you based upon your post, I have changed it to make it WAY more simpler and get what I think is what you want - motion to turn on a light for 5 minutes in the evening. Here is a copy below and as @jameswillo mentions I think you can click on ‘create from backup code’ and use the p0cpo from the below Piston. In WebCore there is certainly more than one way to skin a cat so to speak. Many ways to get to what you need. This is just one. Good luck!

My last comment to @jameswillo is that I do not believe this thread has gotten out of hand. It is still solving the Title of the thread which is Motion Based Light EXCEPT when Manually turned On. Mine just adds a door sensor to the mix. Its @CoZ who is looking for something different than the name of the thread.


#166

@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.


#167

@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:


#168

TCP means Task Cancellation Policy.
The default settings for TCP is to cancel tasks on condition state change.
image
So in your piston above in your IF you have a ‘changes to’ inactive.
image
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.


#169

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


#170

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:


#171

@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.
image

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!


#172

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?


#173

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.


#174

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


#175

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


#176

Thank you!


#177

Is there a reason my lights are ignoring sunrise?


#178

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.


#179

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


#180

please share a green snapshot of the piston.