Dipping My Toes into Home Automation
I’ve long followed the videos and episodes of Jonathan Oxer of SuperHouse, and decided to design my first true automation system around his design ideas. This project describes the basic setup of the automation system I setup and explored, and replaces the dabblings I’ve had with EmonCMS in the past (See the One-wire Project).
Jon is big on the use of MQTT for transport, having developed a lot of his own hardware before it was easily available (especially so in Australia where he is located) and standardizing on the protocol for its general and flexible nature. I wanted to base my system around MQTT as well, using Node-Red to perform logic and bridge sensor inputs with command outputs. The complete software stack that I ended up choosing is as follows:
- Mosquitto MQTT broker
- Node-Red Automation Server
- InfluxDB 1.8 Timeseries Database
- Grafana Visualization
- Telegraf Data Collector
Testing the Software⌗
I started off with a virtual machine running Ubuntu 18.04 Bionic in VirtualBox on my workstation. This let me experiment with setup of the integration between all of the components, get them talking to each other, etc. with easy roll back ability in VirtualBox. VirtualBox is the only virtualization platform I’ve used as of yet, since my former FreeNAS server (now running bare Ubuntu 18.04) is not powerful enough to run something like Proxmox with decent performance in the VMs.
I settled on a number of design decisions overall:
- All data goes through MQTT at some point
- Data direct from sensors (unprocessed) goes into the /raw topic header (which is not logged into Influx)
- Data which has been processed goes into a better topic like /climate or /energy
- I don’t have any outputs yet, other than email notifications, so there are no topics for output yet
- Node-Red transforms data by subscribing to MQTT topics or reading the data directly and writing the data to MQTT for use by other flows
- Telegraf captures all ‘good’ MQTT data and logs it to InfluxDB
- Grafana reads all data from the InfluxDB captured via the MQTT collector and displays it
- I thought that Node-Red could potentially have reliability issues, and wanted to make sure that the setup would work with just Mosquitto, although I quickly found out that Node-Red is in fact very reliable.
Installing the Software⌗
Once I had tested the software, I started learning how to use Linux Containers. I spun up an Ubuntu 18.04 VM and tried my hand at creating, destroying, and managing containers using LXC. Most of the way through this process, I finally learned the difference between LXC and LXD (’new’ Linux Containers), but stuck with ‘old’ LXC since I’d picked it up already by this point.
On my very low power AMD Bulldozer-based file server, I created my first ‘production’ container on the ZFS pool, named ‘Telstar’ after the first communication satellite in space. In many ways, MQTT is like Telstar, in that it takes signals beamned to it and sends them right back out witout interacting with the payload.
Update Summer 2021⌗
At this point, Telstar has been very reliable and collected data for over a year. As I start to transition from Telstar to Home Assistant, I continue to keep critical infrastructure in Telstar, including Mosquitto. I am not sure if I will ever completely migrate off Telstar, although it may be required when I eventually migrate off bare Ubuntu back to TrueNAS for the storage server. It’s extremely difficult to migrate years of data stored in Influx to a new naming convention, so I may have to backup the data and start fresh, and I’m not looking forward to that. I’ll update this page again if anything new happens with Telstar.