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

SharkIQ authentication error #123392

Open
jnooraga opened this issue Aug 8, 2024 · 123 comments
Open

SharkIQ authentication error #123392

jnooraga opened this issue Aug 8, 2024 · 123 comments

Comments

@jnooraga
Copy link

jnooraga commented Aug 8, 2024

The problem

Receiving an error while loading the Shark IQ integration after updating to 2024.8.0:

I have verified my login works through the sharkclean.com website.

What version of Home Assistant Core has the issue?

core-2024.8.0

What was the last working version of Home Assistant Core?

core-2024.7.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Shark IQ

Link to integration documentation on our website

https://www.home-assistant.io/integrations/sharkiq

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-08-08 11:08:33.730 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry <email> for sharkiq
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sharkiq/__init__.py", line 67, in async_setup_entry
    if not await async_connect_or_timeout(ayla_api):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sharkiq/__init__.py", line 40, in async_connect_or_timeout
    await ayla_api.async_sign_in()
  File "/usr/local/lib/python3.12/site-packages/sharkiq/ayla_api.py", line 106, in async_sign_in
    self._set_credentials(resp.status, await resp.json())
  File "/usr/local/lib/python3.12/site-packages/sharkiq/ayla_api.py", line 84, in _set_credentials
    self._access_token = login_result["access_token"]
                         ~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'access_token'
2024-08-08 11:08:43.983 DEBUG (MainThread) [homeassistant.components.sharkiq] Initialize connection to Ayla networks API
2024-08-08 11:08:44.253 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry <email> for sharkiq
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sharkiq/__init__.py", line 67, in async_setup_entry
    if not await async_connect_or_timeout(ayla_api):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sharkiq/__init__.py", line 40, in async_connect_or_timeout
    await ayla_api.async_sign_in()
  File "/usr/local/lib/python3.12/site-packages/sharkiq/ayla_api.py", line 106, in async_sign_in
    self._set_credentials(resp.status, await resp.json())
  File "/usr/local/lib/python3.12/site-packages/sharkiq/ayla_api.py", line 84, in _set_credentials
    self._access_token = login_result["access_token"]
                         ~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'access_token'

Additional information

No response

@home-assistant
Copy link

home-assistant bot commented Aug 8, 2024

Hey there @JeffResc, @funkybunch, mind taking a look at this issue as it has been labeled with an integration (sharkiq) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of sharkiq can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign sharkiq Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


sharkiq documentation
sharkiq source
(message by IssueLinks)

@wnaylor
Copy link

wnaylor commented Aug 9, 2024

Same problem here. Won't work after updating to HA core-2024 8.0

@craig0r
Copy link

craig0r commented Aug 9, 2024

Yep, also seeing the exact same problem here!

@JeffResc
Copy link
Contributor

JeffResc commented Aug 10, 2024

I am also able to reproduce this. It looks like the backend API used by the integration had some changes made and I'm having trouble finding any public documentation for this. I can confirm that this doesn't have to do with any specific HA core version and has to do with the upstream sharkiq pypi package. I can also confirm that the app ID and app secret constants still seem to be correct

It looks like the previously working call to /users/sign_in.json is now resulting in a 403 with the error "You are forbidden to perform this operation" with no reason as to why this API call is no longer functioning as it originally was. I will continue to look into this, but I'm not seeing an immediate resolution without reverse engineering the login logic is and re-implementing it in the upstream dependency.

Issue created on upstream repo: JeffResc/sharkiq#51

@funkybunch
Copy link
Contributor

funkybunch commented Aug 20, 2024

Worth noting that this does not seem to affect all installations. Additional analysis is being done to determine the root cause.

Instead of simply responding "yeah its happening to me too" please include your logs, model, and region to help us get to the bottom of the issue, otherwise it is not helpful.

Likewise, if you have a working installation, please do leave a comment with your model and region to help us determine if there is a pattern.

Finally, some users have reported despite successfully logging into the app with the same credentials, both the app and HA worked after resetting their password. Please try this and let us know if it worked for you as well. Any and all data points are helpful at this stage.

@craig0r
Copy link

craig0r commented Aug 20, 2024

The integration is broken for me in Canada. I have both a Shark IQ and a Shark AI device integrated and previously both working perfectly. Below is the log when I attempt to reload the integration:

Logger: homeassistant.config_entries
Source: config_entries.py:604
First occurred: August 19, 2024 at 4:57:12 PM (2 occurrences)
Last logged: 11:44:54 AM

Error setting up entry [email protected] for sharkiq
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sharkiq/__init__.py", line 67, in async_setup_entry
    if not await async_connect_or_timeout(ayla_api):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sharkiq/__init__.py", line 40, in async_connect_or_timeout
    await ayla_api.async_sign_in()
  File "/usr/local/lib/python3.12/site-packages/sharkiq/ayla_api.py", line 106, in async_sign_in
    self._set_credentials(resp.status, await resp.json())
  File "/usr/local/lib/python3.12/site-packages/sharkiq/ayla_api.py", line 84, in _set_credentials
    self._access_token = login_result["access_token"]
                         ~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'access_token'

@craig0r
Copy link

craig0r commented Aug 20, 2024

I apologize that I didn't attempt this in my previous comment, but I've just tried resetting my password and it didn't work. however, it is now giving me a different error log. Hope this helps!

Logger: homeassistant.components.sharkiq
Source: components/sharkiq/config_flow.py:59
integration: Shark IQ (documentation, issues)
First occurred: 1:34:24 PM (2 occurrences)
Last logged: 1:35:40 PM

string indices must be integers, not 'str'

I'd be curious to know how to change the existing credentials on the integration, as I could only figure out how to input my updated password by using "Add Entry" on the integration config. and SharkIQ is not available in the "Application Credentials" page. Just to be sure, I also deleted my (backed up) existing SharkIQ integration and re-added it with the new password, but the log output is the same.

@Sleeepy2
Copy link

Not sure if mine is the same problem however I can not set it up
Model is UR1410ZWCA
In North America

Logger: homeassistant.config_entries
Source: config_entries.py:604
First occurred: 2:43:25 pm (2 occurrences)
Last logged: 2:47:26 pm

Error setting up entry [email protected] for sharkiq
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sharkiq/__init__.py", line 72, in async_setup_entry
    shark_vacs = await ayla_api.async_get_devices(False)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sharkiq/ayla_api.py", line 222, in async_get_devices
    devices = [SharkIqVacuum(self, d, europe=self.europe) for d in await self.async_list_devices()]
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sharkiq/ayla_api.py", line 208, in async_list_devices
    devices = await resp.json()
              ^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 80, in json
    return await super().json(*args, loads=loads, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1199, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html;charset=utf-8', url='https://ads-field-39a9391a.aylanetworks.com/apiv1/devices.json

@vaeron
Copy link

vaeron commented Aug 23, 2024

I began having failures immediately upon upgrading my HA to 2024.08.0. I am running on an Ubuntu VM. Region is US. Without thinking I removed the configuration and this is what I was met with when I tried to set it back up. Logs from my first attempted logon:

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup

result = await component.async_setup_entry(hass, self)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/components/sharkiq/__init__.py", line 67, in async_setup_entry

if not await async_connect_or_timeout(ayla_api):

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/components/sharkiq/__init__.py", line 40, in async_connect_or_timeout

await ayla_api.async_sign_in()

File "/usr/local/lib/python3.12/site-packages/sharkiq/ayla_api.py", line 106, in async_sign_in

self._set_credentials(resp.status, await resp.json())

^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 80, in json

return await super().json(*args, loads=loads, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1199, in json

raise ContentTypeError(

aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: ', url='https://user-field-39a9391a.aylanetworks.com/users/sign_in.json'

I then reset my password and was met with a failed to connect and this in the logs (I did verify that I can connect to sharkclean's website with the new password):

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sharkiq/config_flow.py", line 57, in _validate_input
    await ayla_api.async_sign_in()
  File "/usr/local/lib/python3.12/site-packages/sharkiq/ayla_api.py", line 106, in async_sign_in
    self._set_credentials(resp.status, await resp.json())
  File "/usr/local/lib/python3.12/site-packages/sharkiq/ayla_api.py", line 84, in _set_credentials
    self._access_token = login_result["access_token"]
                         ~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'access_token'

@tombrant
Copy link

My Robot model is RV2520A0US. The latest integration fails with the access_token error and a 403 response code as reported above. I started using the HA integration in May 2024 (and successfully extended it for room specific cleaning with a custom integration based on the logic in jeffresc/sharkiq). Prior to May, I started running into problems using the Google Assistant with the SharkClean skill. I had been using it to schedule room-based cleaning successfully, but it suddenly stopped working. Alexa's SharkClean skill also failed to work, so I had no solution to schedule specific rooms for cleaning. The reason I mention the above is that I just unlinked and relinked the skills on Alexa and Google Assistant. There was a hint in the link skill page in the Alexa app that says under the heading 'What's new' that they 'replaced the web authorization URI'. There was no information like that on Google Assistant's skill, but when I tried it to perform a room-specific cleaning operation, it worked.

@craig0r
Copy link

craig0r commented Aug 23, 2024

My Robot model is RV2520A0US. The latest integration fails with the access_token error and a 403 response code as reported above. I started using the HA integration in May 2024 (and successfully extended it for room specific cleaning with a custom integration based on the logic in jeffresc/sharkiq). Prior to May, I started running into problems using the Google Assistant with the SharkClean skill. I had been using it to schedule room-based cleaning successfully, but it suddenly stopped working. Alexa's SharkClean skill also failed to work, so I had no solution to schedule specific rooms for cleaning. The reason I mention the above is that I just unlinked and relinked the skills on Alexa and Google Assistant. There was a hint in the link skill page in the Alexa app that says under the heading 'What's new' that they 'replaced the web authorization URI'. There was no information like that on Google Assistant's skill, but when I tried it to perform a room-specific cleaning operation, it worked.

I imagine that'll be helpful, although I looked into the Google Home integration a bit, and it seems like it authenticates against a google-specific URL.... and I've just checked Alexa and it does the same; you actually log into https://alexa-account-linking.iot-sharkninja.com/?client_id=RANDOMTEXT

So, I dunno if it would be possible to leverage the Google/Alexa integrations, but it's definitely interesting to know they had to change their configs as well. Hopefully that's a good sign that there's a way forwards for us too.

@funkybunch
Copy link
Contributor

@tombrant do you happen to have that new URL?

@Frazou1
Copy link

Frazou1 commented Aug 26, 2024

Same problem here in Canada

@dakoellis
Copy link

dakoellis commented Aug 26, 2024

Getting the same KeyErorr: 'Access Token' issue in US, Model is RV2520A0US. @funkybunch I think the one for Alexa at least is the link posted by @craig0r : https://alexa-account-linking.iot-sharkninja.com/?client_id=RANDOMTEXT

@tombrant
Copy link

@tombrant do you happen to have that new URL?

No, unfortunately I don’t but perhaps @craig0r is onto something that can help make progress.

Can you @craig0r elaborate on the form that RANDOMTEXT follows? Is it symmetric with the google specific URL?

@craig0r
Copy link

craig0r commented Aug 26, 2024

@tombrant, @funkybunch

Nope, they're a bit different. I've changed a couple letters at the end of each URL to avoid potential privacy/security issues, but here's what I get when I attempt to authenticate to each:

Google
https://gaccount-linking.iot-sharkninja.com/?response_type=code&client_id=d08c597f811c2650242ccc36859d9c40b57250964babcdf9a21568ec3fbfc569&redirect_uri=https://oauth-redirect.googleusercontent.com/r/shark-field&state=APvkAzG-NNA4N1JxBC1svz_fGq12iUi4-TdZp_Goc4xaLhQFYluaKv2L-o9Mxq_5IGxas1F0SK1zevKEFARwmpsotQnFAdIk5jDF16euHxGpWlGK5BusUFhBrG2HprjUS9K06Y4eaNlfVejPpFqIJ0R2Fap9DIIugzpG-bh2xqpNvbx69MW4ENe7bKsdzU3bB-yM0tioQ5TDvgjXGlWWcES4Qhtpc_WCee1cn4uP_Q3Gl6FYoYUqODunyOGIDDW919NRFOcbn0HSIfMBYrZRJxgXJf08SfbqkiYbsrHfseFHeHLhBlxiRVPBIeAgPG8YrI6joRYSOZ63m9BxKP2OZ7QKzR85mKYyerQqTFw4MoRSwz1DUxyVOpRhOxM0QMw0CQLREN1chvDk6pGk0TT6rwLp6LgdeFqTuFmwulsMqdj_Wgf02tzePLZ4iGp5Hm0vjwnPBeUSOwhIZwCpBjBkUFnIDg

Alexa
https://alexa-account-linking.iot-sharkninja.com/?client_id=9651aaaa8db120b87499939262d138cca75c11fa632db549f755e4a796eba447&response_type=code&scope=device+user&redirect_uri=https%3A%2F%2Fpitangui.amazon.com%2Fapi%2Fskill%2Flink%2FM39CMXRVRKC8C0&state=AmaseyJ2YWxpZGF0aW9uQ29kZSI6IklJN1NGd0VvS0NPVDh3bUsrbDFWMW92d2laUTVTQkJUNmlKdnRBVCtQRms9IiwiZGlyZWN0ZWRJZCI6ImFtem4xLmFjY291bnQuQUc1N1JIUktER7ZYQ0dXU1VKM1Q0V0pQN1dGUSIsInBhcnRuZXJJZCI6IlB6SlRNdmNtRkdEUGxld3RaQmxCRlhJSXQiLCJhcHBsaWNhdGlvbkRvbWFpbiI6IkFMRVhBX1NLSUxMUyIsImFwcGxpY2F0aW9uRG9tYWlucyI6WyJBTEVYQV9TS0lMTFMiLCJBTEVYQV9DT0hPIl0sImV4cGlyYXRpb25UaW1lSW5NaWxsaXMiOjE3MjQ3MDg3MDM2MTcsInVzZXJTdGF0ZSI6W3siayI6InJlcXVlc3RSZWFsbSIsInYiOiJ1cy1lYXN0LTEifSx7ImsiOiJza2lsbElkIiwidiI6ImFtem4xLmFzay5za2lsbC41NzFkYTRjZS03NDFhLTQxN2YtYTVmMS01YjFmYzE4ZWQ2NmMifSx7ImsiOiJjc3JmVG9rZW4iLCJ2IjoiMTY4Nzk1Mzc4In0seyJrIjoicmVxdWVzdEluZ3Jlc3MiLCJ2Ijoic2hvd0VuYWJsZVNraWxsIn0seyJrIjoiY3VzdG9tZXJJZCIsInYiOiJBMUJIQ1ZSVEVIRUg2ViJ9LHsiayI6InJlcXVlc3REZXZpY2VGYW1pbHkiLCJ2IjoiQ29tcEFwcEFuZHJvaWQifSx7ImsiOiJyZXF1ZXN0U3RhZ2UiLCJ2IjoicHJvZCJ9LHsiabI6InNraWxsU3RhZ2UiLCJ2IjoibGl2ZSJ9LHsiayI6InJlcXVlc3RTdGFydFRpbWUiLCJ2IjoiMTcyNDcwNDkwMzYxMyJ9XSwiZGlyZWN0ZWRJZFR5cGUiOiJPQkZVU0NBVEVEX0NVU1RPTUVSX0lEIiwiZ3JhbnRlZFNjb3Blc0luY2x1ZGVkIjpmYWxzZX0BBBBBBBBAAAAAAAAAABQwEVUg_dgVSwzvAW8cAauIQAAAAAAEACngf6ibVUaAWmc6F5PaqyKY-EQaVegl6_Ly58b8nZAekM%3D

@JOHLC
Copy link

JOHLC commented Sep 1, 2024

I am seeing this as well. Region is US/North America and model is RV1100A.

HA Version: 2024.8.3
Install type: Home Assistant OS

Logs:

2024-09-01 12:16:37.455 DEBUG (MainThread) [homeassistant.components.sharkiq] Initialize connection to Ayla networks API
2024-09-01 12:16:37.861 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Shark for sharkiq
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sharkiq/__init__.py", line 67, in async_setup_entry
    if not await async_connect_or_timeout(ayla_api):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sharkiq/__init__.py", line 40, in async_connect_or_timeout
    await ayla_api.async_sign_in()
  File "/usr/local/lib/python3.12/site-packages/sharkiq/ayla_api.py", line 106, in async_sign_in
    self._set_credentials(resp.status, await resp.json())
  File "/usr/local/lib/python3.12/site-packages/sharkiq/ayla_api.py", line 84, in _set_credentials
    self._access_token = login_result["access_token"]
                         ~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'access_token'

@tombrant
Copy link

tombrant commented Sep 3, 2024

From the look of the Google and Alexa auth urls and the arguments being supplied, this appears to be an OAuth Client Credentials Grant flow. In this case, the applications engaged in the API activity to control the device are running on the Google or Alexa hosted servers and are granted authentication through a token exchange with the SharkClean IOT authentication endpoints. This doesn't appear to involve any user-specific credentials being supplied. The fact that the HA authentication is now returning a 403 seems to me to indicate that the original username and password API flow has been explicitly disabled and only registered applications can interact. Does this sound like a valid conclusion to draw based on the information known?
Can someone make an inquiry with SharkNinja to see if they would entertain an HA registration?

@rmuehler
Copy link

rmuehler commented Sep 4, 2024

From the look of the Google and Alexa auth urls and the arguments being supplied, this appears to be an OAuth Client Credentials Grant flow. In this case, the applications engaged in the API activity to control the device are running on the Google or Alexa hosted servers and are granted authentication through a token exchange with the SharkClean IOT authentication endpoints. This doesn't appear to involve any user-specific credentials being supplied. The fact that the HA authentication is now returning a 403 seems to me to indicate that the original username and password API flow has been explicitly disabled and only registered applications can interact. Does this sound like a valid conclusion to draw based on the information known? Can someone make an inquiry with SharkNinja to see if they would entertain an HA registration?

This seems to be true. It seems the API can still authenticate email/password through the current endpoint so I don't think the URL is dead. The 403 makes me think they disabled auth token generation through the ""Shark-Android-field-id" app_id that HA integration has been using. The is a similar "Shark-iOS-field-id" app_id + app_secret that used to work that returns a 403 now.

They probably reworked the mobile apps since 2020 or whenever these app details were first posted and now finally got around to disabling auth token generation from the old app ids. My integration was working fine until yesterday when my token must have expired and I lost client access to the underlying APIs.

@Frazou1
Copy link

Frazou1 commented Sep 11, 2024

Any news yet ?

@craig0r
Copy link

craig0r commented Sep 12, 2024

Any news yet ?

I wouldn't hold your breath. It seems like Shark are deliberately locking out anyone who isn't Google, Amazon, or Apple. My guess is to avoid excess API calls, which is frustrating since other companies deal with this by simply limiting the external API calls (see Ecobee for a good example; they only allow 1 API call per minute, or something along those lines.)

I was able to (mostly) recreate my Shark automations with Google Home via their website at home.google.com/automations (note that you can't do this in the Android/iOS app)

Here's a sample of one of mine:

metadata:
  name: Vacuum Hallway
  description: At 11am on Tuesdays and Thursdays,vacuum the hallway
    vacuum
automations:
  - starters:
      - type: time.schedule
        at: 11:00
        weekdays:
          - TUE
          - THU
    actions:
      - type: assistant.command.OkGoogle
        devices:
          - Dining Room speaker - Dining Room
        okGoogle: Start main vacuum in hallway

This is asking Google Assistant via my device "Dining Room Speaker" to simply run a voice command, and it runs on Tuesdays and Thursdays at 11:00am. I built it using the Gemini assistant built into the site.

I may, however, actually end up adjusting my exiting Home Assistant automations so that instead of interacting directly with the Shark integration, they will simply ask the Google Assistant integration to run "Start main vacuum in hallway." Then at least Home Assistant is still doing the scheduling, even though it can't tell me the status of the vacuums anymore.

@tombrant
Copy link

tombrant commented Sep 12, 2024

re latest comment from @craig0r

I have reverted to using the Google Home automations as well. They were broken for me early this year which is why I ended up adapting the jeffresc/sharkiq HA integration for my own use. Now that HA auth is broken and I'm back on Google Home automations (which can be scheduled) I see that they only work for one room at a time. I had successfully adapted Jeff's integration to support more than one room per cleaning. I'm not sure why the Google automation can't handle more than one room. Also, Alexa automations apparently ignore all room-specific commands and just start cleaning. @craig0r you mention Apple as a supported Shark assistant. That's not in Homekit, is it?

@ghost
Copy link

ghost commented Sep 12, 2024

This is all very unfortunate, as I bought two new shark's the week this went down, after integrating my previous shark for the last year without issue. Sucks because I was on the fence with new shark's or Roborocks.

It's not ideal, but I did the same with google. Made a bubble-card pop-up with various rooms and commands, and it works pretty good.

Screenshot_20240912_115848_Home Assistant

@craig0r
Copy link

craig0r commented Sep 12, 2024

re latest comment from @craig0r

I have reverted to using the Google Home automations as well. They were broken for me early this year which is why I ended up adapting the jeffresc/sharkiq HA integration for my own use. Now that HA auth is broken and I'm back on Google Home automations (which can be scheduled) I see that they only work for one room at a time. I had successfully adapted Jeff's integration to support more than one room per cleaning. I'm not sure why the Google automation can't handle more than one room. Also, Alexa automations apparently ignore all room-specific commands and just start cleaning. @craig0r you mention Apple as a supported Shark assistant. That's not in Homekit, is it?

@tombrant I'm not sure, I just assumed Shark works with Apple devices. I don't have one of my own to check.

@lishan89uc
Copy link

Last I checked shark devices only work through apple via app. No homekit, not even siri shortcuts.

@nikkehsolaris
Copy link

@nikkehsolaris

Here's my version. It needs polishing but, it works.

alias: Action - Vacuum Room(s)
sequence:
  - variables:
      formatted_rooms: |-
        {% set rooms = action %} {% if rooms|length == 1 %}
          {{ rooms[0] }}
        {% else %}
          {{ rooms[:-1] | join(', ') }} and {{ rooms[-1] }}
        {% endif %}
  - action: google_assistant_sdk.send_text_command
    data:
      command: Ask Bruce to vacuum the "{{ formatted_rooms }}"
    enabled: true
  - action: persistent_notification.create
    metadata: {}
    data:
      title: Google command
      notification_id: vacuum
      message: Ask Bruce to vacuum the {{ formatted_rooms }}
fields:
  action:
    selector:
      select:
        options:
          - Kitchen
          - Living Room
          - Hallway
          - Bathroom
          - Foyer
          - Dining Room
          - Playroom
        multiple: true
    name: Action
    description: Select Room
    required: true
    default:
      - Kitchen
      - Hallway
      - Foyer
      - Dining Room
description: ""
icon: mdi:robot-vacuum

Results in the following notification/command being sent: Screenshot_20241206-220717.png

Awesome thank you!

Have you noticed your robots as offline a lot? I can add them via GoogleHome fine, but they never show up as online even when I can clearly see them connected to the Wifi.

@maciekish
Copy link

maciekish commented Dec 29, 2024

@nikkehsolaris
Here's my version. It needs polishing but, it works.
...

Where does this go? HA Automation? Doesn't accept it.

image

@Shayne55434
Copy link

@nikkehsolaris
Here's my version. It needs polishing but, it works.
...

Where does this go? HA Automation? Doesn't accept it.

image

It's a script, not an automation.

@Shayne55434
Copy link

Shayne55434 commented Dec 29, 2024

@nikkehsolaris

Here's my version. It needs polishing but, it works.

alias: Action - Vacuum Room(s)
sequence:
  - variables:
      formatted_rooms: |-
        {% set rooms = action %} {% if rooms|length == 1 %}
          {{ rooms[0] }}
        {% else %}
          {{ rooms[:-1] | join(', ') }} and {{ rooms[-1] }}
        {% endif %}
  - action: google_assistant_sdk.send_text_command
    data:
      command: Ask Bruce to vacuum the "{{ formatted_rooms }}"
    enabled: true
  - action: persistent_notification.create
    metadata: {}
    data:
      title: Google command
      notification_id: vacuum
      message: Ask Bruce to vacuum the {{ formatted_rooms }}
fields:
  action:
    selector:
      select:
        options:
          - Kitchen
          - Living Room
          - Hallway
          - Bathroom
          - Foyer
          - Dining Room
          - Playroom
        multiple: true
    name: Action
    description: Select Room
    required: true
    default:
      - Kitchen
      - Hallway
      - Foyer
      - Dining Room
description: ""
icon: mdi:robot-vacuum

Results in the following notification/command being sent: Screenshot_20241206-220717.png

Awesome thank you!

Have you noticed your robots as offline a lot? I can add them via GoogleHome fine, but they never show up as online even when I can clearly see them connected to the Wifi.

I don't believe so. I did have some initial connectivity issues but, after disabling my pi hole ad blocker, I haven't noticed any.

@nikkehsolaris
Copy link

nikkehsolaris commented Jan 1, 2025

I ended up digging through the APK and running some http intercepts.
Login flow now looks like;

  1. login.sharkninja.com/u/login (then passes some type of state value that i'm not 100% sure on)
  2. login.sharkninja.com/authorize/resume (state again)
  3. login.sharkninja.com/oauth/token (request body includes; client_id, grant_type="authorization_code", code, redirct_uri="com.sharkninja.shark://login.sharkninja.com/android/com.sharkninja.shark/callback",, and code verifier) (response gives; access_token, refresh_token, id_token, scope"openid profile email read:current_user offline_access", expires_in=86400 and token_type="Bearer"
  4. https://login.sharkninja.com/.well-known/jwks.json
  5. https://user-field-39a9391a.aylanetworks.com/api/v1/token_sign_in (request body; app_id="android_shark_prod-7Q-id",app_secret, token) (response; access_token, refresh_token, expires_in, role="EndUser",role_tags=[],code='ok')
  6. https://user-field-39a9391a.aylanetworks.com/users/get_user_profile.json
  7. https://ads-field-39a9391a.aylanetworks.com/apiv1/devices.json

Urls;

  1. login.sharkninja.com
  2. user-field-39a9391a.aylanetworks.com
  3. ads-field-39a9391a.aylanetworks.com
  4. ads-apiv1-sharkue1.aylanetworks.com

Other things of note from the apk;

They may have moved to using cognito on the backend, I see it in the APK and they (ayla networks) are primarily on AWS. Shark is Akami and Ayla is using Route53. Which means its highly likely they are also using WAF and/or Api Gateway.

Happy to test with the token I can scrape from the app, just need a modified HA integration to do it with. (Access token now gets passed for the requests as "authorization: auth_token TOKENHERE" in the header)

EDIT: Can confirm the access token works to hit the apiv1/devices.json via postman when passed via header. Looks like access token is good for 24 hours so a bit painful to get atm but once captured shouldn't be hard to keep from expiring. also access token != auth token, access token is from the /oauth/token response. auth token is what is passed to that endpoint. even though the header name says auth_token they want the access token.

Edit 2; can grab the api url (ads-apiv1-sharkue1.aylanetworks.com) from the apiv1/dsns/DEVICEDSNHERE.json which is found in apiv1/devices.json

@voron69-bit

This comment was marked as spam.

@craig0r

This comment was marked as resolved.

@voron69-bit

This comment was marked as spam.

@craig0r
Copy link

craig0r commented Jan 2, 2025

Can we get this fixed please? This integration is not working.

This kind of response, which contributes nothing, makes it seem like you didn't even read the thread.

No, and I don't have time to. I looked at the last comment, saw people are digging through apk's and other stuff, and I know the integration isn't working, because...it's updated, and not working.

Okay well TLDR for anyone who doesn't have time to read about the issue they're commenting on: it's being worked on, and unless you can contribute towards a fix, all you can do is wait.

@voron69-bit

This comment was marked as spam.

@funkybunch
Copy link
Contributor

@voron69-bit please review the Home Assistant code of conduct prior to commenting https://github.com/home-assistant/core/blob/dev/CODE_OF_CONDUCT.md

If you’re so impatient to get this working again we’d love for you to submit a PR and help out. Everyone responsible for this fix is a volunteer and your disregard for that is not a welcome contribution. Either be productive here or do not engage.

@voron69-bit

This comment was marked as abuse.

@balloob
Copy link
Member

balloob commented Jan 2, 2025

@voron69-bit please stop responding and respect our processes. People are working on figuring out the new API which can take time.

@rheidt
Copy link

rheidt commented Jan 3, 2025

The

I ended up digging through the APK and running some http intercepts. Login flow now looks like;

  1. login.sharkninja.com/u/login (then passes some type of state value that i'm not 100% sure on)
  2. login.sharkninja.com/authorize/resume (state again)
  3. login.sharkninja.com/oauth/token (request body includes; client_id, grant_type="authorization_code", code, redirct_uri="com.sharkninja.shark://login.sharkninja.com/android/com.sharkninja.shark/callback",, and code verifier) (response gives; access_token, refresh_token, id_token, scope"openid profile email read:current_user offline_access", expires_in=86400 and token_type="Bearer"
  4. https://login.sharkninja.com/.well-known/jwks.json
  5. https://user-field-39a9391a.aylanetworks.com/api/v1/token_sign_in (request body; app_id="android_shark_prod-7Q-id",app_secret, token) (response; access_token, refresh_token, expires_in, role="EndUser",role_tags=[],code='ok')
  6. https://user-field-39a9391a.aylanetworks.com/users/get_user_profile.json
  7. https://ads-field-39a9391a.aylanetworks.com/apiv1/devices.json

Urls;

  1. login.sharkninja.com
  2. user-field-39a9391a.aylanetworks.com
  3. ads-field-39a9391a.aylanetworks.com
  4. ads-apiv1-sharkue1.aylanetworks.com

Other things of note from the apk;

They may have moved to using cognito on the backend, I see it in the APK and they (ayla networks) are primarily on AWS. Shark is Akami and Ayla is using Route53. Which means its highly likely they are also using WAF and/or Api Gateway.

Happy to test with the token I can scrape from the app, just need a modified HA integration to do it with. (Access token now gets passed for the requests as "authorization: auth_token TOKENHERE" in the header)

EDIT: Can confirm the access token works to hit the apiv1/devices.json via postman when passed via header. Looks like access token is good for 24 hours so a bit painful to get atm but once captured shouldn't be hard to keep from expiring. also access token != auth token, access token is from the /oauth/token response. auth token is what is passed to that endpoint. even though the header name says auth_token they want the access token.

Edit 2; can grab the api url (ads-apiv1-sharkue1.aylanetworks.com) from the apiv1/dsns/DEVICEDSNHERE.json which is found in apiv1/devices.json

It looks like the aylane networks oath api has a "refresh token" for "keep alive" type workflows. https://docs.aylanetworks.com/reference/authentication

@nikkehsolaris
Copy link

The

I ended up digging through the APK and running some http intercepts. Login flow now looks like;

  1. login.sharkninja.com/u/login (then passes some type of state value that i'm not 100% sure on)
  2. login.sharkninja.com/authorize/resume (state again)
  3. login.sharkninja.com/oauth/token (request body includes; client_id, grant_type="authorization_code", code, redirct_uri="com.sharkninja.shark://login.sharkninja.com/android/com.sharkninja.shark/callback",, and code verifier) (response gives; access_token, refresh_token, id_token, scope"openid profile email read:current_user offline_access", expires_in=86400 and token_type="Bearer"
  4. https://login.sharkninja.com/.well-known/jwks.json
  5. https://user-field-39a9391a.aylanetworks.com/api/v1/token_sign_in (request body; app_id="android_shark_prod-7Q-id",app_secret, token) (response; access_token, refresh_token, expires_in, role="EndUser",role_tags=[],code='ok')
  6. https://user-field-39a9391a.aylanetworks.com/users/get_user_profile.json
  7. https://ads-field-39a9391a.aylanetworks.com/apiv1/devices.json

Urls;

  1. login.sharkninja.com
  2. user-field-39a9391a.aylanetworks.com
  3. ads-field-39a9391a.aylanetworks.com
  4. ads-apiv1-sharkue1.aylanetworks.com

Other things of note from the apk;
They may have moved to using cognito on the backend, I see it in the APK and they (ayla networks) are primarily on AWS. Shark is Akami and Ayla is using Route53. Which means its highly likely they are also using WAF and/or Api Gateway.
Happy to test with the token I can scrape from the app, just need a modified HA integration to do it with. (Access token now gets passed for the requests as "authorization: auth_token TOKENHERE" in the header)
EDIT: Can confirm the access token works to hit the apiv1/devices.json via postman when passed via header. Looks like access token is good for 24 hours so a bit painful to get atm but once captured shouldn't be hard to keep from expiring. also access token != auth token, access token is from the /oauth/token response. auth token is what is passed to that endpoint. even though the header name says auth_token they want the access token.
Edit 2; can grab the api url (ads-apiv1-sharkue1.aylanetworks.com) from the apiv1/dsns/DEVICEDSNHERE.json which is found in apiv1/devices.json

It looks like the aylane networks oath api has a "refresh token" for "keep alive" type workflows. https://docs.aylanetworks.com/reference/authentication

I did not realize they had this API accessible and documented! I'm going to create an account and do some testing this weekend.

@tombrant
Copy link

tombrant commented Jan 3, 2025

The aylanetworks api is presumably the same one that the original, now failing codebase for this project in GitHub used. Is this investigation intended to find a way to authenticate differently from the now broken codebase?

@nikkehsolaris
Copy link

The aylanetworks api is presumably the same one that the original, now failing codebase for this project in GitHub used. Is this investigation intended to find a way to authenticate differently from the now broken codebase?

I mean I personally want to confirm that the login flow is the same from what I scrapped from the APK. I'm curious what the state value passed via the android app is and if it's even necessary.

Still happy to beta test any code changes but my skillsets lie more in info gathering and debugging.

@Danbana
Copy link

Danbana commented Jan 6, 2025

I would be so stoked if this gets fixed!

@bigtimec4guy
Copy link

I'm willing to help in any way I can to assist in getting Shark vacuums working with HA.

@gmorgan9
Copy link

If anyone is wanting to see how to implement the workaround, please check out this video I posted! I am working on posting an article about the yaml scripts. Please let me know if you have any questions!
Shark Clean HA Integration Workaround

@HGupta2018
Copy link

If anyone is wanting to see how to implement the workaround, please check out this video I posted! I am working on posting an article about the yaml scripts. Please let me know if you have any questions! Shark Clean HA Integration Workaround

Watched the video, but didn't see the workaround. It starts with integration already installed. Most of us are stuck where it won't even link with our account.

@bigtimec4guy
Copy link

Yes that's where I'm stuck. Won't even link to the Shark account.

@gmorgan9
Copy link

gmorgan9 commented Jan 22, 2025

If anyone is wanting to see how to implement the workaround, please check out this video I posted! I am working on posting an article about the yaml scripts. Please let me know if you have any questions! Shark Clean HA Integration Workaround

Watched the video, but didn't see the workaround. It starts with integration already installed. Most of us are stuck where it won't even link with our account.

Yes that's where I'm stuck. Won't even link to the Shark account.

Hello,thank you for your feedback and for taking the time to watch the video! I apologize for not including the prerequisites in the video. To address this, I’ve written an article that outlines all the necessary steps to get started, including the integration process. You can check it out here:
Essential Scripts for Shark Clean HA Integration Workaround

Please feel free to reach out if you have any questions or run into issues. I’d also like to note that this solution is intended as a workaround until the original Home Assistant Shark integration is restored.
@HGupta2018 @bigtimec4guy

@bmorgan99
Copy link

RV1001AE
US

025-01-27 04:39:20.398 DEBUG (MainThread) [homeassistant.components.sharkiq] Initialize connection to Ayla networks API
2025-01-27 04:39:20.637 ERROR (MainThread) [homeassistant.components.sharkiq] string indices must be integers, not 'str'

@400HPMustang
Copy link

If anyone is wanting to see how to implement the workaround, please check out this video I posted! I am working on posting an article about the yaml scripts. Please let me know if you have any questions! Shark Clean HA Integration Workaround

I don't suppose there's any way to work around the inability to know when the robot docks? I used to trigger lights turning off when the robot docks and now my robot just vacuums in the dark.

@rmuehler
Copy link

rmuehler commented Jan 31, 2025

I don't suppose there's any way to work around the inability to know when the robot docks? I used to trigger lights turning off when the robot docks and now my robot just vacuums in the dark.

I would do something like this at home.google.com. Shark implements a "starter" for the vacuum docking, and you can expose a helper scene or button from Home Assistant to activate your lights. You can also do this for when the robot starts.

- starters:
      # Trigger when the robot docks
      - type: device.state.Dock
        device: Shark Vacuum Name
        state: isDocked
        is: true
    actions:
      # Activate the "Vacuum Docked" scene exposed from HA
      - type: device.command.ActivateScene
        activate: true
        devices: Vacuum Docked

@400HPMustang
Copy link

I don't suppose there's any way to work around the inability to know when the robot docks? I used to trigger lights turning off when the robot docks and now my robot just vacuums in the dark.

I would do something like this at home.google.com. Shark implements a "starter" for the vacuum docking, and you can expose a helper scene or button from Home Assistant to activate your lights. You can also do this for when the robot starts.

  • starters:
    # Trigger when the robot docks
    - type: device.state.Dock
    device: Shark Vacuum Name
    state: isDocked
    is: true
    actions:
    # Activate the "Vacuum Docked" scene exposed from HA
    - type: device.command.ActivateScene
    activate: true
    devices: Vacuum Docked

Hmm...yeah I don't actually know how to do that. I can create an input boolean like input_boolean.robot_docked but I have no clue how to get it exposed to google home.

@blahnika
Copy link

blahnika commented Feb 1, 2025

Any update? I'm getting the error too...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests