✨ feat: set_thermal_control(thermal_control_id, device_id, set_point, mode) #174

Merged
mat merged 1 commit from feat/thermal-control-write into main 2026-10-27 11:20:45 +00:00
Owner

Summary

 ThermalControlMixin (_thermal_control.py)
+  set_thermal_control(thermal_control_id, device_id, set_point=None, mode=None)
+    → PUT /api/thermalcontrol/{config_id}
+    body built by the client: {"device": {"@class": "Device", "id": int(device_id)}}
+                          + "setPoint" / "mode" only when not None

This issue was presumed blocked ("no thermal device reachable, shapes unconfirmed") — but a 2026-10-27 enum-binding oracle (probing the validation layer against a nonexistent id, no real resource touched) live-verified the body skeleton: the inline device object REQUIRES the Jackson discriminator "@class": "Device" + numeric id (else 400 "Failed to read request"); device is the only required field; setPoint/mode are optional; validation runs before the path lookup. The {id} is the thermal-control config id (a device id 404s), obtained from get_thermal_control(device_id) on devices that have one. The client coerces int(device_id) so string ids serialize numerically. Still honestly documented: the success path is unverified (no thermal-control config exists on the probe account) and mode values are unconfirmed at this endpoint (capacity-level enum: OFF/HEAT/COOL). Field notes updated with the findings (incl. GET by-id → 405).

Evidence

  • Before: AttributeError — the write path was not exposed; the body shape was a total unknown.
  • After: 4 tests (both-fields happy pinning the exact device object with discriminator, set_point-only with mode ABSENT from the body, string device id serializing as JSON number 7, 500 → ComwattAPIError), TDD red→green; pytest = 224 passed; mypy clean. Reviewer verdicts: spec PASS, quality PASS; one fix round (int coercion — spec-originated Important, controller-ruled) scoped re-reviewed PASS.

Merge Danger

Door: two-way — additive method; revert removes it.

Blast Radius: low — one new public write method; the discriminator quirk is built in, not caller-facing.

Closes #108

## Summary ```diff ThermalControlMixin (_thermal_control.py) + set_thermal_control(thermal_control_id, device_id, set_point=None, mode=None) + → PUT /api/thermalcontrol/{config_id} + body built by the client: {"device": {"@class": "Device", "id": int(device_id)}} + + "setPoint" / "mode" only when not None ``` This issue was presumed blocked ("no thermal device reachable, shapes unconfirmed") — but a 2026-10-27 enum-binding oracle (probing the validation layer against a nonexistent id, no real resource touched) live-verified the body skeleton: the inline `device` object REQUIRES the Jackson discriminator `"@class": "Device"` + numeric id (else `400 "Failed to read request"`); `device` is the only required field; `setPoint`/`mode` are optional; validation runs before the path lookup. The `{id}` is the thermal-control **config id** (a device id 404s), obtained from `get_thermal_control(device_id)` on devices that have one. The client coerces `int(device_id)` so string ids serialize numerically. Still honestly documented: the success path is unverified (no thermal-control config exists on the probe account) and `mode` values are unconfirmed at this endpoint (capacity-level enum: OFF/HEAT/COOL). Field notes updated with the findings (incl. GET by-id → 405). ## Evidence - **Before:** `AttributeError` — the write path was not exposed; the body shape was a total unknown. - **After:** 4 tests (both-fields happy pinning the exact device object with discriminator, set_point-only with `mode` ABSENT from the body, string device id serializing as JSON number 7, 500 → `ComwattAPIError`), TDD red→green; `pytest` = **224 passed**; `mypy` clean. Reviewer verdicts: spec **PASS**, quality **PASS**; one fix round (int coercion — spec-originated Important, controller-ruled) scoped re-reviewed **PASS**. ## Merge Danger **Door:** two-way — additive method; revert removes it. **Blast Radius:** low — one new public write method; the discriminator quirk is built in, not caller-facing. Closes #108
✨ feat: set_thermal_control(thermal_control_id, device_id, set_point, mode) (#108)
All checks were successful
Tests / forgejo-pytest (pull_request) Successful in 43s
Tests / forgejo-pytest (push) Successful in 42s
96c30017df
mat changed title from WIP: ✨ feat: set_thermal_control(thermal_control_id, device_id, set_point, mode) to ✨ feat: set_thermal_control(thermal_control_id, device_id, set_point, mode) 2026-10-27 11:20:41 +00:00
mat merged commit e5ca1668f5 into main 2026-10-27 11:20:45 +00:00
mat deleted branch feat/thermal-control-write 2026-10-27 11:20:45 +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!174
No description provided.