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

Shark IQ Integration can't be added - Unexpected error #60422

Closed
captrik opened this issue Nov 26, 2021 · 29 comments · Fixed by #89349
Closed

Shark IQ Integration can't be added - Unexpected error #60422

captrik opened this issue Nov 26, 2021 · 29 comments · Fixed by #89349

Comments

@captrik
Copy link

captrik commented Nov 26, 2021

The problem

Trying to add the Shark IQ Integration to my HA instance (via the Integration UI) always results in the same error message: "Unexpected error"

image

I've attached a stacktrace from the error log of HA core.

I've also followed the troubleshooting section of the integration documentation and turned off all adblockers - without luck.

What version of Home Assistant Core has the issue?

core-2021.11.5

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

Shark IQ

Link to integration documentation on our website

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

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2021-11-26 22:51:03 ERROR (MainThread) [homeassistant.components.sharkiq] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sharkiq/config_flow.py", line 54, in _async_validate_input
    info = await validate_input(self.hass, user_input)
  File "/usr/src/homeassistant/homeassistant/components/sharkiq/config_flow.py", line 32, in validate_input
    await ayla_api.async_sign_in()
  File "/usr/local/lib/python3.9/site-packages/sharkiqpy/ayla_api.py", line 97, in async_sign_in
    self._set_credentials(resp.status, await resp.json())
  File "/usr/local/lib/python3.9/site-packages/sharkiqpy/ayla_api.py", line 73, in _set_credentials
    raise SharkIqAuthError(login_result["error"]["message"])
TypeError: string indices must be integers

Additional information

Submitting the form with a wrong username/password results in the exact same error and stacktrace.

@probot-home-assistant
Copy link

sharkiq documentation
sharkiq source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @ajmarks, 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!
(message by CodeOwnersMention)

@github-actions github-actions bot added the stale label Dec 26, 2021
@creativeosmose
Copy link

Hi there,
Same issue here with:
-HA 2021.12.7
-RV1000SEU
Could the Shark prod region environment be the issue? (I’m on the EU / Europe Prod apparently).
Thanks,

@captrik
Copy link
Author

captrik commented Jan 2, 2022

I'm in EU too.
I think this could be the problem.

For EU there is sharkclean.co.uk and sharkclean.de

There is also sharkclean.com. I've registered a second account there, which works with the login.
But there are no robots linked to this account. Trying to register a robot on sharkclean.com only tells me the my model number (RV1100S1EU) is invalid.

@creativeosmose
Copy link

Indeed..
I saw in another thread that the vacuums were region restricted..
I couldn’t find the API URL that HA connects to (and am unsure that they are 100% the same apart from the region.. so it may not even fix the issue).

@github-actions github-actions bot removed the stale label Jan 2, 2022
@creativeosmose
Copy link

There seems to be a pull request on the initial repo:
ajmarks/sharkiq#11

Can someone with enough rights implement the changes on the HA official addon?

@creativeosmose
Copy link

Can anyone help on this issue please ?
I can support if any additional information is required (logs, etc), or for testing.
Thanks,

@JKing-B16
Copy link

I am having the same unexpected error issue here in Germany, and I too suspect that is the fact that Shark has region specific logins. IE, my login doesn't work on the US site, but only on the DE site.

Does anyone have any instructions on how to switch the branch that the OS is based on when running the HA OS on a Pi3?

Or is there any info on when the fix might be integrated. I would be happy to assist intesting.

@Draes
Copy link

Draes commented Jan 21, 2022

That's it, the current integration does not work on the EU (Different servers)
I got it to work by creating a custom integration

Basically all i had to do was:

  • copy the original integration from this repo
  • remove the sharkiq dependency and add the source code for it instead
  • apply the changes on this Pull Request
  • place it on the custom_components directory

All this could have been avoided if that PR was merged, but since it has been more than 6 months with no news, i wouldn't expect it to be.

I can upload the custom integration if anyone needs it but i wont maintain it.

@superami-code
Copy link

Yes, please upload your integration. It would be greatly appreciated.

@Draes
Copy link

Draes commented Jan 22, 2022

@superami-code here it is

@captrik
Copy link
Author

captrik commented Jan 22, 2022

@Draes thank you, very much appreciated!

@superami-code
Copy link

@superami-code here it is

Thank you!

@creativeosmose
Copy link

Thanks! Works perfectly!

@cyber-arche
Copy link

Thanks! Works perfectly!

Is it still working perfectly?

@creativeosmose
Copy link

Thanks! Works perfectly!

Is it still working perfectly?

Actually, the integration needs to be reloaded every 24-48hours.
I can't pinpoint the issue yet, but it seems to be on the API side - could be due to the numerous requests from my side.
Once reloaded, the robot works immediately.

@creativeosmose
Copy link

creativeosmose commented Feb 2, 2022

Thanks! Works perfectly!

Is it still working perfectly?

Actually, the integration needs to be reloaded every 24-48hours. I can't pinpoint the issue yet, but it seems to be on the API side - could be due to the numerous requests from my side. Once reloaded, the robot works immediately.

Known issue on the "official" integration, see here for the US/Worldwide fix:
ajmarks/sharkiq#14
I'm trying to figure out the Europe URL that would prevent the need from reloading the integration every 24h or so.
*I'm using @Draes ' integration which is compatible with the EU region.

@travipross
Copy link

There should be no URL that avoids the need to reload. That issue is on the client side, failing to fetch a new token when the current one in use expires. On startup, the integration fetches a new token anyway though, which is why a restart "solves" the issue.

If your URLs are working for any amount of time at all, they're the correct URLs. The issue is in the authentication implementation within sharkiqpy itself.

@creativeosmose
Copy link

@travipross understood, I misunderstood your fix ; I thought there was a change in the API that resulted in frequent token expiration. Anyway, clear now, thanks.

So the issue should actually be fixable by actually having a token request once the previous one is expired.
(In the meantime, I'm using an automation to reload the integration as soon as it's not responding.)

@funkybunch
Copy link
Contributor

funkybunch commented Mar 31, 2022

Hi everyone, we recently merged a PR to dev on this repo that updates the API endpoints used by the SharkIQ integration. If you're running a development release of Home Assistant this should be available to you now. The maintainer of the upstream dependency has no recent Github activity, so we are moving to a fork of the original integration and have multiple maintainers of the fork so we can prevent this integration from becoming stale with no ability to merge changes again.

If you have issues or fixes that have not been addressed yet, please open an issue pr PR in https://github.com/JeffResc/sharkiq and we'll get fixes merged into Home Assistant as quickly as possible.

Currently we do not have support for automatically refreshing the token, but it should be a fairly easy fix. If anyone would like to submit a PR we could use the help as myself and the other maintainers are still trying to get existing PRs migrated over from the legacy repo. Discussion for the token refresh issue at JeffResc/sharkiq#5

On that note, @Draes we are working on migrating a PR from the original integration that brings EU support into the main integration, so hopefully soon you will be able to just use the integration that ships with Home Assistant core.

@travipross
Copy link

The maintainer of the upstream dependency has no recent Github activity, so we are moving to a fork of the original integration and have multiple maintainers of the fork so we can prevent this integration from becoming stale with no ability to merge changes again.

Very excited to see this project given a new set of eyes, as I've now got two Shark vacuums integrated with Home Assistant (and by proxy, Google Assistant). I have far more complex cleaning schedules set up through home assistant than what Shark provides, but it's been really disappointing to sometimes lose access entirely.

@jakguru
Copy link

jakguru commented Apr 6, 2022

Looking forward to this being resolved. I can live with the iOS app for now, but I like having everything centralized in HASS

@epruesse
Copy link

Getting the OP error on US servers. Is there a reason not to just fix in core?

@github-actions
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@funkybunch
Copy link
Contributor

funkybunch commented Nov 9, 2022

@ github-actions bot - get that stale label outta here. We're about to resolve it.

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@Breina
Copy link

Breina commented Feb 7, 2023

Issue is still present on the lastest HA release. Keep this open so I don't forget. Might look into this later.

@funkybunch
Copy link
Contributor

Sorry it took so long everyone! Unfortunately I was laid off in TheGreatTechLayoffs™️ and have had to spend all of my time job hunting. Got a new job thankfully so I'm trying to get all of this knocked out before I start next week.

PR IS UP #89349

Hopefully things will be more streamlined moving forward. Thanks for your patience!

@Breina
Copy link

Breina commented Mar 8, 2023

Thanks Funky! Glad to hear your back on your feet as well.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet