bond-api-0.1.9
توضیحات
Asynchronous Python wrapper library over Bond Local API
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | bond-api-0.1.9 |
| نام | bond-api |
| نسخه کتابخانه | 0.1.9 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Eugene Prystupa |
| ایمیل نویسنده | eugene.prystupa@gmail.com |
| آدرس صفحه اصلی | https://github.com/prystupa/bond-api |
| آدرس اینترنتی | https://pypi.org/project/bond-api/ |
| مجوز | MIT |
# bond-api
Asynchronous Python wrapper library over Bond Local API
## Installation
From PyPi:
```bash
pip3 install bond-api
```
## Library Usage
```python3
import asyncio
from aiohttp import ClientResponseError, ClientConnectorError
from bond_api 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())
```
نیازمندی
| مقدار | نام |
|---|---|
| >=3.6.1 | aiohttp |
نحوه نصب
نصب پکیج whl bond-api-0.1.9:
pip install bond-api-0.1.9.whl
نصب پکیج tar.gz bond-api-0.1.9:
pip install bond-api-0.1.9.tar.gz