Please login or register.

Login with username, password and session length
Advanced search  

News:

The New WIFI Module is now available!
                   *****Here's the link******

Pages: [1] 2

Author Topic: Motion sensor and lights on/off  (Read 30437 times)

jarleifv

  • Full Member
  • ***
  • Helpful Post Rating: 6
  • Posts: 41
Motion sensor and lights on/off
« on: November 20, 2010, 09:22:34 PM »

I use 1 motion sensor in the bathroom.

Desired outcome:
Motion sensor detects motion and light comes on. Light stays on during my stay in bathroom. A few minutes after departure from room, light goes off.


Four macros take care of this, using two flags.


Flag 1 = Motion detected during delay
Flag 2 = 5 minute delay active


P1 - Motion triggered during dark
 Conditions:
  flag 1 off   
  AND
  flag 2 off
 Actions:
  Lights on
  set flag 2 on
  Delay 5 minutes
  P3 - ON


P1 - Motion triggered during light
 Conditions:
  flag 1 off
  AND
  flag 2 on
 Actions:
  set flag 1 on


P3 - Motion check - no motion during delay
 Conditions:
  flag 1 off
  AND
  flag 2 on
 Actions:
  set flag 2 off
  lights off


P3 - motion check - motion during delay
 Conditions:
  flag 1 on
  AND
  flag 2 on
 Actions:
  set flag 1 off
  set flag 2 off
  P1 - ON

Logged

bkenobi

  • Hero Member
  • *****
  • Helpful Post Rating: 11
  • Posts: 1273
Re: Motion sensor and lights on/off
« Reply #1 on: February 07, 2011, 01:21:18 AM »

I've been playing with this code all day and can't figure out what P1 and P3 are.  I thought P1 was the motion sensor and P3 was a phantom module, but now I'm not sure.  In the 4th macro it says "P1 - ON", but I'm not sure how to set a motion sensor to ON.  I've set up all the conditions and code except for "P1 - ON" and "P3 - ON".  Anyone have any idea how to implement this code?
Logged

Noam

  • Community Organizer
  • Hero Member
  • **
  • Helpful Post Rating: 47
  • Posts: 2712
Re: Motion sensor and lights on/off
« Reply #2 on: February 07, 2011, 10:20:41 AM »

It looks to me like "P1 On" and "P3 On" are macros. There are two sets for each, using the "else" functionality that is automatic with SmartMacros.
The motion sensor is set to P1.

so, if there is motion, and the light is off, then the light is turned on.
Every 5 minutes, the macro will check for additional motion. If there has been any, then it waits another 5 minutes.
If there hasn't been any motion in the last 5 minutes, then it turns the light off, and resets for the next time.

At least that's how I read it.
Logged

bkenobi

  • Hero Member
  • *****
  • Helpful Post Rating: 11
  • Posts: 1273
Re: Motion sensor and lights on/off
« Reply #3 on: February 07, 2011, 10:41:44 AM »

That's what I was thinking too.  Here's my problem though: if "P1 On" and "P3 On" are macros, how do I call them from a macro?  I don't see any way to select a macro to call it recursively.  The only thing I can think of is that there are P1 and P3 phantom modules that are set to on which then trigger the "P1 On" and "P3 On" macros.  Sound right or am I completely confused still?

EDIT:  Now I'm not sure...  I just read a few more smart macro threads and the "P1 ON" command seems pretty common.  Is there a command I'm missing where I can send that command without having a module?  This must be a basic step that I'm missing since it's so common.  I'm going to feel really stupid when I figure out what I'm missing.   B:(
« Last Edit: February 07, 2011, 10:44:31 AM by bkenobi »
Logged

Noam

  • Community Organizer
  • Hero Member
  • **
  • Helpful Post Rating: 47
  • Posts: 2712
Re: Motion sensor and lights on/off
« Reply #4 on: February 07, 2011, 01:08:44 PM »

... Is there a command I'm missing where I can send that command without having a module?  This must be a basic step that I'm missing since it's so common. 

You can do it by creating a "dummy" appliance module, and having the macro turn that on.
I suppose (I've never tried this), you could use the "advanced command" option in SmartMacros to send just the "P1 On". Not sure if that would work, though.
Logged

bkenobi

  • Hero Member
  • *****
  • Helpful Post Rating: 11
  • Posts: 1273
Re: Motion sensor and lights on/off
« Reply #5 on: February 07, 2011, 03:07:57 PM »

I was thinking that P1 must also be a dummy module since you can't turn on a motion sensor.  I'll try the advanced command to see how that works.  I saw there was a category there and actually played with the RF command, but didn't realize there was a PLC command in there.  Thanks for the suggestion!
Logged

Noam

  • Community Organizer
  • Hero Member
  • **
  • Helpful Post Rating: 47
  • Posts: 2712
Re: Motion sensor and lights on/off
« Reply #6 on: February 07, 2011, 04:11:26 PM »

I was thinking that P1 must also be a dummy module since you can't turn on a motion sensor.  I'll try the advanced command to see how that works.  I saw there was a category there and actually played with the RF command, but didn't realize there was a PLC command in there.  Thanks for the suggestion!

Just create a "dummy" for P1, too.
Logged

bkenobi

  • Hero Member
  • *****
  • Helpful Post Rating: 11
  • Posts: 1273
Re: Motion sensor and lights on/off
« Reply #7 on: February 08, 2011, 12:25:49 AM »

Hmmm, I just realized this doesn't do exactly what I thought the description was saying it did.  This setup will:

1) Turn on a light when motion is detected.
2) If no motion is detected during the 5 minute delay, it will turn off the light and reset.
3) If motion is detected during the 5 minute delay, it will continue to count down the time until the 5 minutes is up.  It will then set a new 5 minute delay and repeat.

As a result, this will, in most situations, keep the light on for 10 minutes from initial motion.  It does not leave the lights on for 5 minutes after motion, it actually turns the lights off at LEAST 5 minutes after the last motion.  This is probably not a big deal, I just didn't understand that initially.

FWIW, I did get this working with the use of 2 dummy modules.  Thanks for the help!
Logged

aussie mate

  • Sr. Member
  • ****
  • Helpful Post Rating: 5
  • Posts: 83
Re: Motion sensor and lights on/off
« Reply #8 on: February 13, 2011, 05:31:53 AM »

I have just programmed and tested the series of 4 macros in this post. - It works well...

I didn't use any dummy modules - just 2 flags and 4 macros.
P1 being the sensor and P3 as a trigger using advance functions commands.(you could use a dummy module here if you wanted to).

It works as follows:
1) Turns the light when motion is detected. (sensor P1 as trigger)
2) If no motion is detected during the 5 minute delay, it will reset flags and turn off the light.
3) If motion is detected during the 5 minute delay, it will reset flag 2 only
4) while the 1st macro will continue to count down the time until the 5 minutes is up.  It will then send the P3 On command - which will have 2 results.
5 a) if no motion has been detected in the last 5 mins - it will run the "no motion during delay"
macro and turn light off.
5 b) if motion has been detected in last 5 mins - because the flag was reset (step 3) - it will restart the 1st macro (step1).

Thus the lights will always stay on until 5 mins after the last movement was detected.
Logged

Noam

  • Community Organizer
  • Hero Member
  • **
  • Helpful Post Rating: 47
  • Posts: 2712
Re: Motion sensor and lights on/off
« Reply #9 on: February 14, 2011, 09:25:58 AM »

... Thus the lights will always stay on until 5 mins after the last movement was detected.

Based on my reading of it, I don't see how it would work if the motion lasts longer than 5 minutes.
The only 5-minute delay is in the initial P1 macro - if the room is dark.
The second one - the one that gets triggered by P3 - has no delay in it, so it won't ever trigger P3 to turn the light back off.

Am I reading this wrong?
Logged

aussie mate

  • Sr. Member
  • ****
  • Helpful Post Rating: 5
  • Posts: 83
Re: Motion sensor and lights on/off
« Reply #10 on: February 15, 2011, 09:40:09 PM »

To help clarify this - I have numbered the 4 macro's starting from the top.

Macro 1 - "P1 - Motion triggered during dark"
macro 2 - "P1 - Motion triggered during light"
Macro 3 - "P3 - Motion check - no motion during delay"
Macro 4 -"P3 - motion check - motion during delay"


The way I believe it works is that if during the 1st 5 mins delay- if there is motion - macro 2 will run - setting flag 1 to ON
then as macro 1 is still running - when the 5 mins delay is up - macro 1 sends P3 ON signal.

Then either macro 3 or macro 4 runs depending on conditions:
if there has been movement - Flags 1 & 2 will be ON - thus macro 4 will run
This macro will clear both flags and then call / send P1 which then restarts the process from the beginning.
This will continue to loop until no movement is detected in the 5 min delay period/s

if no motion was detected in the 5 min delay - then macro 3 will run - turning the light off.

Logged

Noam

  • Community Organizer
  • Hero Member
  • **
  • Helpful Post Rating: 47
  • Posts: 2712
Re: Motion sensor and lights on/off
« Reply #11 on: February 16, 2011, 08:41:13 AM »

I see.
I was missing the fact that the "macro 4" reset both flags and started "macro 1" again.
It is possible, I suppose, that motion during the execution of "macro 4" might cause "macro 2" to be run instead of "macro 1," and therefore might result in the light never turning off.

I wonder if there is a way to add a 5 minute delay to one of the other macros, to make sure that the loop didn't exit with the light still on.
Logged

Lasticko

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 1
Re: Motion sensor and lights on/off
« Reply #12 on: June 28, 2011, 01:38:16 PM »

Just got off the phone with x10 support.

They are baffled why you would need all this.. since the motion sensor module does all this FOR YOU!

For Example:
If your motion sensor is set to A9 ...
then set ALL the lights you want controlled to A9 as well.

When motion is triggerd, it also turns on those lights.
After no motion for 5 minutes (default value), the motion sensor sends the off command and all those lights on A9 get turned off.

Easy breezy.

Am I missing something in this macro/flag combo script that the motion sensor module doesn't cover??
 
Logged

dave w

  • Community Organizer
  • Hero Member
  • **
  • Helpful Post Rating: 133
  • Posts: 5816
Re: Motion sensor and lights on/off
« Reply #13 on: June 28, 2011, 01:52:02 PM »


Am I missing something in this macro/flag combo script that the motion sensor module doesn't cover??
 

Yes.

The motion sensor will turn ON and OFF the light set to its address all the time (i.e. 24/7).  Having the motion sensor trigger macros, allow you to use conditionals to prevent the lights from turning on when you don't want them to. For example you may not want the light on your front porch to come on during bright sun light as the mailman puts mail in your box.
Logged
"This aftershave makes me look fat"

Noam

  • Community Organizer
  • Hero Member
  • **
  • Helpful Post Rating: 47
  • Posts: 2712
Re: Motion sensor and lights on/off
« Reply #14 on: June 28, 2011, 01:59:59 PM »

However, in this case it looks like the OP wanted to use this in the bathroom, presumably to have the light come on each time someone went into the bathroom, and go off 5 minutes after they left.

I suppose the motion sensor on its own could do this. To be honest, I don't know why the OP was trying to do this with a bunch of macros, instead of using the built-in time in the motion sensor. The thread doesn't give a reason for that.

If they want to only have it happen during certain hours (like only at night - perhaps there is a window that provides enough light during the day), then they COULD create a conditional macro, triggered by the "on" from the motion sensor, to turn the light on only if the right time window is met.
A matching "off" macro, triggered by the "off" from the motion sensor, could be used to turn the light off.

Still pretty easy.
Logged
Pages: [1] 2
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.