aiotractive


Nameaiotractive JSON
Version 0.5.7 PyPI version JSON
download
home_pagehttps://github.com/zhulik/aiotractive
SummaryAsynchronous Python client for the Tractive REST API
upload_time2024-01-13 13:27:31
maintainer
docs_urlNone
authorGleb Sinyavskiy
requires_python
licenseThe MIT License
keywords tractive rest api aio async await
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## aiotractive

![Continuous Integration](https://github.com/zhulik/aiotractive/workflows/Continuous%20Integration/badge.svg?branch=main)

**Unofficial** Asynchronous Python client for the [Tractive](https://tractive.com) 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](https://github.com/Danielhiversen/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

```python
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

```python
client.authenticate()

# {'user_id': 'user_id', 'client_id': 'client_id', 'expires_at': 1626821491, 'access_token': 'long access token'}
```

#### Trackers

```python
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

```python
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;)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zhulik/aiotractive",
    "name": "aiotractive",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "tractive,rest,api,aio,async,await",
    "author": "Gleb Sinyavskiy",
    "author_email": "zhulik.gleb@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ee/a5/7bf0302950ca65bef74143b737a118f7b9ef145b1226b9516d62a5fdd076/aiotractive-0.5.7.tar.gz",
    "platform": null,
    "description": "## aiotractive\n\n![Continuous Integration](https://github.com/zhulik/aiotractive/workflows/Continuous%20Integration/badge.svg?branch=main)\n\n**Unofficial** Asynchronous Python client for the [Tractive](https://tractive.com) REST API.\n\n**This project and it's author are not affilated with Tractive GmbH**\n\nThis project is a result of reverse engineering of the Tractive web app.\n\nInspired by [home_assistant_tractive](https://github.com/Danielhiversen/home_assistant_tractive).\n\nInitially some code was borrowed from home_assistant_tractive, but in the end all of it was replaced with my own implementations.\n\nThe package is in active development. **Not all features available in the Tractive web app are implemented.**\n\nImportant notes:\n\n- In order to use Tractive devices and their service you need to have an active subscription.\n- Tractive may change their API at any point of time and this project will be broken. Please, report any issues.\n\n## Installation\n\n`pip install aiotractive`\n\n## Usage\n\n```python\nimport asyncio\n\nfrom aiotractive import Tractive\n\nasync def main():\n  async with Tractive(\"email\", \"password\") as client:\n    # interact with the client here\n    pass\n\nif __name__ == \"__main__\":\n  asyncio.run(main())\n```\n\n\n### Tractive\n\nTractive is the entrypoint class, it acts as an async context manager and provides access to API endpoints.\n\n#### Authentication\n\n```python\nclient.authenticate()\n\n# {'user_id': 'user_id', 'client_id': 'client_id', 'expires_at': 1626821491, 'access_token': 'long access token'}\n```\n\n#### Trackers\n\n```python\ntrackers = await client.trackers()\ntracker = trackers[0]\n\n# Or\n\ntracker = client.tracker(\"TRACKER_ID\")\n\n# Retrieve details\nawait trackers.details() # Includes device capabilities, battery status(not level), charging state and so on\n\nawait tracker.hw_info() # Includes battery level, firmware version, model and so on\n\n# Retrieve current location \nawait tracker.pos_report() # Includes coordinates, latitude, speed and so on\n# Retrieve hardware info\n\n# Retrive history positions\n```python\nnow = datetime.timestamp(datetime.now())\ntime_from = now - 3600 * LAST_HOURS\ntime_to = now\nformat = json_segments\nawait tracker.positions(time_from, time_to, format):\n```\n\n# Control the buzzer\nawait set_buzzer_active(True) # or False\n\n# Control the LED\nawait set_led_active(True) # or False\n\n# Control the live tracking\nawait set_live_tracking_active(True) # or False\n```\n\n#### Trackable objects (usually pets)\n```python\nobjects = await client.trackable_objects()\n\nobject = objects[0]\n\n# Retrieve details\nawait object.details() # Includes pet's name, pet's tracker id and so on\n```\n\n#### Events\n\n```python\nasync for event in client.events():\n    pp(event)\n\n```\n\nAfter connecting you will immediately receive one `tracker_status` event per owned tracker.\nThe first event always includes full current status of the tracker including current position, battery level, states of the buzzer,\nthe LED and the live tracking.\n\nAll following events will have the same name, but only include one of these: either a position, battery info, or a buzzer/LED/live\nstatus.\n\n## Contribution\nYou know;)\n",
    "bugtrack_url": null,
    "license": "The MIT License",
    "summary": "Asynchronous Python client for the Tractive REST API",
    "version": "0.5.7",
    "project_urls": {
        "Homepage": "https://github.com/zhulik/aiotractive"
    },
    "split_keywords": [
        "tractive",
        "rest",
        "api",
        "aio",
        "async",
        "await"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "85568dd6b4d5ec03386244e870e0cd2ec37260ac99831a2a69889095a1376f55",
                "md5": "9e16660248a055b976c0e751319134ff",
                "sha256": "6b8a09eb9dc6364a1f51dff496ad36d62f6b2de8caf879efe4dbfc2265e2fa0a"
            },
            "downloads": -1,
            "filename": "aiotractive-0.5.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9e16660248a055b976c0e751319134ff",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8494,
            "upload_time": "2024-01-13T13:27:30",
            "upload_time_iso_8601": "2024-01-13T13:27:30.437635Z",
            "url": "https://files.pythonhosted.org/packages/85/56/8dd6b4d5ec03386244e870e0cd2ec37260ac99831a2a69889095a1376f55/aiotractive-0.5.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eea57bf0302950ca65bef74143b737a118f7b9ef145b1226b9516d62a5fdd076",
                "md5": "708fd1c0cc5ececd9aef6a638305c455",
                "sha256": "b25a4ddc5df904b3d6b66c8767a26a87e10f8199a994bd7efaead2a7dea8f9f7"
            },
            "downloads": -1,
            "filename": "aiotractive-0.5.7.tar.gz",
            "has_sig": false,
            "md5_digest": "708fd1c0cc5ececd9aef6a638305c455",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8101,
            "upload_time": "2024-01-13T13:27:31",
            "upload_time_iso_8601": "2024-01-13T13:27:31.556381Z",
            "url": "https://files.pythonhosted.org/packages/ee/a5/7bf0302950ca65bef74143b737a118f7b9ef145b1226b9516d62a5fdd076/aiotractive-0.5.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-13 13:27:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zhulik",
    "github_project": "aiotractive",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aiotractive"
}
        
Elapsed time: 0.17459s