Asynchronous, typed API client for the Habitron SmartHub
Project description
Habitron Client
An asynchronous, fully typed API client for the Habitron SmartHub, designed for integration with Home Assistant.
Features
- Non-blocking TCP communication via
asyncioStreamReader/StreamWriter. - Persistent, lock-serialised connection with automatic reconnect on errors.
- Automatic CRC16 calculation and command wrapping.
- High-level coroutines for outputs, dimmers, RGB, shutters, climate and more.
- Safe YAML parsing (
yaml.safe_load) into validatedTypedDictmodels. - Async UDP discovery of SmartHubs on the local network.
- Typed exception hierarchy and a
py.typedmarker (PEP 561 compliant).
Requirements
- Python 3.11+
Installation
pip install habitron-client
Usage
The client is async-only and is used as an async context manager:
import asyncio
from habitron_client import HabitronClient, HabitronError
async def main() -> None:
async with HabitronClient("192.0.2.10") as client:
info = await client.get_smhub_info()
print(info["software"]["version"])
await client.set_output(mod_addr=1, nmbr=2, val=True)
asyncio.run(main())
Error handling
All failures raise a typed exception:
HabitronError (root)
├── HabitronConnectionError (refused / EOF / socket lost)
├── HabitronTimeoutError (no response within the deadline)
└── HabitronProtocolError
├── HabitronChecksumError (CRC mismatch)
└── HabitronBusError (SmartHub reported an error)
Discovery
from habitron_client import discover_smarthubs
hubs = await discover_smarthubs()
Development
pip install -e ".[dev]"
ruff check .
ruff format --check .
mypy --strict src/habitron_client
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file habitron_client-2.0.7.tar.gz.
File metadata
- Download URL: habitron_client-2.0.7.tar.gz
- Upload date:
- Size: 67.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5693b8badc2e35393f20643d7604157ef8ac3f40400998493b43c51262fa79b1
|
|
| MD5 |
1131481e6bca7ab3370ec322de9c3c4e
|
|
| BLAKE2b-256 |
d9edbe20fb818cde86ea7438da529abf161b0550609c92160dcab3e86b5cdf05
|
Provenance
The following attestation bundles were made for habitron_client-2.0.7.tar.gz:
Publisher:
release.yml on dneprojects/habitron-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
habitron_client-2.0.7.tar.gz -
Subject digest:
5693b8badc2e35393f20643d7604157ef8ac3f40400998493b43c51262fa79b1 - Sigstore transparency entry: 1923175501
- Sigstore integration time:
-
Permalink:
dneprojects/habitron-client@64f71c3a0f2c314beb3291c91def84364d4f8870 -
Branch / Tag:
refs/tags/v2.0.7 - Owner: https://github.com/dneprojects
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64f71c3a0f2c314beb3291c91def84364d4f8870 -
Trigger Event:
push
-
Statement type:
File details
Details for the file habitron_client-2.0.7-py3-none-any.whl.
File metadata
- Download URL: habitron_client-2.0.7-py3-none-any.whl
- Upload date:
- Size: 39.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aad0c29a2e1c311281a7b87fd9ae9ba3364f8a18dd154a1fe5f8ab20d51e6132
|
|
| MD5 |
268f085c7db729ff73189e751c846043
|
|
| BLAKE2b-256 |
2c216a0700913e99fe170db4a62f96172a00464c628bed155e4207b22edf5361
|
Provenance
The following attestation bundles were made for habitron_client-2.0.7-py3-none-any.whl:
Publisher:
release.yml on dneprojects/habitron-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
habitron_client-2.0.7-py3-none-any.whl -
Subject digest:
aad0c29a2e1c311281a7b87fd9ae9ba3364f8a18dd154a1fe5f8ab20d51e6132 - Sigstore transparency entry: 1923175712
- Sigstore integration time:
-
Permalink:
dneprojects/habitron-client@64f71c3a0f2c314beb3291c91def84364d4f8870 -
Branch / Tag:
refs/tags/v2.0.7 - Owner: https://github.com/dneprojects
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64f71c3a0f2c314beb3291c91def84364d4f8870 -
Trigger Event:
push
-
Statement type: