Fix application_credentials platform detection (setup fails with ValueError) - #2
Open
darrenthomas28-lgtm wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
application_credentials.pydefinesasync_get_auth_implementationas a method onHisenseApplicationCredentials. 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_errorand the log shows:Home Assistant 2026.9.2, integration version 1.0.0.
Cause
homeassistant/components/application_credentials/__init__.pylooks the function up withhasattr()on the imported platform module, then calls it asplatform.async_get_auth_implementation(hass, auth_domain, credential)— three positional arguments, noself. A method on a class inside that module is not visible to it.Fix
Declares
async_get_auth_implementationat module level with the signature the platform protocol expects, matching the shape used by core integrations such ashomeassistant/components/withings/application_credentials.py. It returns the existingHisenseOAuth2Implementationunchanged, so behaviour after setup is identical.ClientCredentialis imported for the annotation.application_credentialsis already listed inmanifest.jsonunderdependencies, so this introduces no new dependency.Verification
Applied to a live install. The config entry moved from
setup_errortoloaded, and theclimateandsensorentities were created and are controllable.Notes — deliberately not in this PR
HisenseApplicationCredentialsis 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.HisenseOAuth2Implementation.redirect_uriis hard-coded tohttp://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.