Bubba8291 / homebridge-sharkiq

A Homebridge plugin to connect your Shark Vacuum to homebridge.
Apache License 2.0
7 stars 1 forks source link

Unable to add vacuums #17

Closed tjridge closed 3 weeks ago

tjridge commented 1 month ago

Describe The Bug:

Unable to ad devices To Reproduce:

Expected behavior:

Logs:

[08/08/2024, 00:18:151 [SharkIQ] Invalid username or password. [08/08/2024, 00:18:151 [SharkIQ] Invalid username or password. [08/08/2024, 00:18:151 [SharkIQ] None of the DSNs provided matched the vacuum(s) on you r account. [08/08/2024, 00:18:151 [SharkIQ] If you recently updated, vacuums are obtained by the d evice serial number (DSN) instead of the vacuum serial number.

Show the Homebridge logs here, remove any sensitive information.

Plugin Config:

Show your Homebridge config.json here, remove any sensitive information.

Screenshots:

Environment:

Bubba8291 commented 1 month ago

Please make sure the login information is correct and the DSN is correct.

tjridge commented 1 month ago

Both are correct.

mc473 commented 1 month ago

Seeing the same thing here. Was working flawlessly so my guess is Shark changed something backend since they just recently pushed out an app update where their maps were "redesigned".

> [8/9/2024, 5:56:21 PM] [SharkIQ] Invalid username or password.
> [8/9/2024, 5:56:21 PM] [SharkIQ] None of the DSNs provided matched the vacuum(s) on your account.
> [8/9/2024, 5:56:21 PM] [SharkIQ] If you recently updated, vacuums are obtained by the device serial number (DSN) instead of the vacuum serial number.

Environment:

Plugin Version: 1.1.2 Homebridge Version: 1.8.4 Node.js Version: 20.16.0 NPM Version: 10.8.1 Operating System: macOS Sonoma 14.5

Bubba8291 commented 1 month ago

@tjridge @mc473

Cannot reproduce. Are you on the US server or EU server?

tjridge commented 1 month ago

US server.

mc473 commented 1 month ago

Hi Bubba8291!

Apologies for not having helpful information ready for you - it's my first time reporting something related to Homebridge.

I'll attach my config.json with personal information redacted. At least I hope I got everything.

I am in the US. For grins last evening I did try switching to EU but that failed too.

Other things I have tried:

  1. Resetting my SharkClean password in the Shark app on iOS; first time using 24 characters, second time 10.
  2. Removing all vacuums and adding back one at a time - issue surfaces with any of the 3 vacuums I have no matter if they are the only one added, or added in combination with the others.
  3. Removing the plugin and re-adding.
  4. Trying an older version of the plugin.
  5. Trying a beta of Homebridge (v2.0) - rolled back to v1.84.

I cannot pinpoint the exact date this stopped working, but I would say within the last 3 to 4 days - 1 week maximum. I only happened to notice when I was updating my Ring plugin.

Hope this helps. I'm available to provide anything you need to pinpoint a cause.

Thank you, mc473

Bubba8291 commented 1 month ago

@mc473 Thank you!

I will check it in a little while. For now, can you comment your config.json again?

I removed it because the random string that is under the refresh token is sensitive. Treat those tokens like a password.

When you repost it, can you remove all the accessories in the accessories []? And for the platforms, can you remove everything except the SharKIQ platform section?

Thanks

mc473 commented 1 month ago

@Bubba8291 Thank you for removing the json and educating me on the token portion.

I'm attaching the sanitized json based on your request - at least I think I did it correctly? config.json

There is no rush on my side - I can use the app to keep my floors squeaky clean for now.

Let me know if you need an actual account to test with - I'd be happy to help in any way I can.

Thank you! mc473

Bubba8291 commented 1 month ago

@mc473 thank you.

Can you edit the first part and include all of the information it asks for in the environment section?

mc473 commented 1 month ago

Sure thing, @Bubba8291! I think I just updated as requested in my initial post. Let me know if this not what you meant…sometimes my comprehension is a bit off. 😂

Bubba8291 commented 1 month ago

@mc473 Thank you. I pushed a patch that gives more descriptive errors. Can you update and send the log?

mc473 commented 1 month ago

@Bubba8291 Ok, updated to 1.1.3 and am including the log output below. Just to confirm, the username & password should be the same as used to log into the Shark app, correct?

[8/10/2024, 10:31:43 PM] [SharkIQ] Initializing SharkIQ platform...
[8/10/2024, 10:31:43 PM] Loading 11 accessories...
[8/10/2024, 10:31:43 PM] [SharkIQ] API Error: Unable to sign in. Status Code 401
[8/10/2024, 10:31:43 PM] [SharkIQ] Message: You have one more attempt before your account is locked.
[8/10/2024, 10:31:43 PM] [SharkIQ] Invalid username or password.
[8/10/2024, 10:31:43 PM] 

NOTICE TO USERS AND PLUGIN DEVELOPERS
> Homebridge 2.0 is on the way and brings some breaking changes to existing plugins.
> Please visit the following link to learn more about the changes and how to prepare:
> https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0

[8/10/2024, 10:31:44 PM] [SharkIQ] None of the DSNs provided matched the vacuum(s) on your account.
[8/10/2024, 10:31:44 PM] [SharkIQ] If you recently updated, vacuums are obtained by the device serial number (DSN) instead of the vacuum serial number.
Bubba8291 commented 1 month ago

@mc473 Is the username field in your config that you are using an email or an actual username you created?

I don't know if they have usernames since I've always used my email, but the direct API response without the locked message is: Invalid email or password When I made the plugin, I think it said username or password, which is why the message says username and not email. The plugin has that original message within the code if the status code is 401.

Yes, should be the same login in the Shark Clean app. Let me look into it a bit.

mc473 commented 1 month ago

@Bubba8291 That makes sense. I am using my email since that’s required for setup. I see a 403 error now which is probably because the account is locked. I confirmed this by signing out of the app and trying to sign back in.

[8/10/2024, 11:09:43 PM] [SharkIQ] API Error: to sign in. Status Code 403
[8/10/2024, 11:09:43 PM] [SharkIQ] Message: You are forbidden to perform this operation
[8/10/2024, 11:09:43 PM] [SharkIQ] Invalid username or password.

image

Bubba8291 commented 1 month ago

@mc473 When you are able to log back in, let me know if that works and retry homebridge and see if you get any different error from the API Error Message error line.

mc473 commented 1 month ago

@Bubba8291 I guess Shark is still mad at me. This is the error this morning. Let me try to create a new account and move my vacuums over. Give me a little bit to get that done. 👍

image
mc473 commented 1 month ago

@Bubba8291 Ok, new account created and robots re-added. I am using the same credentials on the SharkIQ plugin as I am in the SharkIQ iOS app.

I do not mind sharing credentials with you privately if that helps in troubleshooting? Worst case is you just vacuum my floors repeatedly, right? 😂

[8/11/2024, 10:57:51 AM] [SharkIQ] API Error: Unable to sign in. Status Code 401
[8/11/2024, 10:57:51 AM] [SharkIQ] Message: Invalid email or password.
[8/11/2024, 10:57:51 AM] [SharkIQ] Invalid username or password.
[8/11/2024, 10:57:51 AM] [SharkIQ] None of the DSNs provided matched the vacuum(s) on your account.
[8/11/2024, 10:57:51 AM] [SharkIQ] If you recently updated, vacuums are obtained by the device serial number (DSN) instead of the vacuum serial number.
Bubba8291 commented 1 month ago

@mc473 Was able to reproduce

I created a new account for myself on the SharkClean app. Will investigate now.

Bubba8291 commented 1 month ago

I just got locked out of my main SharkClean account. I am not getting invalid login though, but You are forbidden to perform this operation instead.

From inspecting the app HTTP requests, Shark change their login to oauth. So I got a bit of work to do.

It might take a few days for me to do it, so contributions would be helpful. :)

mc473 commented 1 month ago

@Bubba8291 I'm afraid I'm no good with coding, and only know of OAUTH from dealing with Okta and SAML setups in a prior life.

Is this still correct for monetary contributions?

image
Bubba8291 commented 1 month ago

@mc473 Yes, it is. I appreciate the monetary contribution :)

Bubba8291 commented 1 month ago

@mc473 Can you test the rc version? Just install it with this command: npm install -g homebridge-sharkiq@v1.2.0-rc.1

After there are a few other steps for now.

  1. Open the terminal of the device hosting Homebridge
  2. Go to the homebridge-sharkiq directory by running cd $(npm root -g)/homebridge-sharkiq
  3. Run node login.js
  4. Open the url in the console
  5. Type in your login info. BEFORE YOU PRESS CONTINUE, open the developer console
  6. Go to the network tab, and then press continue.
  7. In the request that shows up with the uri of /authorize/resume, open that one, and view the headers
  8. Search com.sharkninja.shark in the headers
  9. Copy the code in between code= and &. for example in com.sharkninja.shark://login.sharkninja.com/ios/com.sharkninja.shark/callback?code=abcdefghijkl&state=gibberish, abcdefghijkl is the code that needs to be copied
  10. Open http://127.0.0.1:3000/oauth/callback?code=[CODE] and replace [CODE] with the code you just copied
  11. If there are no erros, go back to the terminal and move the sharkiq.json file to the Homebridge storage directory (typically ~/.homebridge) and save it as .sharkiq.json. Typical command would be mv sharkiq.json ~/.homebridge/.sharkiq.json
  12. Restart Homebridge

This process will get tremendously better over the next few weeks, but this is just a starter for now. And doing these steps should be a one and done deal. Once you have that .sharkiq.json file saved, the plugin should update it on its own whenever it needs a new token.

Please let me know if I need to clarify anything.

mc473 commented 1 month ago

@Bubba8291 Thank you for working so quickly on this!

I got all the way to Step 11 and I'm not seeing a sharkiq.json file to move? Is this because I hadn't reconfigured the plugin before starting testing? I didn't have a user/pass or any vacuum IDs populated.

The good news is that there were no errors in Step 10. It gave me an access token, a refresh token, and an 'ok'.

mc473 commented 1 month ago

OH wait...am I supposed to save that result as sharkiq.json and then move it?

Bubba8291 commented 1 month ago

@mc473 Yes, save the response as sharkiq.json and then move it.

Step 11 doesn't work because I published the rc before I made the commit that saves it locally as well. That was my bad on saying it automatically saves locally in the steps.

There is still a lot to do, so it might not even need to be moved next time.

mc473 commented 1 month ago

@Bubba8291 Great job my friend!!! It appears to have worked. 😎

I have three vacuums now. image

Bubba8291 commented 1 month ago

@mc473 Glad to hear!

One more thing. Make sure the .sharkiq.json file is owned by the user running Homebridge. If it's not, it will refresh the token without saving the JSON file.

If you need help with that, let me know.

mc473 commented 1 month ago

@Bubba8291 I think I'm good there. Verified the owner on the file is me and Homebridge is running under my account - I'm the only user and the machine only runs Homebridge. If you'd like me to check further, pass along the instructions and I can verify. Again, appreciate the attention you've given to this.

Bubba8291 commented 3 weeks ago

Published #19