4 Simple Ways to Setup Smart Home Presence Detection

Updated on 3rd Dec 2020 16:18 in General, Home Assistant, Smart

Smart homes have many various features that work together to create a better living experience. Wouldn't it be amazing if your home could greet you as you arrived with any action you desired? This is possible with presence detection, which helps identify who is home and who isn't. What actually is presence detection? How does it work? Why is it important? How can it be used? These are all questions we will answer in this post.

Smart presence detection

What is smart home presence detection?

A smart home consists of many inputs and outputs. Inputs can either be your direct commands or the value of a sensor at a given time which triggers an action. Outputs are the various actions the controller can take, such as turning on the lights or setting the thermostat to a specific temperature setpoint. That same thermostat is a common input most will be familiar with, as it provides the current temperature and accepts commands to turn it on or off. When it comes to automation, it would be great if there was a way to identify who is home, such that different actions can be taken.

Luckily, this is possible thanks to presence detection, which seeks to give the smart home controller a way of knowing who is home and when. In some cases, it can even be used to determine who is in a specific room! Although it can be done, detection inside the home is quite complicated, so we won't spend too much time on that. The important is to know that it is possible and that we will see at least one method of doing so, with varying degrees of accuracy depending on a lot of factors. 

How does presence detection work?

Depending on your specific smart home controller, there will be a long list of ways to perform this task. There are far too many to go over the specifics of each, so we will instead look at Home Assistant, which probably has the largest selection of ways to do this. Some of the methods we will see won't work for every platform, but it is still good to know about them in case you want to build a DIY solution.

Smartphone

Perhaps the easiest method is using each person's smartphone to identify their status. In fact, as we will see, most of these methods involve smartphones in some way. There are some ways around that, but this method involves installing software directly on the phone that will periodically report its location. For example, in Home Assistant, there is the iCloud plugin which will use the Find My service to locate the device and determine if it is home. Another example is the Home Assistant app, which reports its location whenever it is open. With SmartThings, the documentation indicates the app will do a similar thing by reporting the location of the phone it is installed on to the hub.

There are benefits and drawbacks to this method, though the biggest drawback is that software must run on each individual's phone for them to be tracked by the system. This may be seen as intrusive and also won't work if for some reason you can't install things on the person's phone. Imagine the case of a child that may not want to be seen; they could easily deactivate the app, rendering this technique useless. Of course, never install anything on devices you don't own or do this without the permission of the owner of the device! As a result of these issues, this solution could be somewhat inaccurate despite being the easiest to set up by far.

A smartphone can send its location to a smart home
An app can report each person's location periodically.

Network scanning

Scanning is more complicated than other methods as it requires some amount of networking knowledge to get going correctly without too much hassle. The way it works is rather simple: software running on the controller will periodically scan the local network looking for certain devices. If it sees that device A is connected, it will mark the owner as home (or wherever the network is located), allowing automations to run with that information. The scanner can do this because, on any given network, there are only so many IP addresses that can exist (256 for most basic home networks). A scan will then try to connect to every address, marking the device as online if it responds and offline otherwise. Overall, this method works fairly well for most simple applications.

Problems will quickly start accumulating for more complicated setups because most smartphones will turn off their WiFi antenna when they are idle to preserve battery life. That means that unless you have really lucky timing, the scanner will most likely ping the phone while it is idle, which will make it seem as though the device is offline. You may be wondering phones get notifications or messages while they are idle then? The answer is simple: they periodically connect to the WiFi to see if there is any new information. The periodic nature of this makes it challenging to catch a phone online though, as your scanner would need to be constantly running to have any chance of connecting during the few seconds the phone is active. Running it constantly would both seriously drain the resources of the smart controller and overload the network.

Scanning the network for online devices
Scanning the network to see which devices are online

Router client list

Those with networking knowledge are likely screaming "the router!" right now, and with good reason! If you are the owner of a network, be it WiFi, wired, or both, you will necessarily know who your clients are. This is by far the best method of "home" presence detection as it is accurate, simple to perform, and doesn't feel like you are invading each person's privacy while doing it. Every router worth its salt will keep a list of active clients, which is easy to do as it needs to know this information to do its job. This list will contain the MAC address of each device, along with a friendly name (in most cases, some devices don't give away their name). The names will likely be displayed as "Rob's iPhone" or something along those lines. 

Once you get the MAC address of those which should appear in the presence detection, it is as simple as using a sensor called "device_tracker.friendlyname". In Home Assistant, this sensor will then display "Home" or "Away", depending on if the device is in the router's list. The reason that this is one of the best methods is that the router will need to know that the phone has come out of idle mode because it will be the one who fulfils the request to fetch information from the internet. As a result, the router client list will usually contain all devices that are currently home, with a lag of say 15 minutes for when they leave to account for possible extended idle time. The benefit with this approach is that there is no tracking if people aren't home, and it is impossible to turn off as the detection is performed at the router level.

The router client list, where we can see who is connected
An example list where we can see who is connected via the router

Bluetooth tracker

A good way to detect presence more granularly, such as if someone is in a given room, is to use a Bluetooth tracker. The way this system works is that it will periodically check for the presence of a Bluetooth device. Evidently, the range of Bluetooth is far smaller than that of WiFi, which allows the detection to be more localized. This same advantage is also the biggest disadvantage though, as you will need a lot of Bluetooth detectors scattered around if you want to track presence in every location. The cost of fitting a Bluetooth receiver in every room is likely going to be far too high for most, especially if it is the first time using presence detection.

The biggest problem is perhaps that the range is often inconsistent as it can be affected strongly by the environment. As anyone who has ever used a Bluetooth device will know, the signal strength at various distances is subject to change constantly. That means that one day your installation could be fine, but on another, you accidentally trigger the kitchen detector from the living room. This method is far from perfect, but it is quite interesting and maybe worth exploring if you have a use for room-by-room presence detection. 

Why only digital detection methods?

At this point, you may be wondering why there are no "classic" detection mechanisms such as motion detectors or laser tripwire included on the previous list. The reason is quite simply that they are too difficult to use for this purpose. Say you have a room with two doors, how do you detect when someone is entering vs when someone is leaving? Perhaps the second time the sensor was triggered was a second person entering the room, as opposed to the first person leaving. How can you track how many people are in a given room? 

The answer to all of these questions is that you can't - not easily anyways. The movement of most humans is simply too unpredictable to rely on sensors as most of them can only register a single activation which doesn't provide enough information. You could perhaps make use of an IR camera to detect human-like heat signatures which may enable accurate detection, but this is going to get expensive fast. As a result, wireless identification methods are just easier to use. RFID was specifically made for this, so be sure to check it out if you really want accurate room-based detection. 

How can presence detection be used?

We touched on this a bit earlier, but there are so many ways that presence detection can be used to provide a better living experience. The sky is really the limit when it comes to automations but imagine for a second that when you come home, the system identifies that you are alone and sets the temperature to your preferred setting. It could then also change everything back when others get home. Another example could be reminding people to do certain tasks when they arrive, which could be especially interesting with younger kids. There are a near unlimited number of things you can do with the additional information of "who's home?", so take full advantage by setting up presence detection today! 

Other Posts