Skip to content

0.2.4

Choose a tag to compare

@MateoGreil MateoGreil released this 05 Jul 07:18

Reliability & developer-experience release. Fully backward-compatible — no breaking changes; all existing methods keep working.

Added

  • Typed exception hierarchy: ComwattError (base), ComwattAuthError (401 / failed login), ComwattAPIError (other HTTP errors). Now exported from the package root. Exceptions carry status_code, url, detail and the raw response.
  • is_authenticated() — cheap probe of GET /users/authenticated that returns True/False (treats 401/403 as "re-login required").
  • Automatic re-authentication: on a 401 the client re-logs in with the stored credentials and retries the request once (toggle with auto_reauth=False).
  • Configurable request timeout on every HTTP call (ComwattClient(timeout=30)), so a stalled connection can no longer hang forever.
  • close() + context-manager supportwith ComwattClient() as c: ... releases the underlying requests.Session.
  • Absolute start/end time window on all aggregation methods (get_device_ts_time_ago, get_site_networks_ts_time_ago, get_site_consumption_breakdown_time_ago), accepting datetime or ISO-8601 strings, in addition to the relative time_ago_* parameters.
  • Type hints across the client + PEP 561 py.typed marker (the package now ships types to consumers / mypy).
  • Unit-test suite (pytest, HTTP mocked with responses) and CI (Forgejo Actions + GitHub Actions).

Changed

  • Login now verifies the cwt_session cookie was actually set (a 200 with no cookie raises ComwattAuthError).
  • All HTTP calls routed through a single internal _request() helper (consistent error handling, timeout and re-auth).
  • Aggregation query-strings built by a shared _aggregations_query() helper.
  • Packaging migrated setup.pypyproject.toml (PEP 621), with self-hosted Renovate for dependency updates.
  • README refreshed (usage example, method defaults).

Fixed

  • Wrong import in the README example (from comwatt.client …from comwatt_client …).
  • Copy-pasted "Error retrieving sites" messages in the device/capacity methods now report the right context.
  • switch_capacity() sends a lowercase boolean (?enable=true|false) instead of Python's True/False.
  • Documented defaults of get_site_networks_ts_time_ago synced with the real signature (FLOW / NONE, not VIRTUAL_QUANTITY / HOUR / SUM).

Security

  • Minimum requests>=2.32.4 (the previously pinned 2.31.0 is affected by CVE-2024-35195).
  • Dev dependency pytest bumped to v9.

Docs

  • Added reverse-engineered energy.comwatt.com API field notes under docs/ (endpoints, aggregations, WebSocket streaming), live-verified 2026-07-04.