This post may contain affiliate links. Please see our disclaimer for more info.
I need to be able to see where I’m walking in the master bedroom at night without bothering my wife. My wife goes to bed before me; as a result, I’m finding myself navigating the steps to my bed at night much like navigating a dark cave. In addition to not being able to see, my kid and cats like leaving things on the ground for me to trip on. I can’t simply turn on a room light as that would bother the wife and using my phone for a flashlight is annoying. The solution? Of course, Home Assistant with a few gadgets and automations.
In this post, I’ll be detailing setup and operation of a motion sensor controlled smart bulb driven by HA.
Ingredients
- Motion Detector
- Smart Bulb
- Cord & Socket
- HA Components: binary_sensor
Equipment
Integration
Zooz Multisensor Integration
## configuration.yaml
binary_sensor:
- platform: template
sensors:
masterbed_motion:
friendly_name: "Master Bed Motion
device_class: motion
value_template: "{{ states('sensor.masterbed_zooz_alarm_level')|float > 0 }}"
## customize.yaml
sensor.masterbed_zooz_alarm_level:
hidden: true
sensor.masterbed_zooz_alarm_type:
hidden: true
sensor.masterbed_zooz_sourcenodeid:
hidden: true
sensor.masterbed_zooz_burglar:
hidden: true
sensor.masterbed_zooz_power_management:
hidden: true
binary_sensor.masterbed_zooz_sensor:
hidden: true
sensor.masterbed_zooz_emergency:
hidden: true
Automation
Getting things automated correctly turned out to be the most difficult part of this project. Not because turning the bulb on and off with motion is hard, but instead because of all the considerations I wanted to incorporate into the logic. Essentially, the bulb turns on when motion is detected and there isn’t other light on in the room (natural or artificial). Then a loop checks every 10 seconds if there is no longer motion or another light turned on and will turn off, or keep the bulb on if the conditions haven’t been met.
There is a luminance sensor on the Zooz Multisensor, while this appears accurate, it doesn’t update as often as I need to use it reliably in automation.
I’ve put together the psuedo code below to help you map out your automation.
IF
Motion detected in master bedroom
THEN
IF
Bedroom light isn't on
Pseudo sun isn't on
It is after sunset
THEN
Turn on floor bulb - Transition to 40% brightness over 3 seconds
END IF
LOOP
Start 10 second timer
IF
Bedroom light is on
Pseudo sun isn't on ## see my sunrise alarm clock post here
It's during daylight
No motion detected
THEN
Turn off the floor bulb with a 4 second transition
END IF
END LOOP
END IF
hello form Italy congratulations for the project
I wanted to ask you but if the cat enters the bedroom at night, does the light turn on?
Thank you!
Yes – sometimes the cat triggers the motion sensor. Also sometimes moving in the bed can trigger the motion sensor which can be annoying. Luckily many motion detectors have a sensitivity setting where you can edit them to be less sensitive to smaller movements which helps.