Skip to main content

Habitron Client

An asynchronous, fully typed API client for the Habitron SmartHub, designed for integration with Home Assistant.

Features

  • Non-blocking TCP communication via asyncio StreamReader/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 validated TypedDict models.
  • Async UDP discovery of SmartHubs on the local network.
  • Typed exception hierarchy and a py.typed marker (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

Metadata

Release files for habitron-client 2.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for habitron-client 2.4.1
File Size Uploaded Provenance Actions
habitron_client-2.4.1.tar.gz 95.0 kB With provenance Details for habitron_client-2.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for habitron-client 2.4.1
File Interpreter ABI Platform Actions
habitron_client-2.4.1-py3-none-any.whl Python 3 none any Details for habitron_client-2.4.1-py3-none-any.whl

Total release size: 147.4 kB

Release files / habitron_client-2.4.1.tar.gz

Download URL habitron_client-2.4.1.tar.gz
Size 95.0 kB
Tags Source
SHA-256 checksum
How to use checksums
309afa5ec9f049f94413cf11ca2bce310886673c49f8d0ac4ed14ca9a613d1dd
BLAKE2b-256 checksum
How to use checksums
f920590ef112937a2b44929f0eec81717c38bf1800750e330158c306d224b19a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / habitron_client-2.4.1-py3-none-any.whl

Download URL habitron_client-2.4.1-py3-none-any.whl
Size 52.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f28da1b57f79d5abc0dcfd1eca2f3723cbffccf87f1ffd2b16928a82429f3b3c
BLAKE2b-256 checksum
How to use checksums
0bbbc0fbc08f0f408a923f0861af7f83bfc5fc5f9bad625e156f2146b2e95fc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for habitron-client 2.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for habitron_client-2.4.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.4.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page