bond-async


Namebond-async JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/bondhome/bond-async
SummaryAsynchronous Python wrapper library over Bond Local API
upload_time2023-07-13 19:40:33
maintainer
docs_urlNone
authorOlibra LLC
requires_python
licenseMIT
keywords bond local api async
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # bond-async
Asynchronous Python wrapper library over Bond Local API

Forked from https://github.com/prystupa/bond-api
Thanks @prystupa for the great work!

## Installation

From PyPi:

```bash
pip3 install bond-async
```

## Library Usage
```python3
import asyncio

from aiohttp import ClientResponseError, ClientConnectorError

from bond_async import Bond, Action


async def main():
    """Example of library usage."""
    
    bond = Bond("[your ip or hostname here]", "[your bond API token here]")

    try:
        print("Version:")
        print(await bond.version())

        print("Device IDs:")
        device_ids = await bond.devices()
        print(device_ids)

        print("Devices:")
        devices = await asyncio.gather(*[bond.device(device_id) for device_id in device_ids])
        print(devices)

        print("Devices Properties:")
        properties = await asyncio.gather(*[bond.device_properties(device_id) for device_id in device_ids])
        print(properties)

        print("Devices State:")
        state = await asyncio.gather(*[bond.device_state(device_id) for device_id in device_ids])
        print(state)

        print("Turn on fan!")
        await bond.action("[your fan device ID here]", Action.turn_on())

        print("Change fan speed!")
        await bond.action("[your fan device ID here]", Action.set_speed(2))

        print("Turn off fan!")
        await bond.action("[your fan device ID here]", Action.turn_off())
        
    except ClientResponseError as x:
        print("Client response error: ", x)
    except ClientConnectorError as x:
        print("Client connector error: ", x)


if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/bondhome/bond-async",
    "name": "bond-async",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "bond local api async",
    "author": "Olibra LLC",
    "author_email": "mobiledev@olibra.io",
    "download_url": "https://files.pythonhosted.org/packages/88/b8/8f687aef0f5ccf1ef9d5fe84b6b7cc9f30b3656b4182c84fc22d737b48d4/bond_async-0.2.1.tar.gz",
    "platform": null,
    "description": "# bond-async\nAsynchronous Python wrapper library over Bond Local API\n\nForked from https://github.com/prystupa/bond-api\nThanks @prystupa for the great work!\n\n## Installation\n\nFrom PyPi:\n\n```bash\npip3 install bond-async\n```\n\n## Library Usage\n```python3\nimport asyncio\n\nfrom aiohttp import ClientResponseError, ClientConnectorError\n\nfrom bond_async import Bond, Action\n\n\nasync def main():\n    \"\"\"Example of library usage.\"\"\"\n    \n    bond = Bond(\"[your ip or hostname here]\", \"[your bond API token here]\")\n\n    try:\n        print(\"Version:\")\n        print(await bond.version())\n\n        print(\"Device IDs:\")\n        device_ids = await bond.devices()\n        print(device_ids)\n\n        print(\"Devices:\")\n        devices = await asyncio.gather(*[bond.device(device_id) for device_id in device_ids])\n        print(devices)\n\n        print(\"Devices Properties:\")\n        properties = await asyncio.gather(*[bond.device_properties(device_id) for device_id in device_ids])\n        print(properties)\n\n        print(\"Devices State:\")\n        state = await asyncio.gather(*[bond.device_state(device_id) for device_id in device_ids])\n        print(state)\n\n        print(\"Turn on fan!\")\n        await bond.action(\"[your fan device ID here]\", Action.turn_on())\n\n        print(\"Change fan speed!\")\n        await bond.action(\"[your fan device ID here]\", Action.set_speed(2))\n\n        print(\"Turn off fan!\")\n        await bond.action(\"[your fan device ID here]\", Action.turn_off())\n        \n    except ClientResponseError as x:\n        print(\"Client response error: \", x)\n    except ClientConnectorError as x:\n        print(\"Client connector error: \", x)\n\n\nif __name__ == '__main__':\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(main())\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Asynchronous Python wrapper library over Bond Local API",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/bondhome/bond-async"
    },
    "split_keywords": [
        "bond",
        "local",
        "api",
        "async"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7983c796dbe88d79efb7d93b85d05c269094b02e94b2f329c6d7362a793eab6f",
                "md5": "73bf333967d662e89215cfef3a221fa0",
                "sha256": "ea59b0dece1c56a9b5d8f3e8908b01eba8a091bac4a8fa744bb53e170907e514"
            },
            "downloads": -1,
            "filename": "bond_async-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "73bf333967d662e89215cfef3a221fa0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10578,
            "upload_time": "2023-07-13T19:40:32",
            "upload_time_iso_8601": "2023-07-13T19:40:32.398236Z",
            "url": "https://files.pythonhosted.org/packages/79/83/c796dbe88d79efb7d93b85d05c269094b02e94b2f329c6d7362a793eab6f/bond_async-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "88b88f687aef0f5ccf1ef9d5fe84b6b7cc9f30b3656b4182c84fc22d737b48d4",
                "md5": "40b60e2cfdd63abbbdd96a17a44c6556",
                "sha256": "8ad2452d3d69b5db444de33035629ea4804675150050060197945e765f4e4251"
            },
            "downloads": -1,
            "filename": "bond_async-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "40b60e2cfdd63abbbdd96a17a44c6556",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9629,
            "upload_time": "2023-07-13T19:40:33",
            "upload_time_iso_8601": "2023-07-13T19:40:33.877775Z",
            "url": "https://files.pythonhosted.org/packages/88/b8/8f687aef0f5ccf1ef9d5fe84b6b7cc9f30b3656b4182c84fc22d737b48d4/bond_async-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-13 19:40:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bondhome",
    "github_project": "bond-async",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "bond-async"
}
        
Elapsed time: 0.09035s