Newbie alert! Basement light control


#1

Hello! So I’m still a beginner, and this will be just my second piston ever.

Environment: basement has 3 motion sensors and a door with a contact switch, along with a smart bulb.

Goal: When door detects opening, OR any motion is being detected on any of the 3 motion sensors, turn on the light and keep it on for at least one minute or for as long as motion continues to be detected. Effectively, if there is no motion and door is closed, then light will remain on for duration of timer (1 min) then turn off.

I haven’t tested this yet (not at home) but am I on the right track?


#2

This is a great start. There are a couple of things to consider:

  • You could use changes to operators for your comparisons of open an active.
  • You could also add a comparison with a timer to turn off the light. For instance, I have a (simpler) motion light in my breezeway that turns on if the motion sensor changes to active, waits for the motion sensor to change to inactive, then waits five minutes to turn off.

There’s certainly more than one way to get your results, so don’t think mine (which I got from someone else I can’t remember!) is the best. Here is a screenshot of my example:


#3

The piston you have written will turn the light off 1 minute after motion is detected. It won’t wait for motion to change to inactive. Best idea, write a separate expression for shutting the light off that is trigger off the contact being closed or the motion going to inactive.


#4

Check this thread out, using TCP turned off, very simple piston.


#5

Again, this piston will turn the light on immediately when motion is detected and then off again 3 minutes later. It will not wait for motion to be inactive.


#6

If you are using devices that can run locally, use Smart Lighting. That way it will run quicker as it is running locally. Also it will not rely on your internet connection to run.
Failing that, import this. It will do what you want it to do.


EDIT: You can delete/ignore lines 25,31 and 34.


#7

I’d like to, but “Smart Lighting” doesn’t appear to have the ability to stay on based upon motion sensors.

Some good ideas in the other posts, so I’ll be deciphering what I see and reworking my script.


#8

I don’t like to doubt you but it does for me. I think.
You got me thinking now.
I’ve never had a light turn off on me. Yet…
EDIT: They definitely don’t turn off while there is motion in your time window.


#9

If you’ re referring to the thread I posted to, @bobbles indicated it would work and would not turn off lights after 3 min if there was motion during the wait period…

Question:

Please explain how this won’t turn off the lights 3 min after they turn on if motion never stops. The only way I see the timer being reset is if motion stops and the sensor becomes active again. Is active not the same as motion detected?

bobbles:

Because you have set TCP to never.
This means that the tasks will never cancel whenever the motion becomes inactive.
Also the way it works is when motion is detected again within the 3 minute countdown, everything resets. So when motion goes inactive again it restarts.
So in theory if you keep moving around the light will stay on.
EDIT : If you enable trace facility you can watch the timer counting down and resetting with motion.

I’m no expert, just noting what he indicated.If this works, the simplicity of it is compelling.


#10

SmartLighting will turn them off when motion is no longer active after a set number of minutes. It’s right there in the Smart Lighting app. Just select motion as the trigger and then select also turn off and the minute offset option will pop up.

You have to understand how pistons work to understand why they are not turning off. You have to have a trigger event to execute a function. So, you would need another expression that addresses when motion is inactive. That is automatic in SmartLighting but not in a piston because you don’t always want them to turn off.

The piston you listed will turn the lights off after the amount of time. That time begins as soon as they turn on. NOT after motion is not detected. If you turn trace on in the piston and then watch it executed you will see it. Your piston should also use the trigger action of “Changes to” rather than “Is”.


#11

Here’s the piston I’m using for my bathroom lights which are triggered to turn on at motion but off only when they are between a 4-93% so i can bypass the automatic function when i want to (by turning them all the way up).


#12

Smart Lighting can either be based on open/close, OR based upon motion. But not both. But I think I accomplished what I need by making two separate Smart Lighting rules. The layout of the sensors and the way people sometimes go in/out of the basement walkway required allowing either the open/close OR the motion to turn/keep the light on.

While I could do it with a single piston, maybe this way is ultimately simpler.


#13

@bobbles - this piston design has been working for me, since I set it up from your post in the other thread.

Thanks.


#14

I never really thought about this. I was putting everything in a piston because it is fun to create the piston but now that I realize that the Smart Lighting is locally run, I have deleted some of my easy pistons and redid them using Smart Lighting. Thanks for the tip!


#15

Same…and again thanks to @bobbles. :slight_smile: