Skip to content

429 rate limit causes retry storm and potential crash — APIRatelimitExceeded never raised #93

Description

@hedlung

(Claude AI helped me generate this from my extensive problems)

Environment

ha-checkwatt version: 0.2.7
pycheckwatt version: ~0.2.11
Home Assistant Core: 2026.6.4
Home Assistant OS: 18.0

Description
When Checkwatt's API returns HTTP 429 (Too Many Requests), the integration has no backoff or rate limit handling. The result is a retry storm where the integration attempts to log in every minute, receives 429 again, and repeats indefinitely.
On 2026-06-26, this produced hundreds of consecutive 429 errors over several hours, visible in the HA log:

2026-06-26 07:15:33 ERROR [pycheckwatt] Unexpected HTTP status code: 429
2026-06-26 07:15:33 ERROR [custom_components.checkwatt] Failed to login, abort update

This pattern continued from 07:15 through at least 10:46, then recurred in the afternoon and evening.
The following morning (2026-06-27 04:00), HA Core crashed with signal 11 (SIGSEGV) approximately 11 seconds after startup, during loading of custom components including checkwatt. While the direct cause of the segfault is uncertain, the integration was in a degraded state following the previous day's 429 storm.

Root cause
In init.py, _async_update_data catches login failure but raises only UpdateFailed, with no special handling for 429 responses:

if not await cw_inst.login():
_LOGGER.error("Failed to login, abort update")
raise UpdateFailed("Failed to login")

The class APIRatelimitExceeded is defined at the bottom of init.py but is never raised or caught anywhere in the code. This suggests rate limit handling was planned but never implemented.

Expected behavior
When a 429 response is received, the integration should detect it, raise APIRatelimitExceeded, and implement exponential backoff before retrying — rather than retrying every minute indefinitely.

Additional context
The same login failures were observed already on 2026-06-13, suggesting this is a recurring issue possibly related to changes in Checkwatt's API rate limiting policy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions