Skip to content

1.0.x: device-fetch timeout at startup raises HiveReauthRequired (please backport #155 to master) #182

Open

Description

@rainman149

Summary

In pyhive-integration 1.0.10 (the current master release, and what Home Assistant 2026.10.3 will ship), if the first getDevices() call in startSession() times out, the session raises HiveReauthRequired. Home Assistant maps that to ConfigEntryAuthFailed, so a temporary slow API response on a busy restart leaves Hive in setup error and asks the user to re-authenticate, even though the credentials are valid. A manual reload fixes it straight away.

#155 fixes this on dev: when the fetch itself failed it raises HiveConnectionError instead, so HA can retry with ConfigEntryNotReady. But 1.0.x releases come from master, so HA users don't get it.

What happens (1.0.10, src/session.py)

  1. startSession() calls getDevices("No_ID").
  2. In getDevices(), asyncio.TimeoutError (the 5 s ClientTimeout in hive_async_api.getAll) is caught: "Hive API request timed out — keeping cached device data." At startup there is no cached data, so self.data.devices / self.data.products stay {}.
  3. Back in startSession(), if self.data.devices == {} or self.data.products == {} logs "No devices or products returned from Hive API, reauthentication required." and raises HiveReauthRequired.

So a timeout is reported as an auth failure.

Log (Home Assistant 2026.10.2, pyhive-integration 1.0.9, same code in 1.0.10)

05:43:58.185 WARNING [apyhiveapi.api.hive_async_api] Hive API request timed out fetching all nodes.
05:43:58.186 WARNING [apyhiveapi.session] Hive API request timed out — keeping cached device data.
05:43:58.186 ERROR   [apyhiveapi.session] No devices or products returned from Hive API, reauthentication required.
05:43:58.187 WARNING [homeassistant.config_entries] Config entry '<redacted>' for hive integration could not authenticate

This was during a normal HA restart with roughly 60 integrations setting up at the same time. Reloading the entry about five minutes later (no credential change) loaded straight away. One restart earlier the same morning loaded fine, so it's intermittent and depends on load.

Request

Could #155 (or the startSession() part of it) be backported to master for a 1.0.11 release? The smallest version would be: in startSession(), if the device data is empty because the fetch failed or timed out (get_nodes_successful is False), raise a connection-type error rather than HiveReauthRequired. Keep HiveReauthRequired for a real auth failure, or a successful fetch that returns no devices.

Home Assistant would also need to map the new exception to ConfigEntryNotReady, as the #155 description mentions. Related: home-assistant/core#182752.

Thanks for the quick 1.0.10 release for the SSO change in #181.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions