After running for some time, the integration begins failing with 404 errors against the DKN Cloud NA API and stops recovering. Root causes:
404 is not treated as an auth error. The DKN Cloud NA API appears to return 404 (not 401) for expired tokens. The previous auth_error_statuses={401, 403} let those 404s fall through to a generic DknConnectionError, so the coordinator just logged UpdateFailed and kept retrying with the stale token — never triggering a token refresh or reauth.
Refreshed tokens were never persisted.refresh_access_token() stored new tokens only on the in-memory client. On Home Assistant restart we reloaded the old (now-expired) tokens from the config entry, and eventually the in-memory refresh token would expire too.
Changes
Add 404 to auth_error_statuses on is_logged_in, refresh_access_token, and fetch_installations so expired-token 404s trigger the refresh + reauth flow.
Persist refreshed access + refresh tokens back to entry.options after each successful coordinator update.
Make the update listener ignore token-only option changes so token persistence does not cause a reload loop. User-facing options (scan_interval, expose_pii) still trigger a reload as before.
Log API responses with status >= 400 at WARNING (with body) and log INFO when a token refresh is attempted, so failures are diagnosable without enabling debug logging.
Test plan
Restart Home Assistant with the integration installed — devices come up as before.
Watch HA logs over the course of a token lifetime; on the next refresh you should see DKN token expired, attempting refresh followed by normal polling, with no UpdateFailed.
After a refresh, restart HA — the integration should come up cleanly without a reauth prompt (proves the refreshed tokens were persisted).
If/when the refresh token itself ultimately expires, confirm HA shows the reauth UI rather than silently failing.
## Summary
After running for some time, the integration begins failing with `404` errors against the DKN Cloud NA API and stops recovering. Root causes:
1. **`404` is not treated as an auth error.** The DKN Cloud NA API appears to return `404` (not `401`) for expired tokens. The previous `auth_error_statuses={401, 403}` let those 404s fall through to a generic `DknConnectionError`, so the coordinator just logged `UpdateFailed` and kept retrying with the stale token — never triggering a token refresh or reauth.
2. **Refreshed tokens were never persisted.** `refresh_access_token()` stored new tokens only on the in-memory client. On Home Assistant restart we reloaded the old (now-expired) tokens from the config entry, and eventually the in-memory refresh token would expire too.
## Changes
- Add `404` to `auth_error_statuses` on `is_logged_in`, `refresh_access_token`, and `fetch_installations` so expired-token 404s trigger the refresh + reauth flow.
- Persist refreshed access + refresh tokens back to `entry.options` after each successful coordinator update.
- Make the update listener ignore token-only option changes so token persistence does not cause a reload loop. User-facing options (`scan_interval`, `expose_pii`) still trigger a reload as before.
- Log API responses with `status >= 400` at `WARNING` (with body) and log `INFO` when a token refresh is attempted, so failures are diagnosable without enabling debug logging.
## Test plan
- [ ] Restart Home Assistant with the integration installed — devices come up as before.
- [ ] Watch HA logs over the course of a token lifetime; on the next refresh you should see `DKN token expired, attempting refresh` followed by normal polling, with no `UpdateFailed`.
- [ ] After a refresh, restart HA — the integration should come up cleanly without a reauth prompt (proves the refreshed tokens were persisted).
- [ ] If/when the refresh token itself ultimately expires, confirm HA shows the reauth UI rather than silently failing.
The DKN Cloud NA API returns 404 (not 401) when tokens are expired,
which caused the integration to silently fail with UpdateFailed
indefinitely instead of attempting a token refresh or triggering
reauth. Refreshed tokens were also only held in memory, so they
were lost on Home Assistant restart.
- Add 404 to auth_error_statuses on is_logged_in, refresh_access_token,
and fetch_installations.
- Persist refreshed access + refresh tokens back to the config entry
after each successful coordinator update.
- Skip the entry reload listener for token-only option updates to
avoid a reload loop on every refresh.
- Log API 4xx responses at WARNING with the body so failures are
visible in HA logs without enabling debug logging.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
After running for some time, the integration begins failing with
404errors against the DKN Cloud NA API and stops recovering. Root causes:404is not treated as an auth error. The DKN Cloud NA API appears to return404(not401) for expired tokens. The previousauth_error_statuses={401, 403}let those 404s fall through to a genericDknConnectionError, so the coordinator just loggedUpdateFailedand kept retrying with the stale token — never triggering a token refresh or reauth.refresh_access_token()stored new tokens only on the in-memory client. On Home Assistant restart we reloaded the old (now-expired) tokens from the config entry, and eventually the in-memory refresh token would expire too.Changes
404toauth_error_statusesonis_logged_in,refresh_access_token, andfetch_installationsso expired-token 404s trigger the refresh + reauth flow.entry.optionsafter each successful coordinator update.scan_interval,expose_pii) still trigger a reload as before.status >= 400atWARNING(with body) and logINFOwhen a token refresh is attempted, so failures are diagnosable without enabling debug logging.Test plan
DKN token expired, attempting refreshfollowed by normal polling, with noUpdateFailed.