Ideas for a simple motion / lighting rule

I’ll preface this with the fact that my coding skills are very basic at best.

What I want to do is utilize a zwave open / close motion detector to interact with my lights that are on a zwave dimmer. This is all for my home theater. I have the binding for my projector working so I think I could leverage that as well.

What I’m thinking is a rule that if you are the first in, the projector is off. At that point the motion sensor detects you and the lights come up. If you get up in middle of a movie the motion detector goes open again but since the projector is reporting on, the lights stay down. If the movie is over, and the projector is off and there is motion the lights can come back on, but after 5 minutes the lights go off.

I know this isn’t a big deal for someone knowing what they are doing, but I’m not one of those people. If I do it I could spend hours and it still wont work right. Can anyone help me? Thanks!

Here is a snippet from my rules that may be helpful. While it is not exactly what you want, it should give you some ideas.

I detect motion, then I check a lux sensor to see if it is dark enough to turn the light on. You could put any conditions in here you want though. I then turn the switch on and start a timer. At the end of the timer, the light shuts off. I use all generated item names, so some of them get rather long. :slight_smile:

rule "Stairway light"
	Item zwave_device_152e7642b11_node11_sensor_binary changed 
		if ( zwave_device_152e7642b11_node23_sensor_luminance.state<=3 && zwave_device_152e7642b11_node11_sensor_binary.state==ON && UpStairLight.state==OFF ) {
		logInfo("HallMotion","Motion and low light detected upstairs, turning stairway lights on")
		sendCommand (UpStairLight, ON)
		timer = createTimer(now.plusSeconds(600)) [|
				sendCommand(UpStairLight, OFF)
				logInfo("UpStairLight","Turning triggered stairway lights off")
                timer = null ]
		} else {
			logInfo("UpStairLight","rule ran but lights already on.  Nothing to do")
1 Like

see Patterns for a detailed light/motion detection interaction set.

In a situation with frequent motion alerts will this rule still turn off the light after 10 minutes and the switch it back on when the next alert is received? I don’t see the timer being rescheduled if the light already on when motion is detected (maybe it’s a separate rule?).

You are correct, this one does not have the timer reset. It is on a stairway where the motion is pretty much point in time (who hangs out on a stairway?) I could see that if the timing was perfect though, the light could be shut off while somebody is traversing the stairway, so the timer reset is probably a good idea to add.

My mind is blown. I really need to devote some time to studying up on programming and try some of the suggestions.