aiotaika


Nameaiotaika JSON
Version 0.1.2 PyPI version JSON
download
home_page
SummaryTaika asynchronous client library for Python
upload_time2023-04-26 09:50:18
maintainer
docs_urlNone
author
requires_python>=3.8
licenseLGPL-2.1 license
keywords async asyncio taika client iot
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # aiotaika

[![Documentation Status](https://readthedocs.org/projects/aiotaika-python/badge/?version=stable)](https://aiotaika-python.readthedocs.io/en/stable/?badge=stable) [![Latest PyPI release](https://img.shields.io/pypi/v/aiotaika)](https://pypi.org/project/aiotaika/) ![Supported Python versions](https://img.shields.io/pypi/pyversions/aiotaika.svg)

## Taika asynchronous client library for Python

This library provides a very intuitive API for developers to easily create Python applications for Taika Tech's Spatial User Interface (SUI). With SUI, you can program actions to your physical environment, which are triggered based on location, orientation, and/or gesture data coming from a Taika Ring or Taika Tag.

You can find aiotaika's documentation from [Read the Docs](https://aiotaika-python.readthedocs.io/).

## Basic Examples

For more examples, see [examples](/examples) folder of the repository.

### Callback Example

In this example, we subscribe to move events and gesture events of ring ID 3.
In the callback function, we track the latest position and when a gesture event
happens, we print out which gesture was made with the latest location data.

With callbacks one can register one or more callbacks to a single callback function.
However, the Event type must be a parent class of all incoming event objects in that
callback function. Here `RingGestureEvent` and `RingMoveEvent` inherit from
`RingEvent`.

```
import asyncio

from aiotaika import TaikaClient
from aiotaika.events import EventType
from aiotaika.ring import RingGestureEvent, RingMoveEvent

Vector3 last_position

async def my_callback(event: RingEvent) -> None:
    if isinstance(event, RingMoveEvent):
        last_position = event.position
    elif isinstance(event, RingGestureEvent):
        print(f"{event.gesture} in position {last_position}")


async def main() -> None:
    async with TaikaClient(
        host="127.0.0.1", username="root", password=""
    ) as taika:
        rings = taika.rings
        for key, ring in rings.items():
            print("{}: {}".format(key, ring.metadata))
        await rings[3].register_event_cb(EventType.RING_MOVE_EVT, my_callback)
        await rings[3].register_event_cb(EventType.RING_GESTURE_EVT, my_callback)
        await asyncio.sleep(5)


try:
    asyncio.run(main())
except KeyboardInterrupt:
    pass
```

### Asynchronous Generator Example (no callbacks!)

This example shows simply how all the incoming events can be handled via the `events`
AsyncGenerator of the `TaikaClient` class. In this example, we simply print out a
ring's name and position when a `RingMoveEvent` happens.

```
import asyncio

from aiotaika import TaikaClient
from aiotaika.ring import RingMoveEvent

async def main() -> None:
    async with TaikaClient(
        host="127.0.0.1", username="root", password=""
    ) as taika:
        async with taika.events() as events:
            async for event in events:
                if isinstance(event, RingMoveEvent):
                    print(f"Ring {event.metadata.name} position:")
                    print(f"x: {event.position.x}, z: {event.position.z}")
                    print(f"height: {event.position.y}")


try:
    asyncio.run(main())
except KeyboardInterrupt:
    pass
```

## Requirements:

### Hardware

- Taika Development Kit

### Software

_Note: these should be automatically satisfied if `aiotaika` is installed via `pip`._

You can find precise version requirements from [pyproject.toml](/pyproject.toml)

- `Python`
- `asyncio-mqtt`
- `aiomysql`

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "aiotaika",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Jussi Hietanen <jussi@taikatech.fi>",
    "keywords": "async,asyncio,taika,client,iot",
    "author": "",
    "author_email": "Taika Tech Oy <dev@taikatech.fi>",
    "download_url": "https://files.pythonhosted.org/packages/46/2d/a3f9aeeca39126e40292298e738141213d9fbbdd4c2bbed5778fcb167f22/aiotaika-0.1.2.tar.gz",
    "platform": null,
    "description": "# aiotaika\n\n[![Documentation Status](https://readthedocs.org/projects/aiotaika-python/badge/?version=stable)](https://aiotaika-python.readthedocs.io/en/stable/?badge=stable) [![Latest PyPI release](https://img.shields.io/pypi/v/aiotaika)](https://pypi.org/project/aiotaika/) ![Supported Python versions](https://img.shields.io/pypi/pyversions/aiotaika.svg)\n\n## Taika asynchronous client library for Python\n\nThis library provides a very intuitive API for developers to easily create Python applications for Taika Tech's Spatial User Interface (SUI). With SUI, you can program actions to your physical environment, which are triggered based on location, orientation, and/or gesture data coming from a Taika Ring or Taika Tag.\n\nYou can find aiotaika's documentation from [Read the Docs](https://aiotaika-python.readthedocs.io/).\n\n## Basic Examples\n\nFor more examples, see [examples](/examples) folder of the repository.\n\n### Callback Example\n\nIn this example, we subscribe to move events and gesture events of ring ID 3.\nIn the callback function, we track the latest position and when a gesture event\nhappens, we print out which gesture was made with the latest location data.\n\nWith callbacks one can register one or more callbacks to a single callback function.\nHowever, the Event type must be a parent class of all incoming event objects in that\ncallback function. Here `RingGestureEvent` and `RingMoveEvent` inherit from\n`RingEvent`.\n\n```\nimport asyncio\n\nfrom aiotaika import TaikaClient\nfrom aiotaika.events import EventType\nfrom aiotaika.ring import RingGestureEvent, RingMoveEvent\n\nVector3 last_position\n\nasync def my_callback(event: RingEvent) -> None:\n    if isinstance(event, RingMoveEvent):\n        last_position = event.position\n    elif isinstance(event, RingGestureEvent):\n        print(f\"{event.gesture} in position {last_position}\")\n\n\nasync def main() -> None:\n    async with TaikaClient(\n        host=\"127.0.0.1\", username=\"root\", password=\"\"\n    ) as taika:\n        rings = taika.rings\n        for key, ring in rings.items():\n            print(\"{}: {}\".format(key, ring.metadata))\n        await rings[3].register_event_cb(EventType.RING_MOVE_EVT, my_callback)\n        await rings[3].register_event_cb(EventType.RING_GESTURE_EVT, my_callback)\n        await asyncio.sleep(5)\n\n\ntry:\n    asyncio.run(main())\nexcept KeyboardInterrupt:\n    pass\n```\n\n### Asynchronous Generator Example (no callbacks!)\n\nThis example shows simply how all the incoming events can be handled via the `events`\nAsyncGenerator of the `TaikaClient` class. In this example, we simply print out a\nring's name and position when a `RingMoveEvent` happens.\n\n```\nimport asyncio\n\nfrom aiotaika import TaikaClient\nfrom aiotaika.ring import RingMoveEvent\n\nasync def main() -> None:\n    async with TaikaClient(\n        host=\"127.0.0.1\", username=\"root\", password=\"\"\n    ) as taika:\n        async with taika.events() as events:\n            async for event in events:\n                if isinstance(event, RingMoveEvent):\n                    print(f\"Ring {event.metadata.name} position:\")\n                    print(f\"x: {event.position.x}, z: {event.position.z}\")\n                    print(f\"height: {event.position.y}\")\n\n\ntry:\n    asyncio.run(main())\nexcept KeyboardInterrupt:\n    pass\n```\n\n## Requirements:\n\n### Hardware\n\n- Taika Development Kit\n\n### Software\n\n_Note: these should be automatically satisfied if `aiotaika` is installed via `pip`._\n\nYou can find precise version requirements from [pyproject.toml](/pyproject.toml)\n\n- `Python`\n- `asyncio-mqtt`\n- `aiomysql`\n",
    "bugtrack_url": null,
    "license": "LGPL-2.1 license",
    "summary": "Taika asynchronous client library for Python",
    "version": "0.1.2",
    "split_keywords": [
        "async",
        "asyncio",
        "taika",
        "client",
        "iot"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c2644836f42f3dbb1ad85ddb2355b24e556c8c0ae25356408690cb2a27cfb409",
                "md5": "7e136c641a7db5fe27f426487871fe2a",
                "sha256": "641eed4ee168d7508ce467730153e1af9cbe7fa5e9f5f2d78fce1ebaccd8313a"
            },
            "downloads": -1,
            "filename": "aiotaika-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7e136c641a7db5fe27f426487871fe2a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 27691,
            "upload_time": "2023-04-26T09:50:15",
            "upload_time_iso_8601": "2023-04-26T09:50:15.242674Z",
            "url": "https://files.pythonhosted.org/packages/c2/64/4836f42f3dbb1ad85ddb2355b24e556c8c0ae25356408690cb2a27cfb409/aiotaika-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "462da3f9aeeca39126e40292298e738141213d9fbbdd4c2bbed5778fcb167f22",
                "md5": "8d366599c36d1d4a0f5dd7239ec1d49e",
                "sha256": "51494f6f4c01064d50bec55be5ede5a4e293726f53ca62ac1479a21876919555"
            },
            "downloads": -1,
            "filename": "aiotaika-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "8d366599c36d1d4a0f5dd7239ec1d49e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 30382,
            "upload_time": "2023-04-26T09:50:18",
            "upload_time_iso_8601": "2023-04-26T09:50:18.140453Z",
            "url": "https://files.pythonhosted.org/packages/46/2d/a3f9aeeca39126e40292298e738141213d9fbbdd4c2bbed5778fcb167f22/aiotaika-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-26 09:50:18",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "aiotaika"
}
        
Elapsed time: 0.07443s