Mobile apps smarthome

Blogpost

The modern smarthome – A technology overview

I recently went through a big phase in my life: building my own home. And you bet it’s filled with gadgets, servers and robots. In this blog post I would like to give you a bird’s-eye overview of the technologies, products and software packages I used and the thought process behind the decisions. Hopefully it will inspire you to make your own house a bit smarter.

 

The problem with the internet of things

 

The problem that everyone that buys more than 2 smart products runs into is that every brand in the smart home industry promises the same thing: “our app controls your entire home”. This is true when you stick to that one brand for all your smart home needs, but you soon realize that a single vendor does not offer a product for all the things you may want to automate. Philips Hue controls the lights, but not the blinds and Nest controls your thermostat, but not your alarm system, etc. Before you know it, your “single app” is more like a “single folder of apps” to control everything.

“There’s an app for that” has turned into “You need another app for that” over the years. Are your front porch lights controlled by Hue, by Kasa, by Alexa? Who knows…

 

Let’s dive in

 

The first step is to define some goals for yourself. For me the list looked something like this:

  • I wanted to automate as much as possible
  • Basic functionality cannot depend on too many factors
  • I want it to be open-source where possible

 

The first point speaks for itself, it is the whole reason I wanted a smart home. I want the lights to turn on when it gets dark, I want the blinds to open automatically in the morning to help me get out of bed, etc.

That basic functionality should not depend on too many factors, is a lesson I learned along the way. It’s easy to get carried away with advanced stuff and difficult automation rules, but in the end you’re not the only one using your house. You may have kids without a smartphone or you may have friends come over to look after your pets when you are out on vacation. People without access to your smart home app still need to be able to turn on the lights.

Lastly I wanted it to be based on open-source software as much as possible. Proprietary solutions often only integrate with a very limited number of other products, if any at all. In an open source environment you can greatly benefit from community made integrations. I would dare to say the popularity of a product relies on it. Every developer knows it’s way easier to solve problems you encounter along the way if the technology is widely used.

 

Introducing Home Assistant

 

After some research I decided to go with Home Assistant. By their own definition Home Assistant is:

”Open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server.”

It boasts 51k stars on github, a release cycle that is measured in days, has over 1900 official integrations and countless more community-made ones. All these integrations make it so that your “folder of apps” can be replaced with “the Home Assistant app”.

Schermafbeelding 2022 04 06 om 14.53.02

 

 

I won’t go into detail on how to set up Home Assistant as there are few ways you could go about it. The most popular by far is to install it on a Raspberry Pi with their provided image (I went a different route as we’ll see in a minute). Installing and setting up integrations is as simple as searching for the products you wish to set up and following the installation instructions. Documentation and instructions are very comprehensive and clear.

 

 

 

My setup

 

Like every nerd should, I have a few laptops laying around gathering dust, so I decided to install Ubuntu and Docker on one of them, give it a fixed spot in the garage and call it a server. Running everything in docker containers makes it very easy to keep things separated, documented and backed up.

Other than Home Assistant, I have a few containers running that all contribute to my smart home in some way. Let’s go over some of the more prominent ones.

Unifi controller

This piece of software is needed when you are using Ubiquiti network gear. Home Assistant has an integration with the unifi controller to help with presence detection. This means I can create automation rules based on if someone arrives at home or is leaving home, e.g. turning off all the lights.

InfluxDB and Grafana

InfluxDB is a time based database that I can export certain Home Assistant measurements to. Grafana is a visualization tool that graphs out data stored in InfluxDB. This allows me to keep track of energy consumption for example. Below is an example of a few days in October 2021. Yellow is power generated by my solar panels, red is power consumed. The big spike every evening is an electric car charging. Having this kind of data allowed me to analyze if it would be worth investing in a battery.

Schermafbeelding 2022 04 06 om 14.59.31

NodeRed

Home Assistant comes with its own set of tools to create automations, but I found them to be hard to use and somewhat limiting. As a programmer I want full control over everything. NodeRed, and Home Assistant’s integration with it gives me exactly that. In my setup, Home Assistant handles all the communication with devices (e.g. an outdoor light/motion sensor provided by my home automation system) while NodeRed handles all automations (e.g. turning on lights indoors when it gets dark outside).

Caddy

Caddy is an open source web server that I use as a reverse proxy to have all things above accessible from outside my network. It is super easy to set up (just 1 configuration file with a few lines of code) and it handles all SSL certificates and authentication.

 

Tips and tricks

 

Here’s a few tips for those wanting to invest in a similar setup.

  1. Choose your products wisely. The first thing I do when I shop for new products around the house is to see if there is a Home Assistant integration for it. Some products can’t do everything through their API, while others can actually do more through their API than they can with their own app.
  2. Think about security. It’s nice to be able to control things while you are away from home, but spend some time thinking about how to secure everything. Is your setup really secure enough to allow you to open your garage door over the internet?
  3. Make your automations configurable. While creating automations, take the extra step to include an on/off switch for them. Don’t have your babysitter sit in the dark because the Home Assistant detects you are away and turns everything off. Ask me how I know.

I’m very happy with the end result I got. It’s a bit of work to get all the pieces of the puzzle to line up and communicate with each other, but the insights you can get from them are invaluable. And the fact that you can control everything in your home from your smartphone is just “cool”.

 

1580820390101

Massimo Mertens

Java Software Crafter

Massimo is a software crafter who started his career as a full stack PHP developer. After his move to Java in 2011 his focus was mainly on the backend, but with recent developments in frontend frameworks his passion for frontend has been rekindled.