Server for Home Automation - applications

To run the home automation system, I’ve needed a server as a central point. It is possible to run automation controller like Home Assistant, on the Raspberry Pi or ODROID-N2+. These are probably good choices if you don’t want to run too many applications. However, I believe that having a server running 24/7 gives you some nice possibilities. You can run file server, dashboards showing useful data, monitoring system, etc.

In this post, I describe most of the applications running on my home automation server.

Smart Home

Eclipse Mosquitto

Mosquitto

Well known, open source MQTT protocol message broker. The unique features of MQTT protocol, like retaining messages or last will message, make it a perfect match for IoT projects (including home automation). MQTT is supported by every open source home automation controller I know (e.g., Home Assistant, OpenHab, Domoticz).
In my setup, communication between MqGateways and Home Assistant is implemented with MQTT. It makes Mosquitto the key element of my home automation system.

Home Assistant

If you are in DIY home automation, then you probably don’t need any introduction to this application. Home Assistant is an open source software for controlling your smart home devices. There are almost 2000 integrations to take control of your TV, smart bulbs or Zigbee devices.
Every smart device I have, is connected to Home Assistant in some way. I prefer to use MQTT, but it is not always an option. Home assistant takes care of the integrations, but it also allows creating nice dashboards and implementing automations easily. What is more - it puts local control and privacy first, so I can still open my garage door when there is no Internet connection 😉.

Home Assistant Dashboard

https://www.home-assistant.io/

AppDaemon

An excellent addition to Home Assistant. AppDaemon provides an API to Home Assistant. It lets me write more complex automations in Python instead of the YAML files. Home Assistant automations are powerful, but as a software developer, I love the readability and ease of writing code in programming language.

https://appdaemon.readthedocs.io/

Zigbee2MQTT

Zigbee2MQTT

Zigbee is a wireless mesh network standard with the emphasis on low-power consumption, widely used in smart home devices. It is used in devices produced by many brands like IKEA, Osram, Philips, and Xiaomi.
You can get bulbs, temperature and humidity monitors, smart plugs, smoke detectors, and many other types of devices with Zigbee. Most of the mentioned manufacturers sell their own gateway for their devices. However, there are universal Zigbee gateways like Conbee II or CC2531. These universal gateways allow you to control Zigbee devices from multiple manufacturers.
Zigbee2MQTT is a great piece of software, which allows you to use those universal Zigbee gateways and bridges the communication to MQTT (see Mosquitto above). With this setup, it is super easy to integrate those Zigbee devices with home automation controllers like Home Assistant.

I prefer wired communication wherever possible, but when it is not - I use Zigbee devices. I have a couple of IKEA smart bulbs and buttons, Xiaomi Honeywell smoke detector and Aqara Vibration Sensor.

Monitoring and high availability

Prometheus

Prometheus

Prometheus is a monitoring system and a time series database. It is so popular right now, that many applications offer Prometheus metrics out-of-the-box. For those which does not have it built-in, there are often metrics exporter available.

I use Prometheus to gather metrics from my Home Automation server like CPU, memory and disk usage. It also stores metrics, which helps to monitor availability of applications, RClone process results and Docker containers metrics.
MqGateways also produce Prometheus metrics about their memory and CPU usage, occurred errors, etc. It gives me the possibility to monitor, not only the main home automation server, but the entire smart home solution.

All these metrics are stored in Prometheus and can be viewed in Grafana (see below).

Grafana

Grafana is a great dashboard and alerting tool. It nicely connects to Prometheus to read the stored metrics and display them in a readable way.

I use Grafana to monitor my whole smart home solution. Dashboards are super attractive, but it is not the place I look very often. When there is any problem with the server (like high disk usage), Grafana sends me the notification through the Telegram messaging app. This is very handy, because this message contains information about the problem, so I can quickly assess if the problem needs an immediate reaction.

Grafana Dashboard

https://grafana.com/

Keepalived

Keepalived

Having basic home functionalities (like lights) relying on home server might be a bit risky (especially if not every family member is very much into home automation). Failures happen - that is a fact.
To avoid any potential disturbances, I have a smaller backup server running next to the main one. When it is needed - it can run core applications like Home Assistant and Mosquitto. However, I would like to avoid the chaos of trying to explain to someone how to start the backup server (especially when it is dark, because no lights work).

That is why I need Keepalived. When the main server is going down (for whatever reason), Keepalived starts Home Assistant, Mosquitto and AppDaemon on the backup server and changes its IP to replace the main one. There is only a short break in service in case the main server has failed. Everything is going back to normal as soon as the main server is back up and running.

Rclone

Rclone

Rclone is a command-line tool which can manage files on your cloud storage provider. It supports over 40 cloud storage products like Dropbox, Google Drive, pCloud, and much more. However, it also supports standard transfer protocols like SSH. It is like rsync, but with cloud support.

I use Rclone to backup configuration files and data from my home automation server to my local backup server and to cloud storage provider.
In case there is a disk failure, I will be able to restore my local backup server. However, if I will have some serious bad luck, I still have a backup in the cloud.

Usability

Heimdall

Heimdall is a good-looking dashboard for web applications. In my case, it is like a start page for the home automation server. It allows me to easily open other applications installed on my server, without remembering their port numbers.

Heimdall Dashboard

https://heimdall.site/

Portainer

Portainer

Portainer is a container management application with the GUI. It allows you to easily manage Docker containers, which run on the server.

I run most of the applications on my home automation server as Docker containers. Docker CLI tool is very good, but sometimes it is just easier to use GUI to restart a container or to look through the logs.

Summary

This is quite a lot of applications. Most of them are not crucial for home automation to work. However, they extend the functionality, make the solution more stable or more user-friendly.

To make it easy to manage, everything is installed with Ansible and most of the applications are run as Docker containers.

Comments

comments powered by Disqus