跳转到主要内容

Roth's TouchlineSL控制系统的API客户端。

项目描述

一个用于Roth的TouchlineSL系统的Python库

Roth TouchlineSL是一个用于地面供暖、冷却和散热器控制的控制系统。它们有一个公开的API,其文档位于他们的网站

此项目提供Python客户端,用于与API交互和控制供暖系统。它不覆盖API的全部功能,目前提供以下功能:

  • 使用https://roth-touchlinesl.com账户进行认证
  • 列出与账户关联的模块
  • 获取单个区域的详细信息
  • 获取全局供暖计划的详细信息
  • 为区域设置一个恒定的目标温度
  • 将区域分配给特定的全局计划

该库主要设计用于支持Home Assistant集成的发展。

设计

Roth的API设计使得对单个区域或计划的操作相当困难。只有一个端点用于获取区域配置,而且它是返回所有连接到模块的区域数据的同一个端点。

因此,该客户端实现了一些基本的缓存。每次查询模块端点时,结果将缓存30秒。任何POST请求(设置温度、将区域分配给计划)将使缓存失效,所有GET方法都有一个refresh参数,可以用来强制刷新底层数据。

安装

可以像通常一样从PyPi安装此软件包

pip install pytouchlinesl

示例用法

import asyncio
import os

from pytouchlinesl import TouchlineSL

async def touchlinesl_example():
    tsl = TouchlineSL(
        username=os.getenv("TOUCHLINESL_LOGIN"),
        password=os.getenv("TOUCHLINESL_PASSWORD"),
    )

    # Fetch a list of modules associated with the account
    modules = await tsl.modules()
    module = await tsl.module(module_id=modules[0].id)

    # Fetch a zone by name, set a constant target temperature of 17.0
    utility = await module.zone_by_name("Utility Room")
    await utility.set_temperature(17.0)

    # Fetch a zone by ID, assign it to a global schedule named "Living Spaces"
    kitchen = await module.zone(2411)
    living_spaces = await module.schedule_by_name("Living Spaces")
    await kitchen.set_schedule(living_spaces.id)

if __name__ == "__main__":
    asyncio.set_event_loop(asyncio.new_event_loop())
    asyncio.run(touchlinesl_example())

贡献/黑客攻击

无论是代码还是文档的贡献都受欢迎。目前功能有限,但我会根据需求扩展。

该项目没有许多依赖项;只有asynciopytest/pytest-asyncio用于测试。

依赖项使用uv管理。你可以这样开始

# Clone the repository
git clone https://github.com/jnsgruk/pytouchlinesl
cd pytouchlinesl

# Run the tests
uv run pytest
# Lint the code
uv run ruff check --fix
# Format the code
uv run ruff format

如果你更愿意使用标准的Python工具,你也可以这样做

# Clone the repository
git clone https://github.com/jnsgruk/pytouchlinesl
cd pytouchlinesl

# Create a virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install dev/project dependencies
pip install -e '.[dev]'

# Run the tests
pytest -s
# Lint the code
ruff check --fix
# Format the code
ruff format

项目详情


下载文件

下载适用于您平台的电影文件。如果您不确定选择哪一个,请了解更多关于安装软件包的信息。

源分布

pytouchlinesl-0.1.7.tar.gz (17.2 kB 查看哈希)

上传时间

构建分布

pytouchlinesl-0.1.7-py3-none-any.whl (17.2 kB 查看哈希)

上传时间 Python 3

支持者

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