Skip to content

Fix application_credentials platform detection (setup fails with ValueError) - #2

Open
darrenthomas28-lgtm wants to merge 1 commit into
Connectlife-LLC:mainfrom
darrenthomas28-lgtm:fix/module-level-async-get-auth-implementation
Open

darrenthomas28-lgtm wants to merge 1 commit into
Connectlife-LLC:mainfrom
darrenthomas28-lgtm:fix/module-level-async-get-auth-implementation

Conversation

@darrenthomas28-lgtm

Copy link
Copy Markdown

Summary

application_credentials.py defines async_get_auth_implementation as a method on HisenseApplicationCredentials. Home Assistant's application_credentials platform loader resolves that name on the module object, so it is never found and every config entry fails to start.

Reproduction

Add the integration through the UI. The config flow completes and creates the entry ("Created configuration for Hisense AC"), but the entry immediately goes to setup_error and the log shows:

File "/config/custom_components/hisense_connectlife/__init__.py", line 51, in async_setup_entry
ValueError: Integration 'hisense_connectlife' platform application_credentials did not implement
'async_get_authorization_server' or 'async_get_auth_implementation'

Home Assistant 2026.9.2, integration version 1.0.0.

Cause

homeassistant/components/application_credentials/__init__.py looks the function up with hasattr() on the imported platform module, then calls it as platform.async_get_auth_implementation(hass, auth_domain, credential) — three positional arguments, no self. A method on a class inside that module is not visible to it.

Fix

Declares async_get_auth_implementation at module level with the signature the platform protocol expects, matching the shape used by core integrations such as homeassistant/components/withings/application_credentials.py. It returns the existing HisenseOAuth2Implementation unchanged, so behaviour after setup is identical.

ClientCredential is imported for the annotation. application_credentials is already listed in manifest.json under dependencies, so this introduces no new dependency.

Verification

Applied to a live install. The config entry moved from setup_error to loaded, and the climate and sensor entities were created and are controllable.

Notes — deliberately not in this PR

  • HisenseApplicationCredentials is now unused. I left it in place to keep the diff minimal; happy to remove it here or in a follow-up if you would prefer.
  • Separately, HisenseOAuth2Implementation.redirect_uri is hard-coded to http://homeassistant.local:8123/auth/external/callback. Installations not reachable at that exact hostname and port cannot complete the OAuth callback. Raising it here only because issue creation is restricted on this repo — glad to open a separate PR if that would be useful.

Declare async_get_auth_implementation at module level so Home Assistant's application_credentials loader can find it. As a method on HisenseApplicationCredentials it was invisible to the loader's hasattr() check against the module, so every config entry failed setup with a ValueError.
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