Smart Home Automation Success Story: Motion Sensor and Daytime Integration

I’d like to share my journey with integrating a motion sensor into my smart home setup, which has been a fantastic learning experience. My goal was to automate the lighting in my bathroom based on motion detection and the time of day. Here’s how it all came together!

Initially, I wanted the lights to turn on when motion is detected during the day and switch off automatically after a few minutes of inactivity. At night, I wanted the lights to dim slightly for a softer glow. Sounds simple, right? Well, it took some trial and error, but I finally got it working!

The Setup:

  • Motion Sensor: I used a Hue motion sensor to detect activity in the bathroom.
  • Lighting: I have two lights—a Hue switch-controlled light and a Tradfri dimmer.
  • Automation Rule: I created a rule in OpenHAB to handle the logic based on motion and time of day.

Challenges and Solutions:

  1. Timer Functionality: I struggled with getting the timer to work correctly after the motion sensor turned off. The timer would either not start or wouldn’t reset properly. After some research, I realized I needed to ensure the timer was properly cleared each time the motion sensor triggered.

  2. Dimming Levels: Finding the right brightness levels for different times of day took some tweaking. I settled on 80% during the day and 50% in the evening, which provides a nice balance between brightness and energy efficiency.

Final Rule Configuration:
plaintext
rule “Bathroom Lighting Automation”
when Item Hue_Bathroom_Motion received update
then
if (Hue_Bathroom_Motion.state == ON) {
if (vTimeOfDay.state == “MORNING” || vTimeOfDay.state == “DAY” || vTimeOfDay.state == “AFTERNOON”) {
Hue_Bathroom_Switch.sendCommand(ON)
Tradfri_Bathroom_Dimmer.sendCommand(80)
} else if (vTimeOfDay.state == “EVENING” || vTimeOfDay.state == “NIGHT”) {
Hue_Bathroom_Switch.sendCommand(ON)
Tradfri_Bathroom_Dimmer.sendCommand(50)
}
} else {
createTimer(now.plusMinutes(3)) [|
Hue_Bathroom_Switch.sendCommand(OFF)
Tradfri_Bathroom_Dimmer.sendCommand(OFF)
|]
}
end

Outcome:
This setup has been a game-changer for my daily routine. The lights now adjust seamlessly based on my activity and the time of day, providing just the right amount of light without any manual intervention. It’s amazing how a well-configured automation can make such a difference in convenience and comfort!

I hope this story inspires others who are looking to integrate motion sensors and time-based automation into their smart homes. Happy automating! :rocket: