Gracefully Degrading Home Automation

Over the past two years, I have gradually increased my use of home automation in our small city apartment. I started with an IKEA TRÅDFRI light and a button, and today have over 40 devices doing useful things, saving electricity and making our living more pleasant. I won’t lie: I have done a lot of this just for fun and learnt quite a bit in the process. But if it doesn’t eventually result in utility or aesthetics, then I get rid of it. I can’t stand keeping frivolous stuff in the long run.

In this post, I’d like to describe the architecture of our home automation and specifically talk about how a graceful degradation of capabilities is crucial to the reliable operation of devices at home, which itself has important safety implications. Unfortunately, most people do not have access to a setup like mine, and it takes an industry and perhaps regulation to streamline these fundamental capabilities into smart home devices. On the other hand, if you have the time and the skills, this post should have some useful tips.

I chose Zigbee by accident, as the first few devices I purchased from IKEA were Zigbee. It turned out to be a great platform, so I have continued to invest in it. I appreciate that it is an open platform that is not tied to any one company. Furthermore, Zigbee devices purchased today will continue to operate practically forever.

Zigbee, like WiFi, is a network of devices that communicate with each other securely over a wireless link. Unlike common WiFi deployments, Zigbee is a mesh network. This means that devices cooperate with each other to pass messages along the network via the best path. This enables a more robust network that is resilient to signal degradation. Battery powered devices also last longer on a single charge, as they only need to reach their neighbors and not necessarily the main access point.

Zigbee protocol is not trivial to directly interact with. As such, an abstraction layer or a bridge is often put in place to manage the network (pair/configure devices) and provide an easy to use interface for other components to interface with. I use Zigbee2mqtt for this purpose. It interfaces with a Zigbee adapter (much like a WiFi card) and translates the Zigbee messages to and from MQTT messages that are published to an MQTT broker. It also provides convenient ways of adding, removing and configuring devices.

It is now possible to control devices in a simple way and add logic and automation. For example, we can write a program to subscribe to the appropriate MQTT topic and listen for a button click. Once a click message is received, we can then publish a message to turn on a light. This creates a simple light switch. I use Node-RED for both logic and automation. Node-RED provides a nice GUI with lots of built-in functions that mostly eliminates the need to write programs manually. Some examples of automation are: turning on plant lights at sunrise and turning them off at sunset; turning on the bathroom ventilation when a humidity threshold is crossed.

One "neat" feature of Zigbee is that it allows devices to be bound together directly. For example, IKEA buttons can be configured to directly control the state and brightness of a light bulb (of any brand!). This means that even if Zigbee2mqtt is offline, the button continues to control the light! This is an example of graceful degradation. And that is a good segway to talking about the overall architecture.

Below is a diagram of my home network, showing how various components are impacted if one component goes offline. An arrow indicates dependency, with the dependent component pointing to the dependee. In other words, if any component goes offline, only the components that are directly or indirectly pointing towards the offline component will be impacted.

Dependency diagram of various home automation components

To better understand how this setup degrades as components go offline, let’s take the simple example of controlling a light bulb:

I still have some devices that are not on the Zigbee network (such as my hand-rolled intercom controller) so they will stop working when WiFi goes out. I also have some Bluetooth devices which are as resilient as Zigbee devices (albeit with shorter range, until I deploy Bluetooth Mesh).

I have spent many hours building and maintaining my home automation system. Hopefully, with developments like Matter, increasingly less effort is needed to maintain a sane smart home and do so without special skills, such that more people can benefit.