Back
Featured image of post A story of automating my apartment

A story of automating my apartment

TL;DR – open source home automation works great, if you use the right tools: see here.


During a course about secure mobile networks, I came into contact with Zigbee. While I already knew about the standard, and the intended purposes, I also got to know about the inner details of the protocol and the security (or lack thereof).
For fun and amusement, I looked at aliexpress during the lecture, to find out which devices currently use Zigbee, and which protocol they actually implement.
And to my astonishment, I found a multitude of cheap and ready to bind sensors, but more importantly, I also stumbled upon zigbee2mqtt, which implements a bridge between MQTT (a message broker protocol) and Zigbee.
As I already had made my own lights out of RGB-LED strips, I really wanted to further automate them, but without all the hassle of self-made auxiliaries.

I don’t want to use buttons if I can avoid it […]

Zigbee-sensors, Zigbee2MQTT and Homeassistant (which was directly supported by Zigbee2MQTT) seemed like the perfect fit. So I ordered some initial sensors, a Zigbee-Sniffer (which would be flashed as Zigbee-Coordinator) and waited for them to arrive. In the meantime, I set up homeassistant and zigbee2mqtt on one of my orange-pi’s.

At first, I noticed that my setup of orange-pi’s to control my lights was more than unpractical. So I replaced the orange-pi’s with ESP-8266s (NodeMCU), and some code I found on the internet, which was compatible with homeassistant. After the Zigbee parts arrived, they were also seamlessly integrated into homeassistant within minutes.

Now it was time to implement some basic functionality, such as turning the lights on and off with a button or to be woken by a slight fade-in of the lights in the morning. My previous setup required me to ssh into my lights (mostly via my phone) and turn off the lights via the shell.

I tried my best with some initial automation, but the internal scripting system in homeassistant soon showed its limitations. While it is clearly intended for beginners and features a simple and straight forward design, it does not work well for more complex or repetitive setups. For example, it is very cumbersome to reuse any previous components.

This led me to my next addition to my home automation: NodeRed. It is a simple, yet powerful automation system based on graphical flow graphs, with nodes and associated logic.

I began to implement different automation and was very happy with it, but I began to notice that I wanted more sensors — which were not mainstream enough for Zigbee to exist. So I looked at the Internet and the open-source community for help one last time: and found ESPHome. This project is based on esp8266 or esp32, and provides simple implementation for a multitude of actuators and sensors, with direct integration into homeassistant.

With this, I finally could integrate all the sensors and actuators I wanted. There was just one last thing to do: automate the hell out of it: I don’t want to use buttons if I can avoid it, I don’t want to take care of mundane tasks or having to look over my shoulder when leaving the room — to make sure everything was turned off, or to turn every blinky bit of when I wanted to sleep.

After quite some time of implementing and debugging, it is currently in a state where I can comfortable live with it and have more important things to tinker about. And most importantly, it just works, without me having to adjust and fix everything every time I enter my room.

My Recommendations

So for anyone looking for some recommendations for a home automation system:

  • Get Homeassistant, its easy, it has many plugins and is compatible to nearly everything, has a nice UI and runs on a PI.
  • Get Zigbee, its cheap, it works, and it is one less sensor, button or switch you have to worry about.
  • Get Zigbee2MQTT, to connect Zigbee and Homeassistant (obviously).
  • Get NodeRed, for easy and comprehensive automations.
  • Get ESPHome, for everything that does not quite fit in the consumer space (or you want to tinker yourself) – but without reinventing the wheel.
  • Maybe get InfluxDB, to draw cool graphs of your data, but keep homeassistant sleek and lightweight.

I for my part, keep the complete state in homeassistant and have all the critical automation in homeassistant (e.g. do not disconnect the PC if it is still running). All higher-level automation are in NodeRed [and only communicate with homeassistant, and not directly with any device].
Zigbee provides the main fleet of sensors, and everything available as a Zigbee device will be a Zigbee device.
For everything else, I use esphome.

Built with Hugo
Theme Stack designed by Jimmy
0