jfarmer08 / homebridge-wyze-smart-home

Wyze Smart Home plugin for Homebridge.
MIT License
93 stars 14 forks source link

403 CloudFront Error After Changing Password #208

Closed danfratamico closed 4 months ago

danfratamico commented 5 months ago

Describe The Bug:

I received an email to change my Wyze password and noticed afterwards that Homebridge could no longer connect to Wyze. I updated the password, generated a new API key, uninstalled plugin, tried different version, nothing worked.

To Reproduce:

Expected behavior:

Logs:

[01/02/2024, 19:25:16] [Wyze] Error, logging in and trying again
[01/02/2024, 19:25:16] [Wyze] Request failed: AxiosError: Request failed with status code 403
[01/02/2024, 19:25:16] [Wyze] Response PerformRequest ([object Object]): "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<HTML><HEAD><META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n<TITLE>ERROR: The request could not be satisfied</TITLE>\n</HEAD><BODY>\n<H1>403 ERROR</H1>\n<H2>The request could not be satisfied.</H2>\n<HR noshade size=\"1px\">\nRequest blocked.\nWe can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.\n<BR clear=\"all\">\nIf you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.\n<BR clear=\"all\">\n<HR noshade size=\"1px\">\n<PRE>\nGenerated by cloudfront (CloudFront)\nRequest ID: EYUTKOTHfrsOW7nTWudT0OufuJBcS4GWBXmIp4sQ0iPMxtGmmo23Hg==\n</PRE>\n<ADDRESS>\n</ADDRESS>\n</BODY></HTML>"
[01/02/2024, 19:25:16] [Wyze] Error getting devices: AxiosError: Request failed with status code 403

Plugin Config:

{
    "name": "Wyze",
    "username": "XXX",
    "password": "XXX",
    "keyId": "XXX",
    "apiKey": "XXX",
    "refreshInterval": 60000,
    "hms": false,
    "showAdvancedOptions": false,
    "apiLogEnabled": false,
    "logLevel": "none",
    "lowBatteryPercentage": 30,
    "excludeMacAddress": false,
    "excludedeviceType": false,
    "platform": "WyzeSmartHome"
}

Screenshots:

Environment:

danfratamico commented 5 months ago

@Flyinace2000 Did you restart Homebridge after making both changes? You shouldn't need to add the line for mfaCode.

jeremystitt commented 5 months ago

These steps from @WillFulmer work for me, however I still get some odd errors in the log. Was wondering if updating the files here with these fixes would be worth while? Or does this just mask some underlying issues with the Wyze API?

here is my log output:

[03/02/2024, 09:46:53] [Wyze] Initializing WyzeSmartHome platform...
[03/02/2024, 09:46:54] [Wyze] Error: access token is error
    at WyzeAPI._performRequest (/usr/local/lib/node_modules/homebridge-wyze-smart-home/src/wyze-api/src/index.js:132:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at WyzeAPI.request (/usr/local/lib/node_modules/homebridge-wyze-smart-home/src/wyze-api/src/index.js:80:14)
    at WyzeAPI.getObjectList (/usr/local/lib/node_modules/homebridge-wyze-smart-home/src/wyze-api/src/index.js:234:20)
    at WyzeSmartHome.refreshDevices (/usr/local/lib/node_modules/homebridge-wyze-smart-home/src/WyzeSmartHome.js:101:26)
    at WyzeSmartHome.runLoop (/usr/local/lib/node_modules/homebridge-wyze-smart-home/src/WyzeSmartHome.js:90:9)
[03/02/2024, 09:46:54] [Wyze] Error, refreshing access token and trying again
[03/02/2024, 09:46:54] [Wyze] Error, logging in and trying again

Just to provide some assistance for those still struggling.

Same experience here: image

Received email from Wyze "Wyze reset your Wyze account password on 1/31/24"

Then this plugin, due to API calls, broke:

The 2 fixes as identified above was changing two items and it started working for me.

JSON File Config: image

Adding this: image

And the modification of the index.js file: image

Flyinace2000 commented 5 months ago

@Flyinace2000 Did you restart Homebridge after making both changes? You shouldn't need to add the line for mfaCode.

Yes, added the line for MFA in the config and restarted. I just removed and restarted again to see if that helps. Remind me, how to is promo for the MFA pin?

Logs [2/3/2024, 10:57:45 AM] [Wyze] Error: access token is error at WyzeAPI._performRequest (/homebridge/node_modules/homebridge-wyze-smart-home/src/wyze-api/src/index.js:132:15) at processTicksAndRejections (node:internal/process/task_queues:95:5) at WyzeAPI.request (/homebridge/node_modules/homebridge-wyze-smart-home/src/wyze-api/src/index.js:80:14) at WyzeAPI.getObjectList (/homebridge/node_modules/homebridge-wyze-smart-home/src/wyze-api/src/index.js:234:20) at WyzeSmartHome.refreshDevices (/homebridge/node_modules/homebridge-wyze-smart-home/src/WyzeSmartHome.js:101:26) at WyzeSmartHome.runLoop (/homebridge/node_modules/homebridge-wyze-smart-home/src/WyzeSmartHome.js:90:9) [2/3/2024, 10:57:45 AM] [Wyze] Error, refreshing access token and trying again [2/3/2024, 10:57:45 AM] [Wyze] Error, logging in and trying again [2/3/2024, 10:57:45 AM] [Wyze] Request failed: AxiosError: Request failed with status code 403 [2/3/2024, 10:57:45 AM] [Wyze] Response PerformRequest ([object Object]): "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<HTML><HEAD><META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n<TITLE>ERROR: The request could not be satisfied</TITLE>\n</HEAD><BODY>\n<H1>403 ERROR</H1>\n<H2>The request could not be satisfied.</H2>\n<HR noshade size=\"1px\">\nRequest blocked.\nWe can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.\n<BR clear=\"all\">\nIf you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.\n<BR clear=\"all\">\n<HR noshade size=\"1px\">\n<PRE>\nGenerated by cloudfront (CloudFront)\nRequest ID: axz4ag60_nBH-RQpGnaI2TcQUuItc-Dc_-AiXM3CCZQrLf9HFQPvLg==\n</PRE>\n<ADDRESS>\n</ADDRESS>\n</BODY></HTML>" [2/3/2024, 10:57:45 AM] [Wyze] Error getting devices: AxiosError: Request failed with status code 403

hartyparty commented 5 months ago

i ran the fix and seems the only issue is homebridge not able to receive the device info (current state) Screenshot 2024-02-03 100050

tj-noor commented 5 months ago

There is a PR upstream to fix this @ https://github.com/jfarmer08/wyze-api/pull/3

For those not able to match the line numbers, look for the async _performRequest() method, or check this file for reference: https://github.com/jfarmer08/wyze-api/pull/3/files#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556

In my Hyper-V install, the location for the packaged wyze-api was slightly different (index.js was inside the src folder & also reported first here - https://github.com/jfarmer08/homebridge-wyze-smart-home/issues/208#issuecomment-1924428513).

Adding this for others, to update from the Homebridge UI on a Hyper-V / Docker install, open Terminal from the menu and enter:

nano /var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/wyze-api/src/index.js

The fix can be found up here: https://github.com/jfarmer08/homebridge-wyze-smart-home/issues/208#issuecomment-1924396748

Now, if you're still running into auth errors, try restarting the container first. If you suspect an old token being used, check the persist folder for wyze-<uuid>.json files & update/delete them.

e.g.

ls /var/lib/homebridge/persist | grep 'wyze-'

Thank you everyone for your help on this!

tj-noor commented 5 months ago

i ran the fix and seems the only issue is homebridge not able to receive the device info (current state) Screenshot 2024-02-03 100050

your error shows "SUCCESS" indicating that the fix was not applied. Try restarting the container or the machine you're running Homebridge on.

johnecampos commented 5 months ago

+1 Same issue here

tbsaunders1 commented 5 months ago

ran the fix as @WillFulmer outlined and i'm back up! thanks everyone for the help here!

wondroushippo commented 5 months ago

Assuming all of your files are configured in the same way mine were, if you update this file /usr/lib/node_modules/homebridge-wyze-smart-home/src/wyze-api/index.js and adjust line 131

From this:

 131       if (result.data.msg == "DeviceIsOffline") { return result } else

To this:

 131       if (result.data.msg == "DeviceIsOffline" || result.data.msg == "SUCCESS") { return result } else

It appears to work without errors, I am guessing the previous API has changed slightly and it now always returns a msg field in the response data.

This would strictly be a temporary fix until the upstream wyze-api package can be updated.

This worked perfectly, thanks to you and @WillFulmer! Was worried I was gonna have to buy a bunch of new bulbs.

rowrowtheboat commented 5 months ago

i´m having the same issue but im on a mac, how can i access the Index.js?

name99-org commented 5 months ago

To those struggling with the above, one point that's not obvious. The index.js file that needs to be edited is not quite clear there are a lot of these files!

The one you want (at least on a Mac) is at /usr/local/lib/node_modules/homebridge-wyze-smart-home/src/wyze-api/src/index.js

With these two changes:

things are again working for me. However I am NOT using 2FA – there may be additional issues (?) for such people.

Flyinace2000 commented 5 months ago

I think I edited this correctly.

Screenshot 2024-02-03 at 5 20 32 PM

Also removed the wyze related files from the persist folder.

I am using MFA.

tbsaunders1 commented 5 months ago

@rowrowtheboat - see post below…

https://github.com/jfarmer08/homebridge-wyze-smart-home/issues/208#issuecomment-1924774779

but try the nano editor, I wasn’t able to make it work with vi.

Once you get into the right directory for your configuration try this command:

sudo nano 131+ index.js

and it should jump you right to line 131 to make the changes.

mylylyl commented 5 months ago

If you're using the homebridge raspberry pi os then the path is /var/lib/homebridge/node_modules

ejoliet commented 5 months ago

On alpha-7otherwise line 131 is not the same. Duh! Also, why alpha-4 said 'remove MFA support'. Anyway, i've updated line 131 mentioned. I also had to use delete /var/lib/homebridge/persist/wize-.. files, add new mfaCode, restart bridge. Seems to get back my 'switch' in homekit now and now error. Camera UI next with wyze-bridge in HASS. Different problem but probably similar fix :-( Thank you all here!

Andy589 commented 5 months ago

This fix worked for me as well on synology, I closed the ticket I had opened with the same error since this this one is getting more play for the same issue.

directory for me was in /volume1/homebridge

fau1095 commented 5 months ago

Thanks for the fix guys! It worked just fine

Notasmart commented 5 months ago

Assuming all of your files are configured in the same way mine were, if you update this file /usr/lib/node_modules/homebridge-wyze-smart-home/src/wyze-api/index.js and adjust line 131

From this:

 131       if (result.data.msg == "DeviceIsOffline") { return result } else

To this:

 131       if (result.data.msg == "DeviceIsOffline" || result.data.msg == "SUCCESS") { return result } else

It appears to work without errors, I am guessing the previous API has changed slightly and it now always returns a msg field in the response data.

This would strictly be a temporary fix until the upstream wyze-api package can be updated.

This and the user agent change got me fixed up. Thank you!

hmangnx commented 5 months ago

@anderfrank you could do something like this, I believe this will work, though I do not have an older version at hand to test.

if (result.data.msg && result.data.msg != "SUCCESS")

This didn't seem to work for version 0.5.36 as I cant use the newer version because that version doesn't detect my wyze outdoor v2 cams. But the older version does...

The newer version works fine with the fix, but sadly I cant use my outdoor cams....

rowrowtheboat commented 5 months ago

Hi, pals, i'm new to Homebridge (less than 48 hours in) i just fixed the Wyze plug in and all my devices just showed up for the first time, dumb question but, is this plug in only for switches or is it to see the feeds of cameras? because all my cameras just appear as switches.
thanks

ejoliet commented 5 months ago

Hi, pals, i'm new to Homebridge (less than 48 hours in)

i just fixed the Wyze plug in and all my devices just showed up for the first time, dumb question but, is this plug in only for switches or is it to see the feeds of cameras? because all my cameras just appear as switches.

thanks

I have ffmpeg bridge setup to read wyze-bridge. This exposed to homekit i can see the feed of the cameras. If you add 'camera ui', you'll get exposed wvn the motion detected in homekit! This community is awesome!

carter0nline commented 5 months ago

+1, same problem. Tried the fixes mentioned here, wasted two hours of my life, ended up just breaking things even more and giving up. If you eff up this hard too, reinstalliing the plugin brought me back to the error I was getting before

holocronology commented 5 months ago

Same, running in docker on Synology NAS. Tried the above and no changes; same errors.

CygnusTM commented 5 months ago

I'm using a Docker container on my Synology, and after applying the fix, it seems to be able to authenticate and gets the device list, but now it crashes and forces a restart. I'm in a restart loop now. These are the errors:

[2/4/2024, 10:24:12 AM] TypeError: Cannot set properties of undefined (setting 'onoff_line')
    at WyzeLock.lockGetProperty (/homebridge/node_modules/@zswuwing/homebridge-wyze-smart-home/src/accessories/WyzeAccessory.js:368:66)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
[2/4/2024, 10:24:12 AM] Got SIGTERM, shutting down Homebridge...
[2/4/2024, 10:25:07 AM] TypeError: Cannot read properties of undefined (reading 'switch_state')
    at WyzeLock.update (/homebridge/node_modules/@zswuwing/homebridge-wyze-smart-home/src/accessories/WyzeAccessory.js:256:49)
    at WyzeSmartHome.loadDevice (/homebridge/node_modules/@zswuwing/homebridge-wyze-smart-home/src/WyzeSmartHome.js:154:17)
    at WyzeSmartHome.loadDevices (/homebridge/node_modules/@zswuwing/homebridge-wyze-smart-home/src/WyzeSmartHome.js:114:36)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at WyzeSmartHome.refreshDevices (/homebridge/node_modules/@zswuwing/homebridge-wyze-smart-home/src/WyzeSmartHome.js:103:7)
    at WyzeSmartHome.runLoop (/homebridge/node_modules/@zswuwing/homebridge-wyze-smart-home/src/WyzeSmartHome.js:87:9)
wjstone commented 5 months ago

after making that changes mentioned above i'm getting these errors now.

/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/WyzeSmartHome.js:227 this.log.error([${device.product_type}] Error removing accessory ${homeKitAccessory.context.nickname} (MAC: ${homeKitAccessory.context.mac}) : ${error}) ^ ReferenceError: device is not defined at WyzeSmartHome.configureAccessory (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/WyzeSmartHome.js:227:28) at /var/lib/homebridge/node_modules/homebridge/src/bridgeService.ts:328:25 at Array.filter () at BridgeService.restoreCachedPlatformAccessories (/var/lib/homebridge/node_modules/homebridge/src/bridgeService.ts:288:69) at ChildBridgeFork.startBridge (/var/lib/homebridge/node_modules/homebridge/src/childBridgeFork.ts:186:24)

Notasmart commented 5 months ago

Hi, pals, i'm new to Homebridge (less than 48 hours in)

i just fixed the Wyze plug in and all my devices just showed up for the first time, dumb question but, is this plug in only for switches or is it to see the feeds of cameras? because all my cameras just appear as switches.

thanks

I exclude all my cameras from the Homebridge plug-in and use Wyze docker bridge with scrypted to view them in HomeKit. Just another option to the one mentioned above

cwong-archy commented 5 months ago

i am on a pi 5 and using the latest homebridge/homebridge docker image. upgraded the plugin to v0.5.37-alpha.7. modified line 131 but getting the following error -

[2/4/2024, 12:09:55 PM] [WyzeSmartHome] Error: SUCCESS
    at WyzeAPI._performRequest (/homebridge/node_modules/homebridge-wyze-smart-home/src/wyze-api/src/index.js:132:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at WyzeAPI.request (/homebridge/node_modules/homebridge-wyze-smart-home/src/wyze-api/src/index.js:80:14)
    at WyzeAPI.getObjectList (/homebridge/node_modules/homebridge-wyze-smart-home/src/wyze-api/src/index.js:234:20)
    at WyzeSmartHome.refreshDevices (/homebridge/node_modules/homebridge-wyze-smart-home/src/WyzeSmartHome.js:101:26)
    at WyzeSmartHome.runLoop (/homebridge/node_modules/homebridge-wyze-smart-home/src/WyzeSmartHome.js:90:9)
[2/4/2024, 12:09:55 PM] [WyzeSmartHome] Error, refreshing access token and trying again
[2/4/2024, 12:09:55 PM] [WyzeSmartHome] Error, logging in and trying again
[2/4/2024, 12:09:56 PM] [WyzeSmartHome] Error getting devices: Error: SUCCESS

update: i dont know what i did. but i downgrade back to v0.5.36 (as alpha.7 doesnt work for me) and it works again. i can see my light bulbs, led strip, smart plugs. but i do get error in the homebridge log though -

[2/4/2024, 12:19:58 PM] [WyzeSmartHome] Error: SUCCESS
    at WyzeAPI._performRequest (/homebridge/node_modules/homebridge-wyze-smart-home/src/wyz-api/index.js:128:13)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at WyzeAPI.request (/homebridge/node_modules/homebridge-wyze-smart-home/src/wyz-api/index.js:75:14)
    at WyzeAPI.getObjectList (/homebridge/node_modules/homebridge-wyze-smart-home/src/wyz-api/index.js:232:20)
    at WyzeSmartHome.refreshDevices (/homebridge/node_modules/homebridge-wyze-smart-home/src/WyzeSmartHome.js:96:26)
    at WyzeSmartHome.runLoop (/homebridge/node_modules/homebridge-wyze-smart-home/src/WyzeSmartHome.js:85:9)
[2/4/2024, 12:19:58 PM] [WyzeSmartHome] Error, refreshing access token and trying again
[2/4/2024, 12:19:59 PM] [WyzeSmartHome] Error, logging in and trying again
Farmer APIKey and KEYID
[2/4/2024, 12:19:59 PM] [WyzeSmartHome] Error getting devices: Error: SUCCESS
[2/4/2024, 12:21:00 PM] [WyzeSmartHome] Error: SUCCESS
    at WyzeAPI._performRequest (/homebridge/node_modules/homebridge-wyze-smart-home/src/wyz-api/index.js:128:13)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at WyzeAPI.request (/homebridge/node_modules/homebridge-wyze-smart-home/src/wyz-api/index.js:75:14)
    at WyzeAPI.getObjectList (/homebridge/node_modules/homebridge-wyze-smart-home/src/wyz-api/index.js:232:20)
    at WyzeSmartHome.refreshDevices (/homebridge/node_modules/homebridge-wyze-smart-home/src/WyzeSmartHome.js:96:26)
    at WyzeSmartHome.runLoop (/homebridge/node_modules/homebridge-wyze-smart-home/src/WyzeSmartHome.js:85:9)
[2/4/2024, 12:21:00 PM] [WyzeSmartHome] Error, refreshing access token and trying again
[2/4/2024, 12:21:00 PM] [WyzeSmartHome] Error, logging in and trying again
Farmer APIKey and KEYID
[2/4/2024, 12:21:01 PM] [WyzeSmartHome] Error getting devices: Error: SUCCESS
ourstanley commented 5 months ago

So I’ve tried all the fixes listed above and I’m now getting a 400 error saying that I’ve had too many failed logins. Any idea how long I need to wait before trying to login again?

Flyinace2000 commented 5 months ago

So I’ve tried all the fixes listed above and I’m now getting a 400 error saying that I’ve had too many failed logins. Any idea how long I need to wait before trying to login again?

I'm going to turn off HomeBridge (running as a Docker in UnRaid) and try it in the morning giving it about 12 hours downtime.

deejaywoody commented 5 months ago

It appears v0.5.38 released a few mins ago by @jfarmer08 resolved the issue. Letting it bake and then heading over to the donation portal. Appreciate the quickness in pushing a fix 🙌🏻

jfarmer08 commented 5 months ago

username/password is a requirement from Wyze.

boothmusic commented 5 months ago

@jfarmer08 thanks so much for getting a new update out so quickly. For some reason every time I try and put my lights in (they only show up on the mesh light device type) it crashes the whole Homebridge.

boothmusic commented 5 months ago

IMG_5784

jfarmer08 commented 5 months ago

Change the color of the light outside of Homebridge using the WyZe App. I cannot tell which light is causing the issue, but homebridge has a null value set. You can also clear the accessory cache for homebridge in which it should boot. This is a known issue and I will try and get a fix out soon.

SovereignGFC commented 5 months ago

It appears v0.5.38 released a few mins ago by @jfarmer08 resolved the issue. Letting it bake and then heading over to the donation portal. Appreciate the quickness in pushing a fix 🙌🏻

+1 confirming this restores functionality. That said, I did get this message at plugin initialization after Homebridge restarted. image

cwong-archy commented 5 months ago

@jfarmer08 lastest version v0.5.39 boots up super clean (no error) running homebridge docker on my pi5. thanks for the quick update.

Flyinace2000 commented 5 months ago

v0.5.39 fix me as well (2FA and everything)

Andy589 commented 5 months ago

Will the update overwrite and fix the manual changes I made to get everything back up?

Flyinace2000 commented 5 months ago

Will the update overwrite and fix the manual changes I made to get everything back up?

The only change that should survive the update is the update to the config json, (adding the user agent). I guess we should remove that?

thefrosty commented 5 months ago

Can confirm v0.5.39 is working.

jeremystitt commented 5 months ago

I can report the same - appreciate the work to correct this

@jfarmer08 lastest version v0.5.39 boots up super clean (no error) running homebridge docker on my pi5. thanks for the quick update.

name99-org commented 5 months ago

Hi, pals, i'm new to Homebridge (less than 48 hours in) i just fixed the Wyze plug in and all my devices just showed up for the first time, dumb question but, is this plug in only for switches or is it to see the feeds of cameras? because all my cameras just appear as switches. thanks

One thing to remember is that even if you can't get camera functionality working in HomeKit (personally I find it more trouble than it's worth) simply having switch capability is useful! In particular it allows you to automate cameras switching on and off depending on things like when you leave and return to the house. There are ways of doing this within the Wyze app, but IMHO HomeKit gives you substantially more control.

anderfrank commented 5 months ago

Hi, pals, i'm new to Homebridge (less than 48 hours in) i just fixed the Wyze plug in and all my devices just showed up for the first time, dumb question but, is this plug in only for switches or is it to see the feeds of cameras? because all my cameras just appear as switches. thanks

The best way to get your Wyze cams into Homekit is using Scrypted. The dev even has a plugin for Wyze so you do not need to use something like wyze's old RTSP firmware or Docker-Wyze-Bridge.

jfarmer08 commented 4 months ago

https://github.com/jfarmer08/wyze-api/releases/tag/v0.1.1.3 should resolve this.