How to setup Home Assistant on a Raspberry Pi



Originally posted 2018-02-12 11:06:20.

What can you do with Home Automation and Why should I be interested?

google home kariongI’m assuming upfront that if you have found this article by searching then you are probably interested in home automation of at least have an open mind and would like to know how to setup Home Assistant on a Raspberry Pi.

I’ll say that my wife is not a fan at all of Home Automation and probably regrets the day that she was given a Google Home device as a work gift to all employees as it opened up a world of possibilities (for me) and became a source of annoyance for her although she does see some merit in some aspects.

With a Google Play Music Subscription (which also includes access to YouTube Red) it’s easy to play almost any music you can think of without needing to do anything other than say “Hey Google, Play Adele” and away she goes… Nice.

Google Assistant which is used alone with the Google Home App on my iPhone has out-of-the box support for quite a lot of home control equipment. For instance, it has support for the Belkin Wemo switches – WiFi switches. I first purchased one of those when I was working shiftwork and wanted my coffee maker to be on and ready to make a cup of coffee at different times on different days and I was able to program this into the Wemo. Or if we were out and about but knew we would like a cup of coffee when we got home I could use the Wemo app on my iPhone to turn the coffee maker on for us before we got home. (my coffee maker needs 30 minutes to warm up before making coffee) So when I set my Google Home up, I was able to link it to my Wemo and I could control it simply by saying “Hey Google Turn on my Coffee Maker” or Turn Off as the case may be. Nice.

Additionally, once every 4 weeks, we get up early on a Sunday morning and I can set it so my coffee maker comes on early and then turns off after we have left so I can have coffee before we leave. It can then come on again before we get home automatically. (OK so I like coffee!)

Google Home can also control some WiFi lights like the Philips Hue lights out-of-the-box too however the price of those particular lights is very expensive to say the least. So, what’s the point of being able to control lights I hear you asking? Well, here’s a couple of things I find it useful for. First, some lamps in our lounge room – we turn them on every night and using some smart lights and home automation, I can have them come on automatically at Sunset for instance or actually, I have them turn on around 2 hours before sunset. (note the time of sunset varies each day so this is not a fixed time). Also at night when we go to bed, it’s nice to be able to say “Hey Google Bedtime” and then the lights in our bedroom will turn on and instead of stumbling through a dark house, it’s lit up with these lights along the way. Then when in the bedroom and turned on a bedside lamp, I can say “Hey Google Lights Off” and it turns all the other lights off. Another feature with my lounge lights is they can change colour so if we are watching a movie for instance, I can say “Hey Google Lounge Movie” and it knows to change the colour. (even my wife like that!)

I know none of these are killer reasons however they make life a little more fun and easy.

So what lights can I use if the Philips ones are expensive?

Turns out there are a number of different lights that you can use. Xiaomi make the Yeelights and these are supported out-of-the-box by Google Home too. I purchased a couple of those when they were on special for less than $10 at Gearbest. These work well however they each individually connect to your WiFi network and use an IP address for each light which may or may not be an issue. Personally I don’t think it is desirable but some people like that. Additionally, you don’t need any additional hardware to use them and they work really well. The Yeelights however are also quite expensive if you don’t get them on special. (White are over AUD$22 if you pay full price, plus postage and I think I paid around $6 posted)

Another alternative is the LimitlessLED lights, also goes under a variety of other names, Milight etc. interestingly, I see these are almost double the price I paid for these 6 months ago. The exception is the RGBWW lights are still pretty affordable but the GU10 240v downlights are pricey and the bridge is also expensive now. The way these lights work is via a bridge which connects to your wifi network and uses only one IP address then all the bulbs connect with the bridge. I prefer this to the Yeelight approach. The LimitlessLED website is also a bit of a dogs breakfast and it can be a real struggle to work it all out and understand how to get everything working. I have previously done a blog post here on integrating these lights with Google Home and getting everything working nicely.

The LimitlessLED lights work out-of-the-box only with either a remote control you can purchase or via an app for iPhone or Android so if you have a smart phone, to make this system work, you need to buy a Bridge and the bulbs. The remote is an optional extra. One of the ways to make these work with Google Home is to use a free third-party software product called Home Assistant. That is pretty much the subject of this article.

  
  

What software do I need to use Home Assistant?

It is possible to run home assistant on a Mac or Windows or Linux computer, however bear in mind that it needs to be running 24/7/365 for it to function effectively. I know some people play around testing if it works by running it on a windows computer but I have never tried this. I have only ever run it on a Raspberry Pi and there are several ways you can do that.

The original way was to use the raspberry pi all-in-one installer which is now depreciated and unsupported and the instructions have been removed from the Home Assistant website. My blog post originally used this method. (and it was unfortunately depreciated just after I wrote that!)

The next way recommended and supported is called Hassbian. This is really a standard Raspberry Pi Stretch image with the home assistant package preinstalled. This is a really good option if you want more control of the Pi or want to run other software on the Pi in addition to home assistant. I have never used this method to install and run home assistant. I do see some pitfalls in using this method. As an example, Home Assistant uses Python and version 3.4 of python is now depreciated and soon to be unsupported in Home Assistant. The advice is to backup your configuration files and install a fresh image and then restore the configuration files. Now if you are using the Pi for other purposes, this may not be all that convenient so you could just not upgrade but then you don’t get bug fixes and new features etc. On the plus side, you get pretty open access to all the files and can sometimes fix issues without being dependent on getting a fix in the next release.

The third way, and the way I am currently running home assistant is by installing Hassio which effectively turns the system into an appliance with pretty much no access to the underlying system at all. The downside of this is that if there is a bug you need to wait for a hotfix release in order to fix it. A major release comes out every 2 weeks currently and hotfixes come out as needed (sometimes hourly). Hassio also has the major releases delayed by up to a couple of days after it is released for other platforms (like Hassbian etc)

What hardware do I need for Home Assistant?

Hassbian will run on any Raspberry Pi. When I first set up home assistant I was using a Raspberry Pi version 1B that I had just lying around. I believe Hassbian will run without any issue on one of these. When I decided to run Hassio, the minimum requirement is a Raspberry Pi version 3B. I currently have 5 raspberry Pi’s here and I generally use a Pi for a dedicated purpose. They are very inexpensive. USD$25 and I think the 2 of these I purchased recently on special only cost me AUD$35 delivered.

In addition to the Pi you will need a case of some kind. I quite like the transparent ones as shown in the picture.

The area a lot of people will have problems is with the power supply. With a Raspberry Pi v3, a mobile phone charger is just not going to do the job. The Raspberry Pi foundation recommend a 5v 2.5 amp supply. I recently purchased ond that was rated for 3A on ebay for AUD$10. It even had an inline switch. Almost all problems people have with the RPi come down to having an inadequate power supply! Be warned.

The other area that can cause grief is the SD card. The problem with SD cards is it’s like trying to nail down Jelly (jello). No one really seems to want to make any recommendations and there’s always someone who will have a bad experience with whatever you recommend and will have their own pet recommendation. Fun times! My own experience is that I purchased a 32gb NOOBS card from RS Components when I purchased my RPi3. It wasn’t cheap either. Home assistant is not ‘easy’ on SD cards as it is continually writing to and from a SQL database on the card. It is possible to use a newer MariaDB and also to have the database on an external source but I have not tried to do this. It is also possible to make a Raspberry Pi v3 boot and run off a USB stick instead of the SD-Card but I have not yet done that either. In any case, I was finding that the RPi was locking up and I could not control it at all after a day or so. The only thing I could do was to switch it off and on again and it would run for another day. Not great and I didn’t immediately blame the SD-Card. Looking at the home assistant community forum, I decided to try a card many people seemed to recommend (although some ‘horror’ stories) and I got a couple of cheap Samsung EVO Plus cards, Class 10, 1 FHD. I got 32gb cards although someone said they had better luck with smaller capacity. (like I said it’s like herding cats).

You need to be careful with SD-Cards as there are a lot of sharks particularly on eBay and it’s a fairly high chance you could get a counterfeit card. Do a google search for h2testw.exe and run that on the card. There are also search results you can find to tell you how to identify a counterfeit card. I paid only US$10 shipped for the cards I got and they test as genuine. I can also say that since installing Hassio on one a couple of weeks ago I have not had any crash of Home Assistant at all. It is running perfectly and also seems to be a little faster than with the NOOBS card.

If you have enjoyed this article, leave a comment below and let us know what you think.



Leave a Reply