Skip to content

Fix reauthentication when Hive device authentication expires - #237

Closed
bigshow104 wants to merge 2 commits into
Pyhass:devfrom
bigshow104:fix/hive-invalid-device-reauth
Closed

bigshow104 wants to merge 2 commits into
Pyhass:devfrom
bigshow104:fix/hive-invalid-device-reauth

Conversation

@bigshow104

Copy link
Copy Markdown

What does this change?

This PR adds HiveInvalidDeviceAuthentication to the exceptions handled in custom_components/hive/__init__.py.

When a Hive refresh token expires, the API attempts to log in again but may raise HiveInvalidDeviceAuthentication because SMS two-factor authentication is required.

Currently, this exception is not caught, causing the Hive integration to fail setup without triggering Home Assistant's reauthentication flow.

By catching this exception and raising ConfigEntryAuthFailed, Home Assistant correctly displays the Reauthenticate prompt.

This preserves the existing integration, devices and entity IDs without requiring removal or reinstallation.

Related issues

Related to #224.

Testing

Successfully tested on two separate Home Assistant installations:

  • Home Assistant Core 2026.11.0
  • Hive Custom Component v2026.10.1
  • Confirmed the Reauthenticate prompt appeared following a Home Assistant Core restart
  • Completed SMS authentication successfully
  • Confirmed existing Hive devices and entities resumed working

Checklist

  • Tests added or updated, and script/test passes
  • script/lint --check passes
  • If this is going into a release: bumped version in manifest.json

Note: The fix has been tested manually on two installations. Automated tests and lint checks have not yet been run.

@bigshow104
bigshow104 requested a review from KJonline as a code owner November 8, 2026 12:11
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