Passive Location Tracking With Home Assistant And Owntracks

Overview

With the changes to Google Timeline moving to local storage, others had the idea of using self hosted solution such as Dawarich. With Home Assistant with access to my location for location based automations, I could store that data in a dedicated app without additional battery training app on my phone or some other device. This is not a step by step and assumes you have installed everything.

Location Visualisation App

Dawarich looked the most comprehensive however, I had problems setting it up, the tiles were not rendering all of which could be down to me. The project is in active development at the time so in the end I ditched it for Owntracks.

Owntracks has it’s own mobile app so it can be decoupled from the Home Assistant and work as a standalone service if needed. It does not have as many of the filtering features like Dawarich.

Owntracks

The installation requires it to be connected to an MQTT server. It will allow Owntracks to get location data from any source as long it is published in MQTT.

Owntracks requires the recorder to log the data and the web front end to show the data.

Home Assistant

Create an automation like the below. It uses the device information which is updated using the Home Assistant companion mobile) app.
- id: "1744064001680"
alias: "People: Update Danny's Owntracks"
description: "https://devblog.yvn.no/posts/replacing-maps-timeline-with-owntracks/"
triggers:
- trigger: state
entity_id:
- device_tracker.danny_s_phone
conditions: []
actions:
- action: mqtt.publish
metadata: {}
data:
topic: owntracks/danny/iphone
payload: |
{
"_type": "location",
"t": "p",
"tid": "ha",
"lat": {{ state_attr('device_tracker.danny_s_phone', 'latitude') }},
"lon": {{ state_attr('device_tracker.danny_s_phone', 'longitude') }},
"alt": {{ state_attr('device_tracker.danny_s_phone', 'altitude') | default(0) }},
"vac": {{ state_attr('device_tracker.danny_s_phone', 'vertical_accuracy') | default(0) }},
"acc": {{ state_attr('device_tracker.danny_s_phone', 'gps_accuracy') | default(0) }},
"vel": {{ state_attr('device_tracker.danny_s_phone', 'speed') | default(0) }},
"cog": {{ state_attr('device_tracker.danny_s_phone', 'course') | default(0) }},
"tst": {{ now().timestamp() | int }}
}
retain: true
mode: single

Replace device_tracker.danny_s_phone with your phone devicce.

Change owntracks/danny/iphone. The default topic and is owntracks so anything after the slash can be customised to your needs replacing the name and with yours and if you wish to add more details, add further slashes and name.

The rest should be ok as it is.

An up to date automation can be found here.

Summary

This is a really optimised way to tack location data. I love the fact the power hungry data of getting a satellite data is done once and shared with different services.

Replacing Maps Timeline With Owntracks
Anyone have a walkthrough of setting up Dawarich on unRAID?

About Danny

I.T software professional always studying and applying the knowledge gained and one way of doing this is to blog. Danny also has participates in a part time project called Energy@Home [http://code.google.com/p/energyathome/] for monitoring energy usage on a premise. Dedicated to I.T since studying pure Information Technology since the age of 16, Danny Tsang working in the field that he has aimed for since leaving school. View all posts by Danny → This entry was posted in Home Automation, Infrastructure. Bookmark the permalink.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.