aiotractive


Nameaiotractive JSON
Version 0.6.0 PyPI version JSON
download
home_pagehttps://github.com/zhulik/aiotractive
SummaryAsynchronous Python client for the Tractive REST API
upload_time2024-07-20 22:27:26
maintainerNone
docs_urlNone
authorGleb Sinyavskiy
requires_pythonNone
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": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "tractive, rest, api, aio, async, await",
    "author": "Gleb Sinyavskiy",
    "author_email": "zhulik.gleb@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/db/d2/6c4cc1247ce4e057731664019822770a3f958290631a66030dcb2fd550f7/aiotractive-0.6.0.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.6.0",
    "project_urls": {
        "Homepage": "https://github.com/zhulik/aiotractive"
    },
    "split_keywords": [
        "tractive",
        " rest",
        " api",
        " aio",
        " async",
        " await"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e0cac9f18b794a50b1c0b419626a830a512f7166d05d0dbb3a1bd9e264228f75",
                "md5": "1aef4784c8083e41413387352c291fe1",
                "sha256": "166c483e79efecabc6f807f13749b897a47ccd5d4b649775b44e2fc95ef8bd69"
            },
            "downloads": -1,
            "filename": "aiotractive-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1aef4784c8083e41413387352c291fe1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8746,
            "upload_time": "2024-07-20T22:27:24",
            "upload_time_iso_8601": "2024-07-20T22:27:24.511376Z",
            "url": "https://files.pythonhosted.org/packages/e0/ca/c9f18b794a50b1c0b419626a830a512f7166d05d0dbb3a1bd9e264228f75/aiotractive-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dbd26c4cc1247ce4e057731664019822770a3f958290631a66030dcb2fd550f7",
                "md5": "2321e1b1b3f2b30b0fe09de92efa9d1d",
                "sha256": "d29b5d532e1d28979e4e5cc65b9aba3bfa13c4a36a5abf55447125c55adccd31"
            },
            "downloads": -1,
            "filename": "aiotractive-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2321e1b1b3f2b30b0fe09de92efa9d1d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8352,
            "upload_time": "2024-07-20T22:27:26",
            "upload_time_iso_8601": "2024-07-20T22:27:26.010356Z",
            "url": "https://files.pythonhosted.org/packages/db/d2/6c4cc1247ce4e057731664019822770a3f958290631a66030dcb2fd550f7/aiotractive-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-20 22:27:26",
    "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.30591s