Skip to content

Raise BaseStationUnreachableError for comlink 404 responses - #1199

Open
progwriter wants to merge 1 commit into
bachya:devfrom
progwriter:fix/base-station-unreachable-error
Open

progwriter wants to merge 1 commit into
bachya:devfrom
progwriter:fix/base-station-unreachable-error

Conversation

@progwriter

Copy link
Copy Markdown

Describe what the PR does:

Problem

Home Assistant polls SS3 systems every 30 seconds with async_update(cached=False). When the SimpliSafe cloud can't reach the base station for a live refresh, these polls fail with HTTP 404, and each failure logs at ERROR:

ERROR [simplipy] Giving up _async_api_request(...) after 1 tries (aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url='https://api.simplisafe.com/v1/ss3/subscriptions/<sid>/settings/normal?forceUpdate=true')

On one system this happened for days: over 1,000 such lines in 10 days, and over half of all polls failed during one afternoon. The same symptom has been reported before:

With debug logging enabled, the 404 body was:

{"type": "NotFound", "message": "Active sim not returned from comlink", "code": "002", "statusCode": 404, "props": {}}

While these requests failed, the subscription data still reported the base station as online (isOffline: false), and cached requests (forceUpdate=false) to the same endpoints kept succeeding. Today this response surfaces as a generic RequestError, so callers can't tell "the base station can't be reached right now" apart from a real request failure. They can't react to it, for example by falling back to cached data.

Solution

  • Add BaseStationUnreachableError, a subclass of RequestError, so existing except RequestError handlers keep working.
  • Add DATA_ERROR_CODE_MAP, keyed on (type, code), because NotFound alone is too generic to map.
  • Map ("NotFound", "002") to the new error. Other NotFound codes still raise RequestError as before.
  • Document the error in docs/system.md.

The error is raised from the response body, so this response no longer goes through the backoff give-up path and no longer logs at ERROR.

Future work

Once this is released, the Home Assistant SimpliSafe integration can catch BaseStationUnreachableError on its forced poll and retry with cached=True, instead of failing the whole update. Today every such failure marks the update as failed, logs an error, and disconnects the websocket, so real-time events stop until the next successful poll. With the fallback, entities stay available with the latest cached data and the websocket stays connected.

Does this fix a specific issue?

No

Checklist:

  • Confirm that one or more new tests are written for the new functionality.
  • Run tests and ensure everything passes (with 100% test coverage).
  • Update README.md with any new documentation.

Non-cached (forceUpdate=true) SS3 requests can fail with HTTP 404 and
body {"type": "NotFound", "code": "002", "message": "Active sim not
returned from comlink"} when the SimpliSafe cloud can't reach the base
station, while cached requests still succeed.

Map that type/code pair to a new BaseStationUnreachableError (a
RequestError subclass, so existing handlers keep working) so callers
can fall back to cached data. Other NotFound codes are unaffected.
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.

1 participant