My Home Automation setup

My Home Automation setup

I recently upgraded my smart home hardware, and I felt like writing a post describing my current setup to serve as inspiration for those wanting to get started or just interested in home automation in general.

The Software

I use Home Assistant OS like many others. The way I like to describe HA is that it's an Alexa on steroids. With an Alexa, you buy smart devices, link them with the Alexa, and then setup automations to control those devices based on conditions like time, weather, and so on. But the problem with Alexas is that 1) the devices must support Alexas specifically, and 2) the automations themselves are very limited, only allowing you to do simple things.

Home Assistant doesn't have such limitations. HA is open-source and has a thriving community, meaning you can find plugins that enable integrations for pretty much anything you can think of, and if you don't, you can build such plugins yourself assuming you have the programming chops to do it! HA is very extensible, and thus perfect for power users who want to set up complex automations or integrate unusual devices in unusual ways.

The Hardware

For a long time, my setup used to be a simple Raspberry Pi 3b and a SD card. The HA community tells you that this is a bad idea (The 3b is weak and SD cards can die if you use them too much), but in my experience this is fine as long as you don't have too many devices / automations / integrations. It's a good starting point, and it did the trick for me for a couple of years until I started wanting to do more complicated integrations.

Nowadays, I've retired the 3b in favor of a Raspberry Pi 5 w/ 8GB RAM, with a 256GB official RPi NVMe SSD and enclosed on the Argon One V3 case. This gives HA enough power and cooling to do everything that I need with ease.

Today I run the server via a wired connection, but there was a long period of time where I was running it through WiFi. The community says that this is a bad idea for latency reasons, but I never had any such issues. While the wired connection is definitely much faster, the WiFi latency never really bothered me, so I can confirm it's totally fine to run HA over WiFi if you can't run a cable to it.

For voice control, I use an Alexa. The way this works is that HA has a plugin called Emulated Hue which allows you to trick an Alexa into thinking your HA server is a Philips Hue hub, allowing you to expose your devices and scripts to the Alexa in order to make use of its voice features. But you can also pay for HA Cloud and enjoy the official "proper" Alexa integration, which I don't because I want to keep everything running on the local network.

I also have a Sonoff ZBDongle-E USB stick plugged into the server in order to drive my Zigbee devices, which I'll mention in more detail further below.

In addition to all of this, I'm using a very old generic Huawei Android tablet under my TV to serve not only as a physical dashboard, but also as a digital photo album when idle:

The dashboarding functionality itself is achieved by using Wallpanel to expose the tablet's controls to HA, while the photo album logic is handled via HA's lovelace-wallpanel custom integration. I host the photos on the HA itself. For added security, since we're talking about a Chinese Android device, I also have a special rule on my router's firewall that prevents this tablet from communicating with devices outside the local network.

Right now, I do not provide a mechanism to allow me to access my HA instance remotely as I don't want to have to worry about securing it properly, but I wanted to mention that this is perfectly possible by using the Tailscale extension.

The Protocol

Currently, I'm running a combination of WiFi and Zigbee devices, which is an alternate wireless protocol made specifically to be used by IoT devices that uses less energy and lays off a mesh network where the devices communicate with each other (as opposed to WiFi devices where everything goes through the router, thus creating a star network).

The reason I run this mix is just because I didn't know about Zigbee in the beginning. If I could go back in time, I would have the entire network consist of Zigbee devices because I think they are just better than WiFi ones overall. It uses significantly less energy (many Zigbee devices can run on those coin cell batteries), the mesh network allows you to have devices very far away from the server, and best of all: they work even when the WiFi is down.

When you buy Zigbee devices, usually the store will say that you need a hub to drive them, which they also sell. It's true that you need a hub, but it doesn't have to be that store's specific hub. When using something like HA, you can use a USB antenna stick like the one mentioned above and that will allow you to control any Zigbee device from any manufacturer via HA.

The Devices

Here are the IoT devices that I have around my apartment, excluding things that are "smart" by default like TVs and such.

Sonoff Basic R2 (WiFi)

This is a DIY WiFi switch that you hook into "dumb" devices in order to be able to make them smart and turn them on and off via WiFi. Given a bit of skill with electronics (stripping / crimping wires), these switches are much cheaper and more durable compared to buying smart lamps or smart outlets, and I have many of these spread around the apartment!

By default, these require you to expose your device to some awful Chinese cloud server. Luckily for us, you can flash these devices with custom firmware like Tasmota, allowing you to have full control of them. This also requires skills with electronics and some special equipment, so keep that in mind.

As previously mentioned, If I could go back in time, I would have instead bought a Zigbee equivalent to make things easier and better.

IKEA INSPELNING (Zigbee)

These are similar to the above, but as something that you plug directly into the wall socket instead. This allows you to enjoy the same benefits without having to mess with wires. I use these in cases where I'd like to automate something where messing with the wires would be either tricky or outright impossible.

This added flexibility comes with a price; they are much more expensive than the DIY switches. But another cool thing of these wall sockets is that they even come with sensors that measure your electrical consumption, so you can get a lot of cool data by having a bunch of these around your home.

If you'd like something that uses WiFi instead, I can recommend the Sonoff S26 R2, which is what I used before discovering this IKEA Zigbee one. Just note that they suffer from the same issue of exposing your network to some random cloud as the DIY switch mentioned above.

Broadlink RM4C mini (WiFi)

This is a WiFi IR blaster that you can configure IR commands and thus be able to create automations that allow you to control devices that require a remote control, like your TV.

In my case it turned out that newer Samsung TVs have some sort of API integration where you can control them over the web, but I used these blasters for a long time before I discovered this. This also puts your device on some Chinese cloud though, and in this case I'm not sure if custom firmwares are available.

Random IKEA IoT utilities (Zigbee)

IKEA has lots of IoT devices like buttons, remote controls, motion detectors, temperature thingies, air quality monitors, and more. They are all Zigbee and thus very easy to connect to use. I think only the button and the remote control took a bit more effort because you need to find out exactly how they work in order to build automations against them in HA, but nothing that a simple Google search couldn't solve.

Home Assistant App

Last but not least, I have the official Home Assistant app installed on several of my devices. This gives HA access to a bunch of stuff like location, battery level and notifications, which gives me a ton of potential input data for automations.

The Automations

It would be too complicated for me to explain every automation and script that I have, so I'll describe this at a higher level only. When you have all of this stuff connected to HA, you can basically do anything you want. Since automations in HA are basically Python scripts, you are limited only by your creativity. As mentioned in the introduction, if HA doesn't natively support something that you want to do then most likely someone already developed an extension for it, and if for some reason that's not the case, you can code it yourself!

Here are some of my favorite automations:

  • Adjusting the color temperature of my hall lights depending on the sun's current position
  • Automatically turning off my lava lamp if it has been on for more than 6 hours
  • Getting phone notifications when my 3D Printer finishes printing
  • Having a direct feed to the dashboard's camera, visible from any other device, like a CCTV
  • Turning off the photo album's screen when the TV is turned on, and on again when it's turned off, unless the "Time to Sleep" automation has been triggered very recently, in which case the automation should avoid turning it on again
  • Turning on / off the hall's lights based on motion, except if the remote control has been used to manually adjust the light, in which case the automation should do nothing
  • Having physical buttons around the house and assigning pre-programmed actions to them

As you can see, this is no different than coding any software. The biggest hurdle is providing an abstraction that allows HA to gather and send data to things that are not natively supported by the platform, but in my experience, even the most niche devices out there already have plug-and-play solutions developed by the community, which is amazing.