Skip to content

Vendor the API client; add setpoint and operation-mode control - #172

Open
ltsch wants to merge 5 commits into
VolantisDev:mainfrom
ltsch:vendored-client-setpoint
Open

ltsch wants to merge 5 commits into
VolantisDev:mainfrom
ltsch:vendored-client-setpoint

Conversation

@ltsch

@ltsch ltsch commented Oct 19, 2026 •

Copy link
Copy Markdown

The integration depends on the aquanta PyPI package, which has a couple of limitations I kept running into. It logs in once and never refreshes the token, so after the session expires every poll fails until you reload the integration. It also only does Away/Boost — no way to set the target temperature or change the operating mode.

This pulls the client into the repo as api.py, keeping the same interface the old package exposed so the rest of the integration barely changes, and fixes both:

  • Refreshes the Firebase token and re-exchanges the Aquanta session key, with a retry on 401, so it stops going unavailable until a reload.
  • Adds set_temperature and operation-mode selection (eco/intelligence, thermostat, timer, time-of-use, off) to the water heater.

A few notes:

  • Auth and the API base are unchanged (api.aquanta.io/v2, Firebase email/password).
  • setPoint and the tank temperature are both in °C, so the entity stays Celsius.
  • Dropped the aquanta==0.2 requirement from the manifest now that the client is vendored.
  • Ran black, updated the README, and tested against a live account (reads, Away/Boost, and a setpoint write).

Happy to adjust anything.

ltsch and others added 5 commits October 19, 2026 03:17
Replace the external `aquanta==0.2` dependency with an in-repo api.py that is
interface-compatible with it, so __init__/coordinator/entity need only an import
swap. The vendored client adds:

- Token lifecycle: Firebase refresh + automatic re-auth on HTTP 401, fixing the
  failure mode where the integration dies on every poll once the session token
  expires and only recovers on reload.
- Setpoint and operation-mode writes via PATCH /v2/devices/advanced (the pip
  client had no temperature/mode control at all). Endpoint + batch body shape
  verified live.
- Per-call errors raised as RuntimeError (what the integration already catches).

water_heater.py now advertises TARGET_TEMPERATURE and OPERATION_MODE in addition
to AWAY_MODE; current_operation/target_temperature derive from the `advanced`
flags. setPoint and water.temperature are degC (confirmed from app source:
Ju(...,"degC") both directions), so temperature_unit CELSIUS is correct.

Reconstructed from the Aquanta Android app v2.11.1 and cross-checked against
aquanta==0.2. Auth, reads, and the setpoint write are verified live.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- API: typed connection/auth errors; persistent 401 -> auth error (reauth);
  GET rejects empty/non-JSON bodies; close session on failed login; refresh
  only re-logs-in on a rejected token; drop dead token-expiry field.
- Setup: close the session and avoid a stale coordinator when the first
  refresh fails; drop the needless options-change reload (away duration is
  read live).
- Coordinator: rely on per-request timeouts; map auth vs update failures.
- Entities: wrap Away/Boost writes as HomeAssistantError; guard all partial
  cloud data (no KeyErrors); report unknown (not off) when data is missing.
- water_heater: honour operation_mode in set_temperature; remove unused import.
- config_flow: complete the reauth flow; normalise unique_id; coerce the
  away-duration option to int.
- Packaging: align HA version floor (2024.4) across hacs.json/requirements;
  ruff target py312; fix translation key parity; restore .gitignore; stop
  tracking the built aquanta.zip.
- tests: add the missing fixtures, a manager-based setup/reload test, and
  unit tests for the API client.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant