Installing And Running Home Assistant In A Docker Container, What You Need To Know! (How-To)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's going on everyone welcome back but also if this is your first time here welcome today i will be continuing my home assistant install series by installing home assistant in a container now when you hear container you probably think docker but docker isn't the only container tool available to us there are alternatives such as rkt pronounced rocket linux containers and openvz to mention a few having said that however in this video i will be utilizing docker docker compose and portainer but i wanted to let you know that there are other tools available the primary reason for making this video is because some single board computers such as raspberry pi's are difficult to obtain right now and you may simply want to experiment with home assistant without investing in separate hardware however with this type of installation we are going to have to manage all of the upgrades the os and add-ons that we install as well as their data for backups and all of this is achievable but it's a little bit more involved so if this seems interesting to you let's go all right so before we begin i will say that the simplest way to use home assistant is with the full-fledged os as much of the software management is automated into the back end and using a supervised install comes in second because you only have to worry about maintaining the os software but that is not why you're here so we're left with container and core and each of these come with a greater barrier to entry as many people are hesitant to install these because you're going to have to handle everything yourself but it's not as horrible as you might imagine so let's go through with what we're going to have to deal with when we're doing a container install approach so as we can see with the container we are not going to have supervisor we are not going to have the add-ons and we are not going to have backups as well supervisor will not be managing our os for us the supervisor component is a program that controls home assistant installation it also helps with installing and upgrading home assistant and any add-ons you've loaded and of course the supervisor itself the add-ons allow you to enhance home assistance capabilities by installing additional apps that home assistant can integrate with such as mqtt broker node-red grafana and so on backups well this lets you save your home assistant instance called snapshots any add-on data configuration files ssl data and media and finally the managed os is simply the host os of home assistant that uses docker as a container engine but it's not based on a standard linux distribution such as ubuntu but it is built with build root and is optimized to run home assistant which supervisor takes care of as well okay i'm sorry but for this video i am going to assume that you already have docker docker compose and pertainer installed as adding this to the video is going to make it longer than i'd like but i have included the links to install these various pieces of software like docker docker compose and portainer in the description below so once you have those three items installed for your specific operating system come back to this video and continue on all right so in this video and most of my other videos i do do research before doing these videos and tests to make sure that everything can kind of go as smoothly as it can and all of this that i'm about to do can be done from the command line but i prefer to demonstrate it to you graphically because it's a lot easier to understand than just typing a bunch of commands and i chose these containers for home assistant because i believe they will provide a very similar experience to utilizing the full-fledged os version so to get an understanding of what containers i'm talking about if we go over to my github page and look at the docker compose file the containers that i have chosen obviously his home assistant but visual studio code a mosquito broker esp home and zigbee to mqtt for demonstrating zigbee devices so our first step is going to be to establish a new stack in portainer where we will use this docker compose yaml file to define the containers we intend to use we're only going to have to make a few changes to this file before we deploy and that's going to be our path to our configs in our volumes and essentially what this does is we're mapping a directory on our host computer the computer that you're going to be running this off of on the outside of the container to a container directory inside and that's what this semicolon represents so basically what we're doing is moving the persistent data outside the container which is going to allow us to update upgrade or delete our containers without losing the settings or configuration for those containers so i'm going to quickly add this in to give you some insight and if you use any form of linux or if you just ever wondered about the directory structure of linux there's more information that you ever wanted to know if you just search the term file system hierarchy standard so you search that term out you will see what the file system is meant for which will explain everything so when we install software on a linux machine it is classified as an add-on application software package or optional and it should reside in the slash opt directory as we can see here but this is going to add a lot of extra steps for us because we'll have to start messing around with file and folder permissions both inside and outside the containers and i won't be going that depth in this video so just simply select a directory which you already have permissions and if this is going to be your permanent installation just make sure that the location you choose makes sense all right enough nerd talk let's get on with it so we're going to copy this docker compose yaml file and when we go over to portainer we're going to go to the stacks icon which is this one here and then we're just going to add a stack and i will name this home assistant since that's what we're going to be deploying and then we just go ahead and paste that in now i've already updated my volumes the path to my configuration where i want everything to be stored but there is one change that i want to make to vs code because i want to have access to all of my containers configs so i'm just going to remove the home assistant folder and use the docker folder which for me is the root directory in which all my containers are going to be installed off of so once we have those changes made and everything in there we can go ahead and deploy the stack now since i have already downloaded the images this is going to go a lot faster for me than it will for you because it will have to download each of those containers and then install them so now we can see the stack has been deployed and we can see all of our containers running with the exception of mqtt so there's one more thing that we have to do to ensure that this mqtt broker works properly for us if we just want to see what the error is if we click on logs here we can see that it's missing this mosquito.com file so we're going to have to create one and add it into this directory so if we go back over to my github page i have included the projects mosquito comp dot file but it's a pretty large file and you don't have to have all of this stuff in here it can be stripped down to at the top here if we click on this and look at the comment it can be stripped down to just this so i'm just going to copy this out and then i'm going to go into my docker directory and into mosquito and into the config and here we have to create a comp file so let me make this bigger for you can see you can see what i'm doing all right so now we can see we have a blank comp file so let's go in and edit it and then we'll just paste in what we copied out of the comment of the conf file there may be other settings that you want to have for your mosquito broker this is the minimum that i found to get it working it's going to listen on port 1883 persistence is true and that data is going to be stored in this folder on of the container which we map to in which we map to in our stack right here and we also map to the mosquito log folder as well and there's the log folder we're going to allow anonymous mosquito users to connect and if you want you can go through the process of putting in a password file so now we will just exit out and save this file and now we can see that we have a mosquito conf file so let's go back to our pertainer stack and select our mqtt container and hit restart and now we can see that it is running all right now that we've deployed our container successfully and looking in portainer here it does look like everything is functioning but we do have a few things to do in these containers yet which we will handle as we encounter them for now let's move on to the home assistant onboarding so we can either type in this ip address and the port or we can just click on the publish port here and it'll bring us to that so here's the home assistant onboarding so we can just go ahead and give our username and password information and create our account this section is pretty simple we'll just as i said simply enter your details for your new instance select your home location your elevation time zone unit system currency if you want and then hit next and then choose whether or not to share anonymous information with the development team this is going to allow them to provide support for any integrations or faults that you may face because it gives them all of that information so that they can work on those bugs in my opinion i would answer yes to this because they will never know who the data is coming from and it fits with the open source philosophy all right welcome to home assistant so the first thing we're going to do is we're going to enable advanced mode so we get more options for our administrative user so just click on your name down here and if you want to see that you just click on here and it'll expand it out so just click on your name and then scroll down to advanced mode and just turn that on so now what we have home assistant installed but what do we do now given we have no access to anything other than what we see we don't have the add-ons remember and what happened to the containers we deployed where are those i don't see them well all the containers if we go over to portainer we can see them here and all we have to do to load them up is simply click on the publish ports and we will see them there's esp home opened in a new tab and if we open vs code actually i could see that we've made or i've made a mistake so i'll just correct that the port that we have to map and i'll make sure to change it on the github page should be 8080 so after we do make a change to our stack docker compose file we just scroll down here to update the stack and once that updates then we should be able to load up our vs code perfect so we get this error because we're just running and not secured but that's fine because it's just on my local network and no one else has access to it so one of the first things we're going to need to do is have the ability to modify our config in the home assistant folder under the configuration.yaml we can see that if we try to make any changes and save it we're going to get an error that's telling us that we're unable to write to this file it's permission denied so we'll just discard that basically what's going on is in the container the user is not authorized to save files to our home assistant directory so let's go into the container and fix that so in pertainer what you can do is you can click on vs code or under the quick actions we can open up the exact console window the command that we're going to use is a bin bash everything else we just leave default and hit connect so in order to change the permissions to the folder where our home assistant config is we need to first know who's the username or what's the username so just type in who am i and i'll just make that a little bit bigger for you we just type in the command who am i and it'll tell us the user so in this container the user is coder so we're going to have to give coder folder permissions for our slash config folder so in order to give those proper permissions we're just going to use the command sudo tone dash capital r the user name which is coder and the folder we want to give these permissions to which is going to be slash config and then just hit enter so now we can disconnect and if we go back to our stack and open it and go to our homeassistantconfiguration.yaml and then try to make the same changes if we hit x it now is allowing us to save those changes perfect but i don't really want to go to pertainer every time and load up in a new tab the different things that i want to use as i mentioned we want to try to make this as much like the full-fledged os as we can so if we look into some of the integrations that they have provided us and we go into the front-end configurations we can always do a custom panel in which we can provide the urls and then our software is going to sit here for us to click in but i like the side panel so if we look at the integrations we can get that from the iframe panel and the iframe just allows you to add as it says panels to the home assistant front end and they're in the sidebar so if we go into our configuration.yaml vs code and if you did close it remember you can open it just from clicking this publish port and back in my github repository i do have the homeassistantconfiguration.yaml and what we're going to add is this first part here which is the iframe panels so we will just paste that in and as we can see it needs the ip address of the various things that we want to put in our sidebar so if we go back to pertainer we can see the ip addresses that we're going to use so for pertainer in order to get that ip address i'll just have to jump out of the stack and go to the containers list and we can see it here just copy that and paste it in for vs code we can go ahead and just type 0.0.0.0 it's going to be running on port 8080 and esp home you can do the same and actually because we have two that are running on port 8080 we will have to give it the ip address of one of them so we will give it the ip address of the zigbee2mqtt and then we will hit the x to save it and then if we go into our actual home assistant instance we made a configuration change so we go into our configuration settings check to make sure that we haven't messed anything up and then restart so we'll just wait for home assistant to restart and when it restarts we should see some nice icons beside us here well would you look at that now we're starting to get somewhere it's starting to look like the same capabilities as the full-fledged os and so the last few items that we're going to need to worry about are our mqtt broker and a few device port mappings and now that we have access to pertainer vs code the zigbee to mqtt add-on and esp home add-on we can go ahead and close our additional tabs because as we can see within home assistant now we can get that same information i'm just going to minimize some of these and same with home assistant to expand it out you can expand out pertainer to see what everything is so this is perfect so if we go back into our stack you see everything is running with the exception of zigbee to mqtt and let's see why that is well we can see that we don't have an mqtt broker to connect to so let's fix that if we go back over to our github repository we can see we need to add in a few details for our mqtt and the other thing we have to do is add a user for mqtt so if we go over to people and zones and users we're just going to add a non-admin user you can name it whatever you want i'm just going to use mqtt user like i have in all my past videos give it a password and then hit create and then back to configuration devices and services because we do have an mqtt broker container running we just have to set it up in home assistance so search for mqtt and we need the ip address of our mqtt broker so i'm just going to duplicate this page it's going to ask me to log back in so i'm going to go to portainer and go to the containers and see that mqtt is running on this ip address so we just have to enter that ip address in give it our username and password which we chose and perfect we have mqtt now so if we go back to portainer go back into our stack home assistant stack scroll down to the containers and check out our log we can see that it's actually trying to connect to this ip address and that's coming from the container itself so we're going to have to change the zigbee to mqtt configuration.yaml file in the container and this is part of the reason why i wanted to be able to nvs code make changes it is not allowing me to connect okay so back to our containers and open up vs code in a port ah i can see that it wants to run on eight four four three so in our configuration.yaml we're actually going to run our vs code on port 8443 and save it close this and with all configuration changes we do have to restart check to make sure it's valid and then restart and now we should be able to access our vs code within home assistant perfect and here we can see we still have access so as i was saying if we look at the zigbee to mqtt folder see another configuration.yaml and there is a bunch of stuff in here that we can make changes to and this is where it was getting that local host ip address from so we just have to provide it the ip address of our mqtt instance now there are a couple other things in the github repository if we look at the zigbee to mqtt configuration we're going to want to add in the front end and you can just copy this whole thing verbatim if you'd like but i'll just copy the front end and make the changes in here so the home assistant integration we want to set true and we want to give it a front end a web gui which we can use so we can close that so now we can see that each of the containers is now accessible in-home assistant on our sidebar and to take it one step further for the zigbee to mqtt i will just set a device to pairing and we'll see what happens and we can see we have a temperature sensor we can edit this to change it to whatever we want this is an acara temperature sensor let's call it cara sensor and update the home assistant entity id now if we go back to our overview we can see that the sensor data has been added to our home assistant instance and it is picking up the temperature in the room that i'm sitting in with all the computers running in here it is a little warm all right well this is where i'm going to leave you in the video i hope that i have provided you with some value today i hope you like what you saw and that you're able to get your container version of home assistant up and running and if you want to add additional containers just search for those docker compose files and add them to your stack goodbye [Music]
Info
Channel: Binary Tech Labs
Views: 27,678
Rating: undefined out of 5
Keywords: home assistant, home assistant docker, docker, home assistant automation, install home assistant docker, docker container, home assistant synology docker, home assistant docker synology, docker containers, home assistant tutorial, what is home assistant container installation, home assistant container install, home assistant setup, home assistant docker install
Id: rDeA0X0_Dsw
Channel Id: undefined
Length: 27min 39sec (1659 seconds)
Published: Thu Apr 07 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.