Motion Sensor (Security light) with latch

From Universal Devices, Inc. Wiki
Revision as of 05:47, 2 July 2013 by BitSmith (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

As asked by CPRail1, how do we make a motion controlled light that can be latched on? http://forum.universal-devices.com/viewtopic.php?f=27&t=11795

In other words, consider a security light. When there is motion it turns on for three minutes. Also consider that you might want the light to stay on for longer, like when you go into your garage. Nice to have the light turn on automatically, but a bummer when you get to the other end of the garage and the light goes off! So with this code, you enter the garage and the light turns on. And you want to keep it on until you turn it off. Once the light is turned on by the motion sensor, tap the on button and the light will stay on until you turn it off (or until the next motion detection).

Here's how. While there may be several ways to do this, first let's confirm a few things in the Motion Sensor, Item #2842-222. Note that this code can be similarly used with the Wireless Open/Close Sensor Item# 2843-222.


Settings;
[x] Sensing Mode
[ ] On Only Mode
[x] Night mode
Jumpers;  The only one that matters is #5
1 [Open]   Sensitivity
2 [Open]   Disable LED
3 [Open]   Night-Only mode
4 [Open]   On-Only mode
5 [Closed] Remote management

First, I got mine working with a program.

Motion Detection;

If

   Control  'Motion-Sensor' is switched On

Then

   Set Scene 'MotionResponder On
   Wait 10 seconds
   Set Scene 'MotionResponder Off

Else

   - No Actions - (To add one, press 'Action')

Now we'll break it up so that a variable (controlled by a button) determines whether the light stays or times out.

Here are the rules;

  • If person has moved into the area, the light will turn on.
  • If a switch is turned on when it is already on, stay on. To do this, set a variable [Ignore_Motion_Detection] to 1.
  • When the motion program times out, check the variable to see whether to leave the light on or not. Then reset the variable.

This takes three programs. One to watch the switch, one for motion startup rules and one for motion timeout rules.

First, make a variable "Ignore_Motion_Detection". Leave it zero, it will be modified under program control.


Program 1: Watch the switch

Motion Fade Disable;

If    ;If switch is turned on WHILE the light is already on...

       Control 'Security Switch' is switched On
   And Status  'Security Switch' is not Off

Then

   $Ignore_Motion_Detection = 1

Else

   - No Actions - (To add one, press 'Action')


Program 2: Start motion activity

Motion Detection Entry;

If    ;What to do when motion is detected

       Control 'Security Switch' is switched On

Then

   Set Scene 'Security Light' On
   Wait 3 minutes
   Run Program 'Motion Detection Exit' (If)

Else

   - No Actions - (To add one, press 'Action')


Program 3: Start motion cleanup

Motion Detection Exit;

If

   $Ignore_Motion_Detection is 0

Then

   Set Scene 'Security Light' Off

Else  ;Leave light on, but reset the flag so it turns off next time.
 
   $Ignore_Motion_Detection = 0


If you want to keep the light on without automatically resetting, remove the line "$Ignore_Motion_Detection = 0" from the third program and add a fourth program, "Motion Fade Enable"


Please let me know if you find any anomalies or can improve functionality.

Cheers, --BitSmith (talk)


ISY-99i Series INSTEON : How-To Guide