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
asyncioandaiohttpfor 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
Protocoltypes
Installation
# With uv (recommended)
uv add kospel-cmi-lib
# With pip
pip install kospel-cmi-lib
Usage
Create a register backend (HTTP or YAML), load a registry config, and pass both 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.controller.registry import load_registry
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
registry = load_registry("kospel_cmi_standard")
async with aiohttp.ClientSession() as session:
backend = HttpRegisterBackend(session, api_base_url)
async with HeaterController(backend=backend, registry=registry) 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):
registry = load_registry("kospel_cmi_standard")
controller = HeaterController(backend=HttpRegisterBackend(session, api_base_url), registry=registry)
try:
await controller.refresh()
# ... use controller ...
finally:
await controller.aclose()
For offline development or tests, use the YAML backend (no HTTP, no close needed):
registry = load_registry("kospel_cmi_standard")
backend = YamlRegisterBackend(state_file="/path/to/state.yaml")
controller = HeaterController(backend=backend, registry=registry)
await controller.refresh()
Setting Heater Mode
import asyncio
import aiohttp
from kospel_cmi.controller.api import HeaterController
from kospel_cmi.controller.registry import load_registry
from kospel_cmi.kospel.backend import HttpRegisterBackend
from kospel_cmi.registers.enums import HeaterMode, ManualMode
async def main():
registry = load_registry("kospel_cmi_standard")
async with aiohttp.ClientSession() as session:
backend = HttpRegisterBackend(session, "http://192.168.1.1/api/dev/65")
async with HeaterController(backend=backend, registry=registry) as controller:
await controller.refresh()
# Modify settings
controller.heater_mode = HeaterMode.WINTER
controller.manual_temperature = 22.0
controller.is_manual_mode_enabled = ManualMode.ENABLED
# Write all changes at once
success = await controller.save()
print(f"Settings saved: {success}")
asyncio.run(main())
Documentation
Module Documentation
Module-specific documentation is co-located with the code (GitHub automatically displays these when browsing directories):
- kospel/ - HTTP API endpoints and protocol
- registers/ - Register encoding, decoding, and mappings
- controller/ - YAML registry config and load_registry
Project Documentation
- Development Guide - Contributing and extending the library
- Architecture - System design, layers, components, and data flow
- Technical Specs - Implementation details, data formats, protocols, testing, and coding standards
Roadmap
v1.0.0 Engine & Explorer
- Local control - basic device functions can be operated using the library
- Robust interface - an interface for 3rd party tools (i.e., Home Assistant integration)
- Reverse-engineering toolset - ease integration with other device types
v2.0.0 Plug & Play for Kospel ecosystem
- Support multiple device types
- Device discovery
- Advanced state management (error and warning flags, fault detection, debug)
References
This library was reverse-engineered from JavaScript code used in the heater's web interface. Key findings:
- Register encoding uses little-endian byte order
- Flag bits are used for boolean settings within registers
- Temperature and pressure values are scaled for precision
- Read-Modify-Write pattern is required for setting flag bits
License
Apache License 2.0
Links
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 kospel_cmi_lib-0.1.0a4.tar.gz.
File metadata
- Download URL: kospel_cmi_lib-0.1.0a4.tar.gz
- Upload date:
- Size: 22.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20d1693344c1539a1e403edfa3c6cabfe400878a9ceb03146f21e328cab0ae8e
|
|
| MD5 |
601e4d94e3bc9896894eec976dc7bdcd
|
|
| BLAKE2b-256 |
8ecc137f168102e8e4e369c1e1be4b46bf15251fca5f740af78c271509c5c267
|
Provenance
The following attestation bundles were made for kospel_cmi_lib-0.1.0a4.tar.gz:
Publisher:
release-pypi.yml on JanKrl/kospel-cmi-lib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kospel_cmi_lib-0.1.0a4.tar.gz -
Subject digest:
20d1693344c1539a1e403edfa3c6cabfe400878a9ceb03146f21e328cab0ae8e - Sigstore transparency entry: 953519116
- Sigstore integration time:
-
Permalink:
JanKrl/kospel-cmi-lib@cda892bc2c0a07268ecf81e4817994653720e263 -
Branch / Tag:
refs/tags/v0.1.0-alpha.4 - Owner: https://github.com/JanKrl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@cda892bc2c0a07268ecf81e4817994653720e263 -
Trigger Event:
push
-
Statement type:
File details
Details for the file kospel_cmi_lib-0.1.0a4-py3-none-any.whl.
File metadata
- Download URL: kospel_cmi_lib-0.1.0a4-py3-none-any.whl
- Upload date:
- Size: 30.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f5911fdd6deb01c245fc0fc1bd441d446ce94ea6cb1ca24e7e3cb2b07bf3d1d
|
|
| MD5 |
9f60ce78407904f7877216eb7c1c1003
|
|
| BLAKE2b-256 |
dec3edf29d1ae569a4d2b90306caf7d8dd8efc0f52189cf9653408bc47bb7811
|
Provenance
The following attestation bundles were made for kospel_cmi_lib-0.1.0a4-py3-none-any.whl:
Publisher:
release-pypi.yml on JanKrl/kospel-cmi-lib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kospel_cmi_lib-0.1.0a4-py3-none-any.whl -
Subject digest:
9f5911fdd6deb01c245fc0fc1bd441d446ce94ea6cb1ca24e7e3cb2b07bf3d1d - Sigstore transparency entry: 953519117
- Sigstore integration time:
-
Permalink:
JanKrl/kospel-cmi-lib@cda892bc2c0a07268ecf81e4817994653720e263 -
Branch / Tag:
refs/tags/v0.1.0-alpha.4 - Owner: https://github.com/JanKrl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@cda892bc2c0a07268ecf81e4817994653720e263 -
Trigger Event:
push
-
Statement type: