I just wanted the lights to turn off automatically when we all left the house…
I thought it was going to be easy, but after doing a little research, I found a complex system for tracking devices and people, full of details that need to be considered. From GPS trackers to presence sensors, from phantom devices to others to find your pet if it gets lost; each with its own configurations and applications.
If you also want to include device tracking in Home Assistant, this article is here to help you.
From the Presence Detection category of the integration catalog in the Home Assistant documentation, we will see a huge number of available integrations.
Types of tracking
In general, the types of tracking that these integrations usually have are:
-
Outdoor: Uses GPS trackers to determine the exact position of a device outside the home. The GPS coordinates are compared with the zones defined in Home Assistant. If it is within the home zone, the status will be “Home”. If it is not in any zone, the status will be “Not home”. In addition, Home Assistant has a map to visualize the position of the device.
-
Outdoor-Indoor: Does not provide the exact position but indicates whether the device is at home or not. This type of tracking uses methods like connecting to the home’s Wi-Fi network or presence detection based on Bluetooth. The statuses can be “Home” when the device is in the home zone, or “Not home” when it is not in any zone.
-
Indoor: Provides detailed information about the location of a device within the home, indicating which room it is in. It’s useful for knowing if a person or device is in the kitchen, living room, or any other room in the house. This category can also include less intelligent devices, such as presence or motion sensors, which detect people or animals in a room, but cannot identify which person is detected or if there is more than one.
Zones and areas
Once we have the position of the devices, they can be tagged with labels for their positions. For example, a zone indicating the office where you work so that Home Assistant knows when you are at work or assigning devices to rooms to see where the devices are briefly.
Zones
Zones are designed for the first case. From Settings -> Zones
, you can create zones with a GPS position and a distance range. When the device is in that zone, its tracking status will change to the zone identifier.
When we configure a device, it knows whether it is inside or outside the house because the “Home” zone is already created automatically with Home Assistant.
Areas
Areas work similarly to zones, except they act within the house. They are created and configured from Settings -> Areas
. They are usually used to define different rooms and manually assign devices to them.
Thanks to this area organization, we can filter lists to find devices and entities more easily or create automations that affect all devices in an area.
Associating devices with people
Once devices are positioned, they can be linked to Home Assistant users by creating Person entities.
These entities have one or more associated tracking devices so that they complement each other and provide the most accurate location for the user, allowing you to know where they are always.
To declare a person, simply go to Settings -> People
and assign the tracking entities that we have previously created. We only need to keep in mind that Home Assistant will follow these rules:
- If there are Outdoor-Indoor integrations, those that do not provide a GPS position but do provide the zone (e.g., Nmap or Bluetooth), with the “Home” status, the most recently updated integration will be used to determine the position.
- If there are Outdoor integrations that provide a GPS position, the most recently updated integration will be used.
- In any other case, the last update with the “Away from home” status will be used.
In other words, if you are “Home”, the position will first be determined by Outdoor-Indoor tracking integrations, then by Outdoor. If you are “away from home”, the position will first be determined by Outdoor integrations, then by Outdoor-Indoor.
Phantom devices
Although having multiple tracking devices configured for each person increases precision, it is not recommended to use these entities for critical operations. For example, a correct use of these integrations would be to turn heating on or off based on the position of the person or family, but they should not be used for alarms or security until extensive checks and tests have been carried out. And why do I say this?
Integrations related to device tracking are “Best Effort”, meaning they will try their best and provide accurate data, but they will not always succeed.
Thus, if we configure, for example, Nmap and Ping for a mobile device, we will see that they can give contradictory results.
This is because some devices disconnect from Wi-Fi networks to save battery. Others, even if we leave them on standby, remain connected to the network, so the sensors will indicate that they are “on”.
The best way to solve this is to test different integrations until finding the most accurate one for that device or person.
Conclusion
Home Assistant offers many integrations for tracking devices and people. Setting up zones and areas makes organizing and customizing our devices easier. While these integrations are effective, it is important to conduct thorough tests to ensure their accuracy in critical situations.
However, we will have to leave these tests for later. See you in the next article!