Remote access for Home Assistant (DuckDNS/HA Cloud)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome back to the fifth episode in the building a smart home cheaply series if you're just now joining us today we're gonna be focusing on how to get home assistant accessible remotely at this point in the series it's assumed that you now know what smart home automations are what home assistant is what it brings to the table you've installed it you've set it up and now you're interested in how to access it when you are not on your home network whether that's through your phone or through a laptop when you're at the coffee shop also apologies in advance i was kind of tired when i first recorded this video so my tonality might be a little bit off but the information is solid so hopefully that's the key takeaway here from this video as of today there are two ways to access home assistant remotely one way is super straightforward but it does have a subscription cost that money goes towards the developers of home assistant if that's something you want to support and you just want to save yourself some technical work i recommend doing option one which i'll touch on in just a second now if you're interested in option two it involves port forwarding it requires having access to your router settings and just has a little bit more leg work involved we're gonna start with option one which is the subscription model where it sets everything up for you and we'll touch on option 2 later in the video use the scrub bar below to skip to the section that you want to watch at the end of this video we're going to all still be on that same page for the future videos to come this video has a little bit of length to it that's mostly because of option number two and it's also because i thought it was important that you understood what it was that you were doing during option number two i think a lot of tutorials currently gloss over port forwarding and what's going on and i think it's important that you understand what it is that you're doing especially when it involves opening up your network to external traffic that being said i am going to break this video down into segments again using the scrub bar so if you have a little bit more of a technical background you can use the time stamps in the description or that scrub bar to skip to the parts that you find most relevant yesterday the first freeway is very simple you just log into your home assistant you go to configuration click on home assistant cloud at the top and you can start your free one month trial by clicking here essentially you'll just create an account through nabukasa which is their like partner cloud service and you'll start your free trial and they will generate this url for you to use which you can use to plug into their mobile app to access home assistant remotely or just to use when you're on the go on your laptop to access home assistant remotely the advantage of this is that it's very straightforward and it saves you a little bit of technical work essentially what i'm saying is if you're willing to pay that subscription model you're already done with this video because once you follow the instructions on this page and get your account set up and linked up you're going to be done but for people who want to cut costs or get technical with this let's get started all right before we just jump into the configuration i do kind of want to explain what we're going to do here port forwarding is essentially allowing external traffic people that aren't in your local network to access your local network and if that sounds scary it probably should a little bit using ports you can direct traffic to certain services on your local network a service being something like home assistant you probably noticed that when we were accessing home assistant not only did you have to type in the ip address of it but you also had to type in 8123 after that ip address and that is the port that home assistant runs on web traffic often runs on ports 80 and 443 by default so if i were to go to graysonadams.com colon80 you'll see that it just takes me to my website because 80 is implied when you're typing in a website domain your browser is essentially automatically putting a colon 80. okay so what about port 443 port 443 is for secure encrypted traffic which is going to be the majority of how you browse the web these days when accessing through port 443 you're using some sort of certificate which validates that the domain that you're visiting is actually the domain that you're visiting and it's trusted and that's why you get this little lock icon next to domains that you visit like google.com or facebook.com and if you click show certificate on your browser you'll be able to follow the chain of certificates that basically validates that this website is trustworthy what we're going to be doing is setting up our own certificate chain for our external home assistant url normally this would be a pretty convoluted process but home assistant holds our hand a little bit during this what is important though is that you have the ability to log into your router so that we can set up the port forwarding and also so that you can make sure that your home assistant private ip address doesn't change now again if all this sounds way too much and you're just like forget this i'm done i don't want to do home assistant anymore there is that first option and it does have a free trial and that will do everything that we're about to do here with the click of a button okay first thing you're going to want to do go to your router obviously your router's interface is going to look probably different from mine but the concept is still there what we're going to be doing is port forwarding to home assistant so you're going to want to look up the instructions for your model router on how to port forward if you want to poke around instead of googling it's probably under settings advanced or it's probably under firewall or it might be under a section that just straight up says port forwarding once you're there you're going to create this port forwarding rule and if it lets you name it just call it home assistant and you're going to port forward from external port 8123 to the local ip address of home assistant which you already know because that's what you use to access the ui so in my case it's 192 168 1.51 so we're going to be forwarding from your external ip address on port 8123 down into the local ip address of home assistant over port 8123 go ahead and apply your rule let your router reboot or let the settings take effect and then we're going to verify that this worked okay to verify that this worked you have a public ip address to find out what that is just go to google and search what is my ip copy the ip address that comes up open a new tab paste it in and just like how you access your local home assistant over port 8123 you're now you're going to use your public ip address and add a colon 8123 and then press enter okay so now it looks like i can access home assistant through my public ip address over port 8123 obviously we're not going to want to have to remember our public ip address every single time we want to access home assistant and then there's also the case that some internet service providers will rotate your ip address and it will just change sometimes which means that the url that you're currently accessing won't work at some point there's a service called duck dns which is free which lets you have a static domain name that points to your public ip address that means that you can just type out a domain name and press enter and it will automatically route to your public ip address the nice thing about duck dns is that through an integration with home assistant home assistant will notify duck dns when your public ip address changes so that your domain name points to the new ip address automatically that way you can always access home assistant through a domain name and you don't need to know your public ip address anymore to get set up you're going to want to go to duckdns.org and you're going to want to make an account when logged into duckdns you're going to see a page like this you're going to see a token right here and that's going to be important because that's what home assistant is going to use to communicate with duck dns think of this like a password and you don't want to share this you might be laughing because i'm sharing mine i'm going to recycle my token after this video so it's no longer valid the first thing you're going to want to do though is that you'll see here in the bottom there's a domains section and you can actually create your own domain that's hosted at duckdns.org now if you're thinking i'm just going to make this some sort of garbled up domain name that nobody can guess that's not a good way of securing something we're gonna rely on home assistant security to protect us from people logging in so just make it something that you're gonna remember i'm just gonna make mine graysonadams.duckdns.org once it's created duct dns will actually automatically put in your current ip address and tie it to that domain which is fine but again your public ip address can and probably will change so there's a little bit more work we need to do here go ahead and copy the token that's at the top of your page and go back to home assistant in the previous video we covered that there's something called add-ons for home assistant which extend the functionality of home assistant adding additional features that you may or may not use there are a couple of add-ons that we want to install at this point to get set up with duct dns go ahead and go to your supervisor tab and go on to the add-on store look for duck dns in the top under official add-ons or use the search bar at the top go ahead and press install go to the configuration tab at the top and for your domains you're going to want to type in the full domain that you just created so not just in my case grayson adams but graysonadams.duckdns.org replace the null text for token with the actual token from duck dns and then for let's encrypt you're going to put accept terms to true making sure that you actually read their terms which i know you will and to briefly overview let's incorrect is what will actually generate the certificate that lets your browser verify that this is in fact your dns domain and that it is actually you that is hosting it basically that's going to give us that little lock icon on your browser and that way your browser won't freak out and think that this isn't a trustworthy website when we use a certificate we're going to actually be accessing over https instead of http and the advantage of that is that your data is now encrypted and so if somebody were to try to intercept your traffic they would have encrypted data instead of the raw data which is pretty important when we're accessing something like our smart home software so once you've put accept terms to true and you've put in your token and your domain go ahead and press save now i want to try something so let's go back to duck dns and let's replace the current ip field which was automatically populated correctly to something incorrect let's make it 123.123.123.123. and let's press update okay so now graysonadams.duckdns.org is pointed to another ip address and not my home network that means that if we were to try to go there we'd be routed to something else basically i want to test to make sure that our duck dns add-on on home assistant is actually working so let's go back to home assistant go back to the info tab and press start or restart go to the log tab press refresh and you'll see that it's actively working on generating those certificates this will not work if home assistant cannot be accessed remotely so make sure that your port forwarding is set up correctly and that you could access it through your browser over your public ip address otherwise this step will fail if i press refresh one more time we'll see that the test passed and that was able to validate and create the certificates let's go back to duck dns and refresh the page we'll see that duck dns updated the ip address to be my public ip address again which means that the communication between home assistant and duck dns is working so let's try going to the duck dns url now if you set up your port forwarding to forward over port 8123 make sure you put in that port colon8123 after your dns domain name and press enter cool so now we're actually accessing home assistant over duck dns but you'll notice something your browser might say that it's not secure but we generated our certificate so why is it saying that we need to tell home assistant to now use those certificates so to do that let's go back to home assistant let's go to supervisor go to the add-on store and install the file editor enable the show in sidebar option and press start you'll now see in your sidebar file editor so go to that click the folder icon in the top left to go to the file browser and click on configuration.yaml in your configuration file beneath default config we're going to press enter twice this is going to be plain english this isn't coding so don't be intimidated we're just creating a configuration file we're going to create a section in our configuration file for the http settings for home assistant so we're going to write http colon and we're going to press enter go to the settings wheel on the top right go to editor settings scroll down and set your tab size from 4 to 2. scroll down to the bottom and press save settings locally press the tab key and you'll see that it created two spaces instead of four you could have also just pressed the spacebar twice but this will save us a little bit of time while we're writing we're going to type ssl underscore certificate colon space and we're gonna do a slash ssl slash full chain dot pem and then press enter we're telling home assistant the path where our certificates are stored on the next line also indented we're going to put ssl underscore key colon slash ssl slash p-r-i-v key dot p-e-m press the save icon in the top right go to your configuration tab on the left scroll down to server controls and press restart you should immediately see connection lost in the bottom left corner reconnecting if you don't see that there's a chance that there is an error in the file that you just edited to fix that you'll want to go to the logs tab at the top i can't access that because i'm currently rebooting you'll see the logs and it should tell you at the very top the latest error and it should explain what the mis configuration is but if you see connection lost it means it accepted the changes and it's restarting home assistant while it's rebooting i should emphasize something when you set up your port forwarding but remember that you typed in your local ip address for home assistant well there's a chance that your local ip address will also change and it was dynamically assigned to home assistant so if home assistant were to go offline from your network like be unplugged or disconnect from your wifi and get reconnected that local ip address could also change go ahead and google for your router model how to set a fixed private ip address you'll often find that under a setting called ip allocation settings for your router basically you're just going to want to make sure that that ip address does not change and that it is fixed okay so let's access home assistant again uh oh looks like we can't access it anymore and it was all part of my evil plan to lock you out of home assistant i'm kidding basically because we told home assistant to use https and use certificates we can no longer access home assistant over http so in your url bar make sure that you're putting https colon slash now i'm going to emphasize that i'm currently still accessing home assistant through the local ip address i'm not accessing it through duck dns currently when i do this on safari i'm able to access the login page on safari i'm noticing some weird issues like i'm seeing initializing but nothing's happening this is actually an issue with safari basically the certificate that we've assigned to home assistant is telling your browser to expect it to be your duck dns url so basically safari is going wait this url is 192.168 or whatever this isn't your duckdns url so safari is trying to protect you right now and it's saying we're not going to keep loading stuff because we can't verify the identity anymore chrome on the other hand will ask us hey do you want to trust this certificate even though we can't validate it so let's switch over to chrome let's go to the local ip address of home assistant again but we're going to use https now google will say our connection is not private because this certificate is not valid go to advanced and go ahead and proceed now we can access home assistant and we can log in okay so we can still access home assistant locally if we click on the not secure in chrome we'll see that it says it can't validate the certificate and if we click on the certificate itself we'll see that it's trying to use the certificates that we had just created and we'll see that those are assigned to our duckdns url which is why because your local url does not match up with your duck dns domain we're getting this issue so let's try accessing it over the duck dns url make sure to include your port and then also make sure to put https alright cool it loaded so now we're accessing home assistant externally through duct dns and it's secured with a certificate i can now log in with no issues and if i click on the lock in the top left and i go to certificate it's valid alright thank you so much for watching at this point we now have home assistant accessible remotely and through a secure url regardless of which option you went with in our next video we're going to be going over how to access home assistant through the smartphone app or ios there's some cool benefits to that like getting additional data points into home assistant information like your phone's location the battery percentage of your phone whether or not it's charging and other cool bits and pieces of information that you can use in your automations obviously with location being a pretty big one make sure to subscribe if you're interested in this series and in the next videos to come or if you might be interested in other related content that i'll be putting out on my channel see you in the next one you
Info
Channel: Grayson Adams
Views: 40,914
Rating: undefined out of 5
Keywords: hassio, affordable, easy, how-to, diy, home automations, raspberry pi, Grayson Adams, home assistant, home automation, walkthrough, guide, how to, duckdns, home assistant cloud, nabu casa
Id: 98EXFyDwe3E
Channel Id: undefined
Length: 18min 4sec (1084 seconds)
Published: Tue Aug 18 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.