CoRE Piston based on presence incorrectly running all the time


(Gene Clark) #1

So I hope someone can help me out with this… I’ve got a piston that I want to have turn on my porch light on whenever it’s after sunset and before sunrise and triggered by my SmartThings arrival sensor & iPhone being present, but I’ve noticed that they both are always show they are falsely coming or going causing the porch light switches on & off. It’s generally only on for about a half hour to an hour, but still wastes electricity plus by now I think my neighbors must be wondering what the hell im doing.

Is there a more reliable way to do this? Can I put another condition in that will present this from happening? Thanks!


#2

Post a picture of your piston so we can check it out. What I do in this situation is add a variable that would indicate that light has been turned on previously and include that as a condition. When it’s time to turn off the light, then add a task that will reset that variable to false.


(Gene Clark) #3

Oh my bad - I saved the picture but spaced out on uploading it.


#4

I would insert another condition in your condition set. Initialize this local boolean variable.

AND
Variable lightOn is false

Then in your set of tasks, right after the push notification.

Set boolean variable lightOn to true
Wait for common time (sunrise)
Set boolean variable lightOn to false

Let me know if that makes sense.


(Gene Clark) #5

I’m going to try that, but as for it making sense - not really. I’ve been wondering how to use variables for a while now and tried once before with no success.

On a side note, can you set a variable to save the on/off state and level of a dimmable light so I can have a level increase to 100% flashing multiple times when a contact sensor status changes, but afterwards have the light return to whatever brightness it was at before the piston ran? Not see if that makes sense or not.


#6

You can use the Save attribute to variable tasks for that. Make sure to add a Wait of about 2 seconds before you perform any other task on the light/dimmer to give it time to save the variable. To restore the settings, use Load attribute from variable


(Gene Clark) #7

Thanks for your help - I’ll try fixing my porch light tonight and let ya know how it works.


(Gene Clark) #8

One more thing - do you know if there’s a way to duplicate pistons to copy what I’ve already done and still have something there in case this won’t work?


(Gene Clark) #9

Ok so I went back in to add another condition, chose variable then Boolean but don’t see one that’s says lighton. All these start with $ before the words and none have lighton listed. Am I in the wrong area?


#10

No way to copy/duplicate pistons at the moment.

You need to initialize/create the variable first. Open your piston and at the bottom should be an area to Initialize variables.


(Gene Clark) #11

How does this look?


#12

You’ll need the condition Variable lightOn is false in your IF


(Gene Clark) #13

Ok…?


#14

It has to be in the same group as the first three conditions.


(Gene Clark) #15

LOL I told you that I’m still not fully understanding everything yet - this good?


#16

That looks like it should work. Just to explain the the use of the variable lightOn. This will prevent the light from turning on again until the next day. Now, in this scenario, I don’t see the porch light being turned off by the same piston so once your other piston turns the light off and the phone presence comes and goes again, it will not turn on the porch light again.


(Dan Fox) #17

I believe you have a problem with Time is after Sunset and Time is before sunrise. Before Sunrise is midnight to sunrise, After Sunset is Sunset to midnight, therefore both can’t be true together. Instead put in a piston restriction: Only execute if time is between sunset and sunrise.


(Gene Clark) #18

Ok so I put the command for turning the switch on as pointed out by the red arrow…


(Dustin Clark) #19

I think what he was trying to say was to remove your two TIME conditions and add them as a restriction instead.

Or you could remove one and change the other so that time is BETWEEN sunset and sunrise


(Gene Clark) #20

Ok so now the porch light doesn’t come on at all automatically.