I’ve been working on my home automation system quite a bit recently. So far I’ve automated a few things, namely my work room’s light and power, and my bedroom’s light and fan. When I get around to it I’ll be automating all the outside lights and some more power points. In this post I’ll quickly go over all the components you need for my home automation system and what they do.
The main components are:
- MQTT Broker (Server) – this is the “communications mainframe”
- Home Assistant Server – a nice interface/automation server
- Server Hardware – I use an orange pi zero
- Automation hardware – WiFi relays, sensors etc
1) Mosquitto (The MQTT Broker)
Mosquitto is an open source MQTT broker. Now the first thing to explain is what is MQTT? I mentioned it’s like a communications mainframe, well it kind of is. If you aren’t familiar with the publish subscribe concept I suggest you read up on it. However, the main concepts are you have clients that connect to a broker. (MQTT terminology in bold) A client can subscribe or publish a message to a topic. A topic might look like “sensors/kitchen/temperature”. When a client is subscribed to a specific topic, that client will receive all messages published to that topic.
This tutorial by Digital Ocean is a fantastic resource for setting up the basics of an MQTT broker. It’s a great introduction on how to set up a working broker, and how to secure it. However, I reccomend that you go one step further. See how to use ACLs and multiple user accounts to limit what topics each client can subscribe and publish to. This ensures if an account is ever compromised, the damage can be contained.
2) Home Assistant
Home Assistant is an open source, python 3 based home automation hub. They had me at open source and python 3. 😉 It is fairly easy to use but the killer feature is it’s integration. It integrates with everything! I can almost guarantee if you want something integrated it already has a compatible component.
The main components I use are WeMo (curse thee belkin, I should never have wasted my money on a WeMo), chromecast, MQTT, owntracks and pushbullet. I’m still adding more when I have the time so this list will probably be out of date quickly. It’s configured with a single yaml file, which is a little annoying and will definitely get convoluted fast.
To see the ever expanding list of built in components check out this link. In my opinions its the best one out there. It also has by far the nicest looking interface, it comes with a mobile friendly web app.
3) Server Hardware
This title is slightly misleading as you don’t really need a server. I bought a few Orange Pi Zeros and have been pleasantly suprised at how well they work. In Australia, I could get 2 for a similar price as a single raspberry pi zero. The raspberry pi is also only available in quantities of one at the moment. But the main reason I like them better for this purpose is the full size ethernet and USB port on board, and the built in WiFi.
The full sized ethernet port is a big plus, makes it so much easier to work with. However, with great price comes terrible software support. I didn’t feel that comfortable with a dodgy looking baidu cloud/google drive link for the operating system. I ended up trying it on only to find out it wouldn’t boot from any “official” image. However, armbian to the rescue! They support the orange pi zero and it booted up straight away. I could see it on my network so I went ahead and installed mosquitto and home assistant.
Here is the official armbian page and download links for the orange pi zero. I like ubuntu so that what I went ahead with. Note, neither of these operating systems contains a desktop environment so you’ll have to get familiar with the command line.
4) Automation Hardware
A couple years ago I bought a belkin WeMo for my 3D printer; I wanted to be able to turn it off when it was done and I wasn’t home. However, it’s a terrible product. Sorry Belkin, you tried, but it just doesn’t work. It’s slow, laggy and never stays connected properly. The only thing going for it is it’s price tag, oh wait I forgot it’s $70. But at least they make an api available – actually nevermind they don’t do that either. To be fair it was one of the first plug and play WiFi relays around so I’ll give them that.
My favourite piece of hardware at the moment is the sonoff by itead. It needs a bit of hacking to get going. But once you’ve loaded TASMOTA onto it they’re awesome. TASMOTA is basically plug and play; upload, configure and you’re done. Basically, you wire a sonoff in between any device/appliance you want to control wirelessly. I’m renting and have decided not to modify any of the wiring in my house because I value our insurance validity.
NOTE: Do not try this unless you know what you’re doing and you have a qualified electrician look over your work. Something as simple as mixing up the colour of the wire can cause someone in the future to shock, injure or kill themselves! (electrical standards exist for a reason)
What I’ve decided to do is buy some slampher‘s to go on my lights where they fit. You can modify the button and wire one into a blank faceplate. This means you’ve still got a manual butotn but it’s WiFi connected. For all other appliances I’m making up power boards and extension boards with a sonoff built in. This means I can plug anything in and make it WiFi connected – all without voiding my house insurance and upsetting my landlord.
Another option for lightswitches is the sonoff touch. However I don’t like it’s price tag or the fact I legally have to get an electrician to install it for me. I’d rather a slampher and DIY button for a fraction of the cost. That being said, they do look really nice.
That’s my brain dump for tonight. I’ve gone into more detail of my MQTT setup and will eventually do the same for all the other topics. (see what I did there 😉 ) Hopefully this is a good overview of all the major components needed and will point you in the right direction.