Skip to main content

Python client for Kospel C.MI electric heater HTTP API

Project description

kospel-cmi-lib

Python client for the Kospel C.MI electric heater HTTP API.

Features

  • Async-first: Built on asyncio and aiohttp for non-blocking I/O
  • Type-safe: Strict type hinting throughout
  • Registry-driven: Settings defined declaratively in a central registry; dynamic property access on HeaterController
  • Simulator-capable: Full simulator for offline development and testing (no hardware required)
  • Protocol-based: Decoder/encoder interfaces via Python Protocol types

Installation

# With uv (recommended)
uv add kospel-cmi-lib

# With pip
pip install kospel-cmi-lib

Usage

Create a register backend (HTTP or YAML), then pass it to HeaterController. When using HttpRegisterBackend, call aclose() or use the controller as an async context manager to release the HTTP session when done.

Recommended: async context manager (resources released automatically):

import asyncio
import aiohttp
from kospel_cmi.controller.api import HeaterController
from kospel_cmi.kospel.backend import HttpRegisterBackend, YamlRegisterBackend


async def main() -> None:
    api_base_url = "http://192.168.1.1/api/dev/65"  # Replace with your heater URL
    async with aiohttp.ClientSession() as session:
        backend = HttpRegisterBackend(session, api_base_url)
        async with HeaterController(backend=backend) as controller:
            await controller.refresh()
            print(controller.heater_mode)  # Access registry-defined settings
            # controller.heater_mode = "manual"  # Modify (if writable)
            # await controller.save()  # Write pending changes to the device
    # Session and controller resources released here


asyncio.run(main())

Alternative: explicit aclose() (for long-lived integrations like Home Assistant):

controller = HeaterController(backend=HttpRegisterBackend(session, api_base_url))
try:
    await controller.refresh()
    # ... use controller ...
finally:
    await controller.aclose()

For offline development or tests, use the YAML backend (no HTTP, no close needed):

backend = YamlRegisterBackend(state_file="/path/to/state.yaml")
controller = HeaterController(backend=backend)
await controller.refresh()

Documentation

License

Apache License 2.0

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kospel_cmi_lib-0.1.0a3.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kospel_cmi_lib-0.1.0a3-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file kospel_cmi_lib-0.1.0a3.tar.gz.

File metadata

  • Download URL: kospel_cmi_lib-0.1.0a3.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kospel_cmi_lib-0.1.0a3.tar.gz
Algorithm Hash digest
SHA256 df393a82740a436d5241df46a38497f814fd3ef9ccbf10bfd3d342589c29916e
MD5 9f66f90032419da70130a68907b243bf
BLAKE2b-256 985112f0fe200c27bb3ecd9a7ed8bd1e654e6a5c0eba5c5549c9c78e43a3fe85

See more details on using hashes here.

Provenance

The following attestation bundles were made for kospel_cmi_lib-0.1.0a3.tar.gz:

Publisher: release-pypi.yml on JanKrl/kospel-cmi-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kospel_cmi_lib-0.1.0a3-py3-none-any.whl.

File metadata

File hashes

Hashes for kospel_cmi_lib-0.1.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 4914e5b5e7b05e3a7de4700661f9915cfb41540a4345269f9bb741bf2931432c
MD5 42267c099df28d41db95499fd8ac9cf8
BLAKE2b-256 b38944b727071bd6ae5e96a4489801033f83abe318063a9acaee046824bf3de7

See more details on using hashes here.

Provenance

The following attestation bundles were made for kospel_cmi_lib-0.1.0a3-py3-none-any.whl:

Publisher: release-pypi.yml on JanKrl/kospel-cmi-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page