Home Automation

Home > Projects > Home Automation

Home automation is a hobby of mine and it provides a great outlet to learn about networks, systems, and software involved. Through home automation I've learned about DNS servers, port forwarding, https encryption, Docker, and so much more.

I recently migrated from a Raspberry Pi 3 to an old MacBook I had lying around since the Pi's reliance on a micro SD card was limiting. All projects listed below are running in Docker containers on the MacBook running Ubuntu. This means everything listed below is happening within my local network and not in any cloud based service.

The Home Assistant UI for my Living Room
Home Assistant page showing graphs of different sensors in my home
An automation written in YAML

Home Assistant

Tech used: Home Assistant, Docker, YAML, DuckDNS, LetsEncrypt, Javascript

Overview

Home Assistant is an open source application designed to combine as many possible inputs and outputs of a smart home into a single local server with an attractive UI. Examples of inputs and outputs are Hue lights, smart switches, smart thermostats, various sensors, local weather, and pretty much anything else you can think of. Because this is an open source platform anyone can plug into the API of a product not yet supported. These inputs and outputs are linked together via automations which allow for complex logic that you don't get with a traditional consumer smart-home hub.


Frontend

This all comes together in the frontend which is accessible via a web UI using React. From here I can manually control any of the outputs I've connected and see graphs of connected sensors like hygrometers, thermometers, and lux sensors. This UI is extremely customizable, anyone can create a new components through JavaScript. (View home assistant interactive UI Demo)


Configuration

Automations, scripts, config files, UI control and pretty much everything else in Home Assistant is written in YAML. Using the framework built into Home Assistant YAML can do conditionals, loops, and most other basic functions of a procedural programming language.


Encryption

This web traffic is all encrypted via https with a certificate from LetsEncrypt (an open and free certificate authority). It's then accessible outside of my local network with a free domain provided by DuckDNS which points to an open port on my router.

InfluxDB and Grafana

Tech used: InfluxDB, Grafana

There's a lot of data flowing into the server from lots of different sources. To store it in a scalable way I use InfluxDB which is an open source time series database. Influx is mainly filled with sensor data, system statistics, and network statistics.

InfluxDB then connects to Grafana, an open data visualization and monitoring tool. This allows me to have quick visualizations of what's going on in my home and get alerts when something is off.

Dashboard for the AdGuard home dns server

Local Ad-blocking DNS server

Tech used: Docker, AdGuard home

Also running on my network is a dns server provided by AdGuard home. I updated the primary DNS servers in my router to point to this local server. When the router requests a URL known to be used for ads or tracking (ex. ads.nexage.com or ssl.google-analytics.com) it purposely returns the incorrect IP address to block the content. Because this is happening at the network level any device on my network will have it's ads blocked without any per device configuration necessary. It also allows me to get detailed statistics about what's happening on my network.

Messages sent to the MQTT server

In another Docker container an open source MQTT server called Mosquito is running. MQTT is a lightweight messaging protocol useful for getting devices communicating locally. Through MQTT sensors, switches, my blinds project, and many other open source things can be controlled and logged by the central server.