One of the great things about taking on a project such as home automation is experimenting with the different combinations of devices. Take lighting as an example. Traditionally, you flick a switch to turn lights on and off. In some cases like external floodlights, the addition of motion sensors improves the control.

Now, take a moment to step on outside the box. Start thinking about what other ways could you control the activation of a light? And when it activates, could that light convey some form of meaning rather than just as a source of illumination? This is what I set out to find, and for my home, I came up with two practical use cases.

Driveway lighting

Garage door sensor
Xiaomi door sensor mounted on a custom 3D printed bracket

My house is not the ideal candidate for commonly available smart lighting due to every internal light being an MR16 fitting. It must be difficult for manufacturers to get the smarts small enough to fit into a tiny downlight.

But with three external lights using E27 fittings (two at the driveway), it meant I could at least use some smart lighting. After my success with the Xiaomi sensors, I opted for a similar lighting brand, Yeelight. A much cheaper alternative to the Philips Hue. The benefits of Yeelights are that they connect directly to Wifi, and are Google Assistant compatible out of the box.

So how are these lights being controlled? If you were thinking through a motion detector, then you’d be partially right. But not the motion of a person, rather the motion of the garage door. That is because as I go from inside to outside through the garage door and at night, I want the lights to go on. And as I drive into the driveway and remotely open the garage door from the car, I also want some extra lighting.

Using a custom mounted door sensor it communicates with the lights to activate them. After 10 minutes the lights are then automatically turned off.

The Home Assistant scripting looks like this.

Lights on

The garage door state turns on.

trigger:
- entity_id: binary_sensor.door_garage
  platform: state
  to: 'on'

With the condition that it is after sunset and before sunrise.

condition:
- condition: state
  entity_id: sun.sun
  state: below_horizon

Then turn on the lights with full brightness and a white colour.

action:
- data:
    brightness_pct: 100
    color_name: white
    entity_id: group.lights_driveway
    transition: 2
  service: light.turn_on

Lights off

When the garage door state turns on.

trigger:
- entity_id: group.lights_driveway
  platform: state
  to: 'on'

Wait 10 minutes before turning the lights off.

action:
- delay: 00:10:00
- data:
    entity_id: group.lights_driveway
    transition: 2
  service: light.turn_off

At a later stage when a driveway facing security camera is installed, I’ll use the camera’s computer vision to sense driveway movement and activate the lights instead.

In this video you will see the lights activate as the door opens, then through Google Assistant they can be manually turned off. Note when the lights are turned off, the Home Assistant server recognises this and updates its interface. The two have a symbiotic relationship.

Hallway status light

Now that the garage door has a sensor, as well as other openings around the house, those states can be used to check which is an open state. Currently, my Home Assistant has a page which shows me those details. The problem with this method is having to use a device, and open that page which is somewhat inconvenient.

Home Assistant door and window states
Tracking door and windows through Home Assistant

I found an easier way has been to use the Xiaomi Gateway’s built-in light as a colour-coded signal, triggered by a motion sensor every time I walk by. A red colour indicates the garage door is open, orange for when the garage door is closed but when other doors are open, and green for when the house is completely closed.

Orange state example

Gateway light for door and window states
Xiaomi Gateway using colour to show opening states

When either hall motion detectors are activated.

trigger:
- entity_id: binary_sensor.motion_hall_1
  platform: state
  to: 'on'
- entity_id: binary_sensor.motion_hall_2
  platform: state
  to: 'on'

And there is at least one other door open, and the garage door is closed.

condition:
- condition: state
  entity_id: group.doors
  state: 'on'
- condition: state
  entity_id: binary_sensor.door_garage
  state: 'off'

Then turn on the Gateway light and set the colour.

action:
- data:
    brightness: 10
    entity_id: light.gateway_light_f0b429cc57fd
    rgb_color:
    - 255
    - 100
    - 0
  service: light.turn_on

The motion detectors have an inbuilt timer which turns off when no motion is detected. At which point the Gateway light also turns off.

As you can see from the above examples, this is not overly complicated to script.