Tractive GPS tracker

Anyone implemented some solution for integration for GPS tracking for dogs?
I’m actually using Tractive GPS but seems that they’re not releasing API

I’ve been wondering this myself. I would love to have this added to my dashboard.

1 Like

The best thing i can come up with is to add a webpage card and put in your public sharing link.

It would great if someone could handle to get API from tractive… unfortunately i don’t have the skills to do that. Having a webpage does not grant the possibility to have automation etc

Oh this GPS tracker integration would be perfect to bundle with my feature request: Keeping tracking history and show statistics and route

It’s quite a simple API.
To get a token
Post a application/json to ‘https://graph.tractive.com/3/auth/token’ with a header ‘X-Tractive-Client’ = ‘5728aa1fc9077f7c32000186’
The data (in json) will be such as.
@{'platform_email' = 'email'; 'platform_token' = 'password'; 'grant_type' = 'tractive' }

This will respond with among others a userid and a token. Both are needed for the next step.

Send a GET to hxxps://graph.tractive.com/3/user/USERID/trackers with a header of
‘X-Tractive-Client’ = ‘5728aa1fc9077f7c32000186’ & “Authorization” = “Bearer AccessToken”

After this you send a GET to hxxps://graph.tractive.com/3/tracker/TRACKERID with the same headers as previously.

If you want a history you can issue a GET to hxxps://graph.tractive.com/3/tracker/TRACKERID/positions?time_from=FROMINSEC&time_to=TOINSEC&format=json_segments

The FROMINSEC and TOINSEC is a unixtimestamp so its in seconds since 1970-01-01, if you set FROM to 0 you will get all the history, regardless if you pay for the premium subscription or not.

I use these URLs myself to update a Grafana dashboard.

I have made a custom component here: https://github.com/Danielhiversen/home_assistant_tractive
It is still work in progress.

1 Like

Ciao Daniel

I could setup the component easily and the device tracker was created correctly, i will try it and let you know if this works fine. Do you think it’s possible to get also battery level?

Great.

Battery level should now be available as an attribute if you update the component.

Hey @Danielhiversen

I was also planning to work on an integration for Tractive back in March, but my development came to a halt because i can’t let my cat out anymore.

I just wanted to ask the community if there’s anybody interested in it and found this thread. My plan was to continue to work on a python client library to communicate with the Tractive API. I’ve already implemented a mechanism to automatically extract the X-Tractive-Client in case they ever change that but implemented just the first basic endpoints before i stopped working on it.

Would you be interested to use this library if I continue to work on that and release it publicly? AFAIK it’s a requirement for API-Client code to be outsourced in a library rather than be directly in the Home Assistant source code, that’s why I started with that.

I’m basically searching for an excuse to learn more about python and publishing python libraries (I’m more experienced in Java/Rust/C/etc) and it seems like there could be a motivation for me here to actually go through with it :slight_smile:

Just let me know what you think. If you already implemented everything yourself and you don’t see any benefit in me working on that, i’ll probably look for a different project to expand my horizon. :sweat_smile:

hi @Danielhiversen i made a couple of test and seems that sensor does not update properly. Tractive app say’s i’m out of home but for ha component i’m still at home. how is the component status refreshed?

@hertg To make an external library is just to copy two of the function to a new repository.

@enribomber I currently do not have any device to test on. Any errors in the log?

No error in log. Today I’m @work with my tractive and still shows “at home” but i’m 15 km away

Is it correct in the tractive app?

yes, it shows my actual location

What is the time attribute for the device?

time

1602067808

I see latitude and longitude are not updated as they are reflecting home location

Hi @Danielhiversen have been able to look into this?

I think I solved it yesterday.
But I currently do not have any device to test on, so any feedback would be great.

I see github is not updated, if you can update it i will test the component