控制Shelly设备的异步库。
aioshell的Python项目详细描述
艾奥舍利
控制Shelly的异步库
这个图书馆正在开发中
需要python3并使用asyncio、aiohttp和aiocoap。在
importasynciofrompprintimportpprintimportaiohttpimportaioshellyasyncdefmain():options=aioshelly.ConnectionOptions("192.168.1.165","username","password")asyncwithaiohttp.ClientSession()asaiohttp_session,aioshelly.COAP()ascoap_context:try:device=awaitasyncio.wait_for(aioshelly.Device.create(aiohttp_session,coap_context,options),5)exceptasyncio.TimeoutError:print("Timeout connecting to",ip)returnforblockindevice.blocks:print(block)pprint(block.current_values())print()if__name__=="__main__":asyncio.run(main())
包括的示例
存储库包含两个示例,可以快速试用。在
连接到设备并在收到状态更改时打印其状态:
^{pr2}$立即连接到devices.json
中的所有设备并打印其状态:
python3 example.py
捐款指南
对象层次结构和属性/方法名称应与Shelly API匹配。在
- 项目
标签: