0.2.4
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 carrystatus_code,url,detailand the rawresponse. is_authenticated()— cheap probe ofGET /users/authenticatedthat returnsTrue/False(treats 401/403 as "re-login required").- Automatic re-authentication: on a
401the client re-logs in with the stored credentials and retries the request once (toggle withauto_reauth=False). - Configurable request
timeouton every HTTP call (ComwattClient(timeout=30)), so a stalled connection can no longer hang forever. close()+ context-manager support —with ComwattClient() as c: ...releases the underlyingrequests.Session.- Absolute
start/endtime window on all aggregation methods (get_device_ts_time_ago,get_site_networks_ts_time_ago,get_site_consumption_breakdown_time_ago), acceptingdatetimeor ISO-8601 strings, in addition to the relativetime_ago_*parameters. - Type hints across the client + PEP 561
py.typedmarker (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_sessioncookie was actually set (a200with no cookie raisesComwattAuthError). - 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.py→pyproject.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'sTrue/False.- Documented defaults of
get_site_networks_ts_time_agosynced with the real signature (FLOW/NONE, notVIRTUAL_QUANTITY/HOUR/SUM).
Security
- Minimum
requests>=2.32.4(the previously pinned2.31.0is affected by CVE-2024-35195). - Dev dependency
pytestbumped tov9.
Docs
- Added reverse-engineered
energy.comwatt.comAPI field notes underdocs/(endpoints, aggregations, WebSocket streaming), live-verified 2026-07-04.