Getting Started With Home Assistant - Presence Detection Including Ubiquiti UniFi Presence Detection

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Applause] hi i'm stu from hive mind automation and welcome back to the hive in this episode of the getting started series we're going to explore presence detection we'll talk about what presence detection means different ways to detect presence and what we can do with presence detection so let's get started [Music] so first of all what do i mean when i talk about presence detection well i tell you what i don't mean is shaking the gifts under the christmas tree to try and guess what your mum got you this year in the context of home assistant presence detection needs any number of methods to determine where in the world the occupants of your home are and then using that information as triggers or conditions for automations in your home assistant instance as an example of a trigger if you have presence detection set up and a zone defining your work location you can set up an automation that triggers when you leave the work zone to turn on your lights if it's after dark or even set a smart thermostat to the right temperature or push a notification to your partner's phone to ask them if they need you to stop at the shops for milk on the way home you can also use presence detection values as conditions in automations an example of this might be having an automation to turn the lights on in the morning to help you wake up a little bit like a sunrise alarm clock but including the condition that you need to be home for that action to take place there's a number of ways that we can perform presence detection but all of them do rely on a device which is always with you more often than not the best choice here is to use your smartphone one way you can do this is to have a home assistant hook into your network router to monitor when a device connects or disconnects from the network this can work pretty well but it does have some implications for devices like smartphones which can often go into a deep sleep when the screen is off and if they're in that deep sleep sometimes they might not appear on the network home assistant core has built-in integrations for many brands of network router and you should definitely check out the integrations page of the home assistant website to see if your router brand is included and i'll take a look at one of these methods the ubiquiti unifi integration a little later on in this video if your router is not supported by one of those integrations another option is using the nmap tracker the nmap truck is a pretty simple tracker that just performs a fast scan of your network to determine which devices are online and again it won't detect those phones that are in that deep sleep mode but it might be enough to trigger an automation when you arrive home another alternative is using the ping tracker which pings devices and it'll come up in a true state if they're detected on the network and a false state if that ping fails in the case of smartphones this could potentially increase your battery drainage if they're responding to pins all the time so use those alternative methods with caution another thing that you could do is track bluetooth devices and this works especially well if you're running home assistant on a raspberry pi 3 or 4 which have built-in bluetooth because every bluetooth interface has a media access control or mac address like wi-fi and ethernet interfaces we can use these unique ids to track when phones enter or leave the bluetooth range of the raspberry pi bluetooth does have a smaller range than most wi-fi networks so it's worth taking that into consideration if you've got a big house and the raspberry pi's all the way at the back you might find that you're not detected properly when you're standing at the front door the last method i'll talk about although there's many more is using gps if you're using a modern smartphone which i'm going to assume that you are if you're watching a video about smart homes your phone likely has gps built in and there's a couple of different apps that we can install on the phone to make use of this gps data we spoke about the home assistant app in video 8 about setting up the mobile apps and there's an android version of that video in the pipeline and the home assessment app adds some entities to our home assistant instance including location data there's other apps that we can use to push the gps data to home assistant as well own tracks and the android fork next tracks seem to be popular free open source apps that you can install on your device and push the location data to home assistant directly utilizing web hooks your home assistant instance does need to be exposed to the internet in order for web hooks to work but if you followed my duck dns video or my home assistant cloud video both of those linked in the description below you've already got that part under control so that's some of the ways that we can perform presence detection now let's take a look at how we set up a device tracker or two and it might be worth considering multiple methods of device tracking such as bluetooth gps and network in order to have reliable data for when a person is home or away for now let's head over to home assistant and we'll set up my ubiquity unifi integration so after we've logged into home assistant now using our multi-factor authentication thanks to that previously mentioned duck dns episode we'll take a look at the configuration menu and then integrations we're going to hit the plus button down in the bottom right hand corner and search for unify now if you're following along at home you likely won't see this unified protect item in here because i installed that add-on using hacks in a previous video i'm planning to upgrade my cctv controller in the not too distant future and when that happens i'll be filming to bring you along for the ride and we'll actually take a look at utilizing this unifi protect integration to pull camera feeds into home assistant again but i digress we'll click on ubiquity unify and you'll see that it's a pretty simple configuration once it's finished installing all we need is the hostname the username the password the port number and whether or not we're going to verify the ssl certificate now i've got my unifi controller running in a docker container on my docker host much like the unifi video controller video more on docker in a future video but you can run the unifi controller on your home assistant raspberry pi if you're so inclined just bearing in mind that it could cause some issues if you're also making use of mqtt which we'll also be looking at in a video coming soon before we enter the username and password in here i'm going to create a new user a name and password in the unifi controller and so we'll pop over to the unifi controller to do that now i've already logged into my unifi controller here and i'm going to go down to settings in the left hand side and i'm going to click on admins i want to add a new admin and manually set and share the password it's going to give the new admin a name of home assistant and i'm going to create a secure password because this is my production environment i'm going to uncheck require the user to change their password i'm not going to worry about an email and i'm going to set this user as an administrator and we won't worry about ticking these boxes here and we'll click create on that now so i'll pop back over to home assistant and i'm going to enter the host which is the ip address of my docker host the username of home assistant and the secure password that i created before we'll leave the port at 8443 and we'll leave the verify ssl certificate unchecked okay so we now have success we've created the configuration and it's found the following devices and we can assign these devices to different areas in our home we're not going to do that right now because this is all of the devices detected by this device tracker so we'll just click finish and now you'll see that we've got this ubiquity unify section here so click on this 44 devices link here and we'll see all of the devices that home assistant is now aware of because of this ubiquity unify integration so we can scroll through this device list or search for a particular device name and i'm going to search for my iphone and we can drill into there to take a closer look now this doesn't really give us too much information because we can't really allocate this to another user but what we can do is take a look at the entity details and i'm going to copy this entity id and i'm going to now assign that entity id to my person entity so i'll go to the configuration menu and we'll scroll down and i want to click on people and then i'm going to click on me in here we're going to focus on is the bottom section which is the select the devices but that belong to this person section what i'm going to do is paste in that entity id that i copied a moment ago so device underscore tracker stewie's iphone so we'll click that and i'm going to click update so now that i've done that home assistant knows that the person entity and the device tracker entity are linked so heading back over to the dashboard and you'll see that my face is here this is the badge for my person entity and if i click on that badge with my memoji on there we should see that it's listed as being home and it's based on the source of device underscore tracker stewie's iphone okay great so now what do we do with this information well let's head back to the config menu and we'll take a look at some automations that we created in a previous video on how they use presence detection either as a trigger or as a condition so we'll head to the automations tab and firstly we'll take a look at this lights on when i get home automation and we'll drill in here i might make that screen a bit bigger so we can see and if we scroll down to look closer at the triggers you'll so the trigger here is the state trigger type of person. stuart changing from the state of a way to the state of home and when that trigger occurs these conditions are validated and then the actions can occur if the conditions validate secondly if we pop back out to automations and take a look at this porch light on automation that i've created so in this automation our trigger is not anything to do with presence detection but our condition is to do with presence detection so in this case when the trigger occurs 15 minutes before sunset every day the condition becomes that person.stuart needs to be in the home zone and that brings me to the last part of presence detection that i want to talk about and that's zones we head back to our configuration menu and then scroll down and click on zones we can use this page to create multiple zones on the map so that our presence detection is extended now any zone outside of your home zone can only really be triggered by a gps but based presence detection method such as the home assistant mobile app own tracks or one of the many other gps based this means that we can set up a zone for work a zone for home zone for the kids school the zone for the gym zone for the in-laws house and the list goes on and then if we've set up these zones and we're using gps device trackers we can trigger or condition automations based on those zones such as when i exit the work zone after a certain time of the day and the outside temperature is below 10 degrees nobody else is at home and the inside temperature is below another threshold we can set the thermostat to 20 degrees so i don't come home to a freezing cold house another example might be if you've got kids you could set up an automation that sends a notification to your phone when they leave school and another when they get home from school so you have some peace of mind about the whereabouts of your kids the last example i'll give with presence detection is something i'll cover more in a future video and that is one that i use all the time and i don't even have to think about it anymore and that's arming and disarming the alarm system automatically based on presence so if i'm the last person to leave the house the alarm system will automatically arm itself in a way mode and if i'm the first person to get home the alarm will automatically disarm itself it works so well that i actually forgot that it was a thing until i was preparing the video for this script so that's my take on presence detection in home assistant i do hope that this video has been helpful for your home automation journey and tell me in the comments section down below how you plan to use presence detection in your home automation setup and if you ask really nicely i might even do another deep dive video on some of the other presence detection methods maybe bluetooth nmap or some of the other gps options obviously i won't be able to deep dive many of the other network methods because i don't have all those router types but i do recommend referring to the documentation on the home assistant website if you need help thank you so much for watching i'm stu from hive mind automation and i'll see you next time
Info
Channel: Hive Mind Automation
Views: 3,502
Rating: 5 out of 5
Keywords: smart home gadgets, GPS Location, home automation ideas, home gadgets, smart home tech, Home Automation, smart home, OwnTracks, HomeKit, Ubiquiti Unifi Controller, Raspberry Pi, Smart Home, Bluetooth, Presence Detection, Home Assistant, ultimate smart home, smart home automation
Id: md6klpH1IYQ
Channel Id: undefined
Length: 15min 27sec (927 seconds)
Published: Sat Nov 21 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.