Add capacity actuator helpers (pilot-wire, thermal-mode, set-point) #45

Merged
mat merged 1 commit from capacity-actuators into main 2026-07-08 09:01:26 +00:00
Owner

Summary

Adds the three missing capacity actuator helpers, wrapping documented /api/capacities/{id}/... endpoints, and groups all capacity control in a dedicated CapacitiesMixin:

  • set_pilot_wire(capacity_id, state)PUT /capacities/{id}/pilot-wire?state=
  • set_thermal_mode(capacity_id, state)PUT /capacities/{id}/thermal-mode?state=
  • set_thermostat_set_point(capacity_id, value)PUT /capacities/{id}/thermostat-set-point?value=

switch_capacity is moved from DevicesMixin into the new comwatt_client/_capacities.py CapacitiesMixin (behaviour unchanged) so all capacity control lives together, consistent with the domain-mixin split.

⚠️ Verification caveat (please read)

These are write operations on real hardware, and the state enum values for pilot-wire / thermal-mode are backend-defined and unconfirmed (the API docs mark them TODO). The test account has no pilot-wire/thermostat device, so they could not be exercised against live hardware. Therefore:

  • state / value are passed through as-is — no client-side enum validation. Docstrings point users at the capacity's selectValues field for valid values.
  • Tests are HTTP-mocked (responses), like the entire existing suite: they verify URL/param construction and error propagation, not hardware behaviour.

Changes

  • comwatt_client/_capacities.py: new CapacitiesMixin (switch_capacity moved in + 3 new helpers).
  • comwatt_client/_devices.py: switch_capacity removed.
  • comwatt_client/client.py: ComwattClient now also inherits CapacitiesMixin.
  • tests/test_capacities.py: new; the switch_capacity tests moved here + success/error tests for the 3 new helpers.
  • tests/test_devices.py: switch_capacity tests removed (moved).
  • README.md: documents switch_capacity (previously undocumented) + the 3 new helpers, with the enum caveat.

Test plan

  • pytest → 99 passed.
  • mypy comwatt_client → clean (11 source files).
  • Public API unchanged for existing callers (client.switch_capacity(...) still works — it's still a method on ComwattClient).

Opened as a draft (WIP) — mark ready for review when you're happy.

## Summary Adds the three missing capacity **actuator** helpers, wrapping documented `/api/capacities/{id}/...` endpoints, and groups all capacity control in a dedicated `CapacitiesMixin`: - `set_pilot_wire(capacity_id, state)` → `PUT /capacities/{id}/pilot-wire?state=` - `set_thermal_mode(capacity_id, state)` → `PUT /capacities/{id}/thermal-mode?state=` - `set_thermostat_set_point(capacity_id, value)` → `PUT /capacities/{id}/thermostat-set-point?value=` `switch_capacity` is **moved** from `DevicesMixin` into the new `comwatt_client/_capacities.py` `CapacitiesMixin` (behaviour unchanged) so all capacity control lives together, consistent with the domain-mixin split. ## ⚠️ Verification caveat (please read) These are **write** operations on real hardware, and the `state` enum values for `pilot-wire` / `thermal-mode` are **backend-defined and unconfirmed** (the API docs mark them TODO). The test account has no pilot-wire/thermostat device, so they could not be exercised against live hardware. Therefore: - `state` / `value` are **passed through as-is** — no client-side enum validation. Docstrings point users at the capacity's `selectValues` field for valid values. - Tests are HTTP-mocked (`responses`), like the entire existing suite: they verify URL/param construction and error propagation, not hardware behaviour. ## Changes - `comwatt_client/_capacities.py`: new `CapacitiesMixin` (`switch_capacity` moved in + 3 new helpers). - `comwatt_client/_devices.py`: `switch_capacity` removed. - `comwatt_client/client.py`: `ComwattClient` now also inherits `CapacitiesMixin`. - `tests/test_capacities.py`: new; the `switch_capacity` tests moved here + success/error tests for the 3 new helpers. - `tests/test_devices.py`: `switch_capacity` tests removed (moved). - `README.md`: documents `switch_capacity` (previously undocumented) + the 3 new helpers, with the enum caveat. ## Test plan - [x] `pytest` → 99 passed. - [x] `mypy comwatt_client` → clean (11 source files). - [x] Public API unchanged for existing callers (`client.switch_capacity(...)` still works — it's still a method on `ComwattClient`). Opened as a draft (WIP) — mark ready for review when you're happy.
Add capacity actuator helpers (pilot-wire, thermal-mode, set-point)
All checks were successful
Tests / forgejo-pytest (push) Successful in 42s
Tests / forgejo-pytest (pull_request) Successful in 42s
e1e1ff4802
Introduce a dedicated CapacitiesMixin (comwatt_client/_capacities.py) and
add three write helpers that wrap the documented /capacities/{id}/...
endpoints:

- set_pilot_wire(capacity_id, state)        -> PUT .../pilot-wire?state=
- set_thermal_mode(capacity_id, state)      -> PUT .../thermal-mode?state=
- set_thermostat_set_point(capacity_id, v)  -> PUT .../thermostat-set-point?value=

switch_capacity is moved from DevicesMixin into the new CapacitiesMixin so
all capacity control lives together (behaviour unchanged). state/value are
passed through as-is: the pilot-wire/thermal-mode enum values are defined
by the backend and could not be verified against a live device on the test
account, so no client-side validation is imposed (see docstrings /
capacity selectValues).

Tests are HTTP-mocked (responses), like the rest of the suite: they assert
URL/param construction and error propagation. 99 passed, mypy clean.
mat changed title from WIP: Add capacity actuator helpers (pilot-wire, thermal-mode, set-point) to Add capacity actuator helpers (pilot-wire, thermal-mode, set-point) 2026-07-08 09:01:22 +00:00
mat merged commit 1536e57760 into main 2026-07-08 09:01:26 +00:00
mat deleted branch capacity-actuators 2026-07-08 09:01:26 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mat/python-comwatt-client!45
No description provided.