Jump to content

Night Light program...


Recommended Posts

I created a night light program...

Using a motion sensor, and a dimmable lightswitch.

 

The concept here is that a motion sensor can turn lights on and off, but that using the switches will override the motion sensor.

The motion sensor only works between certain hours (eg Sunset to Sunrise)

The motion sensor only works if the lights are off.

If the motion sensor is activated, then it turns off the lights after XX (setting on the motion sensor.)

If I turn on the lights while the motion sensor is activated, then the motion sensor no longer has control of the lights.

If I turn off the lights while the motion sensor is activated, then I disable the motion sensor for XXX minutes (controled in the program.)

 

I setup two variables:

INTEGER: MotionAllow (0-Off, 1-On)

STATE: NightLight (0-Off, 1-On)

 

I created 4 programs.

 

p1MotionDetected

If      Control 'Motion1-Sensor' is switched On

    And $MotionAllow is 1

    And Status 'DeskLights' is Off

    And From    Sunset 

        To      Sunrise (next day)

Then    $NightLight  = 1

Else -  No Actions

 

p1MotionUndetected

If      Status  'Motion1-Sensor' is Off

    And $MotionAllow is 1

    And $NightLight is 1

Then    $NightLight  = 0

Else -  No Actions

 

p2TurnOnNightLight

If      $NightLight is 1

Then    Set 'DeskLights' 20%

Else    Set 'DeskLights' Off

p3MotionDisallow

If      Control 'DeskLights' is switched On

     Or Control 'DeskLights' is switched Off

     Or Control 'DeskLights' is switched Fast On

     Or Control 'DeskLights' is switched Fast Off

     Or Control 'DeskLights' is switched Fade Up

     Or Control 'DeskLights' is switched Fade Down

Then    $MotionAllow  = 0

Else -  No Actions

 

p4MotionAllowAgain

If      Status  'DeskLights' is Off

    And $MotionAllow is 0

Then    Wait  2 minutes 

        $MotionAllow  = 1

        $NightLight  = 0

Else -  No Actions

 

 

So, everything works.

 

The $MotionAllow determines if the Motion sensor is allowed to be operational or not - this is how I override it when someone turns ON/OFF lights.  If it is 1 (the default) then the motion sensor can do its thing.

 

The p1 programs decide if we're allowed to turn the lights on or off, and sets the $NightLight

The p2 program does the turning on and off, based on $NightLight.

The p3 program interrupts the turning off if any button is pressed, using $MotionAllow.

The p4 program resets the $MotionAllow variable once the lights get turned off.  However, it waits for 2 minutes so that we can force the lights to be off for a while.  This also resets the $NightLight varilable, so that we are clear that the lights should be off.

 

Things that I don't like.

I didn't like how p3 was so dependent on looking at the controls for the light.

I tried to be clever with another version that looked like this:

 

p3MotionOverride

If      Status  'DeskLights' is not 20%

    And Status  'DeskLights' is not Off

Then -  No Actions

Else    $MotionAllow  = 0

 

The idea behind this program was that if the lights were not at 20% or OFF then the lights must have been fiddled with, so disable the $MotionAllow variable, and stop the timer from working.

The issue, however, was that when the system turned on the lights it would fade them up, and briefly the value would be between 0% and 20% and that was enough to trigger the "someone's fiddled with the lights" bit.

 

So, I have an issue - if the wife presses the "ALL OFF" button on the remote, then I need to capture that as well.  I really need to capture EVERY way that these lights could get turned off - which is kind of a pain.

 

Does anyone have any better suggestions on how to tell if anyone has pressed any buttons?

Really looking for a clever way to check this, without having to capture all of the button presses.

Link to comment

FYI, the reason I did this as a program, and not as a scene...

 

When I did this as a scene.

If the lights were already on (say at 100%) then the motion sensor would set them to 20% and then turn them off 1 minute later.

If the motion sensor came on, and then you turned the lights up to 100%, the motion sensor would still turn them off within a minute.

Link to comment

Okay, I came up with a better P3 program...

 

p3MotionAllow
If      Status  'DeskLights' is 20%
    And $NightLight is 1
Then
        $MotionAllow  = 1
Else  - No Actions
 
p3MotionDisallow
If      Status  'DeskLights' is not 20%
    And $NightLight is 1
Then
        $MotionAllow  = 0
Else  - No Actions
 
The idea here is:
If the lights are at 20%, and we think the night light should be on, then allow the motion control to control the lights.
However, if the lights are not at 20% and yet we think we have the night light on, then someone's pressed something, so turn off the motion control.
Link to comment

I have a different method, not because yours isn't good, but only to provide an alternative. In fact, your method is better than mine because yours is free and mine requires an investment of at least $50.

 

Wire a Micro Dimmer in parallel with the device that controls the light (e.g., SwitchLinc, KeypadLinc). The Micro Module can be installed in the switch box if it fits or in the ceiling box if it doesn't.

 

1.Create a scene with the MS as controller and the SwitchLinc as a responder.

2.Set the On-level of the SwitchLinc to 10-20% or whatever you want as a night light.

 

Optional: 3. Set the On-level of the SwitchLinc to any value greater than the Micro Module and less than 100%. That will result in three levels of light, night light, preset and full on.

 

Manually turning the SwitchLinc on will override the MS.

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...