Home Assistant

Over the last 18 months or so, I’ve been running Home Assistant to automate various things in the Grumpy Household. Overall, it’s been quite a success. This post aims to dive into what I’m doing, how I’m doing it, and what I want to do going forwards. Grumps will generally be kept to a minimum, as I’m pretty happy with the way it all comes together.

The Setup

Home Assistant (HA) is running on a 4GB Raspberry Pi 4, using an Argon ONE M2 case with a 250GB SSD. The case is super nice, although there were a couple of additional steps to follow to get it all working correctly. Using an SSD allows me to capture various sensor states over a longer period of time, which will let me look (at some stage!) for seasonal patterns in things like humidity levels in different rooms.

Sensor Hardware

Home Assistant has support for a huge number of different IoT sensors and devices out of the box. When choosing which ones to go for in your setup, one of the first choices you have to make is which protocol these devices should use to communicate. I chose the Zigbee protocol, as hardware for it was easily found and not too expensive, but HA has support for WiFi, Bluetooth and more. I used a ZZH USB dongle1 and have been very happy with it.

Having been in Camp Zigbee for some time now, I’m considering switching to use ZWave instead, primarily because of the transmission distance advantage that it has over Zigbee. We also have a few issues with some of the Zigbee sensors not transmitting through one of the walls of the house, which has resulted in some… workarounds2. ZWave does tend to be more expensive though, so will need to do some small experiments before going all in.

Zigbee Workarounds

One of the common HA use cases is to trigger on the change of state of a device and perform an action in response. However, for some types of Zigbee sensor (particularly things like door sensors), the state of the sensor will switch to Unavailable after some time. Unavailable might mean closed if the door has been closed for some time, but it could also mean open if the door has been open for some time (think long summer days in the Grumpy Garden with the doors open). So Unavailable doesn’t really tell you much.3

Rather than relying directly on the state of Zigbee devices like these, I use Home Assistant Input Booleans. These are simple True/False flags that don’t change state by themselves. If I have an Input Boolean called Gate to Hell Open, I modify its state when the state of the associated sensor changes to Open or Closed. If the state changes to Unavailable, the input boolean is left alone until the sensor is triggered again at some later point. You can then run your logic off changes to the input boolean instead, which is much simpler.

So What Am I Doing With It?

Sensors

I’ve got the usual temperature and humidity sensors in most rooms around the house. This is mainly for ad-hoc monitoring, I’ve yet to use it for any meaningful pattern detection on humidity levels or anything, but it’s nice to get more info from around the house.

Since we live in fear of the neighbourhood cats breaking in to steal cat food from the outside shed, we have some outside door sensors to trigger when they are opened at odd times of the day, and to remind us to close them if we’re away from home.

Plugs

Automations using plugs are quite a common use-case for Home Assistant. At Grumpy Manor, we use plug automation for two main purposes:

  • Automate turning devices on/off based on certain criteria. Some of these include turning off a plug at 3 in the morning if we’ve turned it on earlier in the day, to prevent excessive power usage, or to reboot the printer once a day (a bit weird but the print server sometimes loses it, so this helps it find it again.)
  • Use the plug power sensors to tell us when our dryer has finished running. If the power was up above a certain threshold for more than one minute, we know the dryer is on. When it’s been below that threshold again for more than one minute, we can assume it’s finished. (Dryers tend to pause for a few seconds from time to time, so there needs to be a time component to the check).

Lights

We have quite a few Ikea TRÅDFRI light bulbs spread around the house, and we’ve set those up in Home Assistant light groups. These groups are then set to auto-dim when the television is turned on, and will un-dim when it’s switched off. We also have a couple of Shelly 1Ls installed in a couple of light switch recesses to allow us to automatically activate sensor lights when the sun goes down, and turn off during the day, as they sometimes tend to trigger during daylight hours otherwise.

I’ve also experimented a bit with LED light strips, using some cheap strips and controllers bought from AliExpress. They all work fine, but the main problem I’ve got is that I’m still a bit clueless on how to attach these in different configurations around the windows. The typical 3M tape on the back doesn’t really seem to stick very well to the walls, which has led to them falling off4. I’ll revisit these at some point to see though, as they look quite cool at night, especially when set to glow bright Zombie Green.

Ye Olde EV

The Grumpy Household has a little electric vehicle that we got a couple of years ago. Naturally, some enterprising soul has written a somewhat hacky Home Assistant integration that allows you to trigger automations when the state of the car changes. We run a check several times each night so that if the remaining charge in the battery is at less than 20% and the car isn’t plugged in, ready to charge, we get spammed to plug it in. This has saved our vacon on several occasions when we had a big drive planned the next day.

So What Do I Want To Do With It?

This is actually the hard bit. The things listed above are the kind of low-hanging fruit that Home Assistant makes very easy to deal with. It’s harder to work out what else it can do. Reading around on the interwebs has provided a few ideas. Reading about different types of supported hardware is often a good idea to discover new possibilities too.

Alexa Integration

Hooking HA up to our Alexas is somewhat complicated due to the way that Amazon run everything (on AWS, surprise surprise). It tends to be a bit fiddly to setup - the last time I checked, you needed to setup an Amazon dev account of some sort, deploy your own AWS instance of an agent, and hook your HA installation up to it.

A simpler way is to use Nabu Casa, a paid-for offering from a company that’s run by many Home Assistant developers. Nabu Casa allows you to hook your Alexas up to HA with a couple of clicks, which is very appealing. The cost is relatively minimal, so is something that I’ll give a shot at some point soon.

Remote Locking

This is where things get interesting. NFC-based locks that are controllable by Home Assistant would be incredibly useful if you forget to lock the doors when you’re driving away. It also leads to super funky possibilities like embedding an NFC chip in your hand and using that to unlock doors, so you never forget your keys.

The implications for this are potentially far reaching though - if the power cuts out, or Home Assistant goes down, does that mean you can’t open the doors anymore? That would clearly be unacceptable, so careful research is needed. I’ll also need to be careful not to let anyone cut off my hand to break into the house, but that’s a different kind of problem…

Light Strips For The Stairs

OK, so this one isn’t particularly clever or novel, but having LED lighting on the staircase going upstairs, triggered by motion sensors, will prevent having to fiddle about with light switches while carrying stuff upstairs. The main pain point here is working out the best way to wire it all in, and how many controllers I’ll need for the light strips. Probably not too difficult overall though.

Per-Room Heating

I’d absolutely love to have per-room heating control, using Zigbee-controlled valves to interact with the temperature sensors in the room to main a steady room temperature. This looks reasonably doable, and would definitely be aided by…

Control Screens Around The House

Having small touchscreen controls around the house to control various per-room settings, would be super cool, and also a fun IoT project to get stuck into. Apparently, it’s not sensible to keep old tablets or phones turned on all year around, as it messes with the batteries, so some kind of direct mains power hookup will be needed.

MOAR Shellys

Shellys are awesome, and super flexible. Would be nice to set these up for all light switches to enable some better automations, particular around simulated home lighting when on holiday. Otherwise, if someone comes in to feed the Grumpy Pet Menagerie5 and turns off a light switch on the way out, the whole light simulation automation will fall apart.

Better Dashboards

So far, my dashboards tend to be fairly straightforward, making relatively heavy use of vertical and horizontal groups to control the placement of various sensor displays and controls. While this is, you know, fine, it doesn’t look particularly amazing.

Dashboards!
One of these looks better than the other... Can you guess which one is Grumpy?

I’d love it to really “wow holy shit, what the heck is that piece of awesomeness” me when I bring up the dashboard and have lots of information and controls in an elegant and straightforward visualisation. I suspect this will mean that I need to learn some proper Javascript and to get down and dirty with some CSS-style shenanigans, so I’m not going to jump into it straight away. But it’s definitely something I’d like to tick off at some point.

What Could Possibly Go Wrong?

Famous last words really. The answer here is “a few things, but not enough to put me off”.

Home Assistant is a very polished experience for simple sensors, but as soon as you start adding a bit more complexity to your setup, things have a habit of breaking from time to time. Thinking about it, this isn’t surprising. HA works to provide a common facade to hundreds (more likely thousands) of different devices and types of hardware. Doing this isn’t easy! Doubly so when hardware manufacturers release upgrades to their systems.

Some of the hardware integrations are implemented using relatively non-official means (the Renault integration seems to use a hardcoded API key that sometimes needs to be updated), which means that they can break without any real notice. As the project matures though, this seems to be happening less, and some of the hardware manufacturers are more supportive of HA integrations.

Some of the integrations don’t play nicely with the UI, and instead of having simple config screens, YAML configuration needs to be hacked in via a text editor instead. While this isn’t really a deal-breaker for the typical Home Assistant enthusiast6, it adds a small extra layer of complexity.

The biggest single issue itself with setting up your home with Home Assistant is… itself in a way. If the Pi running it breaks down, what does this mean for the hardware around your home that it’s controlling? Granted, all of the hardware is typically setup outside of HA first, typically using some form of app on your phone, so it acts more as a single point of control. You can always go back to using the phones apps to control the individual devices if need be.

HA can take a backup of itself each time it is upgraded (this is enabled by default), and I back these up to another machine using scp, and the images are then backed up off-site, so it should be relatively easy to restore a failed installation if things do go horribly wrong.

The other slightly odd side-effect comes from how good it is. When things start working, it’s super tempting to start extending the setup, and automating more and more things around the house. In the case of Zigbee-controlled light switches for instance, these may require existing switches to be replaced.

This may have a longer-term problem if the house you’re setting all of this up in gets sold. Buyers may be more reluctant to learn how this customised setup works, and would potentially require you to replace your shiny system with something more standard. This wouldn’t be necessary with Shellys if configured correctly, but it’s an example of longer-term issues that might arise.

Summary

Overall, setting up Home Assistant has led to some nice quality of life improvements around Grumpy Manor, and I’m definitely excited to see what else I can do with it. Expect some form of follow-up post in a couple of years detailing how far down the rabbit hole I went!


  1. ZZH stands for “zig-a-zig-ah”. Spice Girls not included. ↩︎

  2. The workaround involves Zigbee repeaters close to the wall in question, which is a bit silly as each Zigbee device is a repeater anyway! I did say that there wouldn’t be many grumps, but this is definitely one of them. ↩︎

  3. This all comes down to power efficiency. Zigbee sensors aren’t real-time, but only send updates from time to time when their state changes. Temperatures, for instance, don’t change that much over the course of 5 seconds, so there’s no point in providing updates every 10ms. This leads to better battery life. The downside is that after a while, Unavailable just means “haven’t heard from you in a while”. ↩︎

  4. It may also be, now that I write about it, that the strips aren’t really proper 3M strips but something cheaper and less reliable. Will need to investigate further, otherwise I may need to 3D print some guides to attach to the wall and run the strips through. ↩︎

  5. The menagerie includes a cat, a snake, and a 3D printer. ↩︎

  6. Let’s face it, if you got this far with a HA setup, there’s a good chance you encounter YAML in your day job. ↩︎