As someone who has been integrating smart home devices into my daily life, I wanted to share my experience with the Philips Hue Motion Sensor. This device has been a game-changer for automating my kitchen lights, and I thought it would be helpful to walk through my setup and any challenges I encountered along the way.
I’ve been using OpenHAB for a while now, and while it has a steep learning curve, the flexibility it offers is unmatched. My goal was to create a rule where the motion sensor would trigger the kitchen lights to turn on only if the room was dark enough and if I was present. After some trial and error, I managed to write a rule that does just that. Here’s a snippet of the rule I created:
plaintext
rule “HUE - KITCHEN: LIGHTS ON WHEN DETECTION IS REGISTERED”
when
Item HUE_KITCHEN_MD received update ON
then
var corLightLevel = (HUE_KITCHEN_MD_LIGHT_LVL.state as Number).floatValue - (HUE_LIGHT_LVL_LIMIT as Number).floatValue
logInfo(“hue.rules”,"MOTION DETECTED ; CORRECTED LIGHT LEVEL " +corLightLevel.toString+“lx”)
if (gPresence.state == ON) {
if (corLightLevel < 1 ) {
if (KitchenTimer === null || KitchenTimer.hasTerminated()) {
gHUE_KITCHEN.sendCommand(ON)
logInfo(“hue.rules”,“KITCHEN: MOTION DETECTED - LIGHTS ON”)
KitchenTimer = createTimer(now.plusSeconds(120), [|
gHUE_KITCHEN.sendCommand(OFF)
logInfo(“hue.rules”,“SWITCHING KITCHEN LIGHTS OFF”)
])
} else {
logInfo(“hue.rules”,“RESCHEDULING KITCHEN LIGHT TIMEOUT”)
KitchenTimer.reschedule(now.plusSeconds(120))
}
}
}
end
The rule works by checking the corrected light level (to account for the kitchen lights illuminating the sensor) and my presence. If both conditions are met, the lights turn on and stay on for 120 seconds. If motion is detected again within that window, the timer resets. However, I ran into an issue where the timer wouldn’t reschedule properly. After some research, I realized that setting KitchenTimer = null at the end of the timer was preventing the else branch from triggering. Removing that line fixed the issue!
This experience has been both frustrating and rewarding. It’s amazing how a single device can enhance your daily routine, but debugging can be a puzzle. I’m grateful for communities like this one where I can troubleshoot and learn from others’ experiences. If anyone has tips or alternative approaches to achieve similar functionality, I’d love to hear them!
Happy automating! ![]()