The Piss Run. Using one sensor to turn on and off bedroom and bathroom lights.
- JohnBentley
- Posts: 4
- Joined: Fri Jul 05, 2019 3:17 am
The Piss Run. Using one sensor to turn on and off bedroom and bathroom lights.
## 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).
Re: The Piss Run. Using one sensor to turn on and off bedroom and bathroom lights.
Hi,
thank you for sharing this How-To. It shows again that there are many good ideas around, and that hue can be used for almost any use case, beyond capabilities of the official app.
Concerning "Motion sensor bed. Piss. Off." - what is the condition "Hue ambient light sensor 1. It is dark." for? If it is not required, I would maybe leave it out (due to its kinda tricky update behaviour).
Regards, Marcus
thank you for sharing this How-To. It shows again that there are many good ideas around, and that hue can be used for almost any use case, beyond capabilities of the official app.
Concerning "Motion sensor bed. Piss. Off." - what is the condition "Hue ambient light sensor 1. It is dark." for? If it is not required, I would maybe leave it out (due to its kinda tricky update behaviour).
Regards, Marcus
2x Bridge V2 (+deCONZ/HA-Bridge)
Hue Go (+BT), Lightstrip (in/out), Play, Bloom; E14+E27 Bulb; Iris, Aura.
Motion sensor (in/out), Dimmer (old/new), Smart Button, Tap Dial.
P.S.: Ich bin *kein* Entwickler von all 4 hue, aber Hue Poweruser!
Hue Go (+BT), Lightstrip (in/out), Play, Bloom; E14+E27 Bulb; Iris, Aura.
Motion sensor (in/out), Dimmer (old/new), Smart Button, Tap Dial.
P.S.: Ich bin *kein* Entwickler von all 4 hue, aber Hue Poweruser!
- JohnBentley
- Posts: 4
- Joined: Fri Jul 05, 2019 3:17 am
Re: The Piss Run. Using one sensor to turn on and off bedroom and bathroom lights.
Hi MarcucZ,
Thanks for your reply and sorry for the lateness of this response.
Well caught on "Hue ambient light sensor 1. It is dark." for an off rule. You are right on both counts: this is unnecessary; and unnecessary conditions are best removed.
Since the OP I've modified my Piss Run rule set to do even more complex things. I now use two sensors in order to register the direction of movement. If I merely enter the bedroom, and the Piss run is not "armed", then this turns on lights at full brightness. If I'm already in bed then getting out of bed will arm and start the piss run, so so the bedroom (and bathroom) lights will be switched to a Nightlight.
The rule set is somewhat convoluted. As this is liable to be confusing rather than instructive for others, I won't post the rule set.
However, in the ruleset it turns out I have removed the "Hue ambient light sensor 1. It is dark." for the off rule, in line with what you have suggested.
Incidentally other experiments have seemed to prove that the "trigger" condition of "Sensor status updated", for motion sensors, is unnecessary unless you want to throw in a time delay. Otherwise a "Presence detected" or "Presence not detected" condition seems to work by itself. Moreover Philips Hue seems to have changed the way it stores presence changes at the API level. That is, (I seem to recall from experiments) use the official app and generate some official motion sensor rules. View these rules in all4hue. This will reveal some conditions unsupported by all4hue, to do with presence detection.
When I have time I'll make a separate and detailed post about this.
Joy.
Thanks for your reply and sorry for the lateness of this response.
Well caught on "Hue ambient light sensor 1. It is dark." for an off rule. You are right on both counts: this is unnecessary; and unnecessary conditions are best removed.
Since the OP I've modified my Piss Run rule set to do even more complex things. I now use two sensors in order to register the direction of movement. If I merely enter the bedroom, and the Piss run is not "armed", then this turns on lights at full brightness. If I'm already in bed then getting out of bed will arm and start the piss run, so so the bedroom (and bathroom) lights will be switched to a Nightlight.
The rule set is somewhat convoluted. As this is liable to be confusing rather than instructive for others, I won't post the rule set.
However, in the ruleset it turns out I have removed the "Hue ambient light sensor 1. It is dark." for the off rule, in line with what you have suggested.
Incidentally other experiments have seemed to prove that the "trigger" condition of "Sensor status updated", for motion sensors, is unnecessary unless you want to throw in a time delay. Otherwise a "Presence detected" or "Presence not detected" condition seems to work by itself. Moreover Philips Hue seems to have changed the way it stores presence changes at the API level. That is, (I seem to recall from experiments) use the official app and generate some official motion sensor rules. View these rules in all4hue. This will reveal some conditions unsupported by all4hue, to do with presence detection.
When I have time I'll make a separate and detailed post about this.
Joy.