Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Token refresh seems to be too slow for the TTL currently being enforced by Wyze #567

Closed
cchan0535 opened this issue Apr 3, 2024 · 22 comments
Labels
bug Something isn't working Stale

Comments

@cchan0535
Copy link

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:

  1. Configure the integration. See devices working.
  2. Enable debug logging.
  3. Wait exactly 24 hours.
  4. See devices stop working (flood of ErrMsg': 'USER_ACCOUNT_NOT_EXIST' and 'msg': 'access token is error' in the logs)
  5. Wait 24 more hours
  6. See integration refresh the token ([wyzeapy.wyze_auth_lib] Should refresh. Refreshing...)
  7. See device status queries suddenly start succeeding again
  8. 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)

@cchan0535 cchan0535 added the bug Something isn't working label Apr 3, 2024
@wor1dedit
Copy link

Having the same issue

@brg468
Copy link
Collaborator

brg468 commented Apr 3, 2024

I swear I pushed an update for this but maybe I never did. I’ll look into it more in a few days.

@dslucki
Copy link

dslucki commented Apr 12, 2024

I am having the same issue

@syst3mboot
Copy link

Same issue here

@brg468
Copy link
Collaborator

brg468 commented Apr 18, 2024

The fix is linked above, just waiting for it to be merged.

@jscherry
Copy link

Is there any way to fix this before the new pull release?

@brg468
Copy link
Collaborator

brg468 commented Apr 19, 2024

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

@dslucki
Copy link

dslucki commented Apr 19, 2024 via email

@brg468
Copy link
Collaborator

brg468 commented Apr 19, 2024

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.

@dslucki
Copy link

dslucki commented Apr 19, 2024 via email

@syst3mboot
Copy link

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.

@brg468
Copy link
Collaborator

brg468 commented Apr 19, 2024

It depends on your install. On HA OS it’s basically impossible to find or purposly hidden, hence that workaround.

@dslucki
Copy link

dslucki commented Apr 24, 2024

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!

@twoolums
Copy link

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 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?

@brg468
Copy link
Collaborator

brg468 commented May 16, 2024

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

@twoolums
Copy link

No worries, I just wanted to make sure before I did that and maybe cause something else to break with it :)

@bh56
Copy link

bh56 commented May 16, 2024

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?

@brg468
Copy link
Collaborator

brg468 commented May 16, 2024

Whenever the maintainer pushes a new version. Can’t really give you a timeframe beyond that.

@bh56
Copy link

bh56 commented May 16, 2024

Is the maintainer Home Assistant or SecKatie?

@brg468
Copy link
Collaborator

brg468 commented May 16, 2024

SecKatie

Copy link

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.

@github-actions github-actions bot added the Stale label Jun 16, 2024
@cchan0535
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

9 participants