home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.66k stars 29.95k forks source link

Can't connect SharkIQ integration: `string indices must be integers, not 'str'` #126047

Open Bassadin opened 5 days ago

Bassadin commented 5 days ago

The problem

When trying to add my Shark IQ account, it get an error "Failed to connect", while the logs say what I posted below. I know that the password is correct because I directly copy pasted it from my password manager and I can use it to log in to my account using the official Shark app as well as Google Home just fine.

What version of Home Assistant Core has the issue?

core-2024.8.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

sharkiq

Link to integration documentation on our website

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

Diagnostics information

Error happens at config flow, can't enable debug logging :(

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.sharkiq
Source: components/sharkiq/config_flow.py:59
integration: Shark IQ (documentation, issues)
First occurred: September 15, 2024 at 2:59:43 PM (4 occurrences)
Last logged: 2:13:30 PM

string indices must be integers, not 'str'

Additional information

Seems like a similiar error than https://github.com/home-assistant/core/issues/105013, but changing my password does not resolve the issue.

home-assistant[bot] commented 5 days ago

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)

bakernigel commented 3 days ago

Having the same problem.

2024-09-18 11:03:10.214 DEBUG (MainThread) [homeassistant.components.sharkiq] Initialize connection to Ayla networks API
2024-09-18 11:03:10.744 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry xxxxx@yahoo.com 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-09-18 11:04:18.199 DEBUG (MainThread) [homeassistant.components.sharkiq] Initialize connection to Ayla networks API
2024-09-18 11:04:18.675 ERROR (MainThread) [homeassistant.components.sharkiq] string indices must be integers, not 'str'
2024-09-18 11:12:02.348 ERROR (MainThread) [homeassistant.components.roku.coordinator] Timeout fetching roku data
2024-09-18 11:48:27.939 DEBUG (MainThread) [homeassistant.components.sharkiq] Initialize connection to Ayla networks API
2024-09-18 11:48:28.360 ERROR (MainThread) [homeassistant.components.sharkiq] Unexpected exception
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'
2024-09-18 11:48:28.363 ERROR (MainThread) [homeassistant.components.sharkiq] 'access_token'
bakernigel commented 2 days ago

Confirmed the POST request to /users/sign_in.json is now resulting in a 403 with the error "You are forbidden to perform this operation" as documented in https://github.com/JeffResc/sharkiq/issues/51 by @JeffResc. Shark or Ayla seems to be now blocking logins using the sign_in API. As long as you don't restart HA, you may stay logged in but as soon as you restart HA you will lose your connection to Shark and there is no way to reconnect. The issue is not related to any HA release, but will occur when you restart HA after an update. Don't see any easy resolution to this problem. The Shark APP does not use the Ayla sign_in API. Instead it logs in to //login.sharkninja.com with user name and password, gets a token, then logins to Ayla using the token. Maybe the Sharkiq SDK in HA could be modified to use a similar method but that is beyond my capabilities.

ElleScott commented 1 day ago

Having the same issues.

What version of Home Assistant Core has the issue? core-2024.9.2

What type of installation are you running? Home Assistant OS

Logger: homeassistant.components.sharkiq Source: components/sharkiq/config_flow.py:59 integration: Shark IQ (documentation, issues) First occurred: 11:00:05 AM (1 occurrences) Last logged: 11:00:05 AM

string indices must be integers, not 'str'

Diagnostics information Error happens at config flow, can't enable debug logging

I have confirmed I do not have the three issues that were listed, [https://github.com/home-assistant/core/issues/94206#issuecomment-1815254484]

I can run the shark from Alexa, Google Home, and the Shark App. I have changed my password for the Shark device and still receive the same error,