Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.13"]
python-version: ["3.14"]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
Expand All @@ -45,7 +45,7 @@ jobs:

- name: Upload coverage HTML
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: coverage-report
path: htmlcov/
Expand All @@ -62,12 +62,12 @@ jobs:
contents: write

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v7
with:
python-version: "3.13"
python-version: "3.14"

- name: Install uv
run: |
Expand All @@ -94,7 +94,7 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1

- name: Create GitHub Release
uses: softprops/action-gh-release@v2.4.1
uses: softprops/action-gh-release@v3.0.3
with:
files: dist/*
generate_release_notes: true
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.13
3.14
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uv 0.13.5
14 changes: 9 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,20 @@ The main `Cbox` class provides async context manager support for connecting to a

**Key Classes:**
- `Cbox`: Main API class that uses aiohttp's ClientSession for HTTP communication
- Uses async context manager pattern (`async with Cbox.connected_to(host)`)
- All API methods are async and raise exceptions on failure
- Uses async context manager pattern (`async with Cbox.connected_to(host)`), which owns and closes its session
- `Cbox(session, host)` uses an external session (e.g. Home Assistant's shared one) and never closes it
- All API methods are async; failures raise `CboxConnectionError` or `CboxCommandError` (both `CboxError`),
invalid arguments raise `ValueError`
- Every request goes through `_send(cmd)` with a timeout (10s by default)
- Endpoint: `/cgi-bin/sendmsg.lua` with query parameter `cmd`

- `CboxInfo`: Dataclass representing the state of the device (temperatures, setpoints, status, firmware info)
- Includes factory method `from_dict()` to parse API responses
- Custom `__repr__()` returns JSON representation

- `StoveStatus`: Enum of device operational states (OFF, BURNING, HEATUP, various alarms)
- `FanStatus`: Enum of fan speed settings (OFF, SPEED_1-5, HIGH, AUTO)
- `StoveStatus`: Enum of device operational states (OFF, BURNING, HEATUP, various alarms); unknown codes map to
`UNKNOWN`, the raw code is kept in `CboxInfo.rawStatus` and `CboxInfo.is_alarm` flags codes >= 241
- `FanStatus`: Enum of fan speed settings (OFF, SPEED_1-5, HIGH, AUTO); unknown codes map to `UNKNOWN`

**API Methods:**
- `fetch_info()`: Gets complete device state via `GET ALLS` command
Expand Down Expand Up @@ -125,7 +129,7 @@ All I/O operations are async using:

## Python Version

This project requires Python 3.13 or higher. The CI pipeline tests against Python 3.13.
This project requires Python 3.14 or higher (as Home Assistant does). The CI pipeline tests against Python 3.14.

## Project Structure

Expand Down
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This project provides an API to interact through http with a `Connection Box` (a

## How to

Check your python installation, `python 3.13.+` is required
Check your python installation, `python 3.14.+` is required

```sh
python --version
Expand All @@ -25,19 +25,30 @@ Start playing around => check [workbench for local dev](workbench_for_local_dev.

```python
async with Cbox.connected_to(host) as cbox:
# Fetch current cbox info
print(await cbox.fetch_info())
# Fetch current cbox info
print(await cbox.fetch_info())

# Change cbox settings
await cbox.change_status(Cbox.Status.OFF)
await cbox.change_fan_setpoint(FanStatus.AUTO)
await cbox.change_temperature_setpoint(19)
await cbox.change_power_setpoint(4)
# Change cbox settings
await cbox.power_off()
await cbox.change_fan_setpoint(FanStatus.AUTO)
await cbox.change_temperature_setpoint(19)
await cbox.change_power_setpoint(4)

# Fetch changed cbox info
print(await cbox.fetch_info())
# Fetch changed cbox info
print(await cbox.fetch_info())
```

If you already manage an `aiohttp.ClientSession` (e.g. in Home Assistant), give it to the `Cbox` along with the host,
it will be used as is and won't be closed:

```python
cbox = Cbox(session, host)
info = await cbox.fetch_info()
```

Errors are reported with `CboxConnectionError` (device unreachable, timeout, bad HTTP response) and `CboxCommandError`
(command rejected by the device), both inheriting from `CboxError`.

Here is the output

```json
Expand Down
31 changes: 16 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
[build-system]
requires = ["uv_build>=0.9.4,<0.10.0"]
requires = ["uv_build>=0.13.5,<0.14.0"]
build-backend = "uv_build"

[project]
name = "connbox"
version = "0.1.0"
requires-python = ">=3.13"
version = "0.1.1"
requires-python = ">=3.14"
description = "This is a service to connect and interact with a connbox for Pellet stoves (Palazzetti, Jotul)"
readme = "README.md"
license = { file = "LICENSE" }
dependencies = [
"aiohttp>=3.13.3",
]
authors = [
{ name = "Sylvain Daclin" }
]
keywords = ["pellet", "stove", "connbox", "palazzetti", "jotul", "fumis", "iot"]
homepage = "https://github.com/sdaclin/cbox"
repository = "https://github.com/sdaclin/cbox"
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Home Automation",
]

[project.urls]
Homepage = "https://github.com/sdaclin/cbox"
Repository = "https://github.com/sdaclin/cbox"

[project.packages]
find = { where = ["src"] }

dependencies = [
"aiohttp>=3.10.8",
]

[dependency-groups]
dev = [
"coverage>=7.6.4",
"pytest>=8.4.2",
"pytest-aiohttp>=1.0.5",
"pytest-asyncio>=0.24",
"coverage>=7.17.0",
"pytest>=9.1.1",
"pytest-aiohttp>=1.1.1",
"pytest-asyncio>=1.4.0",
]
lint = [
"ruff>=0.14.0",
"ruff>=0.17.2",
]

[tool.ruff]
Expand Down
20 changes: 18 additions & 2 deletions src/connbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
"""All you need to manage a connbox."""

from connbox.connbox import Cbox, CboxInfo, FanStatus, StoveStatus
from connbox.connbox import (
Cbox,
CboxCommandError,
CboxConnectionError,
CboxError,
CboxInfo,
FanStatus,
StoveStatus,
)

__all__ = ["Cbox", "CboxInfo", "StoveStatus", "FanStatus"]
__all__ = [
"Cbox",
"CboxCommandError",
"CboxConnectionError",
"CboxError",
"CboxInfo",
"FanStatus",
"StoveStatus",
]
Loading
Loading