Bedroom Motion Sensor Automation: A Smart Home Success Story

After a year of learning and experimenting with OpenHAB, I’m thrilled to share a successful automation project that has transformed my bedroom experience. This setup automatically adjusts lighting based on who enters the room and prevents lights from turning on during brief absences, like midnight trips to the bathroom.The rule detects motion and identifies the user through network presence. If I’m home, it turns on mood lighting, while if my parents visit, it activates brighter ceiling lights. To avoid annoying light activations during short trips, the system uses a timer that only turns lights on after a 60-second absence.Here’s the rule I developed, which has been running smoothly for months:plaintextrule "Bedroom Motionsensor"when Item MotionSensor changed to ONthen if(Sun.state != OFF) return; if(User_Home.state == ON && Mood_Light.state == OFF) { Mood_Light.sendCommand(ON) } else if (User_Home.state == OFF && Mood_Light.state == OFF && Door.state == ON && ToiletVisit == 0) { if(motionTimer === null) { Ceiling_Light.sendCommand(ON) Ceiling_Light_Bri.sendCommand(75) motionTimer = createTimer(now.plusSeconds(60), […]) } else { motionTimer.reschedule(now.plusSeconds(60)) } }endHardware used includes a Raspberry Pi 3B+, Hue Motion Sensor, Hue light bulbs, Xiaomi Aqara door switch, and Bitron Funkstick. Bindings like Zigbee, Network, and Astro were essential for this integration.This project has been a game-changer for my smart home setup, offering convenience and energy efficiency. I’d love to hear how others have tackled similar automation challenges or if anyone has suggestions for improving this rule!