bwp91 / homebridge-govee

Homebridge plugin to integrate Govee devices into HomeKit.
MIT License
442 stars 49 forks source link

HTTP client not connecting #761

Open shermanjoshua opened 3 months ago

shermanjoshua commented 3 months ago

After attempting a restart to scan for a new device, I noticed that it wasn't connecting. The new device would use the AWS client, but as you can see from the logs, that isn't starting because the HTTP client can't start. It's obviously failing somewhere in the login() function in http.js. I have not yet had a chance to look at the response from the api, but I did notice the message about needing to wait for the reset on the attempt timer, so I suspected either the PW was incorrect or something. After waiting for the timer and re-attempting (restarting everything in Homebridge), the message just came back, but the timer was reset to 5 minutes. So my suspicions were:

Details of your setup.

Please paste any relevant logs below.

[3/30/2024, 10:27:02 AM] [Govee] Initializing Govee platform...
[3/30/2024, 10:27:02 AM] [Govee] Initialising plugin v10.5.0 | System darwin | Node v20.10.0 | HB v1.7.0 | HAPNodeJS v0.11.1...
[3/30/2024, 10:27:02 AM] [Govee] Plugin initialised. Setting up accessories...
[3/30/2024, 10:27:04 AM] [Govee] [LAN] client enabled and found 1 device(s).
[3/30/2024, 10:27:04 AM] [Govee] [HTTP] could not use existing access token as does not exist, this is normally not an issue.
[3/30/2024, 10:27:05 AM] [Govee] [HTTP] disabling client as The number of consecutive failed logins for this account has reached the maximum. Please try again in 3 minutes. at default.login (file:///usr/local/lib/node_modules/homebridge-govee/lib/connection/http.js:58:15).
[3/30/2024, 10:27:05 AM] [Govee] [AWS] disabling client as requires HTTP client.
[3/30/2024, 10:27:05 AM] [Govee] [BLE] disabling client as not supported on mac devices.
[3/30/2024, 10:27:05 AM] [Govee] [4C:25:CD:33:33:35:12:65] initialising with options {"adaptiveLightingShift":0,"aws":"unsupported","ble":"unsupported","brightnessStep":1,"colourSafeMode":false,"lan":"enabled"}.
[3/30/2024, 10:27:05 AM] [Govee] [4C:25:CD:33:33:35:12:65] initialised with id [4C:25:CD:33:33:35:12:65] [H6066].
[3/30/2024, 10:27:05 AM] [Govee] ✓ Setup complete. This plugin has been made with ♥ by bwp91, please consider a ☆ on GitHub if you are finding it useful!
[3/30/2024, 10:27:35 AM] [Govee] [4C:25:CD:33:33:35:12:65] current colour [4590K / 218M].

User Note:

I did go ahead and grab the code to peek at what was failing. I also looked through docs and issues and have a thread to pull -

I am 90% sure this is some weird issue with login like you have noted in the docs somewhere (I'll find the link). I can log in to my account on the Govee site using the name/password from the config just fine. Rather than just default to the solution there, I figured I'd log this to give a chance to look for a solve. Also, I don't want to change my PW very much just because I have a bunch of other controls around that I'd have to update after realizing they are no longer working 😂

If I have the time in the next few days, I'll also plug away at this. Just need to read up on how to debug these plugins...

shermanjoshua commented 3 months ago

Got the console debugger going at least. Govee IS indeed returning {status: 400, message: 'Incorrect password'} in the response (this is on the initial run). I confirmed again that the PW does work to log me into Govee manually. I also tried this with the string manipulation of the password removed (commented out the lines, ran the rebuild script, waited the requisite 5 minutes, and hit debug - if these are not the right steps please let me know. I'm just assuming this is correct based on what the project looks like) and still got the same PW error.

I also see another message in the response about having too many requests altogether (the message says that the max attempts is 30 in 24 hours). That definitely is NOT enough attempts for someone trying to debug the authentication. Thanks Govee 🙄

It certainly does seem like this is something weird on Govee's side. Maybe they lose info on PWs between the site/app and this service for some reason? I haven't changed PWs recently or anything, so I'm definitely confused without knowing more about their internal workings.

I think my ideas around a PR (or a few) I could work on for this are:

I may take a pass at that if I have some more time, but would love to hear thoughts from anyone interested 😃

bwp91 commented 3 months ago

Try changing your password in the govee app.

i believe the accounts on their website are separate to govee app accounts.

The plugin needs credentials that are used for the app, not their website