Profile
Back to NewsBack
GitHub Trending 16 min
Reader Mode
vgcouso/ha-tracker: HA Tracker allows advanced management of user tracking, their positions and zones through which they pass

vgcouso/ha-tracker: HA Tracker allows advanced management of user tracking, their positions and zones through which they pass

19 hours ago

PayPal Logo Buy Me A Coffee

HA Tracker logo
HA Tracker logo


CONTENTS

- HA Tracker - Options - Device Trackers - Home Assistant - OwnTracks - GPSLogger - Traccar Client - Traccar Server - 3D Map - Screens - Users - Zonas - Filters - ChatGPT - Automations

INTRODUCTION

  • HA Tracker is an application designed to track the position of registered Home Assistant users who send positions through various mobile applications
  • You can manage specific zones of the application
  • It also allows you to filter positions between two dates, grouped by zone, and obtain a detailed summary with statistics
  • It offers a panel and a card for home assistant as well as a blueprint to create automations
  • It is also integrated with ChatGPT using a GPT to query users' positions over time

REQUIREMENTS

To install this integration in Home Assistant, you will need:

  • An installation of Home Assistant (see https://www.home-assistant.io/)
  • HACS installed in your Home Assistant environment (see https://hacs.xyz/)
  • For security, HA Tracker requires Home Assistant to work over https. For that you have several alternatives from "Settings → Add-ons → Add-on store":
- Duck DNS - Let's Encrypt It may be necessary to assign ports 80, 443 and 8123 of the router to the IP of the computer with Home Assistant installed (check the add-ons documentation)


INSTALLATION

HA Tracker

The steps to install this integration are as follows:

  1. Click hacs_badge</a>
  2. Click on download and install
  3. Restart Home Assistant.
  4. Go to: "Settings → Devices and Services → Add Integration"
  5. Search for HA Tracker, select it and on the Configuration screen, configure options and press Send
You can access the application by opening the panel from the menu on the left or also from a web browser at the address:

https://HOST/ha-tracker/index.html This URL accepts 2 parameters: - debug=1: to avoid using minified JavaScript - token=ll_token: Where "ll_token" is a long-lived token

Install screen
This is the install screen

Once HA Tracker is installed a Custom Card will be available to place on the panels

Card screen
This is the card screen

By default, Home Assistant stores 10 days. You can increase this time, but keep in mind that this will increase the database size. It's also best to use MariaDB as your database. Here are the instructions for Home Assistant OS or Supervised:

  • Go to: Settings -> Add-ons -> Add-on Store -> MariaDB -> Install
  • Once MariaDB is installed, go to its settings and, under Logins, enter a password for the homeassistant user.
  • To store 30 days, add the following to the "configuration.yaml" file:
recorder:
  purge_keep_days: 30
  auto_purge: true
  db_url: mysql://homeassistant:[PASSWORD]@core-mariadb/homeassistant?charset=utf8mb4

  • Finally, restart Home Assistant
Very important: This change may increase the disk size of Home Assistant too much.

Options

  • General:
Core behavior and units. - Refresh Interval (in seconds): (Minimum value: 10 seconds) - The time the client uses to update its information from the server - Admin only - Make the integration accessible only by admin - Enable Debugging: - Messages in the web browser console (F12 key) - Use imperial units - Using Imperial Units in HA Tracker
  • Geocoding:
Reverse geocoding parameters. - Geocoding Time (in seconds): (Minimum value: 10 seconds) - Time between positions to request a person's address from the server - Minimum Distance for Geocoding (in meters): (Minimum value: 20 meters) - Distance between positions to request a person's address from the server
  • Stops:
Stop detection thresholds. - Stop radius (in meters): (Minimum value: 0 meters) - Radius around which positions are considered stopped. - If the value is 0, stops are not calculated. - Stop time (in seconds): (Minimum value: 0 seconds) - Time that a position must spend at a point to be considered stopped. - If the value is 0, stops are not calculated. - Reentry gap (in seconds): (Minimum value: 0 seconds) - If you leave for a moment and return to the same place immediately, it counts as the same stop. - If the value is 0, stops are not calculated. - Outside gap (in seconds): (Minimum value: 0 seconds) - The stop is not closed for an exit less than this time. - If the value is 0, stops are not calculated.

You must adjust these two parameters according to the application used to send the positions and the device on which it is installed.

  • Accuracy:
Parameters for considering positions. - GPS accuracy (meters): (Minimum value: 10 meters) - Positions with a GPS accuracy value greater than this parameter are discarded. - Maximum speed (km/h): (Minimum value: 100 km/h) - Positions where the speed resulting from dividing space by time is greater than this parameter are discarded. You must adjust these two parameters according to the application used to send the positions and the device on which it is installed.
  • Anti-spike:
It filters out sporadic jumps in positions and uses the five points A->B->C->D->E for its calculation. C is eliminated if, based on the following parameters, it offers a significant change in its position with respect to A->B and D->E. - Factor k: (Minimum value: 1.5) - Detour speed threshold. C is cleared if the speed of section B->C->D is greater than speeds A->B and D->E. The higher the threshold, the fewer peaks are cleared. - Detour ratio: (Minimum value: 1.1) - Generic deviation threshold: (dBC + dCD)/dBD > R. This implies a clear "two-way" response. The higher the threshold, the fewer cases are considered peaks. - Radius (meters): (Minimum value: 0 meters) - Minimum lengths B->C and C->D in meters. Avoid erasing micro-oscillations below the noise level. The higher the value, the fewer peaks are erased. - If the value is 0, Anti-spike is not calculated. - Time (seconds): (Minimum value: 0 seconds) - Maximum time window in seconds for B->D to be fast. If it takes longer, it's not a spike. The lower the window, the faster the spikes. - If the value is 0, Anti-spike is not calculated.

You must adjust these two parameters according to the application used to send the positions and the device on which it is installed.

  • Sources:
Copyable mobile app webhook URLs - OwnTracks webhook URL - Copy this URL into the OwnTracks app - GPSLogger webhook URL - Copy this URL into the GPSLogger app - Traccar webhook URL - Copy this URL into the Traccar app


The server requests addresses from openstreetmap.org which has a limit of one request per second

Increase Geocoding Time and Minimum Distance for Geocoding if you have many open applications and connected devices

The URLs for OwnTracks and GPSLogger must be changed and are used in the mobile apps to access the properties that will connect it to the Home Assistant integration


HA Tracker options screen
This is the options screen


Device Trackers

You must install an app on your smartphone to send managed positions through Home Assistant integrations. We'll look at some of them below.

Integrations create Device Trackers in Home Assistant when connected and they are shown in the integration where you can rename them in: "Settings → Devices and Services → Integration → Pencil icon next to the device"

Change name screen
This is the change name screen

Device Trackers must be assigned to users: "Settings → People → Username → Devices that belong to this person"

Important: If there are multiple devices associated with a person, HA Tracker takes the first one.


Home Assistant

Home Assistant for mobile is the official app and is available for both: iOS and Android devices. Then: - The first thing to do is connect to Home Assistant and give the device a name - Then, grant it the permissions it requests

  • Then, assign the device to a person in Home Assistant: "Settings → People"
  • In Home Assistant, you'll find connected devices under: "Settings → Devices & services → Mobile App"
Home Assistant with HA Tracker
This is Home Assistant with HA Tracker

In Android make sure in the "Settings → Companion app" that:

  • Background access is enabled
  • "Manage sensors → background location" is enabled. Here you can activate High precision mode (consumes more battery but provides more positions) and define every how many seconds you want to receive positions.

OwnTracks

OwnTracks is an iOS and Android app designed to send your phone's positions to a URL.

OwnTracks screen
This is the OwnTracks screen

The first thing you need to do is install the OwnTracks integration: - Go to: "Settings → Devices and Services → Add Integration" - Search for OwnTracks, select it. The configuration screen will open - Press Send button and integration will be created

Then you can then install OwnTracks on your devices from iOS and Android. Then: - Allow the permissions that the application requests for its correct operation. - On some Android versions, restarting your phone requires you to open the app to send positions. Sometimes setting the app to use the battery without restrictions, always allow location and allow notifications fixes it. - On some devices you must enable the option to run in the background

To configure the application: here's a link - Set a unique Device ID and Tracker ID for each phone - The URL provided to you when setting up the integration can also be found under "Settings → Devices & services → HA TRacker → Configuration → Sources"

  • In Home Assistant, you'll find connected devices under "Settings → Devices & services → OwnTracks"
- There you can change its name in Home Assistant
  • Finally, assign the device to a person in Home Assistant: "Settings → People"

GPSLogger

GPSLogger is an Android app designed to store or send your phone's positions to a URL.

GPSLogger Android screen
This is the GPSLogger Android screen

The first thing you need to do is install the GPSLogger integration: - Go to: "Settings → Devices and Services → Add Integration" - Search for GPSLogger, select it. The configuration screen will open. - Press Send button and integration will be created Then you can then install GPSLogger on your devices through the F-Droid Android app store.

Get it on F-Droid

To install GpsLogger: - Allow the permissions that the application requests for its correct operation. - On some Android versions, restarting your phone requires you to open the app to send positions. Sometimes setting the app to use the battery without restrictions, always allow location and allow notifications fixes it. - On some devices you must enable the option to run in the background To configure the application: here's a link - The URL provided to you when setting up the integration can also be found under "Settings → Devices & services → HA TRacker → Configuration → Sources"

  • In Home Assistant, you'll find connected devices under "Settings → Devices & services → GPSLogger"
- There you can change its name in Home Assistant
  • Finally, assign the device to a person in Home Assistant: "Settings → People"

Traccar Client

Traccar Client is an iOS and Android app designed to send your phone's positions to a URL.

The first thing you need to do is install the Traccar Client integration: - Go to: "Settings → Devices and Services → Add Integration" - Search for Traccar Client, select it. The configuration screen will open. - Press Send button and integration will be created Then you can then install OwnTracks on your devices from iOS) and Android. Then: - Allow the permissions that the application requests for its correct operation. - On some Android versions, restarting your phone requires you to open the app to send positions. Sometimes setting the app to use the battery without restrictions, always allow location and allow notifications fixes it. - On some devices you must enable the option to run in the background

To configure the application: here's a link - Set a unique Device identifier - The URL provided to you when setting up the integration can also be found under "Settings → Devices & services → HA TRacker → Configuration → Sources"

  • In Home Assistant, you'll find connected devices under "Settings → Devices & services → OwnTracks"
- There you can change its name in Home Assistant
  • Finally, assign the device to a person in Home Assistant: "Settings → People"
---

Traccar Server

Traccar Server allows you to view the real-time location of your GPS devices.

In Traccar server you need to create two Computed Attributes: - For Battery with: - Description: "batteryLevel" - Attribute: "Battery level" - Expression: "batteryLevel" - For Speed with: - Description: "speedMps" - Attribute: "Speed" - Expression: "speed * 0.514444"

Traccar Server Computed Attributes
Traccar Server Computed Attributes
These Computed Attributes need to be assigned to groups and/or devices in Traccar Server.

Traccar Server Groups
Traccar Server Groups
The first thing you need to do in Home Assistant is install the Traccar Server integration: - Go to: "Settings → Devices and Services → Add Integration" - Search for Traccar Server, select it. The configuration screen will open. - Complete the fields with those of the Traccar server - Press Send button and integration will be created

In "Settings → Devices and Services → Traccar Server → Options" it is necessary to add two Custom Attributes: batteryLevel and speedMps

Traccar Server Options
Traccar Server Options
  • In Home Assistant, you'll find connected devices under "Settings → Devices & services → Traccar Server"
- There you can change its name in Home Assistant
  • Finally, assign the device to a person in Home Assistant: "Settings → People"
---

QUICK START

3D Map

  • When using a mouse, you need to right-click to rotate and tilt. On a smartphone, you can use two fingers.
  • It has the following buttons:
- Zoom - Reset bearing to north - Search for locations - Switch between layers (OpenStreetMap, Esri, and OpenFreeMap)

Screens

Users

  • These are the same ones created in Home Assistant and may have an associated device tracker. In that case, they are displayed on the map.
  • If you click on a user on the map, a popup will appear with the information of the last position and a link that directs to Google Maps.
HA Tracker users screen
This is the users screen

Zones

  • Home Assistant zones:
- In these zones, you can only change their visibility and their color on the map. - To change their name, radius, or location, you must do so in Home Assistant.
  • Zones created within the application:
- These zones can be moved and have their radius changed. - Zones created within the application are visible in Home Assistant but cannot be modified there. - The name of the zones must be unique and its size must be less than 30 characters. - You can assign a different color to each one. - The zone color is used as the background for cells in the user, zone, filter tables, and in the summary of visited zones.

HA Tracker zones screen
This is the zones screen


HA Tracker dialog in zones
This is the dialog in zones


Filters

A filter applied to a user within a specific date range displays positions grouped by zone and a summary of the most relevant data.

There are three tabs on this screen: - The first tab shows the list of filtered positions grouped by the zone in which they were found. - In the table with the positions they are grouped by the name of the zone in which they are located and can be expanded by clicking on the triangle icon on the left. - You can filter the positions of a group by clicking on the filter icon to the right of the table. - In this table, you'll also see the stops made. To correctly identify them, it's very important to adjust the Speed ​​for stop value in the server options. - The second tab contains a summary of the most relevant statistics for the filter and for each zone visited. - The third tab displays a chart by day, divided into 6-hour segments. - At the top of each chart, the color of the area visited is shown, and at the bottom, it's red if the time has been stopped or green if the time has been moving. Additionally, the speed graph is displayed in dark green. - The position selected in the first tab is shown with a blue vertical line in the chart. - Clicking on the chart takes you to that position within the Positions tab.

On the map, the filter is represented by:

  • The route with the filter positions on the map appears in green at the start and blue at the end.
  • A Stop icon shows the stops made
  • With enough zoom, markers appear that, when pressed, locate the row in the leaderboard.
In addition, there is the possibility of exporting the filters made to various file formats.

HA Tracker calendar on the filter screen
This is the calendar on the filter screen


HA Tracker filter with positions screen
This is the filter with positions screen


HA Tracker summary screen
This is the summary screen


HA Tracker chart screen
This is the chart screen


ChatGPT

  • At the moment GPT for HA Tracker is in beta version
  • Due to restrictions set by Cloudflare, which acts as a proxy between GPT and your Home Assistant, the number of requests for all users is limited when using the free version
  • You can find the GPT at this link: HA Tracker for Home Assistant
  • When you open GPT, it will ask you for your Home Assistant's address, which must be https. Also, you cannot enter HOST names with port
  • Once you have logged into the HOST and clicked the "Continue" button, you will be redirected to a screen to log in to your Home Assistant and connect it to the GPT for use.
Home Assistant URL
This is the screen to enter the Home Assistant URL
  • Within the GPT you can perform a multitude of queries:
- Give me a summary of what [user] did yesterday - Where are the users now? - Where was [user] yesterday at 6:00 PM? - What zones did [user] visit? - What time were you in each area today [user]? - Give me [user]'s stops yesterday - Give me [user]'s stats for today

Automations

In "Settings → Automations & scenes → Create automation", a new Blueprint is available called: "Persons in Zones Alert (HA Tracker)"

Here you can create new automations that allow you to receive a custom text or voice notification, to the devices you define, when users enter or leave the zones.

Automations screen
This is the automations screen


CHANGELOG

See the CHANGELOG for details about changes and updates.

Chat with me