ha-wyzeapi
ha-wyzeapi copied to clipboard
[Bug] Token refresh seems to be too slow for the TTL currently being enforced by Wyze
Describe the bug
First things first, thanks for building this integration!
On to the problem:
I lose access to my Wyze devices for exactly 24 hours every other day. I assume that this is happening because the integration internally has a 48hr refresh timer but Wyze has changed token TTL on their side without announcing it. Their documentation also still says 48 hours from what I can see. Nevertheless, my tokens are dying 24 hours to the minute (23:57 UTC in my case) after being issued and functionality doesn't return until WyzeAPI refreshes everything the following day.
To Reproduce Steps to reproduce the behavior:
- Configure the integration. See devices working.
- Enable debug logging.
- Wait exactly 24 hours.
- See devices stop working (flood of ErrMsg': 'USER_ACCOUNT_NOT_EXIST' and 'msg': 'access token is error' in the logs)
- Wait 24 more hours
- See integration refresh the token ([wyzeapy.wyze_auth_lib] Should refresh. Refreshing...)
- See device status queries suddenly start succeeding again
- Enjoy 24 more hours of functionality before the cycle repeats.
Expected behavior Tokens refresh frequently enough that I never lose access to my devices
System configuration WyzeApi Version: Current (fresh install on an HA Green)
Having the same issue
I swear I pushed an update for this but maybe I never did. I’ll look into it more in a few days.
I am having the same issue
Same issue here
The fix is linked above, just waiting for it to be merged.
Is there any way to fix this before the new pull release?
You can download from my branch and put the wyzeapy
folder from src
in your config folder, and that should work. Can’t promise it won’t break anything else but it shouldn’t. Remember to delete that folder when an official update comes out.
https://github.com/brg468/wyzeapy/tree/handle-token-refresh
I don't think I mind trying that. But I'm a noob and not really sure what to do. It sounds like you're saying to take https://github.com/brg468/wyzeapy/tree/handle-token-refresh/src/wyzeapy folder and replace it with my \config\custom_components\wyzeapi folder?
On Thu, Apr 18, 2024 at 5:43 PM Brian Rogers @.***> wrote:
You can download from my branch and put the wyzeapy folder from src in your config folder, and that should work. Can’t promise it won’t break anything else but it shouldn’t. Remember to delete that folder when an official update comes out.
https://github.com/brg468/wyzeapy/tree/handle-token-refresh
— Reply to this email directly, view it on GitHub https://github.com/SecKatie/ha-wyzeapi/issues/567#issuecomment-2065548636, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGNJRDA62MZDGPBRL7HULZDY6BSEHAVCNFSM6AAAAABFUKVVJSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRVGU2DQNRTGY . You are receiving this because you commented.Message ID: @.***>
No leave your wyzeapi
folder in custom components, but place the wyzeapy
folder from my branch directly in your config folder(same place as configuration.yaml
file) then restart. This will overwrite the dependency folder that’s not easily accessible on most HA setups.
Got it, thank you for the details. I will see if this works or not. I suppose I will have to wait 24 hours?
On Thu, Apr 18, 2024 at 7:05 PM Brian Rogers @.***> wrote:
No leave your wyzeapi folder in custom components, but place the wyzeapy folder from my branch directly in your config folder(same place as configuration.yaml file) then restart. This will overwrite the dependency folder that’s not easily accessible on most HA setups.
— Reply to this email directly, view it on GitHub https://github.com/SecKatie/ha-wyzeapi/issues/567#issuecomment-2065617307, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGNJRDAJH6A7DYEGNDHLP23Y6B3WRAVCNFSM6AAAAABFUKVVJSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRVGYYTOMZQG4 . You are receiving this because you commented.Message ID: @.***>
Thank you so much, resolved the issue <3.
Just for my own interest, where exactly is the dependencies folder on HA? Wanted to apply this change manually yesterday and searched through so many libs
folders on the system but couldnt find wyzeapy anywhere, eventually just gave up.
It depends on your install. On HA OS it’s basically impossible to find or purposly hidden, hence that workaround.
Got it, thank you for the details. I will see if this works or not. I suppose I will have to wait 24 hours? … On Thu, Apr 18, 2024 at 7:05 PM Brian Rogers @.> wrote: No leave your wyzeapi folder in custom components, but place the wyzeapy folder from my branch directly in your config folder(same place as configuration.yaml file) then restart. This will overwrite the dependency folder that’s not easily accessible on most HA setups. — Reply to this email directly, view it on GitHub <#567 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGNJRDAJH6A7DYEGNDHLP23Y6B3WRAVCNFSM6AAAAABFUKVVJSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRVGYYTOMZQG4 . You are receiving this because you commented.Message ID: @.>
OK, this works as expected now. Thank you!
You can download from my branch and put the
wyzeapy
folder fromsrc
in your config folder, and that should work. Can’t promise it won’t break anything else but it shouldn’t. Remember to delete that folder when an official update comes out.https://github.com/brg468/wyzeapy/tree/handle-token-refresh
I get a 404 on this link/tree and looking through all your branches I don't see one call handle-token-refresh. Any suggestions so I can try to resolve my issue of 24 on 24 off with wyze in HA?
Sorry I probably deleted that branch once the PR got merged. You can download the main branch from here now:
https://github.com/SecKatie/wyzeapy
No worries, I just wanted to make sure before I did that and maybe cause something else to break with it :)
I rather not do a workaround. Can you clarify for me when this will be merged into an update that I won't have to do a workaround for?
Whenever the maintainer pushes a new version. Can’t really give you a timeframe beyond that.
Is the maintainer Home Assistant or SecKatie?
SecKatie
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Apologies, I forked and fixed the issue myself immediately after posting so I lost track of the thread. Just switched back over to the official version and can confirm that the problem is resolved in the latest release.
Appreciate the fix! Closing the issue.