跳转到主要内容

Nibe Uplink REST API的Python包装器

项目描述

模块

该模块是一个由asyncio驱动的nibe uplink公共API接口。它每4秒限制一个HTTP请求,因此请尽量通过批量请求来充分利用您的请求。

状态

https://github.com/elupus/nibeuplink/actions/workflows/python-package.yml/badge.svg https://codecov.io/gh/elupus/nibeuplink/branch/master/graph/badge.svg?token=WZy5CcdYom

示例

def token_read():
    return None

def token_write(token):
    pass

async def run():
    async with nibeuplink.Uplink(client_id         = 'XXX',
                                 client_secret     = 'YYY',
                                 redirect_uri      = 'ZZZ',
                                 access_data       = token_read(),
                                 access_data_write = token_write,
                                 scope             = 'READSYSTEM') as uplink:

        if not uplink.access_data:
            auth_uri = uplink.get_authorize_url()
            print(auth_uri)
            result = input('Enter full redirect url: ')
            await uplink.get_access_token(uplink.get_code_from_url(result))

        # Request all systems
        print(uplink.get_systems())


        # Request data for specific system
        print(uplink.get_system(12345))

        # Request data for parameters. Note request them in paralell using gather semantics
        # that way, the module with batch up the requests into a single request to api
        print(await asyncio.gather(uplink.get_parameter(12345, 11111),
                                   uplink.get_parameter(12345, 22222)))




loop = asyncio.get_event_loop()
loop.run_until_complete (run())

控制台

该模块包含一个名为 nibeuplink 的命令行实用程序,用于测试和从Nibe Uplink请求数据,它将在当前目录中名为nibeuplink.json的文件中存储令牌信息。

示例

实用程序的帮助信息

nibeuplink -h

请求所有系统

nibeuplink --client_id 'XXX' --client_secret 'YYY' --redirect_uri 'ZZZ'

请求特定系统的数据

nibeuplink --client_id 'XXX' --client_secret 'YYY' --redirect_uri 'ZZZ' --system 12345

请求参数数据

nibeuplink --client_id 'XXX' --client_secret 'YYY' --redirect_uri 'ZZZ' --system 12345 --parameter 11111 22222

项目详情


下载文件

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

源代码分发

nibeuplink-1.3.0.tar.gz (14.3 kB 查看哈希值)

上传于 源代码

构建版本

nibeuplink-1.3.0-py3-none-any.whl (16.2 kB 查看哈希值)

上传于 Python 3

由以下支持