Bathroom motion sensor + switch, with night mode


#1
  1. Description
    I’m having a little trouble stepping through how I would code this, although it seems like it would be a fairly common use case. I want to set up one of the following combos (whichever method is cheaper and/or easier to program).
  1. motion sensor + smart wired dimmer with doubletap (like the Homeseer unit) + dumb bulb
  2. motion sensor + battery powered dimmer (like Osram’s) + smart bulb
  3. motion sensor + 3-button switch (is there one?) + smart bulb

I also want it to also behave mostly like a normal switch if someone manages to hit the switch before the motion sensor detects motion, and also have override capability. Note that I’ve set up a virtual switch called “Sleep Mode” that gets turned on when I go to bed.

The expected behaviors below assume option 1 or 2. I still need to check if there’s a neutral wire at this location. If not, then I’m left with 2 or 3. For option 3, the sentences below would change accordingly: the top button would be 100%, middle button 20%, and bottom button OFF. I don’t really need continuous dimming in the bathroom, I just need a way to control 3 different levels (off, dim, bright).

2) Expected behavior

  • When the motion sensor detects motion, and sleep mode is on, turn ON to 20%.
  • When the motion sensor detects motion, and sleep mode is off, turn ON to 100%
  • When the switch is tapped UP 1x and sleep mode is on, turn on light to 20%, and stay at that level as long as motion is active, or unless the switch is tapped UP 2x, or tapped DOWN.
  • When the switch is tapped UP 1x and sleep mode is off, turn on light to 100%, and stay at that level as long as motion is active, or unless the switch is tapped DOWN 1x or 2x.
  • When the switch is tapped UP 2x, turn on the light to 100% regardless of night mode and stay that way as long as motion is active.
  • When the switch is tapped DOWN 2x, turn on the light to 20% regardless of night mode and stay that way as long as motion is active.
  • When the switch is tapped DOWN 1x, turn off the light and ignore the motion sensor for 30 seconds, unless the light is turned back on.
  • When no motion is detected for 2 minutes, turn off the light.

3) What is happening/not happening?
I’m trying to avoid the following situations:

  • if the switch is tapped on 2x, the light will come on to 100%, but as soon as the motion sensor detects motion, if night mode is on, it will fall back to 20%.
  • if someone leaves the room and re-enters within 2 minutes, the light still turns off at the end of 2 minutes.

4) Post a Green Snapshot of the piston!
I haven’t created one yet, still trying to figure out how to code it.

5) Attach any logs (From [ST IDE]
N/A


#2

I just found this dimmer with integrated motion sensor, from this thread. If it had double-tap, that would be perfect.

EDIT: I suppose I could simply either speed up the dimmer ramp rates, or program a piston with this switch that does the following, if that’s not already it’s default behavior:
If the switch is already on at less than 100% and the UP switch is pressed (not held down), then set level to 100%.
If the switch is already on at 100% and the UP switch is pressed (not held down), then set level to 10%.

In this way the UP switch would act like a toggle between bright and dim.


#3

Found this from the other thread. I actually think what you described in your second post is possible with the ge motion dimmer. The up button will be triggered. So you just have a piston that says if up is pushed and 99% then set to 10%.

The switch exposes the up/down buttons so technically you could get double tap to work. One of the biggest problem however is the onboard motion sensor tends to “push” these buttons. So if the switch is in an vacancy mode and sees no motion for the set time, it then turns off. The way the device handler sees this is the switch turned off by the off button push. You could of course not use the onboard motion control and use webCoRE for turning on/off which would get around that issue.


#4

Thanks for that. I was hoping to use the onboard motion control because I know it would be very quick to turn on the light when motion is detected (before someone’s hand can get to the switch). I’ll have to see what the response times look like with the webCoRE method.


#5

When you write this piston, just have it check the condition of the light before you do anything to the level. So essentially if the light is already ON and motion is detected, leave it alone.

Do you mean at the end of the initial 2 minute window? If so you could get around that by either setting up on the motion sensor how much time it takes before the sensor goes back to inactive. Combine that with a wait in the piston which only fires when the motion sensor has been inactive for 2 minutes. Basically as long as your motion sensor detected motion at an interval more frequent than your WAIT time before you turn off the light you’d be fine.

As for the GE switches, I have several of the regular dimmers and with the right DTH they all have double-tap features built in to them (the new ones anyway). But I don’t own one of those ones with the motion sensor built in. Thought about it…but I didn’t want the “look” to be different than the other 3 switches in the same gang box.


#6

The second item of what you’re trying to prevent shouldn’t happen as long as your timeout for the motion sensor is longer that 2 minutes. My sensors all are set at least higher than that and they continue to report “active” to ST until the timeout of no motion is detected.

As for the first, i have all my motion actions limited by the light being at a certain level or a virtual switch to control whether the motion happens or not. Here are a couple of my motion pistons.

Before turning the light on I check that it has been off for a period of time. This prevents the light from coming on as I leave the room.

All of the other things you are trying to control would be controlled by the Device Type Handler, not by WebCore. Some are possible and some are not. Most switches will return to the last level they were set to if the “on” side is pressed. The only one that has a default level for motion sensing is the GE Dimmer with integrated motion detector. Turning up by so much would be achieved by holding the on button not just tapping it for all the dimmers I’ve seen.