Effortless Lighting, Part 2

During my first post on motion-activated lighting, I showed how a PSIR sensor paired with some LED strips can make for very nice lighting that turns on and off without any intervention. Here, I'll describe how integrating these devices with a home automation orchestrator can make them complement each other in powerful ways that make you feel like you're living in the future.

Great Scott!

The house was built with recessed lighting in mind, but the lights that were installed when we moved in were an unrecognizable technology that ran on 120 VAC and had some kind of series lighting element suspended in an unknown goo. It seemed more a fire hazard than a luxury, and it didn't take me long to replace them with LED strips. This was in several places in the house, but the places that pertain to this project were under the master bathroom counter (discussed in Effortless Lighting, Part 1) and on the master ceiling. Naturally, I replaced them with LEDs controlled by ESP8266 devices running ESPHome for easy Home Assistant integration.

The next part of the plan involved additional LED lights under the beds as well as more PSIR motion sensors to make all the automation seamless. The LED lights are simple strips adhered under the bed frame.

The brightness is increased for this photo, but these lights are usually very dim as they only turn on in the middle of the night.

The PSIR motion sensors are mounted in bases that I designed and had fabricated at JLCPCB. There are three. One points at the floor next to each side of the bed, and the third points at the bathroom door. Importantly, the one on the left also detects motion at the main entry, which is useful for automating the ceiling lights through Home Assistant.

The LEDs and motion sensors are connected through an enclosure I made by hand. As I mentioned in the recent post about 3D printing, I hope this will be the last enclosure I fabricate by hand.

This was a particularly ugly enclosure not just because I made it by hand from an old box lying around, but also because I repurposed some XLR sockets I had lying around. As is too often the case, only after I'd assembled the box and soldered the XLR plugs to the wires did I realize the sockets and the plugs were both female. I had to get the long male-to-male XLR adapters shown in the photo, which makes it particularly ugly. Thankfully, it's hidden under the bed.

The monster under the bed

So, how does it all tie together in Home Assistant? Here's how the lighting in the master bathroom and master bedroom works during the day.

Good Morning!

In the morning, I run a Good Morning Adults routine on my phone. I could set this to run automatically at a specific time, but I prefer to run it manually so that it doesn't wake us up if we're sleeping in on a day off. This immediately triggers several routines:

  • Turn off the noisemaker
  • Arm daytime lighting
    • If the sun hasn't risen, this enables motion control for the ceiling lights
    • Once this sun rises or if the sun has already risen, the ceiling lights are disabled, and the shades come up

Good Evening!

Ten minutes before sunset, the Evening Lighting routine runs automatically. First, the shades go down.

0:00
/0:31

Automated Shades

The bed motion sensors then control the ceiling lights. When motion is detected by the sensor under the left side of the bed, which points to the main bedroom door, the ceiling lights turn on in succession, first by that door, and then by the bathroom door.

0:00
/0:03

Ceiling lights coming on when someone walks in through the main master entry

Alternatively, if motion is detected by the motion sensor pointing at the bathroom door, the ceiling lights come on in reverse.

0:00
/0:02

Ceiling lights coming on when someone walks in through the bathroom door entry

After a few minutes, if no motion is detected, the lights will turnoff automatically.

Motion control of the recessed bathroom light is also enabled. When motion is detected in the bathroom, the recessed lights will come on at moderate brightness. Similarly, these will time out and turn off when no motion is detected.

Good Night!

At 10 PM or if we run it manually, the Good Night Adults routine puts everything into bedtime mode.

  • The bedroom noisemaker turns on.
  • The ceiling lights are disabled and the recessed lights on the bed are enabled.
  • The brightness of the bathroom recessed light is dimmed.

When we get up to go to the bathroom in the middle of the night, the experience is seamless. We don't need to touch a single switch, and the lighting is low enough that it doesn't induce wakefulness in the person who's up or wake the person who's still in bed.

  • When motion is detected on one side of the bed, the lights on that side of the bed are turned on.
  • When motion is detected near the bathroom door, Home Assistant tells the bathroom recessed lights to turn on in anticipation that someone's coming in.
  • When motion is detected again near the bathroom door or in the bathroom, any bed light that has been on in the past 15 minutes will turn on.
  • When no motion is detected for 30 seconds, all of these lights turns off.

While Home Assistant could certainly do all of this, I wanted some of the logic running on the microcontrollers. I created a motion-controlled switch with a timeout. So, Home Assistant doesn't actually turn off the lights, but instead only notifies the controllers of when they should turn on and restart their timeout clock. With no additional notifications from Home Assistant about motion, they turn off on their own. This makes them rely a little less on Home Assistant and simplifies the automations that I have to create in Home Assistant. It's much easier to make an automation in Home Assistant that says, "When controller 1 detects motion, tell controller 2 about it," than it is to say, "When controller 1 detects motion, tell controller 2 to turn on its light. Then, after there's no motion on controller 1 or controller 2 for 30 seconds, tell controller 2 to turn off its light." The ESPHome configs I use are in a public repo on GitHub if you're curious.

The motion controlled lighting gives the master suite a very special kind of luxury. Even though these devices aren't unique, combining them this way makes it feel like we're in the future that was envisioned in the '90's. If only I could get the doors slide open and closed with an electronic swoosh, then it'd really feel like we were on the Starship Enterprise.