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())
贡献/黑客攻击
无论是代码还是文档的贡献都受欢迎。目前功能有限,但我会根据需求扩展。
该项目没有许多依赖项;只有asyncio
和pytest
/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的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 577bafe50b134f3d119c898bedb4619129ba6a14c59e435dba5eec31de03b07c |
|
MD5 | a8e01c30a6517a4834846d81a006039d |
|
BLAKE2b-256 | ef2c9a5cf5f16e3a9afc9161c2570dc29bea5ed3270b9550f861c80c7fe7daad |
关闭
pytouchlinesl-0.1.7-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 64e458990836d1435b49e8aec400b5609a1e2827f7344d74f59cda4abef9d7e1 |
|
MD5 | 7dfb05cc75f579d234972dc1c3e5d93a |
|
BLAKE2b-256 | e402c0ab3bf4248031a1abc655cd721b25330076cb6600fd45f1bc5d5deb78ee |