What is a smart home?
Last year I bought my first smart devices for my home. It started with an Echo Dot I received as a gift. Then I bought some Philips Hue lights and I configured them to be controlled by Alexa. It was nice, but I wasn't impressed. I mean, it's nice to control your lights remotely, but it just didn't feel like I was living in Tony Stark's mansion. I know, I'm not a billionaire who can learn Thermonuclear Astrophysics over the night, but I wondered... how far can I go with my limited resources and programming knowledge? Could I create a smart home on a budget? And what does "on a budget" really mean? I'll go over these topics one by one in multiple articles because there's a lot to talk about. For now, let's talk about some basic things like...
What is a smart home?
Here's what google says:
a home equipped with lighting, heating, and electronic devices that can be controlled remotely by smartphone or computer.
I'm not saying it's wrong, but it's not complete. Remote control isn't the goal, that's just an advantage that a smart home provides. What's missing is the fact that all those devices must communicate with each other through a hub(the brain of the house), and its job is to use those devices to make our life easier, with as little input from ourselves as possible. Sounds complicated? Then let me give you some examples:
- Remote controlled lights are useful, but lights that turn themselves on when I enter a room are even better, but for this you need a motion sensor, and the motion sensor must communicate with the lights through our central hub.
- The next improvement is to turn the lights off when you leave the room, so how do you do that? You could use bluetooth to detect the devices from that room, and our hub could decide that there's no motion and there's no device in that room, so the lights should go off.
- What if you just left your device in another room and you're sitting in bed watching TV? There's no movement, there's no device, should the lights go off? Of course not, our hub could detect that the TV is on and leave the lights on.
I could go on with this but I think you get the point. A remote-controlled home allows you to turn your lights off using your smartphone, but a smart home turns off the lights for you, and it does that by collecting information from your devices and by learning your routines and preferences. Now you may ask yourselves if this means that you have to buy all your devices from the same manufacturer, otherwise, how is a Samsung TV going to communicate with a Philips Hue light, or how is a Xiaomi motion sensor going to communicate with the Philips Hue light? Don't they have different protocols and APIs? Sure, but there is a way to do it, and that is...
When I moved in, I remember that I used the Philips Hue app to turn off all the lights when I left home, and it was working great, except that I couldn't make an exception for when I left home and my wife was still in the apartment. I began to search for something that could do this, and that's when I discovered Home Assistant, an open-source app developed in Python which supports most of the smart devices that exist right now on the market. First I installed it on an old laptop that I had lying around to see how it works, and once I saw how awesome it is I was convinced that this should be the "brain" of the house. So I bought a Raspberry Pi 4 and installed it using Docker. Then with just a few clicks, I could add the Philips Hue integration, and after I configured device tracking I could write simple automations that did what I need. It's mostly YAML and JSON, and you need to understand some concepts like entities and services, so there's a bit of a learning curve but once you get past that, the sky is the limit.
Here are some pictures of my Home Assistant setup and automations, it's still a work in progress but it's enough to give you an idea of what you can do:
Take full control of your devices
The great thing about Home Assistant is not only that it allows you to add any device you want, but it doesn't need a cloud connection. That means the only point of failure is your home network connection. Do you want to know why this is a good thing? Here's why:
I used to turn on my AC every time I left the office using its manufacturer Android app, and in the 30 minutes it took to get home it was enough to cool the apartment down. However, on July 2nd there was a Cloudflare shortage, and the cloud service I was using at work was down for the moment so I decided to leave home, but guess what? The API of my smartphone app was also using Cloudflare and they too went down, so there was no way to control my AC with the app. If I had been using Home Assistant back then, I could've integrated the API of my AC with it, so I just had to turn it on from Home Assistant which was on the same network with my AC and could easily control it. But it's not all about cloud shortages, imagine that you're buying a device and in a few months/years that company goes bankrupt and its servers go down. What do you do then? Your smart device becomes a brick, that's what happens.
I should be honest here and let you know that not all devices can cut their cloud connection if you're using Home Assistant. For example, my Tuya smart socket has an API and I have to give Home Assistant my email and password for that account in order to control it. So Home Assistant sends a request to their API, and their servers contact my socket telling it what to do. If they shut down their servers, then my socket will still work but it can't be remote-controlled anymore, so this is something you have to consider when you're buying a new device.
One app to rule them all
This is my list of apps that control my devices. Now I just keep them as a backup because Home Assistant can control all of my devices. There are some missing features, sure, and that's another reason why I keep the apps. For example, I have a map of my apartment and I can select where I want to vacuum, but the Mi Home app can also show me the live position of the vacuum and what surface was vacuumed.
Adding features to your devices
Home Assistant also allows me to add missing features, one example was the device tracking that I enabled for my Hue lights, so they would turn off only when everybody left home. A better example is how I improved my Xiaomi app for the vacuum. The Xiaomi app doesn't have the notion of rooms, you can draw rectangles in the app so it knows what area you want to clean, but you can't draw over an area and label it. Home Assistant has a plugin for Xiaomi where I can set up my rooms and I can also make a routine in Alexa that starts my vacuum. So now I can just say "Alexa, clean the bedroom" and Alexa will send this information to Home Assistant which will send the bedroom coordinates to the vacuum and put it to work. Do you see how awesome is that? I can use my voice and tell it where I want it to clean, and no one else can do this with just the official app. Xiaomi eventually added this in the next version of their vacuum so if you want it you have to upgrade your device, but I got it for free!
Home Assistant has its own REST API that you can use to control everything. I actually found a nice .NET wrapper for this API called HADotNet and it's actually pretty simple to use. Using that you can create your custom dashboard or mobile app, whatever you want, and you have to use a single API instead of learning one for each type of device.
I promised that I will tell you how you can make a smart home on a budget and the first step was to understand that you don't need to choose a single brand for all your smart devices like they would like you to believe, and even more, you can add additional features to your devices if you use Home Assistant. In the next part, I'll talk about how to choose the right devices depending on your needs and you'll see that going with the most expensive ones is not always the best option.