Skip to content

Fix date timezone, improve error codes and docstrings#138

Open
johanzander wants to merge 1 commit intoindykoning:masterfrom
johanzander:improve-error-codes-and-docstrings
Open

Fix date timezone, improve error codes and docstrings#138
johanzander wants to merge 1 commit intoindykoning:masterfrom
johanzander:improve-error-codes-and-docstrings

Conversation

@johanzander
Copy link
Copy Markdown
Collaborator

Summary

Bug fixes:

  • Fix default date handling: use local system timezone instead of UTC. The Growatt API expects calendar dates in the local timezone — using UTC causes wrong dates to be queried for anyone not running in UTC
  • Fix base_api.py: legacy TLX method incorrectly raised GrowattV1ApiError (a V1-specific exception); changed to GrowattError (base class)
  • Fix GrowattV1ApiError.__init__: error_code and error_msg were typed as optional but all V1 raise sites always provide them; made required

New:

  • Add GrowattV1ApiErrorCode IntEnum with generic API error codes, exported from the package so callers (e.g. HA coordinator) can use err.error_code == GrowattV1ApiErrorCode.NO_PRIVILEGE instead of hardcoding magic numbers

Docs:

  • Add endpoint-specific error codes to all API method docstrings
  • Add References sections with API doc URLs to all API methods
  • Standardise GrowattV1ApiError docstring to reference GrowattV1ApiErrorCode

Formatting:

  • Modified files reformatted with ruff

🤖 Generated with Claude Code

New:
- Add GrowattV1ApiErrorCode IntEnum with generic API error codes, exported
  from the package so callers can use GrowattV1ApiErrorCode.NO_PRIVILEGE
  instead of hardcoding magic numbers

Bug fixes:
- Fix base_api.py: legacy TLX method incorrectly raised GrowattV1ApiError
  (a V1-specific exception); changed to GrowattError (base class)
- Fix default date handling: use local system timezone instead of UTC so
  Growatt API receives the correct calendar date for the plant location
- Fix GrowattV1ApiError.__init__: error_code and error_msg were typed as
  optional but all V1 raise sites always provide them; made required

Docs:
- Add endpoint-specific error codes to all API method docstrings
- Add References sections with API doc URLs to all API methods
- Standardise GrowattV1ApiError docstring to reference GrowattV1ApiErrorCode

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.

2 participants