Repository navigation
Conversation
When the stored refresh token is no longer valid, Wyze responds with
code 2002 ("refresh token is error"). wyzeapy surfaces this as a generic
UnknownApiError rather than AccessTokenError, so async_setup_entry let
it propagate and Home Assistant showed "Failed to set up" with no way
to re-enter credentials, even though the config flow supports reauth.
Map code 2002 to ConfigEntryAuthFailed so Home Assistant starts the
existing reauth flow. Other UnknownApiError codes are re-raised as
before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Thanks for the contribution! The problem with only applying this change here is that it doesn't help in the situation that the token is revoked while HA is running, which is likely what will happen most of the time (happened to me last night). The change to wyzeapy in SecKatie/wyzeapy#407 should address that scenario as well as trigger a re-auth on restart by including the 2002 error as an AccessTokenError, while preventing the rate limiting that can occur when this error goes uncaught. |
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.
When the stored refresh token is no longer valid, Wyze responds with code 2002 ("refresh token is error"). wyzeapy surfaces this as a generic UnknownApiError rather than AccessTokenError, so async_setup_entry let it propagate and Home Assistant showed "Failed to set up" with no way to re-enter credentials, even though the config flow supports reauth.
Map code 2002 to ConfigEntryAuthFailed so Home Assistant starts the existing reauth flow. Other UnknownApiError codes are re-raised as before.
I was getting into this situation where the Wyze API was returning an error code 2002. Apparently my API token had been revoked, even though it appeared on Wyze's portal. After this bug fix, I was able to re-authenticate using a newly-generated API key.
Disclaimer: partially authored by Claude; verified by me, a real human software engineer :)