The Piss Run. Using one sensor to turn on and off bedroom and bathroom lights.
Posted: Mon Jul 08, 2019 9:21 am
## Piss Run
Problem:
In the middle of the night you wake up in bed and want to piss. You'd like lights in the bedroom and bathroom (perhaps located down the hall) to turn on in response to motion detection and, once you return to bed, turn off automatically. You'd like the time spent in the bathroom to be variable. That is, you don't want a fixed timer that risks either: putting you in the dark part way through your piss; nor keeps the lights on for too long after you've returned to bed.
The solution:
* You get out of bed. A motion sensor in the bedroom, located under the bed, raises a presence event which (through motion sensor rules) turns on the bedroom and bathroom lights.
* The lights are set to a low light custom "MyNightlight" scene.
* You "run" to the bathroom and do your piss, taking any length of time greater than 10 to 15 seconds (this limitation will be explained below), and return to the bedroom.
* When you return to the bedroom you a free to around the room for any length of time and the lights will remain on due to the sensor detecting presence.
* After you climb into bed the bedroom and bathroom lights turn out automatically, on the sensor detecting no presence.
Limitations:
The piss (being out of bedroom sensor range) must be at least 10 to 15 seconds long to enable the bedroom sensor to "rearm" a turn off action. But the bed and bathroom lights are left on for as long as you like after this.
This is in virtue of the behaviour of hue motion sensors. When a hue motion sensor first detects presence (there's some motion) it wil fire:
+ A "Sensor status updated" and "Presence" event; then
+ 10 to 15 seconds later, if there is no motion, a "Sensor status updated" and "No Presence" event.
So we need some way to ignore this initial "Sensor status updated"/"No Presence" event pair (which will probably occur when you are out of the bedroom and in the bathroom as you begin your piss). Ee want to only respond to a subsequent "Sensor status updated"/"No Presence" event pair, turning the light off only then (rather than as you are aiming for the dunny).
The key to the solution is to use a 3 valued flag (a "Memory sensor for value"), as below ...
### Hardware
* Motion sensor bedroom. This is placed somewhere under your bed so that footsteps trigger the sensor but on-bed activities do not. Placing the sensor in the middle, at the head, can help make this work when either party in the bed gets out (on either side of the bed). However, you might want to place the sensor more toward the edge of the bed for ambient light sensing reasons ... or, if you want to handle two people and ambient light sensing, you may need to adjust the formula to cope with two sensors.
* Bedroom Color Light Bulb.
* Bathroom Color Light Bulb.
### Zone and Scene
BedAndBath.
With "MyNightlight" Scene. Copy the default Nightlight scene and set as desired.
### Memory Sensor Bedroom
All4Hue App.
* Accessories > Menu > Add memory sensor for value
* [Memory for Value] > Press > [Rename]: MotionSensorBed.Companion
### Motion sensor bedroom Rules
All4Hue App.
* Accessories > Hue Motion Sensor 1 > Press > [Rename]: Motion Sensor bed
* Motion Sensor bed > Press > [Configure with wizard] (do wizard and you end up with 2 rules for the sensor).
* Rules. Edit and create rules to end up with 3 rules for the Motion sensor bed as follows:
Description: Motion sensor bed. Piss. On.
Conditions:
* Hue ambient light sensor 1. It is dark.
* Motion sensor bed. Sensor status updated (a trigger condition)
* Motion sensor bed. Presence detected.
* MotionSensorBed.Companion. Value equals 0
Actions:
* BedAndBath Zone. Turn on
* MyNightlight. Activate scene.
* MotionSensorBed.Companion. Save 1 to memory.
(The following ensures the motion sensor will not turn off on the initial "No presence" event which, without the rule, would occur 10 to 15 seconds after the initial "Presence" event)
Description: Motion sensor bed. Piss. Rearm.
Conditions:
* Motion sensor bed. Sensor status updated (a trigger condition)
* Motion sensor bed. No presence detected.
Actions:
* MotionSensorBed.Companion. Save 2 to memory.
* Bathroom. Increase brightness by 10%. (A subtle clue that the 10 to 15 seconds has passed and your system is rearmed, ready to turn off upon a motion no-presence event. You could do anything else here as you desire: flash the light; or change the color).
Description: Motion sensor bed. Piss. Off.
Conditions:
* Hue ambient light sensor 1. It is dark.
* Motion sensor bed. Sensor status updated (a trigger condition)
* Motion sensor bed. No presence detected. (Wait until one has finished dancing around the bedroom)
* MotionSensorBed.Companion. Value equals 2
Actions:
* BedAndBath Zone. Turn off.
* MotionSensorBed.Companion. Save 0 to memory. (Reset to initial conditions)
## Optional Reset Timers
To ensure that the lights don't remain on if you set them on and fail to re-enter the bedroom to set them off (e.g. because you rise for the morning) you can optionally set some reset timers
Description: Motion sensor bed. Piss. On.
Conditions:
* Hue ambient light sensor 1. It is dark.
* Motion sensor bed. Sensor status updated (a trigger condition)
* Motion sensor bed. Presence detected.
* MotionSensorBed.Companion. Value equals 0
Actions:
* BedAndBath Zone. Turn on
* MyNightlight. Activate scene.
* MotionSensorBed.Companion. Save 1 to memory.
* PissResetTimer.ClearMemory. Start timer.
* PissResetTimer.LightsOff. Start timer.
Description: PissResetTimer.ClearMemory
Countdown: 00:05:00
Action: MotionSensorBed.Companion. Save 0 to memory
Description: PissResetTimer.LightsOff
Countdown: 00:05:00
Action: BedAndBath zone. Turn off
(By the way, thanks for Rene for a great app that makes it easy to hack Hue beyond the limits of the official app, and without having to go directly to API calls).
Problem:
In the middle of the night you wake up in bed and want to piss. You'd like lights in the bedroom and bathroom (perhaps located down the hall) to turn on in response to motion detection and, once you return to bed, turn off automatically. You'd like the time spent in the bathroom to be variable. That is, you don't want a fixed timer that risks either: putting you in the dark part way through your piss; nor keeps the lights on for too long after you've returned to bed.
The solution:
* You get out of bed. A motion sensor in the bedroom, located under the bed, raises a presence event which (through motion sensor rules) turns on the bedroom and bathroom lights.
* The lights are set to a low light custom "MyNightlight" scene.
* You "run" to the bathroom and do your piss, taking any length of time greater than 10 to 15 seconds (this limitation will be explained below), and return to the bedroom.
* When you return to the bedroom you a free to around the room for any length of time and the lights will remain on due to the sensor detecting presence.
* After you climb into bed the bedroom and bathroom lights turn out automatically, on the sensor detecting no presence.
Limitations:
The piss (being out of bedroom sensor range) must be at least 10 to 15 seconds long to enable the bedroom sensor to "rearm" a turn off action. But the bed and bathroom lights are left on for as long as you like after this.
This is in virtue of the behaviour of hue motion sensors. When a hue motion sensor first detects presence (there's some motion) it wil fire:
+ A "Sensor status updated" and "Presence" event; then
+ 10 to 15 seconds later, if there is no motion, a "Sensor status updated" and "No Presence" event.
So we need some way to ignore this initial "Sensor status updated"/"No Presence" event pair (which will probably occur when you are out of the bedroom and in the bathroom as you begin your piss). Ee want to only respond to a subsequent "Sensor status updated"/"No Presence" event pair, turning the light off only then (rather than as you are aiming for the dunny).
The key to the solution is to use a 3 valued flag (a "Memory sensor for value"), as below ...
### Hardware
* Motion sensor bedroom. This is placed somewhere under your bed so that footsteps trigger the sensor but on-bed activities do not. Placing the sensor in the middle, at the head, can help make this work when either party in the bed gets out (on either side of the bed). However, you might want to place the sensor more toward the edge of the bed for ambient light sensing reasons ... or, if you want to handle two people and ambient light sensing, you may need to adjust the formula to cope with two sensors.
* Bedroom Color Light Bulb.
* Bathroom Color Light Bulb.
### Zone and Scene
BedAndBath.
With "MyNightlight" Scene. Copy the default Nightlight scene and set as desired.
### Memory Sensor Bedroom
All4Hue App.
* Accessories > Menu > Add memory sensor for value
* [Memory for Value] > Press > [Rename]: MotionSensorBed.Companion
### Motion sensor bedroom Rules
All4Hue App.
* Accessories > Hue Motion Sensor 1 > Press > [Rename]: Motion Sensor bed
* Motion Sensor bed > Press > [Configure with wizard] (do wizard and you end up with 2 rules for the sensor).
* Rules. Edit and create rules to end up with 3 rules for the Motion sensor bed as follows:
Description: Motion sensor bed. Piss. On.
Conditions:
* Hue ambient light sensor 1. It is dark.
* Motion sensor bed. Sensor status updated (a trigger condition)
* Motion sensor bed. Presence detected.
* MotionSensorBed.Companion. Value equals 0
Actions:
* BedAndBath Zone. Turn on
* MyNightlight. Activate scene.
* MotionSensorBed.Companion. Save 1 to memory.
(The following ensures the motion sensor will not turn off on the initial "No presence" event which, without the rule, would occur 10 to 15 seconds after the initial "Presence" event)
Description: Motion sensor bed. Piss. Rearm.
Conditions:
* Motion sensor bed. Sensor status updated (a trigger condition)
* Motion sensor bed. No presence detected.
Actions:
* MotionSensorBed.Companion. Save 2 to memory.
* Bathroom. Increase brightness by 10%. (A subtle clue that the 10 to 15 seconds has passed and your system is rearmed, ready to turn off upon a motion no-presence event. You could do anything else here as you desire: flash the light; or change the color).
Description: Motion sensor bed. Piss. Off.
Conditions:
* Hue ambient light sensor 1. It is dark.
* Motion sensor bed. Sensor status updated (a trigger condition)
* Motion sensor bed. No presence detected. (Wait until one has finished dancing around the bedroom)
* MotionSensorBed.Companion. Value equals 2
Actions:
* BedAndBath Zone. Turn off.
* MotionSensorBed.Companion. Save 0 to memory. (Reset to initial conditions)
## Optional Reset Timers
To ensure that the lights don't remain on if you set them on and fail to re-enter the bedroom to set them off (e.g. because you rise for the morning) you can optionally set some reset timers
Description: Motion sensor bed. Piss. On.
Conditions:
* Hue ambient light sensor 1. It is dark.
* Motion sensor bed. Sensor status updated (a trigger condition)
* Motion sensor bed. Presence detected.
* MotionSensorBed.Companion. Value equals 0
Actions:
* BedAndBath Zone. Turn on
* MyNightlight. Activate scene.
* MotionSensorBed.Companion. Save 1 to memory.
* PissResetTimer.ClearMemory. Start timer.
* PissResetTimer.LightsOff. Start timer.
Description: PissResetTimer.ClearMemory
Countdown: 00:05:00
Action: MotionSensorBed.Companion. Save 0 to memory
Description: PissResetTimer.LightsOff
Countdown: 00:05:00
Action: BedAndBath zone. Turn off
(By the way, thanks for Rene for a great app that makes it easy to hack Hue beyond the limits of the official app, and without having to go directly to API calls).