Cat gps tracker

Hello, there are several gps tracker for cats oe dogs on the market. With and without monthly payment. Does anyone know one which works well with openhab? Or a documented api?
To show the location on or a map or trigger a rule as soon as the cat is at home.
I am located in Germany if there are local differences.
Thank you

cat are notorious for not working well in home automation :rofl:
please see this cat thread for reference (and a good laugh even if you don’t own a cat)

here is my response in that thread quoted here for reference:

guy puts contact switch on cat flap
data doesn’t make sense
guy put video camera pointing at flap to see WTF
cat sticking head out flap but not going thru

1 Like

Haha yes thats funny. Detecting the motion of a mechanical flap is tricky. But i was more thinking of a gps tracker :wink: i noticed that tractive cat tracker do have a API, but i dont find any offical information. There seems to be a home assistant “binding” and a python script. Is anyone using something like this?

The nice things about having a working Python script, you can adopt it to run as a service and push the data to OH using the REST API or MQTT. You might be able to translate that code into the HTTP calls you need to make and use an OH rule or the HTTP binding to do it. Either way, it’s going to take a little work, but it’ll be a great learning opportunity.

1 Like

Thank you for your answer. Using the python script and sending the data via mqtt to openhab sounds smart.
Is it possible and reasonable to run the python script on the same raspberry pi with openhabian? Can you give a hint how to run the script as a Service? Should i put it to crontab or how the run it in a target frequency?
Thank you :slight_smile:

It’s impossible to say. Usually scripts like this are pretty light weight but there are far too many variables to give anything like a definitive answer.

There’s tons of tutorials online that will do a better job than I can. Look for how to run a program as a service with systems.

If it’s running as a service, it’s always running. It starts up when the machine starts and runs in the background.

Thank you rlkoshak for your answer!
I tried using the python libary. But i am a python beginner. Unfortunatelly there seems to be very little support in the git repo about this libery.
I created an issue but looking on the open issues there are no answers since month.
I dont have an idea how to use this libary :frowning:

Do you have some python and raspberry pi experience and can give me a hint maybe?
This would be great :slight_smile:
Here is the issue i created: HowTo Start? · Issue #32 · zhulik/aiotractive · GitHub

Thank you very much!! :slight_smile:

I doubt a mere hint is going to be more than the example it gives in the main README.

You install the library using pip.

You create your own Python script.

You import the library.

You use the library.

Dear rlkoshak,

thank you for your help.
I managed now to get it working. I posted my code in the Git-Issue linked above. In case someone is searching for a way to add a tractive gps tracker to openhab.

Due to the integration i did the following things (as an inspiration maybe):

  • show on the wall display if the cat is at home or (if not) how far away
  • when the cat left the home, when it arrived
  • an alexa echo notification when the cat is in the garden (to open the door)
  • Alexa answers to “where is the cat?” when the cat left the home, how far away the cat is and opens a map with the location
1 Like

There’s apparently a Home Assistant binding for Tractive: Tractive - Home Assistant. It looks to consist fully of python scripts.

I don’t know whether that is “easily” converted to an openHAB binding? That’s out of my league, I’m afraid…

Anyway, @sl4m, I used your first script (HowTo Start? · Issue #32 · zhulik/aiotractive · GitHub) to check whether our dog is home when all human residents are away. If that’s the case, my Sonos starts playing music that alledgedly sooths dogs :smiley:

import asyncio

from aiotractive import Tractive

# Our dog turns out to have tracker with _id '8LETTERID'; a friend's dog, which I also have added in the app has a tracker with_id 'ANOTHER8LETTERID'
dodsids = {
   'Our dog' : '8LETTERID',
   "Friend's dog" : 'ANOTHER8LETTERID'

async def main():
  async with Tractive("", "mypassword") as client:
    await client.authenticate()
    trackers = await client.trackers()
    for x in range (0, len(trackers)):
        tracker = trackers[x]
        detail = await tracker.details()
        trackerid = detail['_id']
        if (trackerid == dogsids['Our dog']):
           home = detail['state_reason']

if __name__ == "__main__":

When all humans are gone, this triggers a switch (based on our tado apps), and then a rule runs with (among other things) this:

const returnwhenhome = "POWER_SAVING"
const returnwhencharging = "CHARGING"
var doghome = actions.Exec.executeCommandLine(time.Duration.ofSeconds(5), 'python', 'bin/python/')
if (doghome.includes(returnwhenhome) || doghome.includes(returnwhencharging)) {
        // Sonos on dog soothing music