跳转到主要内容

Python模块,用于与Rainforest EAGLE-200通信。

项目描述

Aioeagle

用于控制Rainforest EAGLE-200的异步库

需要 Python 3.8+,并使用 asyncio 和 aiohttp。

import asyncio
from pprint import pprint

import aiohttp
from aioeagle import EagleHub


CLOUD_ID = "123456"
INSTALL_CODE = "abcdefghijklmn"


async def main():
    async with aiohttp.ClientSession() as session:
        await run(session)


async def run(websession):
    hub = EagleHub(websession, CLOUD_ID, INSTALL_CODE)
    devices = await hub.get_device_list()

    if len(devices) == 0:
        print("No devices found")
        return

    device = devices[0]

    pprint(device.details)
    print()
    pprint(await device.get_device_query(device.ENERGY_AND_POWER_VARIABLES))


asyncio.run(main())

本地测试

python3 example.py <cloud_id> <install_code>

超时

Aioeagle没有为任何请求指定超时。您需要在自己的代码中指定它们。我们推荐使用 async_timeout

import async_timeout

with async_timeout.timeout(10):
    devices = await hub.get_device_list()

贡献指南

类别层次结构和属性/方法名称应与EAGLE-200 API匹配。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源分布

上传时间:

构建分布

上传时间: Python 3

支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面