jfarmer08 / homebridge-wyze-smart-home

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

Error getting devices: TypeError: devices is not iterable #216

Closed vascott1 closed 4 months ago

vascott1 commented 4 months ago

Just updated to the latest version. 0.5.42 after watching to flurry of posts going by about the API issues. Amazing group worked on that to get it squared away.

Now I am getting this in my logs.

[10/02/2024, 09:38:01] [wyze-smart-home] Error getting devices: TypeError: devices is not iterable [10/02/2024, 09:39:01] [wyze-smart-home] Error getting devices: TypeError: devices is not iterable [10/02/2024, 09:40:02] [wyze-smart-home] Error getting devices: TypeError: devices is not iterable [10/02/2024, 09:41:02] [wyze-smart-home] Error getting devices: TypeError: devices is not iterable [10/02/2024, 09:42:02] [wyze-smart-home] Error getting devices: TypeError: devices is not iterable [10/02/2024, 09:43:03] [wyze-smart-home] Error getting devices: TypeError: devices is not iterable

Then, when I try to control something. In this case a wall switch I get the following. I see the "access token error" at the bottom so after changing my password as required by Wyze, I deleted and created a new Key iD/Api Key and restarted homebridge with the same errors.

[10/02/2024, 09:43:49] [homebridge-wyze-smart-home] This plugin generated a warning from the characteristic 'On': characteristic value expected boolean and received undefined. See https://homebridge.io/w/JtMGR for more info. [10/02/2024, 09:43:59] [wyze-smart-home] Request failed: AxiosError: Request failed with status code 401 { status: 401, statusText: '', headers: Object [AxiosHeaders] { date: 'Sat, 10 Feb 2024 14:43:59 GMT', 'content-type': 'application/json;charset=UTF-8', 'content-length': '154', connection: 'close' }, config: { transitional: { silentJSONParsing: true, forcedJSONParsing: true, clarifyTimeoutError: false }, adapter: 'http', transformRequest: [ [Function: transformRequest] ], transformResponse: [ [Function: transformResponse] ], timeout: 0, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, env: { FormData: [Function], Blob: [class Blob] }, validateStatus: [Function: validateStatus], headers: Object [AxiosHeaders] { Accept: 'application/json, text/plain, /', 'Content-Type': 'application/json', 'Accept-Encoding': 'gzip', 'User-Agent': 'myapp', appid: '9319141212m2ik', appinfo: 'wyze_android_2.19.14', phoneid: 'wyze_developer_api', access_token: 'xx removed actually access token xxx', 'Content-Length': '118' }, method: 'post', url: 'https://wyze-sirius-service.wyzecam.com/plugin/sirius/set_iot_prop_by_topic', data: '{"did":"LD_SS1_7C78B2FDA12F","model":"LD_SS1","props":{"switch-power":true},"is_sub_device":0,"nonce":"1707576239578"}' }, request: <ref 1> ClientRequest { _events: [Object: null prototype] { abort: [Function (anonymous)], aborted: [Function (anonymous)], connect: [Function (anonymous)], error: [Function (anonymous)], socket: [Function (anonymous)], timeout: [Function (anonymous)], finish: [Function: requestOnFinish] }, _eventsCount: 7, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: false, _last: true, chunkedEncoding: false, shouldKeepAlive: false, maxRequestsOnConnectionReached: false, _defaultKeepAlive: true, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, strictContentLength: false, _contentLength: '118', _hasBody: true, _trailer: '', finished: true, _headerSent: true, _closed: false, socket: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, secureConnecting: false, _SNICallback: null, servername: 'wyze-sirius-service.wyzecam.com', alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object: null prototype], _eventsCount: 10, connecting: false, _hadError: false, _parent: null, _host: 'wyze-sirius-service.wyzecam.com', _closeAfterHandlingError: false, _readableState: [ReadableState], _maxListeners: undefined, _writableState: [WritableState], allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: [TLSWrap], _requestCert: true, _rejectUnauthorized: true, parser: null, _httpMessage: [Circular 1],

  [Symbol(verified)]: true,
  [Symbol(pendingSession)]: null,
  [Symbol(async_id_symbol)]: 3343,
  [Symbol(kHandle)]: [TLSWrap],
  [Symbol(lastWriteQueueSize)]: 0,
  [Symbol(timeout)]: null,
  [Symbol(kBuffer)]: null,
  [Symbol(kBufferCb)]: null,
  [Symbol(kBufferGen)]: null,
  [Symbol(kCapture)]: false,
  [Symbol(kSetNoDelay)]: false,
  [Symbol(kSetKeepAlive)]: true,
  [Symbol(kSetKeepAliveInitialDelay)]: 60,
  [Symbol(kBytesRead)]: 0,
  [Symbol(kBytesWritten)]: 0,
  [Symbol(connect-options)]: [Object]
},
_header: 'POST /plugin/sirius/set_iot_prop_by_topic HTTP/1.1\r\n' +
  'Accept: application/json, text/plain, */*\r\n' +
  'Content-Type: application/json\r\n' +
  'Accept-Encoding: gzip\r\n' +
  'User-Agent: myapp\r\n' +
  'appid: 9319141212m2ik\r\n' +
  'appinfo: wyze_android_2.19.14\r\n' +
  'phoneid: wyze_developer_api\r\n' +
  'access_token: xxx again, removed access token xxxx
  'signature2: 1020d1feabacd18b869adf1815e8ea37\r\n' +
  'Content-Length: 118\r\n' +
  'Host: wyze-sirius-service.wyzecam.com\r\n' +
  'Connection: close\r\n' +
  '\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: Agent {
  _events: [Object: null prototype],
  _eventsCount: 2,
  _maxListeners: undefined,
  defaultPort: 443,
  protocol: 'https:',
  options: [Object: null prototype],
  requests: [Object: null prototype] {},
  sockets: [Object: null prototype],
  freeSockets: [Object: null prototype] {},
  keepAliveMsecs: 1000,
  keepAlive: false,
  maxSockets: Infinity,
  maxFreeSockets: 256,
  scheduling: 'lifo',
  maxTotalSockets: Infinity,
  totalSocketCount: 1,
  maxCachedSessions: 100,
  _sessionCache: [Object],
  [Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
joinDuplicateHeaders: undefined,
path: '/plugin/sirius/set_iot_prop_by_topic',
_ended: true,
res: IncomingMessage {
  _readableState: [ReadableState],
  _events: [Object: null prototype],
  _eventsCount: 4,
  _maxListeners: undefined,
  socket: [TLSSocket],
  httpVersionMajor: 1,
  httpVersionMinor: 1,
  httpVersion: '1.1',
  complete: true,
  rawHeaders: [Array],
  rawTrailers: [],
  joinDuplicateHeaders: undefined,
  aborted: false,
  upgrade: false,
  url: '',
  method: null,
  statusCode: 401,
  statusMessage: '',
  client: [TLSSocket],
  _consuming: false,
  _dumped: false,
  req: [Circular *1],
  responseUrl: 'https://wyze-sirius-service.wyzecam.com/plugin/sirius/set_iot_prop_by_topic',
  redirects: [],
  [Symbol(kCapture)]: false,
  [Symbol(kHeaders)]: [Object],
  [Symbol(kHeadersCount)]: 8,
  [Symbol(kTrailers)]: null,
  [Symbol(kTrailersCount)]: 0
},
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'wyze-sirius-service.wyzecam.com',
protocol: 'https:',
_redirectable: Writable {
  _writableState: [WritableState],
  _events: [Object: null prototype],
  _eventsCount: 3,
  _maxListeners: undefined,
  _options: [Object],
  _ended: true,
  _ending: true,
  _redirectCount: 0,
  _redirects: [],
  _requestBodyLength: 118,
  _requestBodyBuffers: [],
  _onNativeResponse: [Function (anonymous)],
  _currentRequest: [Circular *1],
  _currentUrl: 'https://wyze-sirius-service.wyzecam.com/plugin/sirius/set_iot_prop_by_topic',
  [Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kBytesWritten)]: 0,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
  accept: [Array],
  'content-type': [Array],
  'accept-encoding': [Array],
  'user-agent': [Array],
  appid: [Array],
  appinfo: [Array],
  phoneid: [Array],
  access_token: [Array],
  signature2: [Array],
  'content-length': [Array],
  host: [Array]
},
[Symbol(errored)]: null,
[Symbol(kUniqueHeaders)]: null

}, data: { code: 2001, current: 0, hash: '1', instance_id: 'ea0b5bca6b35498db69bde9b55fde9fd', isShowToast: 0, message: 'Access token error', total: 0, version: 1 } } [10/02/2024, 09:44:00] [homebridge-wyze-smart-home] This plugin threw an error from the characteristic 'On': Unhandled error thrown inside write handler for characteristic: Request failed with status code 401. See https://homebridge.io/w/JtMGR for more info.

Plugin Config:


attached config.json: 
[config-4.json](https://github.com/jfarmer08/homebridge-wyze-smart-home/files/14229652/config-4.json)

**Screenshots:**
<!-- If applicable, add screenshots to help explain your problem. -->

**Environment:**

* **Plugin Version**: 0.5.42
* **Homebridge Version**: 1.7.0<!-- homebridge -V -->
* **Node.js Version**: 18.16.0 <!-- node -v -->
* **NPM Version**: 9.5.1<!-- npm -v -->
* **Operating System**: Raspian<!-- Raspbian / Ubuntu / Debian / Windows / macOS / Docker / hb-service -->

<!-- Click the "Preview" tab before you submit to ensure the formatting is correct. -->
Notasmart commented 4 months ago

Same here, just started a little while ago for me. It worked this morning

nyjklein commented 4 months ago

Same here. And devices not responding.

Fell back to v0.54.0 and all is working fine again.

vascott1 commented 4 months ago

Same here. And devices not responding.

Fell back to v0.54.0 and all is working fine again.

No such luck for me. Same issue on 0.5.40. Will just wait and watch to see the fix. I commend the people working on this login-in though. Keeping up with a moving target! Kudos!

tteuer commented 4 months ago

Same exact issue here. Rolling back to 0.5.40 did not resolve the issue for me. First appeared in my Homebridge logs today, 2/10 at 6:24AM PST, if that is helpful.

loc-samurai commented 4 months ago

I am getting the same _TypeErro: devices is not _iterable__ as well. Starting happening after updating to v0.5.42. Rolling back to v0.5.40 or any earlier versions worked for me. Just adding my 2 cents to the pot here in an attempt to be helpful. I am grateful for those brains bigger than mine working on this.

franco4785 commented 4 months ago

Got the "devices is not iterable" error as well after updating the plugin to v0.5.42

Stumped, I went into HomeBridge's settings and clicked "Remove All Cached Accessories" thinking this would fix it, but it didn't. It removed all my Wyze accessories -- expected functionality from clicking "Remove All Cached Accessories".

The issue I'm facing now is that no devices are found at all. I turned on debug via Wyze's settings, and the error that it logs every 60 seconds (whatever you have set for 'Refresh Interval') is

[10/02/2024, 15:54:59] [Wyze] Refreshing devices...
[10/02/2024, 15:54:59] [Wyze] Error getting devices: TypeError: Cannot read properties of undefined (reading 'length')

My guess is that the plugin isn't getting any devices from Wyze, which seems like the issue from the "devices is not iterable" & "Error getting devices: TypeError: Cannot read properties of undefined (reading 'length')" error messages -- "devices" can't be iterated / counted because none are actually returned.

Just my two cents, hopefully this helps narrow down where the issue is!

adolton1 commented 4 months ago

Getting the same error as well. I noticed it yesterday after remembering I needed to update my Wyze password in the plugin. I tried getting a new Wyze API key and uninstalling/reinstalling the Wyze plugin in Homebridge with no luck.

I just tried going back to v0.5.40 and that worked for me.

DougBikes commented 4 months ago

Rolling back to v0.5.40 did not work for me, still getting the [Wyze] Error getting devices: TypeError: devices is not iterable

Reset Cache did not stop the error from occurring.

SawkeeReemo commented 4 months ago

Adding myself to the growing list of users experiencing this bug.

SawkeeReemo commented 4 months ago

I think I just figured out how to fix this. Follow these steps exactly:

  1. Upgrade to the latest version of this plugin if you are not on it for any reason [v0.5.42]

  2. Go through the setup procedure where you go to that Wyze API site and generate a new API key.

  3. Enter that into the plugin’s config in the GUI in Homebridge, and restart the child bridge.

  4. If you are still getting the problem, downgrade to v0.5.40, and check the logs when it restarts. You should see that the new API key is not compatible with the old version of this plugin and a bunch of errors happen.

  5. Now upgrade the plugin again to the latest version. It should be working now. That’s what just did it for me!

Curious to know if this helps anyone else!

DougBikes commented 4 months ago

@SawkeeReemo Tried your steps and continue to have error

halvesty commented 4 months ago

I think I just figured out how to fix this. Follow these steps exactly:

1. Upgrade to the latest version of this plugin if you are not on it for any reason [v0.5.42]

2. Go through the setup procedure where you go to that Wyze API site and generate a new API key.

3. Enter that into the plugin’s config in the GUI in Homebridge, and restart the child bridge.

4. If you are still getting the problem, downgrade to v0.5.40, and check the logs when it restarts. You should see that the new API key is not compatible with the old version of this plugin and a bunch of errors happen.

5. Now upgrade the plugin again to the latest version. It should be working now. That’s what just did it for me!

Curious to know if this helps anyone else!

I downgraded to v0.5.40 and was able to complete all the steps, but did not upgrade to 42. Not seeing a bunch of errors on 40. I can turn on a camera via the Home app, and it turns on, but then the Home app displays it as off after a few seconds but the camera is still on.

Edit: updated to 42 and seeing the same behavior. What's odd is that nothing is showing up in the logs and I have API logging enabled.

Edit edit: Followed @franco4785's cached accessories step below and all is well again.

franco4785 commented 4 months ago

I think I just figured out how to fix this. Follow these steps exactly:

  1. Upgrade to the latest version of this plugin if you are not on it for any reason [v0.5.42]
  2. Go through the setup procedure where you go to that Wyze API site and generate a new API key.
  3. Enter that into the plugin’s config in the GUI in Homebridge, and restart the child bridge.
  4. If you are still getting the problem, downgrade to v0.5.40, and check the logs when it restarts. You should see that the new API key is not compatible with the old version of this plugin and a bunch of errors happen.
  5. Now upgrade the plugin again to the latest version. It should be working now. That’s what just did it for me!

Curious to know if this helps anyone else!

@SawkeeReemo , can confirm as soon as I downgraded to v0.5.40 it worked. I then upgraded to v0.5.42 and it kept working. I even took it one step further and clicked “Remove All Cached Accessories” in HomeBridge’s settings to confirm that it wasn’t just retaining the old cached accessories from v0.5.40, and it still worked.

@halvesty, @DougBikes, is this how your plugin’s debug is configured? If not, would you mirroring what you see in my screenshot? That way we can get an extra layer of debug logs from the errors you’re getting? Happy to try and help fellow users.

IMG_0363

tteuer commented 4 months ago

I think I just figured out how to fix this. Follow these steps exactly:

  1. Upgrade to the latest version of this plugin if you are not on it for any reason [v0.5.42]
  2. Go through the setup procedure where you go to that Wyze API site and generate a new API key.
  3. Enter that into the plugin’s config in the GUI in Homebridge, and restart the child bridge.
  4. If you are still getting the problem, downgrade to v0.5.40, and check the logs when it restarts. You should see that the new API key is not compatible with the old version of this plugin and a bunch of errors happen.
  5. Now upgrade the plugin again to the latest version. It should be working now. That’s what just did it for me!

Curious to know if this helps anyone else!

I tried these steps and it did not work for me. I did not get any sort of error message stating the new API key wasn't compatible with that version on 0.5.40. The only error message I got is the one this entire thread is about. Updating back to 0.5.42 gives the same error message.

I do not have any cached Waze accessories as I created a child bridge during troubleshooting, which wiped out my old accessories. The log files state 0 caches accessories when the plugin in loading as well.

it's interesting downgrading to 0.5.40 works for some, but not others.

bowtiedave commented 4 months ago

Here are the steps I took to get it to work:

Not sure if I needed to do in this order, but I have everything working again. It seems like the breakdown is related to Wyze issues with resetting passwords. Review other issue 215 for more details

halvesty commented 4 months ago

Generating a new API key and clearing cachedAccessories fixed it for me. No need to downgrade/upgrade.

I noticed something when I regenerated my API key: the key expires in a year. Maybe the old one did too!

Did everyone else experiencing problems today generate keys a year ago?

No, mine was barely a week old as I just started using this plugin.

carTloyal123 commented 4 months ago

The re-authentication issues are likely a part of a known issue where Wyze noticed a huge amount of login attempts from this bridge. Recommendation is to reset your Wyze password, get a new api key, and update the bridge to the latest. If you keep using older versions you will likely continue to have issues.

I will look at this particular issue over the next few days and see about a fix.

matthewmspace commented 4 months ago

Got the error as well. Had to downgrade back to v0.5.40 and then reset the Wyze Developer API key.

adolton1 commented 4 months ago

It’s working for me now on v0.5.42 after getting this error. Steps I went through:

  1. Reset my Wyze password after getting the email from them on Feb 2 (issue #208)
  2. Feb 9 updated Wyze plugin to v0.5.42 and updated password in settings
    • This is when I first noticed the error, not sure if I was getting it before
  3. Feb 10 tried getting a new API key (old one didn’t expire until October) - same error
  4. Uninstalled/reinstalled Wyze plugin (deleting config) - same error
  5. Reverted to v0.5.40 - no longer getting error, everything working as usual
  6. Feb 11 updated back to v0.5.42 - everything still working without error
DougBikes commented 4 months ago

Changed password, updated API Key, uninstalled and reinstalled still no joy Turned on API Logging, debug: now receiving this error message [2/11/2024, 6:32:03 PM] [Wyze Smart Home] Refreshing devices... [2/11/2024, 6:32:04 PM] [Wyze Smart Home] Error getting devices: TypeError: Cannot read properties of undefined (reading 'length')

franco4785 commented 4 months ago

Changed password, updated API Key, uninstalled and reinstalled still no joy Turned on API Logging, debug: now receiving this error message [2/11/2024, 6:32:03 PM] [Wyze Smart Home] Refreshing devices... [2/11/2024, 6:32:04 PM] [Wyze Smart Home] Error getting devices: TypeError: Cannot read properties of undefined (reading 'length')

@DougBikes downgrade to v0.5.40 Your error message in the log is exactly what I was getting. As soon as I downgraded, it worked. Give it a try!

tteuer commented 4 months ago

Changed password, updated API Key, uninstalled and reinstalled still no joy Turned on API Logging, debug: now receiving this error message [2/11/2024, 6:32:03 PM] [Wyze Smart Home] Refreshing devices... [2/11/2024, 6:32:04 PM] [Wyze Smart Home] Error getting devices: TypeError: Cannot read properties of undefined (reading 'length')

Same here. Just tried it a fifth time and the various things people have posted. Nothing works. Same error no matter which version of the plug in is installed and no matter how many times I've generated a new API key.

0.5.42 was working just fine when I first updated to it and nothing changed on my end between then and when it suddenly started throwing this error, which leads me to think this is something plugin and or/ wyze appi related and not necessarily on the user end. It is odd it's working with some of the above steps for some people though.

traviswparker commented 4 months ago

The 401 error from the API makes me think this is a case of the auth data being stale but the plugin not handling it properly.

The auth/refresh tokens are stored in persist, and uninstalling/reinstalling/clearing cached accessories won't fix that.

If replacing your API key didn't fix it (which you should do anyway before it expires) try this:

Stop Homebridge. Delete persist/wyze-*.json Start Homebridge.

No need to clear cached accessories, that will remove/recreate them in HomeKit and may affect more than Wyze devices.

Notasmart commented 4 months ago

Same here, just started a little while ago for me. It worked this morning

Shortly after I originally posted, I rolled back to 0.5.40 and was still getting errors but my devices were working. A few hours ago I updated to 0.5.42 and I have zero errors and everything is still working.

tteuer commented 4 months ago

The 401 error from the API makes me think this is a case of the auth data being stale but the plugin not handling it properly.

The auth/refresh tokens are stored in persist, and uninstalling/reinstalling/clearing cached accessories won't fix that.

If replacing your API key didn't fix it (which you should do anyway before it expires) try this:

Stop Homebridge. Delete persist/wyze-*.json Start Homebridge.

No need to clear cached accessories, that will remove/recreate them in HomeKit and may affect more than Wyze devices.

You sir, are a genius. This was the fix that worked for me!

traviswparker commented 4 months ago

Good. That's confirmation of what is going on, and a way to handle it. If a 401 or other unexpected response, assume the API does not like the token, so clear it and reauth.

For the cases where it "just started working again" the likely reason why is because the token finally expired and the plugin refreshed it.

vascott1 commented 4 months ago

Awesome. Fixed it for me as well.

Thanks!

On Feb 11, 2024 at 11:02 PM, <Travis Parker @.***)> wrote:

The 401 error from the API makes me think this is a case of the auth data being stale but the plugin not handling it properly.

The auth/refresh tokens are stored in persist, and uninstalling/reinstalling/clearing cached accessories won't fix that.

If replacing your API key didn't fix it (which you should do anyway before it expires) try this:

Stop Homebridge. Delete persist/wyze-*.json Start Homebridge.

No need to clear cached accessories, that will remove/recreate them in HomeKit and may affect more than Wyze devices.

— Reply to this email directly, view it on GitHub (https://github.com/jfarmer08/homebridge-wyze-smart-home/issues/216#issuecomment-1938037042), or unsubscribe (https://github.com/notifications/unsubscribe-auth/ALLAX24DJH33YZCV72WXSYLYTGH4BAVCNFSM6AAAAABDCZDM2CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZYGAZTOMBUGI). You are receiving this because you authored the thread.Message ID: @.***>

steelopus commented 4 months ago

The 401 error from the API makes me think this is a case of the auth data being stale but the plugin not handling it properly.

The auth/refresh tokens are stored in persist, and uninstalling/reinstalling/clearing cached accessories won't fix that.

If replacing your API key didn't fix it (which you should do anyway before it expires) try this:

Stop Homebridge. Delete persist/wyze-*.json Start Homebridge.

No need to clear cached accessories, that will remove/recreate them in HomeKit and may affect more than Wyze devices.

Worked for me, too. Homebridge service crashed twice after I initially restarted the service, but it seemed to self-correct and boot normally the third time.

Thank you @traviswparker for the fix

(homebridge-wyze-smart-home is running normally now for me - on v0.5.42)

TwistdSpokes commented 4 months ago

The 401 error from the API makes me think this is a case of the auth data being stale but the plugin not handling it properly.

The auth/refresh tokens are stored in persist, and uninstalling/reinstalling/clearing cached accessories won't fix that.

If replacing your API key didn't fix it (which you should do anyway before it expires) try this:

Stop Homebridge. Delete persist/wyze-*.json Start Homebridge.

No need to clear cached accessories, that will remove/recreate them in HomeKit and may affect more than Wyze devices.

I am having this same trouble after upgrading to v0.5.42 - I tried all the suggestions above and still have the same issues. I am trying to understand what to do here but this is not my forte. Any additional info how I access this persist/wyze to delete it?

I am running homebridge on a windows machine via hyperV - not sure if that makes a difference.

Appreciate any help to resolve, hoping this is the key but just not sure where to complete this.

traviswparker commented 4 months ago

The 401 error from the API makes me think this is a case of the auth data being stale but the plugin not handling it properly. The auth/refresh tokens are stored in persist, and uninstalling/reinstalling/clearing cached accessories won't fix that. If replacing your API key didn't fix it (which you should do anyway before it expires) try this: Stop Homebridge. Delete persist/wyze-*.json Start Homebridge. No need to clear cached accessories, that will remove/recreate them in HomeKit and may affect more than Wyze devices.

I am having this same trouble after upgrading to v0.5.42 - I tried all the suggestions above and still have the same issues. I am trying to understand what to do here but this is not my forte. Any additional info how I access this persist/wyze to delete it?

I am running homebridge on a windows machine via hyperV - not sure if that makes a difference.

Appreciate any help to resolve, hoping this is the key but just not sure where to complete this.

Homebridge has a terminal in the UI, on the ... menu in the top right. So in the terminal just type:

rm persist/wyze*

and restart homebridge

TwistdSpokes commented 4 months ago

The 401 error from the API makes me think this is a case of the auth data being stale but the plugin not handling it properly. The auth/refresh tokens are stored in persist, and uninstalling/reinstalling/clearing cached accessories won't fix that. If replacing your API key didn't fix it (which you should do anyway before it expires) try this: Stop Homebridge. Delete persist/wyze-*.json Start Homebridge. No need to clear cached accessories, that will remove/recreate them in HomeKit and may affect more than Wyze devices.

I am having this same trouble after upgrading to v0.5.42 - I tried all the suggestions above and still have the same issues. I am trying to understand what to do here but this is not my forte. Any additional info how I access this persist/wyze to delete it? I am running homebridge on a windows machine via hyperV - not sure if that makes a difference. Appreciate any help to resolve, hoping this is the key but just not sure where to complete this.

Homebridge has a terminal in the UI, on the ... menu in the top right. So in the terminal just type:

rm persist/wyze*

and restart homebridge

That did the trick! thanks for the clarity and the resolution!

jfarmer08 commented 4 months ago

Going to need full error log for this.

jfarmer08 commented 4 months ago

Can someone try version https://github.com/jfarmer08/homebridge-wyze-smart-home/releases/tag/v0.5.43

tteuer commented 4 months ago

Can someone try version https://github.com/jfarmer08/homebridge-wyze-smart-home/releases/tag/v0.5.43

I had already manually cleared the auth token following the steps posted by @traviswparker to resolve the issues with 0.5.42 but updating to 0.5.43 doesn't appear to have broken anything, FWIW. Thank you for your continued work on this!

WaywardWilderness commented 4 months ago

I too had manually cleared the auth token and 0.5.42 was working. Upgrade to 0.5.43 also works without issue.

vascott1 commented 4 months ago

Was doing well for a while and now the issue is back. I feel bad for Farmer and his attempts to figure this out. Seems like a moving target and an issue on the Wyze end of things. Just gonna keep my fingers crossed that this gets resolved. Trying to decide if it pays to move to the latest plugin version. Not sure it can hurt :)

Well.... 5.44 fixed it! Sweet!

BBfly1 commented 4 months ago

tried all of the above suggestions ... 1.) Homebridge has a terminal in the UI, on the ... menu in the top right. So in the terminal just type: rm persist/wyze*; and restart homebridge

2.) new API ID/key

3.) versions v0.5.40 thru v0.5.44 with all of the suggestions above

Note: I can still login manually on the Wyze website so I know I'm not locked out ...

BUT, still getting the error 400 ...

log:

[15/02/2024, 15:03:54] [Wyze] Initializing WyzeSmartHome platform... [15/02/2024, 15:03:56] [Wyze] Request failed: AxiosError: Request failed with status code 400 [15/02/2024, 15:03:56] [Wyze] Response PerformRequest ([object Object]): {"description":"Invalid credentials, please check username, password, keyid or apikey","requestId":"fdd52965-69c2-48ff-b137-eec7df14015d","errorCode":1000} [15/02/2024, 15:03:56] [Wyze] Error getting devices: Error: Invalid credentials, please check username, password, keyid or apikeyAxiosError: Request failed with status code 400

disabling the plugin for now.

tired of dealing with this and very frustrated. bb

traviswparker commented 4 months ago

log:

[15/02/2024, 15:03:54] [Wyze] Initializing WyzeSmartHome platform...

[15/02/2024, 15:03:56] [Wyze] Request failed: AxiosError: Request failed with status code 400 [15/02/2024, 15:03:56] [Wyze] Response PerformRequest ([object Object]): {"description":"Invalid credentials, please check username, password, keyid or apikey","requestId":"fdd52965-69c2-48ff-b137-eec7df14015d","errorCode":1000} [15/02/2024, 15:03:56] [Wyze] Error getting devices: Error: Invalid credentials, please check username, password, keyid or apikeyAxiosError: Request failed with status code 400 disabling the plugin for now.

tired of dealing with this and very frustrated. bb

400 is a different error, that is a login failure. Double check the email, password, key ID and API key are correct. You may also want to leave the plugin disabled for at least an hour. Wyze's Cloudfront protection will temporarily block you after too many failed logins.

May also want to try removing persist/wyze* and the plugin's config section, and setting it up again from scratch. A 400 error is "Bad Request" not "Unauthorized" so it is possible it does not like the user-agent or something else that has been changed from the defaults.

BBfly1 commented 4 months ago

I can login on the website and app no problem. I have generated a new API ID/key several times. Currently the plugin is disabled. I will let sit as is for a while and try again later just in case generating AP ID/keys has confused the Wyze authentication process.

UPDATE: 2024-0216 reset password, deleted and reset API ID/Key, upgraded to latest ver (v0.5.44) and it now works with no errors. Thanks to all.

Thanks, bb

On Thu, Feb 15, 2024 at 3:18 PM Travis Parker @.***> wrote:

log: [15/02/2024, 15:03:54] [Wyze] Initializing WyzeSmartHome platform...

[15/02/2024, 15:03:56] [Wyze] Request failed: AxiosError: Request failed with status code 400 [15/02/2024, 15:03:56] [Wyze] Response PerformRequest ([object Object]): {"description":"Invalid credentials, please check username, password, keyid or apikey","requestId":"fdd52965-69c2-48ff-b137-eec7df14015d","errorCode":1000} [15/02/2024, 15:03:56] [Wyze] Error getting devices: Error: Invalid credentials, please check username, password, keyid or apikeyAxiosError: Request failed with status code 400 disabling the plugin for now.

tired of dealing with this and very frustrated. bb

400 is a different error, that is a simple login failure. Double check the email, password, key ID and API key are correct. You may also want to leave the plugin disabled for at least an hour. Wyze's Cloudfront protection will temporarily block you after too many failed logins.

— Reply to this email directly, view it on GitHub https://github.com/jfarmer08/homebridge-wyze-smart-home/issues/216#issuecomment-1947355727, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDLJ5ZGPLUPPRFZMJEKXIDTYTZ3TLAVCNFSM6AAAAABDCZDM2CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBXGM2TKNZSG4 . You are receiving this because you commented.Message ID: @.***>

jfarmer08 commented 4 months ago

Hopefully this next release will help us understand why we are still seeing this issue.

carTloyal123 commented 4 months ago

IUPDATE: 2024-0216 reset password, deleted and reset API ID/Key, upgraded to latest ver (v0.5.44) and it now works with no errors. Thanks to all. Thanks, bb

Thanks for the update and glad it is fixed! Closing this for now since everyone seems to be back in order. Thanks for the help everyone!