Asynchronous Python client for the Tractive REST API
Project description
aiotractive
Unofficial Asynchronous Python client for the Tractive REST API.
This project and it's author are not affilated with Tractive GmbH
This project is a result of reverse engineering of the Tractive web app.
Inspired by home_assistant_tractive.
Initially some code was borrowed from home_assistant_tractive, but in the end all of it was replaced with my own implementations.
The package is in active development. Not all features available in the Tractive web app are implemented.
Important notes:
- In order to use Tractive devices and their service you need to have an active subscription.
- Tractive may change their API at any point of time and this project will be broken. Please, report any issues.
Installation
pip install aiotractive
Usage
import asyncio
from aiotractive import Tractive
async def main():
async with Tractive("email", "password") as client:
# interact with the client here
pass
if __name__ == "__main__":
asyncio.run(main())
Tractive
Tractive is the entrypoint class, it acts as an async context manager and provides access to API endpoints.
Authentication
client.authenticate()
# {'user_id': 'user_id', 'client_id': 'client_id', 'expires_at': 1626821491, 'access_token': 'long access token'}
Trackers
trackers = await client.trackers()
tracker = trackers[0]
# Or
tracker = client.tracker("TRACKER_ID")
# Retrieve details
await trackers.details() # Includes device capabilities, battery status(not level), charging state and so on
await tracker.hw_info() # Includes battery level, firmware version, model and so on
# Retrieve current location
await tracker.pos_report() # Includes coordinates, latitude, speed and so on
# Retrieve hardware info
# Retrive history positions
```python
now = datetime.timestamp(datetime.now())
time_from = now - 3600 * LAST_HOURS
time_to = now
format = json_segments
await tracker.positions(time_from, time_to, format):
Control the buzzer
await set_buzzer_active(True) # or False
Control the LED
await set_led_active(True) # or False
Control the live tracking
await set_live_tracking_active(True) # or False
#### Trackable objects (usually pets)
```python
objects = await client.trackable_objects()
object = objects[0]
# Retrieve details
await object.details() # Includes pet's name, pet's tracker id and so on
Events
async for event in client.events():
pp(event)
After connecting you will immediately receive one tracker_status
event per owned tracker.
The first event always includes full current status of the tracker including current position, battery level, states of the buzzer,
the LED and the live tracking.
All following events will have the same name, but only include one of these: either a position, battery info, or a buzzer/LED/live status.
Contribution
You know;)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aiotractive-0.6.0.tar.gz
.
File metadata
- Download URL: aiotractive-0.6.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d29b5d532e1d28979e4e5cc65b9aba3bfa13c4a36a5abf55447125c55adccd31 |
|
MD5 | 2321e1b1b3f2b30b0fe09de92efa9d1d |
|
BLAKE2b-256 | dbd26c4cc1247ce4e057731664019822770a3f958290631a66030dcb2fd550f7 |
File details
Details for the file aiotractive-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: aiotractive-0.6.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 166c483e79efecabc6f807f13749b897a47ccd5d4b649775b44e2fc95ef8bd69 |
|
MD5 | 1aef4784c8083e41413387352c291fe1 |
|
BLAKE2b-256 | e0cac9f18b794a50b1c0b419626a830a512f7166d05d0dbb3a1bd9e264228f75 |