No Music - Introduction to Presence Detection In Home Assistant - ESPresense & MQTT (HOW TO) Part 1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
presence detection what exactly is it and how does it work well presence detection is commonly used in home automation to control lighting and appliances based on whether your home or a certain room is occupied there are a variety of methods for detecting presence each with its own set of pros and cons and today we'll be looking at setting up presence detection for your home in-home assistant this will be a two-part video to help keep the length to a minimum and if this seems interesting to you stick around and let's go [Music] when it comes to home automation your home must be smart enough to detect when it is occupied and at the time of recording there are already 67 integrations in home assistant that can help in this regard which are typically classified into two types those that monitor your wi-fi network and those that monitor your gps if you are watching this you know that presence detection and activity event classification are possibly the most difficult things to get working with a reasonable amount of reliability and in many cases it simply comes down to trial and error as a variety of factors are at play here there are many devices that can be used such as ble beacons wi-fi or gps on your phone and wearables like watches but they all have a few things in common they require you to carry a dedicated electronic device they suffer low detection accuracy and are prone to false alarms to get around some of this you can add these devices to a group or even add motion detectors to the mix to help with reliability but i believe the most promising option is the bayesian integration introduced in home assistant 0.53 it is derived from thomas bay's theorem and defines the likelihood of an occurrence based on prior knowledge of conditions that may be relevant to the event this youtuber may not know me because i am a new channel but it is a current and well explained video on the bayesian integration and if you want to learn more about it head over to smart home makers channel which is linked below another major challenge with presence detection is a time issue because most integrations utilize an api that only pulls devices at defined intervals this can result in you entering a dark room before home assistant even notices you are there having said all that one of the most typical detection methods will be to use your phone and the home assistant companion app so let's start there simply go to the companion apps getting started instructions which is provided below this procedure is straightforward and well explained if you accept the permissions required for location access after installing the app a device tracker and sensor entity will be established for the phone allowing these detection methods to be leveraged by home assistant via the app which also should now show up in your home assistant instance and as you can see that tracker and sensor is picking up my location and setting my status to home and we can see that in the configuration under devices and services and clicking on entities from the mobile app we're seeing my cell phone come in so let's talk about the types of trackers that we can find bluetooth will employ devices such as raspberry pi's and esp devices to scan for bluetooth mac addresses and depending on the size of your house one device may be sufficient however you will most likely need numerous devices to capture your location especially if you want to create automations for your home's various areas some possibilities include bluetooth low energy beacons also known as ble such as the ibeacon eddystone beacons or tile there are others on the market such as the beacons i'm eager to try from a company called gao rfid when it comes to wi-fi checking whether devices are connected to your network is usually the simplest approach to detect presence also wi-fi has a larger range than bluetooth so it may already cover your entire home however you must constantly have your phone's wi-fi connection turned on and you lose the option to set up automations for particular rooms unless you want to add wi-fi access points all over but that can get expensive really fast if your router is supported you may use what it already knows to determine whether or not people are home with some of home assistance presence detection integrations don't worry if your router isn't supported home assistant can still find your wi-fi connected devices in other ways one we've already talked about which is the home assistant companion app another alternative is nmap tracker nmap can directly scan the network for devices keep in mind that newer smartphones typically turn off wi-fi while inactive as a result trackers like this may be unreliable on their own ping icmp is yet another alternative which sends icmp echo requests using a ping this is handy when devices operate a firewall and block udp or tcp packets yet react to icmp requests like the android phones to be effective your devices must be configured to use static ip addresses and finally there's gps when i'm not at home i use gps on my phone primarily the google maps platform with location sharing enabled to tell home assistant where i am this enables some really powerful zone automations often known as geofencing home assistant can now detect when you're at the grocery store at school or the office and give it the power to monitor when you're on your way home and evaluate if the heating or air conditioning should be turned on before your arrival or any other routines you can think of as i briefly mentioned before there are various methods to accomplish presence detection with home assistant however using these devices individually does prove to be a bit unreliable so you can create groups to make it more powerful while providing a more consistent experience finding sensors in a group gives your system redundancy so if one tracker goes down another will still report that you are at home let's take a look at how we can get a group entered into our configuration you can do this one of two ways you can either use the file editor or the studio code server i'm going to go into it through studio code server so once you load it up just find your groups.yaml and when you're in your groups.yaml we're going to create a group the name for this group can be anything you want i'm just going to use my username this is optional but we can provide a name for that group and i forgot a space there we go and then we just list the entities that we want to track there it's picking up my cell phone i don't have any other entities installed so i will just give this example just so you have a better understanding and that's what it would look like for your groups we also touched on a few integrations used to detect presence but if you look at home assistance integrations page under presence detection you can find a number of possibilities 67 to be exact test them out and see what works for you if you are unfamiliar with mqtt check out the hookups video linked below to get a deep dive on the topic as this is going to be the presence integration that we are going to do so that said i have a bunch of esp8266s and esp32 boards lying about so i went with an mqtt room presence integration originally using esp32 mqtt room but it has since been deprecated and i've wanted to update what i've been using so i've chosen to install es presence on my lab before migrating it over to my production system if however you have a number of raspberry pi's which currently are nearly impossible to get a hold of i can highly recommend you check out room assistant either way the first thing we're going to have to do is make sure that we have an mqtt broker installed i've already gone ahead and installed this on my lab instance but for you to simply add it just go over to the configuration under add-ons and in the add-on store and you can just type mqtt and there's the mosquito broker so when you load that up yours will stay install right here go ahead and click install and just wait for it to finish installing after it has installed we will need to start the add-on which yours will say start here just go ahead and click start and then you're going to wait for it to configure you can check the status of it by hitting the log button you click here and at the bottom you can just hit refresh until it is up and running another thing you may want to enable is the watchdog so that if your mqtt broker does crash home assistant will automatically restart it for breaking changes i always leave all of my integrations auto update on off because i like to read whether or not my configuration is going to break if something has changed now that the broker has been started we need to add a new user for mqtt to use this user does not need to be an admin and there are two reserve names that cannot be used which are home assistant all one word and add-on in order to add a user we will just go to configuration people and zones and then click on users if you are not seeing the option to add a new user down here you have to select advanced mode in your home assistant profile to get there just click on your name down here and scroll down and you see advanced mode just make sure that it is selected on so now let's go back and add our user the username i'm going to choose is just going to be mqtt dash user and i'll choose a strong alphanumeric password as i said i will not make it administrator and then hit create now all that's left for us to do is to configure the new integration home assistant should have auto discovered it so all we have to do is select it and check the box to enable mqtt discovery you should have a notification here that's saying that it found a new device if you don't that's not a problem you can go back to the configuration and go back to devices and services and look for it in the integration list i'm sorry for all the integrations that you do see here there are a number of other people here and it's just picking up their devices yours won't be as crowded or shouldn't be as crowded so here we can see it's discovered mqtt so we just click on configure do you want to configure home assistant to the mqtt broker provided by the add-on mosquito broker and that is what we installed so we will just hit submit and finally we can make sure that it is working with a program called mqtt explorer if you're familiar with an api called postman mqtt explorer is very similar in that we can publish and subscribe to topics to ensure our broker is working so let's just go ahead and open that up so if you head over to this webpage mqtt explorer.com which is provided below and just scroll down to the download section install the appropriate version to the operating system that you are running now all we have to do is open up mqtt explorer so we're going to add a new connection and give it the ip address of our home assistant mqtt server the username which we put in was mqtt dash user and the strong alphanumeric password that we chose and then hit connect so now we are connected so let's subscribe to a topic we'll just call it test topic and we'll start listening we'll go back over and we'll publish to that test topic when we hit publish we should see something dumb show up down here perfect it is working this is where i leave you in this video please check out part two where i go into setting up es presence and we try out a few automations to see it working and if you've made it this far in the video i really appreciate you i hope you discovered something useful today and i'd love to hear your questions thoughts or concerns in the comment section below and i hope to see you in future videos goodbye
Info
Channel: Binary Tech Labs
Views: 6,544
Rating: undefined out of 5
Keywords: Presence, detector, sensor, home assistant, home automation, electronics, location, internet of things, pir sensor, ping, esp32, tracking, mosquitto, espressif, ble, radar, unifi, esp, home assistant raspberry pi, smart home, integration, basic install, how to, affordable, setup, tutorial, room presence, human presence
Id: VYFAjnsUC1A
Channel Id: undefined
Length: 13min 53sec (833 seconds)
Published: Tue Mar 29 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.