Home Assistant Beginners Guide 2020 – Installation, Addons, Integrations, Scripts, Scenes and AutomationsJanuary 29, 2020
2:30 RaspberryPi Installation
4:02 Virtual Machine Installation
6:22 Initial Hass.io Setup
8:55 Essential Addons
11:07 Adding Devices to HA
15:03 Scripts and Automations
Today on the hookup we’re going to take a look at the most powerful home automation platform available today, Home Assistant. I’m going to run through some of its best features, addons that everyone should be using, and most importantly, I’m going to show you how to get started right now in 2020, for free.
On the hookup I cover all kinds of connected products like robotic vacuums, security cameras, switches, LEDs, and window coverings, but the one thing that all the devices on my channel have in common is the ability to connect together using home assistant to make my home a smart home. Home assistant is a free, local, open source platform that allows products from hundreds of different manufacturers and protocols to integrate seamlessly with DIY projects and homemade solutions.
I’m not going to sugarcoat it, home assistant is extremely powerful, but it’s not without issues. I was hoping to make a video that would show how much easier it has gotten to integrate all of your devices into home assistant, but after starting a fresh home assistant installation and attempting to add several integrations via the built in UI, I came to the realization that home assistant is still very much a beta product will probably never be a plug and play solution. If you’re not willing to google error messages and read forums to troubleshoot your installation, it’s probably not for you. That being said, once you get your devices connected home assistant is extremely robust and dependable. I have over 100 smart devices in my house that are connected and automated seamlessly in home assistant and very rarely need any troubleshooting or upkeep.
If I haven’t scared you away yet, stick around for this getting started guide where I’m going to cover installation options and instructions, the 2020 home assistant features tour, and my must have addons. By the end of this video I’ll have installed a fresh copy of home assistant on a virtual machine, added an assortment of off the shelf and DIY devices from different manufacturers, and created a nice looking UI as well as automations, scripts, and scenes to control my new devices… here we go.
At it’s core home assistant is a computer program, and as such needs to be installed on a computer. Two years ago I think most people were installing home assistant on a dedicated raspberry pi, and while that’s still a viable option, a significant number of users including myself have moved their home assistant installations to their personal computer, or an always on computer in their house using a virtual machine. A raspberry pi is still a good option if you don’t have a reliable always on computer at available, but a virtual machine is going to give you more power, flexibility, and reliability. As far as I’ve seen, the only downside of a virtual machine is it is slightly more difficult (but not impossible) to connect devices like zigbee and zwave adapters via USB. For completeness in this video I’m going to cover both basic installation methods:
Starting with the raspberry pi installation you’ll need a 32gb or larger microSD card, an adapter to connect it to your computer, a separate mac or PC, and of course a raspberry pi. Start by downloading the home assistant image file for your specific model of raspberry pi, as well as the etcher software that will write that image onto your microSD card.
After installing etcher, start it and select the home assistant image file in step one. Plug your microSD card into your computer and select it as the destination drive in etcher, then click begin.
Once etcher is finished you can unplug your microSD card from your computer. If you are planning on connecting your raspberry pi to your network using a wired connection you can put the SD card right into the raspberry pi and power it on, but if you are planning on using wifi you’ll need to plug the microSD back into your computer for a few additional steps. Navigate to your SD card which should now be called hassos-boot, and make a folder called config, inside that folder make another one called network. Next you’ll create a new text file called my-network, paste the template from the home assistant documentation, and update your wireless network’s SSID and password. Hit save, then delete the .txt part of the filename. Then Eject your microSD card and plug it into your raspberry pi and your installation will be automated from this point on.
As I mentioned before, I’ve moved my home assistant installation from a raspberry pi to a virtual machine a little over a year ago, and my smart home has never been more responsive and stable than it is today. If you’re migrating from a pi to a virtual machine I’d recommend you follow my complete tutorial, but here are the instructions for a fresh installation:
To start you’re going to download three files: Oracle VirtualBox, the VirtualBox extensions pack, and the Home Assistant VMDK file. Install VirtualBox and the VirtualBox extensions pack, then in VirtualBox click on “New”.
Give your virtual machine a name and select linux as the type, ubuntu 64 bit is the default option, don’t change it. For now, just keep the allocated ram at 1 gigabyte and press next. Select “use an existing virtual hard disk file” and browse to the home assistant VMDK file you just downloaded. Whatever you do, do not start the VM at this point, if you do you’ll need to start over. Right click on the VM and click on the system tab. Under the motherboard heading select “Enable EFI”, then under processor you can change the number of cores available for your VM, I’d suggest 2 cores. Next in network click the dropdown and choose “Bridged Adapter” and then select your computer’s main connection under “Name”. Click on advanced and under promiscuous mode select “allow all”.
Press OK and then click on “File” -> “Virtual Media Manager”. Right click on the home assistant VMDK file and choose copy. Press next, select VDI, and press next again. I’d recommend you keep this file set to dynamically allocated and press next again. Give your new disk image a descriptive name like home_assistant_hd and hit copy. Close out of the virtual media manager and right click on your virtual machine again and select settings. Under “storage”, right click on the SATA controller and select “add hard disk”, select choose existing disk and navigate to the “home_assistant_hd” file and press open. Remove your original VMDK disk by right clicking and selecting remove attachment. The last thing you need to do is go back to the virtual media manager and expand the size of your home_assistant_hd disk up to 32 gigabytes. Close the virtual media manager and boot up your virtual machine.
If you try out home assistant and end up loving it, I’ll leave a link down in the description with short tutorial for how to get your virtual machine to run in the background on your computer and immediately start up on boot.
Regardless of the method you used, when you plug in your raspberry pi or start up your virtual machine you’ll need to give home assistant a few minutes to start up and download some files. After a few minutes open up your browser to hassio.local:8123 to access your home assistant dashboard. If your computer or network doesn’t support mDNS you’ll need to find the actual IP address of your home assistant machine by looking on your router or using an app like Fing.
Once you’ve navigated to your home assistant instance you’ll be asked to create your first user. Users can have different languages and themes associated with them, and in the future will be able to have different levels of access and different UIs, but for now they are most just used to login to the home assistant UI.
After creating your username you’ll be asked to add any integrations for your smart home. Integrations are specially configured platforms and services that theoretically don’t require you to make any changes to your configuration file. In my experience, most of these integrations have other dependences that need to be installed or configured before using the integrations UI, so I’d recommend skipping this step for now.
After exiting the integrations configuration you’ll be presented with the main home assistant dashboard, and yours will be pretty empty since we don’t really have any devices yet. The home assistant wiki shows the all the devices that can currently be integrated in home assistant and how to get them working. When browsing integrations there are a couple things to take note of. The first is whether the integration can be added via the UI, or whether it needs to be written into your configuration file. And the second is the specific IoT class for the integration which refers to how home assistant knows the state of your connected devices.
When at all possible I try to keep all my home automation locally controlled, this means that I don’t need to be as worried about security, my devices will still function without an internet connection, and perhaps most importantly, the future connectivity of my devices will not be endangered by business decisions that are completely unrelated to me.
The four main IoT classes are described first as either Cloud, meaning a remote computer that requires an internet connection, or local meaning they communicate directly with a device or hub that is on your home network. The part of the IoT class description is how home assistant keeps track of the state of the device. Push means that any change in device state will be immediately communicated to home assistant, and polling means that home assistant will periodically contact the cloud service or device to ask for its current state. Local push will give you the most reliable instantaneous results, and cloud polling will be the slowest and least reliable.
Custom firmware like Tasmota and DIY projects like my motorized blinds use MQTT to communicate with home assistant, which as you can see uses the best IoT class: Local push. To begin to utilize these MQTT devices, we need to install the MQTT addon. On the left side of the home assistant UI you’ll see a button that says hassio. Clicking it brings you to the dashboard where you can see any currently installed addons, and whether any updates are available for home assistant. The next tab is where you can make backups of your home assistant instance, and after that is the addon store. The addon store simplifies the process of adding additional programs to your home assistant computer, and even though it’s called a store, everything in it is free.
The first addon we’re going to install is our MQTT broker, which is called mosquito. Select it and click install. As with everything in home assistant, the most important thing is to actually read the documentation. In this addon it says to install the app, start it and wait for it to load up checking the log for errors, then create a user for mqtt in the home assistant user menu. I’m going to call mine mqttuser and make my password mqttpass, you should use something more secure. Next head over to the integrations page and you should see MQTT ready to be configured, click it and check the box that says allow discovery. MQTT is now configured.
The next addon we should install is visual studio code, which will let me easily add entries to my configuration file to add devices. Select the addon, click install, then for this one we’ll need to change the ssl entry in the config file to false because we aren’t going to expose this home assistant instance to the internet, then click start, and check the logs to make sure everything started up properly.
Last we’ll install the samba share addon, not because you’ll be using it all the time, but in the event that you really mess up your configuration file, it may be the only way for you to recover. Select the samba share addon, then click install. By default the addon is setup without a password, but I’d recommend adding one since this will allow anyone who is on your home network to access your configuration files, which could include sensitive login and password information for your smart home devices. After adding a password in the config file, click save, then start, then check the logs for errors.
If you’ve watched my channel before you know that I also love node-red, but in the interest of time we’re going to save that for another video.
Now that we’ve got all the building blocks in place, it’s time to get our devices added.
Obviously, everyone is going to have slightly different devices to integrate, but there are four main types of integrations in home assistant:
The first type is autodiscovery, which is exactly what it sounds like. Some devices may be set up in a way that home assistant can automatically detect and integrate them. Tasmota for instance can be configured to auto discover by entering the command “SetOption19 1” into the tasmota device’s console after setting up MQTT on that device. I’ll be adding this light switch through autodiscovery.
The second type of integration is one that can be added strictly using the integrations UI in the configuration menu. I’ll be adding the Plex integration which will give me information about which devices in my house are watching which programs. To add this integration I’ll simply select plex in the integrations menu which will send me to the plex website to authorize home assistant using my plex login and password, I’ll hit sign in, give it a minute to think, select my plex server, and the integration is complete.
These first two integration types don’t require a restart and your devices will be immediately available. The next two will require additions to your configuration file, and home assistant will need to be restarted before your devices show up.
The third type of integration is a platform integration where many devices will be added at once by adding login credentials for a cloud service. I’m going to add the Tuya platform integration which will add any devices from my Tuya smart life app into home assistant automatically. To add this integration I’ll need to go to my hassio tab and open up visual studio code and click open web ui. Then I’ll copy and paste the configuration from the tuya integration documentation into my configuration file and update the entries with my login information.
The last type of integration is a manual integration of a device type. Lots of DIY projects like my MQTT blinds have custom configurations that need to be added under a device type heading in your configuration. Device types include things like light, switch, cover, and binary_sensor. Each of these device types should only have one heading and then multiple entries under them. For instance, if I want to add 3 of my custom MQTT blinds I’d add a single heading for cover and then three different entries for each of the 3 blinds. 90% of the time when you add things to your home assistant configuration you’ll just copy a generic template into your config file and then update any required information.
At this point we’ve added all our integrations, and we just need to check our work. Click on your user name in the bottom right corner and toggle advanced mode. Now in configuration server controls you’ll have a button that says check config. Hit that, wait and wait a bit. Assuming it comes back with no errors we can then hit the restart home assistant button and give it a minute or so to reboot. When the connection lost message goes away all your new devices should be added. Depending on your setup, home assistant may or may not automatically add these devices to your dashboard. But with the introduction of the lovelace interface, the home assistant dashboard is easier to use and more powerful than ever.
Click on the three dots in the upper right, then select configure UI. On the configuration screen you can add new tabs, or add organized groups of devices in containers called cards. These cards range from things like the super fancy picture elements card, to the completely utilitarian entities card. Since almost everything that happens in my house is handled automatically, or via voice assistant, I almost never look at the UI and prefer the simple entities card, but if you want to have a tablet driven smart home the ability to create a beautiful custom UI is definitely there.
Now that all our devices are added and setup, we can use home assistant for it’s intended purpose, which is automation. The three main home assistant tools for automation are going to be scripts, scenes, and automations. Automations allow you to select triggers and conditions to perform specific actions, scripts tie a series of actions together, and scenes will save the current state of several devices to be able to recall them later on.
In this quick demo I’m going to set up an alert that flashes a light on and off if my daughter’s kindle starts watching plex during her reading time.
Lets start by making our script. I want to turn this tuya lightbulb off and on 3 times with a delay in the middle. In the scripts menu I’ll name my script flashLights, then for my first action I want to call the service light.toggle which will toggle the state of the lights. Next I want to add a 2 second delay, then I want to toggle them again, another two second delay, another toggle, and another 2 second delay and another toggle. This turns the lights off and on twice and leaves them in the same state that they were when they started. Go ahead and click the orange button to save and then take note of the last few digits in the script URL so we can add it to our automation.
In the automations menu we want to monitor my daughter’s kindle, which was added via the plex integration. So for trigger, I’ll select state, for the entity I want my daughter’s kindle, and then I need to specify a state that it changes to. If you’re not sure about what the states would be called you can always test them in the developer tools section. Click on states, then find the device you are trying to monitor. Play around on the device and see how the state changes. You can see that the plex automation not only allows me to monitor the state of the device, but also things like the content being watched, and the rating of that content. In this instance I can see that when plex isn’t on the state is unavailable, and when plex is playing content the state is called playing. In my automation I’ll make my trigger when the device state goes to playing.
Next I want a condition. My daughter is allowed to watch movies on her kindle during specific times, but she should only be using it for reading between 4pm and 6pm, so I’m going to add a time condition and put in the 24 hour format for after 4pm and before 6pm.
Last I need an action, which is where I want to call my script from before to flash the lights. Unfortunately the scripts aren’t called using their name, but instead using that number from the scripts URL. So under action just start typing script and then select the script that has the same number as the one that you just created. Hit save, and then test it out.
One realization I had when making this video was how absolutely overwhelming this all has to seem to a new user.
But the great news is that if you want to learn, there are TONS of resources available to you and lots of people willing to help. On youtube there are some great channels dedicated almost entirely to home assistant tutorials like JuanMTech, BurnsHA, and DigiblurDIY. Both myself and DrZzs have facebook groups full of thousands of home assistant users who have probably seen and dealt with every problem that you could ever throw at them and there’s a home assistant discord channel offering quick solutions to your issues. Most importantly the answers to all your questions are probably in the extensive home assistant documentation if you’re willing to do a bit of light reading. If you found this video helpful and you’d like me to make more like it let me know by leaving a comment and hitting that like button.
Thank you to all my awesome patrons over at patreon for continuing to support my channel. If you’re interested in supporting my channel please check out the links down in the description. If you enjoyed this video please consider subscribing and as always, thanks for watching the hookup.
[Hassio Raspberry Pi Installation]
Hassio Install Files: https://www.home-assistant.io/hassio/installation/
RaspberryPi Wi-Fi Setup Template: https://github.com/home-assistant/hassos/blob/dev/Documentation/network.md
Recommended RasPi Version: https://amzn.to/30ZIKjE
[Hassio Virtual Machine Installation]
VirtualBox Install Files: https://www.virtualbox.org/wiki/Downloads
Hassio VMDK Download: https://www.home-assistant.io/hassio/installation/
Install VirtualBox Service (start on boot): https://youtu.be/vnie-PJ87Eg?t=644
[YouTube Home Assistant Channels]
The Hook Up: https://www.facebook.com/groups/473812443269387/?ref=share
Follow me on Twitter: @TheHookUp1
Support my channel: Patreon:
Music by www.BenSound.com