ISY-99i/ISY-26 INSTEON:Using Motion Sensors in Bathrooms

From Universal Devices, Inc. Wiki
Jump to: navigation, search

Some may prefer not to use motion sensors as occupancy sensors in bathrooms, on the grounds that in such a location one certainly doesn't want the lights going off unexpectedly--a valid concern.

However, I find the bathroom to be a location which gains a high level of convenience through automation, as long as the sensors provide complete coverage and the programming is made sufficiently solid as to avoid the above scenario. Here I will attempt to present examples of such programming.

These programs will be based on INSTEON motion sensors and door contacts (TriggerLinc), but could be easily modified for X-10 sensors and contacts (DS10A). Some background on motion sensor use may be found in the wiki article Using X-10 Motion Sensors.

To have the light simply turn on when motion is sensed, and turn off when the motion sensor times out:

1. Program Motion 1 - Enabled

If
        Control 'Main Bath Motion.1-Sensor' is switched On
    And Control 'Main Bath Motion.1-Sensor' is not switched Off

Then
        Set 'Main Bath Lights' On

Else
        Set 'Main Bath Lights' Off

This is less than satisfactory for several reasons. First, rather than having the on time controlled entirely by the motion sensor, one may wish to allow ISY to determine the timeout, thereby allowing the on time to be changed programmatically:

2. Program Motion 2 - Enabled

If
        Control 'Main Bath Motion.1-Sensor' is switched On
    And Control 'Main Bath Motion.1-Sensor' is not switched Off

Then
        Set 'Main Bath Lights' On

Else
        Wait  4 minutes 
        Set 'Main Bath Lights' Off

Here the Wait time occurs after the motion sensor has timed out and sent the Off command, so if the motion sensor's timer is set to the default of one minute, then the total timeout period of this program will be five minutes.

Another improvement is to separate the on portion and the timer portion of the program, in order to allow having the INSTEON On command sent to the light switch only when the light is currently off, thereby reducing INSTEON traffic by not sending redundant On commands when the light is already on:

3. Program Main Bath Motion On - Enabled

If
        Control 'Main Bath Motion.1-Sensor' is switched On
    And Status  'Main Bath Lights' is not On

Then
        Set Scene 'sMain Bath Lights' On

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

4. Program Main Bath Motion Timer - Enabled

If
        Status  'Main Bath Motion.1-Sensor' is Off

Then
        Wait  4 minutes 
        Set 'Main Bath Lights' Off

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

Here program 3 turns the lights on in response to motion, if they are not already on. When the motion sensor stops sensing motion, times out, and sends the Off command, its status becomes False and program 4 begins the countdown to turning the lights off. If during this period motion is once again detected, the motion sensor sends another On command, the sensor's status becomes True, and program 4 halts.

The motion sensor control of the lights may be programatically enabled and disabled by use of a flag:

5. Program Main Bath Motion On - Enabled

If
        Control 'Main Bath Motion.1-Sensor' is switched On
    And Program 'Main Bath Motion Timer Enable' is True
    And Status  'Main Bath Lights' is not On

Then
        Set Scene 'sMain Bath Lights' On

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

6. Program Main Bath Motion Timer - Enabled

If
        Status  'Main Bath Motion.1-Sensor' is Off
    And Program 'Main Bath Motion Timer Enable' is True

Then
        Wait  4 minutes 
        Set 'Main Bath Lights' Off

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

7. Program Main Bath Motion Timer Enable - NOT Enabled

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')

Then
        Set Program 'Main Bath Motion Timer Enable' To Run At Startup

Else
        Set Program 'Main Bath Motion Timer Enable' To Not Run At Startup

Here we use a program (Main Bath Motion Timer Enable) as a flag to determine whether the motion sensor should turn the light on (program 5) and whether the timer should be allowed to turn the light off (program 6). To allow the motion sensor to turn the light on, but prevent the timer from turning the light off, add the And Program 'Main Bath Motion Timer Enable' is True line only to program 6 and not to program 5.

Notice first that the flag program is not enabled (the Enabled box at the right side of the window is not checked). This means that the program will never run automatically in response to changing conditions in the If; it will run only when told to do so either by another program, or by manually running it from the Program Summary tab. [There is one other condition under which it will run, and that condition will be explained in the next paragraph.] In this case, since the program has no conditions, it will not run automatically in any case. But clearing the Enabled box for programs which shouldn't run automatically is a good habit to get in to.

Notice also that when the flag is made True (the Then is executed), the flag program sets itself to run at startup, and when the flag is made False (the Else is executed), the program sets itself to not run at startup. This is the other time (mentioned in the previous paragraph) when a program may run even though the Enabled box is not checked.

When ISY reboots, each program which is not set to run at startup has its status set to False. Programs set to run at startup will evaluate the If conditions and run either the Then path or the Else path (thus making the program's status either True for False respectively) depending on whether the conditions evaluate to True or False. When a program which has no conditions is run at startup, the Then path is executed.

As a result, when the Main Bath Motion Timer Enable program is set to True, it configures itself to run at startup so that after an ISY reboot (for example after a power failure) it will once again have a True status. Likewise, when the program is set to False it configures itself to not run at startup and therefore will again have a False status after reboot. The effect is that ISY remembers the state of this program even across reboots.

With this code in place, the motion sensor control may be enabled and disabled by any desired action or schedule. For example, turning the Main Bath Lights switch Fast On to disable sensor control, and Fast Off to reactivate control:

8. Program Main Bath Motion Timer Enable/Disable - Enabled

If
        Control 'Main Bath Lights' is switched Fast On
    And Control 'Main Bath Lights' is not switched Fast Off

Then
        Run Program 'Main Bath Motion Timer Enable' (Else Path)

Else
        Run Program 'Main Bath Motion Timer Enable' (Then Path)

Notice that if the timer is currently counting down to shutoff (program 6) when the Main Bath Motion Timer Enable flag is set to False, the countdown will be halted.

Now we approach the question of how long the timer should be set for. In light of the concern mentioned at the beginning of this article, the timeout must not be made too short. On the other hand, making the timeout longer than necessary results in wasted electricity and reduced effectiveness and convenience.

Earlier I mentioned changing the timeout programatically, and in fact a two-level timing paradigm is one answer to the previous question.

For example, I have an interior (no windows) main bathroom which is completely covered by the motion sensor, except for the bath/shower, because the bath/shower has doors which the sensor cannot see through.

Consider that if the bathroom is occupied (as indicated by the motion sensor) but the bathroom door is open, then it is likely that the occupant won't be too long (perhaps washing hands, etc.). If the door is closed, on the other hand (but please don't close the door on either of your hands), the occupant might be expected to be somewhat longer, especially if bathing/showering, the exact conditions under which the sensor cannot see.

The solution: a two-level timer. When the door is open, time out and shut off the lights (and fan) five minutes after motion ceases. When the door is closed, increase that time to 45 minutes, to allow for a nice hot bath or a leisurely 20 minute shower. It could be set even longer for that matter. After all, if the door is closed and there is no motion for an hour, there is a more serious problem than the lights being left on!

The open/closed status of the door may be determined using either an INSTEON TriggerLinc, or an X-10 DS10A.

To implement the two-level timer, the triggering portion and the timing portion of the timer program are separated to allow for a conditional timing interval:

9. Program Main Bath Motion Re-Trigger - Enabled

If
        Status  'Main Bath Motion.1-Sensor' is Off
    And Program 'Main Bath Motion Timer Enable' is True

Then
        Run Program 'Main Bath Motion Timer' (If)

Else
        Stop program 'Main Bath Motion Timer'

10. Program Main Bath Motion Timer - NOT Enabled

If
        Status  'Main Bath Contact.1' is Off

Then
        Wait  40 minutes 
        Run Program 'Main Bath Motion Timer' (Else Path)

Else
        Wait  5 minutes 
        Set Scene 'sMain Bath All Slow' Off

When the motion sensor status becomes False, the re-trigger program (program 9) starts the timer program (program 10). Should new motion occur during the countdown (or the Main Bath Motion Timer Enable flag become False), the re-trigger program halts the timer program.

When the timer program is started, it will run Then if the door is closed; if the door is open it will run Else. The Else provides the five minute interval, while the Then provides a 40 minute interval before calling the Else for the final five minutes, prior to turning the scene (lights and fan) off.

Notice that program 10 is not enabled, and this fact is important since we don't want the program to run automatically, but only when called.

Another modification made in this program is to turn the lights and fan off using a sMain Bath All Slow scene, which has the fan switch (relay) ramp-rate set to .1 seconds (fastest possible), but the light switch set to a 30 second or one minute ramp rate. This rate of change in light level is fast enough for the occupant to notice it, and to make some motion to retrigger the light, and is slow enough to give him plenty of time.

This means we have two separate scenes for the lights; one with a quick ramp rate for turning the light on, and the other with the slow ramp rate for turning the light off. Alternately, you could use a single scene with a slow ramp rate for turning the light off, and then use Fast On with the same scene to turn it quickly on.

My preference is to use two scenes, because using Fast On will cause the lights to come on to 100% with the fastest possible ramp rate (.1 seconds or nearly instantaneous). I usually set my lights to come on to 90% with a .5 second ramp rate. This slower ramp rate and reduced level reportedly should increase the life of the bulb significantly.

This slow-dim-to-off is a technique I use widely where there are motion sensors/timers turning lights off. In my master bedroom and ensuite I don't use motion sensors. Rather, there is a KeypadLinc in a pedestal on either side of the bed. Each has a button which causes both the lamp on the corresponding side of the bed, and the ensuite lights to do a slow fade up which is easy on the eyes in a dark room, to a low level sufficient for the purpose at hand but not bright enough to wake someone.

Next we should give some thought to what occurs following a power interruption. Since ISY cannot poll the status of RF devices (motion sensor, door contact), should it default to assuming the door is open or closed?

In the case of an interior bathroom, if the power fails while the bathroom is occupied and the door is closed, the occupant will likely open the door since there will be no light. During a power failure, should someone enter the bathroom it is unlikey he would shut the door, as there would be no light. So either way, when the power returns it is quite likely the door will be open.

However, once power is restored and ISY reboots, it can take ISY five minutes to query the INSTEON network in a modest installation and much longer in a large installation. During that time someone may very well enter and close the door. Clearly it is safer to assume the door is closed, since that will provide the longer timeout period before shutting off the light. The downside is that if someone enters, thereby triggering the motion sensor, and then leaves without having ever shut the door and then opened it, the lights/fan will take much longer to time out than is necessary. This condition will persist until the door is closed and opened.

As it turns out, when a device status is unkown, as in the case of RF devices following reboot, ISY defaults the status to Off with regards to programs. So in program 10 the door status will default to closed.

There is a third possibility, and that is to remember the door status just as we remember the enable flag:

11. Program Main Bath Door Status Closed - NOT Enabled

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')

Then
        Set Program 'Main Bath Door Status Closed' To Run At Startup

Else
        Set Program 'Main Bath Door Status Closed' To Not Run At Startup

Next we need a program to set or clear the flag when the door closes or opens:

12. Program Main Bath Door Status Change - Enabled

If
        Control 'Main Bath Contact.1' is switched Off
    And Control 'Main Bath Contact.1' is not switched On

Then
        Run Program 'Main Bath Door Status Closed' (Then Path)

Else
        Run Program 'Main Bath Door Status Closed' (Else Path)

The reason for two separate programs is because the flag program which we wish to remember across reboots, should not have any conditions in the If clause to ensure that it assumes the proper state after power up. Were we to place the above conditions in the flag program, the flag would always be False (door open) after a reboot.

Finally, we modify program 10 to test the flag:

13. Program Main Bath Motion Timer - NOT Enabled

If
        Program 'Main Bath Door Status Closed' is True

Then
        Wait  40 minutes 
        Run Program 'Main Bath Motion Timer' (Else Path)

Else
        Wait  5 minutes 
        Set Scene 'sMain Bath All' Off

One question we have not addressed to this point is what should happen if the door opens or closes during the countdown period? In the above programs, the timer will continue with whichever time period it is currently running. We can modify the Main Bath Door Status Change program (program 12) to restart (or stop) the timer when the door opens or closes:

14. Program Main Bath Door Status Change - Enabled

If
        Control 'Main Bath Contact.1' is switched Off
    And Control 'Main Bath Contact.1' is not switched On

Then
        Run Program 'Main Bath Door Status Closed' (Then Path)
        Run Program 'Main Bath Motion Re-Trigger' (If)

Else
        Run Program 'Main Bath Door Status Closed' (Else Path)
        Run Program 'Main Bath Motion Re-Trigger' (If)

Here, each time the door status changes, the re-trigger program (program 9) is called. If the motion status is On, or the enable flag is False, the timer will be stopped. Otherwise, the timer program (program 13) will be called again, will reevaluate the door status, and initiate the appropriate time interval.

Another feature we could add is to have the fan turn on if the door is closed and the light is on:

15. Program Main Bath Door Status Closed Fan On Timer - Enabled

If
        Program 'Main Bath Door Status Closed' is True
    And Status  'Main Bath Lights' is not Off

Then
        Wait  5 minutes 
        Set 'Main Bath Fan' On

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

If you wish to have the fan turn on immediately, simply remove the Wait.

Finally, as with any INSTEON motion sensor application, we can take note of a low battery indication:

16. Program Main Bath Motion Low Battery - Enabled

If
        Status  'Main Bath Motion.3-LowBattery' is On

Then
        Repeat Every  24 hours 
           Send Notification to All

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

Putting it all together, a complete program group (contained within a f_Main Bath Door/Motion folder for organizational purposes) may look like this:

Program Main Bath Door Status Change - Enabled

If
        Control 'Main Bath Contact.1' is switched Off
    And Control 'Main Bath Contact.1' is not switched On

Then
        Run Program 'Main Bath Door Status Closed' (Then Path)
        Run Program 'Main Bath Motion Re-Trigger' (If)

Else
        Run Program 'Main Bath Door Status Closed' (Else Path)
        Run Program 'Main Bath Motion Re-Trigger' (If)

Program Main Bath Door Status Closed - NOT Enabled

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')

Then
        Set Program 'Main Bath Door Status Closed' To Run At Startup

Else
        Set Program 'Main Bath Door Status Closed' To Not Run At Startup

Program Main Bath Door Status Closed Fan On Timer - Enabled

If
        Program 'Main Bath Door Status Closed' is True
    And Status  'Main Bath Lights' is not Off

Then
        Wait  5 minutes 
        Set 'Main Bath Fan' On

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

Program Main Bath Motion Low Battery - Enabled

If
        Status  'Main Bath Motion.3-LowBattery' is On

Then
        Repeat Every  24 hours 
           Send Notification to All

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

Program Main Bath Motion On - Enabled

If
        Control 'Main Bath Motion.1-Sensor' is switched On
    And Status  'Main Bath Lights' is not On

Then
        Set Scene 'sMain Bath Lights' On

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

Program Main Bath Motion Re-Trigger - Enabled

If
        Status  'Main Bath Motion.1-Sensor' is Off
    And Program 'Main Bath Motion Timer Enable' is True
    And (
             Status  'Main Bath Lights' is not Off
          Or Status  'Main Bath Fan' is not Off
        )

Then
        Run Program 'Main Bath Motion Timer' (If)

Else
        Stop program 'Main Bath Motion Timer'

Program Main Bath Motion Timer - NOT Enabled

If
        Program 'Main Bath Door Status Closed' is True

Then
        Wait  40 minutes 
        Run Program 'Main Bath Motion Timer' (Else Path)

Else
        Wait  5 minutes 
        Set Scene 'sMain Bath All Slow' Off

Program Main Bath Motion Timer Enable - NOT Enabled

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')

Then
        Set Program 'Main Bath Motion Timer Enable' To Run At Startup

Else
        Set Program 'Main Bath Motion Timer Enable' To Not Run At Startup

Program Main Bath Motion Timer Enable/Disable - Enabled

If
        Control 'Main Bath Lights' is switched Fast On
    And Control 'Main Bath Lights' is not switched Fast Off

Then
        Run Program 'Main Bath Motion Timer Enable' (Else Path)

Else
        Run Program 'Main Bath Motion Timer Enable' (Then Path)

This is just one of many possible approaches to automating bathroom lights and fans.




ISY-26 INSTEON / ISY-99i Series INSTEON : How-To Guide