{"id":1022,"date":"2020-01-29T07:25:53","date_gmt":"2020-01-29T12:25:53","guid":{"rendered":"http:\/\/www.thesmarthomehookup.com\/test_install\/?p=1022"},"modified":"2023-02-08T16:01:03","modified_gmt":"2023-02-08T21:01:03","slug":"home-assistant-beginners-guide-2020-installation-addons-integrations-scripts-scenes-and-automations","status":"publish","type":"post","link":"https:\/\/www.thesmarthomehookup.com\/test_install\/home-assistant-beginners-guide-2020-installation-addons-integrations-scripts-scenes-and-automations\/","title":{"rendered":"Home Assistant Beginners Guide 2020 &#8211; Installation, Addons, Integrations, Scripts, Scenes and Automations"},"content":{"rendered":"<p><iframe src=\"https:\/\/www.youtube.com\/embed\/sVqyDtEjudk\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<h5 style=\"text-align: center;\">Timestamp Bookmarks:<\/h5>\n<p style=\"text-align: center;\">2:30 RaspberryPi Installation<br \/>\n4:02 Virtual Machine Installation<br \/>\n6:22 Initial Hass.io Setup<br \/>\n8:55 Essential Addons<br \/>\n11:07 Adding Devices to HA<br \/>\n15:03 Scripts and Automations<\/p>\n<p>Today on the hookup we\u2019re going to take a look at the most powerful home automation platform available today, Home Assistant.&nbsp; I\u2019m going to run through some of its best features, addons that everyone should be using, and most importantly, I\u2019m going to show you how to get started right now in 2020, for free.<\/p>\n<p>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.&nbsp; 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.<\/p>\n<p>I\u2019m not going to sugarcoat it, home assistant is extremely powerful, but it\u2019s not without issues.&nbsp; 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. &nbsp;If you\u2019re not willing to google error messages and read forums to troubleshoot your installation, it\u2019s probably not for you.&nbsp; That being said, once you get your devices connected home assistant is extremely robust and dependable.&nbsp; 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.<\/p>\n<p>If I haven\u2019t scared you away yet, stick around for this getting started guide where I\u2019m going to cover installation options and instructions, the 2020 home assistant features tour, and my must have addons.&nbsp; By the end of this video I\u2019ll 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\u2026 here we go.<\/p>\n<p>At it\u2019s core home assistant is a computer program, and as such needs to be installed on a computer.&nbsp; Two years ago I think most people were installing home assistant on a dedicated raspberry pi, and while that\u2019s 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.&nbsp; A raspberry pi is still a good option if you don\u2019t have a reliable always on computer at available, but a virtual machine is going to give you more power, flexibility, and reliability.&nbsp; As far as I\u2019ve 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. &nbsp;For completeness in this video I\u2019m going to cover both basic installation methods:<\/p>\n<p>Starting with the raspberry pi installation you\u2019ll 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.&nbsp; 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.<\/p>\n<p>After installing etcher, start it and select the home assistant image file in step one.&nbsp; Plug your microSD card into your computer and select it as the destination drive in etcher, then click begin.<\/p>\n<p>Once etcher is finished you can unplug your microSD card from your computer.&nbsp; 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\u2019ll need to plug the microSD back into your computer for a few additional steps.&nbsp; 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.&nbsp; &nbsp;Next you\u2019ll create a new text file called my-network, paste the template from the home assistant documentation, and update your wireless network\u2019s SSID and password.&nbsp; Hit save, then delete the .txt part of the filename.&nbsp; Then Eject your microSD card and plug it into your raspberry pi and your installation will be automated from this point on.<\/p>\n<p>As I mentioned before, I\u2019ve 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.&nbsp; If you\u2019re migrating from a pi to a virtual machine I\u2019d recommend you follow my complete tutorial, but here are the instructions for a fresh installation:<\/p>\n<p>To start you\u2019re going to download three files: Oracle VirtualBox, the VirtualBox extensions pack, and the Home Assistant VMDK file.&nbsp; Install VirtualBox and the VirtualBox extensions pack, then in VirtualBox click on \u201cNew\u201d.<\/p>\n<p>Give your virtual machine a name and select linux as the type, ubuntu 64 bit is the default option, don\u2019t change it.&nbsp; For now, just keep the allocated ram at 1 gigabyte and press next.&nbsp; Select \u201cuse an existing virtual hard disk file\u201d and browse to the home assistant VMDK file you just downloaded.&nbsp; Whatever you do, do not start the VM at this point, if you do you\u2019ll need to start over.&nbsp; Right click on the VM and click on the system tab.&nbsp; Under the motherboard heading select \u201cEnable EFI\u201d, then under processor you can change the number of cores available for your VM, I\u2019d suggest 2 cores.&nbsp; Next in network click the dropdown and choose \u201cBridged Adapter\u201d and then select your computer\u2019s main connection under \u201cName\u201d.&nbsp; Click on advanced and under promiscuous mode select \u201callow all\u201d.<\/p>\n<p>Press OK and then click on \u201cFile\u201d -&gt; \u201cVirtual Media Manager\u201d.&nbsp; Right click on the home assistant VMDK file and choose copy.&nbsp; Press next, select VDI, and press next again.&nbsp; I\u2019d recommend you keep this file set to dynamically allocated and press next again.&nbsp; Give your new disk image a descriptive name like home_assistant_hd and hit copy.&nbsp; Close out of the virtual media manager and right click on your virtual machine again and select settings.&nbsp; Under \u201cstorage\u201d, right click on the SATA controller and select \u201cadd hard disk\u201d, select choose existing disk and navigate to the \u201chome_assistant_hd\u201d file and press open.&nbsp; Remove your original VMDK disk by right clicking and selecting remove attachment.&nbsp; 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.&nbsp; Close the virtual media manager and boot up your virtual machine.<\/p>\n<p>If you try out home assistant and end up loving it, I\u2019ll 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.<\/p>\n<p>Regardless of the method you used, when you plug in your raspberry pi or start up your virtual machine you\u2019ll need to give home assistant a few minutes to start up and download some files.&nbsp; After a few minutes open up your browser to hassio.local:8123 to access your home assistant dashboard.&nbsp; If your computer or network doesn\u2019t support mDNS you\u2019ll need to find the actual IP address of your home assistant machine by looking on your router or using an app like Fing.<\/p>\n<p>Once you\u2019ve navigated to your home assistant instance you\u2019ll be asked to create your first user.&nbsp; 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.<\/p>\n<p>After creating your username you\u2019ll be asked to add any integrations for your smart home.&nbsp; Integrations are specially configured platforms and services that theoretically don\u2019t require you to make any changes to your configuration file.&nbsp; In my experience, most of these integrations have other dependences that need to be installed or configured before using the integrations UI, so I\u2019d recommend skipping this step for now.<\/p>\n<p>After exiting the integrations configuration you\u2019ll be presented with the main home assistant dashboard, and yours will be pretty empty since we don\u2019t really have any devices yet.&nbsp; The home assistant wiki shows the all the devices that can currently be integrated in home assistant and how to get them working.&nbsp; When browsing integrations there are a couple things to take note of.&nbsp;&nbsp; The first is whether the integration can be added via the UI, or whether it needs to be written into your configuration file.&nbsp; And the second is the specific IoT class for the integration which refers to how home assistant knows the state of your connected devices.<\/p>\n<p>When at all possible I try to keep all my home automation locally controlled, this means that I don\u2019t 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.<\/p>\n<p>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.&nbsp; The part of the IoT class description is how home assistant keeps track of the state of the device.&nbsp; 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.&nbsp; Local push will give you the most reliable instantaneous results, and cloud polling will be the slowest and least reliable.<\/p>\n<p>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.&nbsp; To begin to utilize these MQTT devices, we need to install the MQTT addon.&nbsp; On the left side of the home assistant UI you\u2019ll see a button that says hassio.&nbsp; Clicking it brings you to the dashboard where you can see any currently installed addons, and whether any updates are available for home assistant.&nbsp; The next tab is where you can make backups of your home assistant instance, and after that is the addon store. &nbsp;The addon store simplifies the process of adding additional programs to your home assistant computer, and even though it\u2019s called a store, everything in it is free.<\/p>\n<p>The first addon we\u2019re going to install is our MQTT broker, which is called mosquito.&nbsp; Select it and click install.&nbsp; As with everything in home assistant, the most important thing is to actually read the documentation.&nbsp; 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.&nbsp; I\u2019m going to call mine mqttuser and make my password mqttpass, you should use something more secure.&nbsp; 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.&nbsp; MQTT is now configured.<\/p>\n<p>The next addon we should install is visual studio code, which will let me easily add entries to my configuration file to add devices.&nbsp; Select the addon, click install, then for this one we\u2019ll need to change the ssl entry in the config file to false because we aren\u2019t going to expose this home assistant instance to the internet, then click start, and check the logs to make sure everything started up properly.<\/p>\n<p>Last we\u2019ll install the samba share addon, not because you\u2019ll 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.&nbsp; Select the samba share addon, then click install.&nbsp; By default the addon is setup without a password, but I\u2019d 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.&nbsp; After adding a password in the config file, click save, then start, then check the logs for errors.<\/p>\n<p>If you\u2019ve watched my channel before you know that I also love node-red, but in the interest of time we\u2019re going to save that for another video.<\/p>\n<p>Now that we\u2019ve got all the building blocks in place, it\u2019s time to get our devices added.<\/p>\n<p>Obviously, everyone is going to have slightly different devices to integrate, but there are four main types of integrations in home assistant:<\/p>\n<p>The first type is autodiscovery, which is exactly what it sounds like.&nbsp; Some devices may be set up in a way that home assistant can automatically detect and integrate them.&nbsp; Tasmota for instance can be configured to auto discover by entering the command \u201cSetOption19 1\u201d into the tasmota device\u2019s console after setting up MQTT on that device.&nbsp; I\u2019ll be adding this light switch through autodiscovery.<\/p>\n<p>The second type of integration is one that can be added strictly using the integrations UI in the configuration menu.&nbsp; I\u2019ll be adding the Plex integration which will give me information about which devices in my house are watching which programs. &nbsp;To add this integration I\u2019ll 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\u2019ll hit sign in, give it a minute to think, select my plex server, and the integration is complete.<\/p>\n<p>These first two integration types don\u2019t require a restart and your devices will be immediately available.&nbsp; The next two will require additions to your configuration file, and home assistant will need to be restarted before your devices show up.<\/p>\n<p>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.&nbsp; I\u2019m going to add the Tuya platform integration which will add any devices from my Tuya smart life app into home assistant automatically.&nbsp; To add this integration I\u2019ll need to go to my hassio tab and open up visual studio code and click open web ui.&nbsp; Then I\u2019ll copy and paste the configuration from the tuya integration documentation into my configuration file and update the entries with my login information.<\/p>\n<p>The last type of integration is a manual integration of a device type.&nbsp; Lots of DIY projects like my MQTT blinds have custom configurations that need to be added under a device type heading in your configuration.&nbsp; Device types include things like light, switch, cover, and binary_sensor.&nbsp; Each of these device types should only have one heading and then multiple entries under them.&nbsp; For instance, if I want to add 3 of my custom MQTT blinds I\u2019d add a single heading for cover and then three different entries for each of the 3 blinds.&nbsp; 90% of the time when you add things to your home assistant configuration you\u2019ll just copy a generic template into your config file and then update any required information.<\/p>\n<p>At this point we\u2019ve added all our integrations, and we just need to check our work.&nbsp; Click on your user name in the bottom right corner and toggle advanced mode.&nbsp; Now in configuration server controls you\u2019ll have a button that says check config.&nbsp; 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.&nbsp; When the connection lost message goes away all your new devices should be added.&nbsp; Depending on your setup, home assistant may or may not automatically add these devices to your dashboard.&nbsp; But with the introduction of the lovelace interface, the home assistant dashboard is easier to use and more powerful than ever.<\/p>\n<p>Click on the three dots in the upper right, then select configure UI.&nbsp; On the configuration screen you can add new tabs, or add organized groups of devices in containers called cards.&nbsp; These cards range from things like the super fancy picture elements card, to the completely utilitarian entities card.&nbsp; 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.<\/p>\n<p>Now that all our devices are added and setup, we can use home assistant for it\u2019s intended purpose, which is automation.&nbsp; The three main home assistant tools for automation are going to be scripts, scenes, and automations.&nbsp;&nbsp; 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.<\/p>\n<p>In this quick demo I\u2019m going to set up an alert that flashes a light on and off if my daughter\u2019s kindle starts watching plex during her reading time.<\/p>\n<p>Lets start by making our script.&nbsp; I want to turn this tuya lightbulb off and on 3 times with a delay in the middle.&nbsp; In the scripts menu I\u2019ll 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.&nbsp; This turns the lights off and on twice and leaves them in the same state that they were when they started.&nbsp; 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.<\/p>\n<p>In the automations menu we want to monitor my daughter\u2019s kindle, which was added via the plex integration.&nbsp; So for trigger, I\u2019ll select state, for the entity I want my daughter\u2019s kindle, and then I need to specify a state that it changes to.&nbsp; If you\u2019re not sure about what the states would be called you can always test them in the developer tools section.&nbsp; Click on states, then find the device you are trying to monitor.&nbsp; Play around on the device and see how the state changes.&nbsp; 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.&nbsp; In this instance I can see that when plex isn\u2019t on the state is unavailable, and when plex is playing content the state is called playing.&nbsp; In my automation I\u2019ll make my trigger when the device state goes to playing.<\/p>\n<p>Next I want a condition.&nbsp; 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\u2019m going to add a time condition and put in the 24 hour format for after 4pm and before 6pm.<\/p>\n<p>Last I need an action, which is where I want to call my script from before to flash the lights.&nbsp; Unfortunately the scripts aren\u2019t called using their name, but instead using that number from the scripts URL.&nbsp; So under action just start typing script and then select the script that has the same number as the one that you just created.&nbsp; Hit save, and then test it out.<\/p>\n<p>One realization I had when making this video was how absolutely overwhelming this all has to seem to a new user.<\/p>\n<p>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.&nbsp; On youtube there are some great channels dedicated almost entirely to home assistant tutorials like JuanMTech, BurnsHA, and DigiblurDIY.&nbsp; 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\u2019s a home assistant discord channel offering quick solutions to your issues.&nbsp; Most importantly the answers to all your questions are probably in the extensive home assistant documentation if you\u2019re willing to do a bit of light reading.&nbsp; If you found this video helpful and you\u2019d like me to make more like it let me know by leaving a comment and hitting that like button.<\/p>\n<p>Thank you to all my awesome patrons over at patreon for continuing to support my channel.&nbsp; If you\u2019re interested in supporting my channel please check out the links down in the description.&nbsp; If you enjoyed this video please consider subscribing and as always, thanks for watching the hookup.<\/p>\n<h5>Links:<br \/>\n[Hassio Raspberry Pi Installation]<br \/>\nHassio Install Files: <a href=\"https:\/\/www.home-assistant.io\/hassio\/installation\/\">https:\/\/www.home-assistant.io\/hassio\/installation\/<\/a><br \/>\nRaspberryPi Wi-Fi Setup Template: <a href=\"https:\/\/github.com\/home-assistant\/hassos\/blob\/dev\/Documentation\/network.md\">https:\/\/github.com\/home-assistant\/hassos\/blob\/dev\/Documentation\/network.md<\/a><br \/>\nRecommended RasPi Version: <a href=\"https:\/\/amzn.to\/30ZIKjE\">https:\/\/amzn.to\/30ZIKjE<\/a><\/h5>\n<h5>[Hassio Virtual Machine Installation]<br \/>\nVirtualBox Install Files: <a href=\"https:\/\/www.virtualbox.org\/wiki\/Downloads\">https:\/\/www.virtualbox.org\/wiki\/Downloads<\/a><br \/>\nHassio VMDK Download: <a href=\"https:\/\/www.home-assistant.io\/hassio\/installation\/\">https:\/\/www.home-assistant.io\/hassio\/installation\/<\/a><br \/>\nInstall VirtualBox Service (start on boot): <a href=\"https:\/\/youtu.be\/vnie-PJ87Eg?t=644\">https:\/\/youtu.be\/vnie-PJ87Eg?t=644<\/a><\/h5>\n<h5>[YouTube Home Assistant Channels]<br \/>\nJuanMTech: <a href=\"https:\/\/www.youtube.com\/user\/Jfelipe83M\">https:\/\/www.youtube.com\/user\/Jfelipe83M<\/a><br \/>\nBurnsHA: <a href=\"https:\/\/www.youtube.com\/channel\/UCSKQutOXuNLvFetrKuwudpg\">https:\/\/www.youtube.com\/channel\/UCSKQutOXuNLvFetrKuwudpg<\/a><br \/>\nDigiblurDIY: <a href=\"https:\/\/www.youtube.com\/channel\/UC5ZdPKE2ckcBhljTc2R_qNA\">https:\/\/www.youtube.com\/channel\/UC5ZdPKE2ckcBhljTc2R_qNA<\/a><\/h5>\n<h5>[Facebook Groups]<br \/>\nThe Hook Up: <a href=\"https:\/\/www.facebook.com\/groups\/473812443269387\/?ref=share\">https:\/\/www.facebook.com\/groups\/473812443269387\/?ref=share<\/a><br \/>\nDrZzs: <a href=\"https:\/\/www.facebook.com\/groups\/1969622823351838\/?ref=share\">https:\/\/www.facebook.com\/groups\/1969622823351838\/?ref=share<\/a><\/h5>\n<h5>Follow me on Twitter: @TheHookUp1<br \/>\nSupport my channel: Patreon:<br \/>\n<a href=\"https:\/\/www.patreon.com\/thehookup\">https:\/\/www.patreon.com\/thehookup<\/a><\/h5>\n<p>Music by www.BenSound.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Timestamp Bookmarks: 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\u2019re going to take a look at the most powerful home automation platform available today, Home Assistant.&nbsp; I\u2019m going to run through some of its best [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2545,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1022","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"acf":[],"mb":[],"mfb_rest_fields":["title","gutenberg_elementor_mode"],"_links":{"self":[{"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts\/1022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/comments?post=1022"}],"version-history":[{"count":6,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts\/1022\/revisions"}],"predecessor-version":[{"id":2300,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts\/1022\/revisions\/2300"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/media\/2545"}],"wp:attachment":[{"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/media?parent=1022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/categories?post=1022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/tags?post=1022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}