core: SharkIQ Integration loses connection frequently; integration must be reloaded daily.

The problem

My Shark vacuums lose connection with home assistant frequently, approximately once per day (but I have not timed it). They show ‘unavailable’ state. Reloading the integration fixes it immediately and the correct state is shown. From logs it appears to be an authentication issue.

vacuums_before vacuums_after

Environment

  • Home Assistant Core release with the issue: 2020-12-1
  • Last working Home Assistant Core release (if known): never
  • Operating environment (OS/Container/Supervised/Core): Supervised
  • Integration causing this issue: sharkiq
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/sharkiq/

Problem-relevant configuration.yaml

none, set up with UI

Traceback/Error logs

There are over 1200 instances of the word ‘shark’ in my logs, but this seems to be the one causing the problem. If you’d like all of the shark errors I can dive deeper.



2020-12-20 13:16:31 ERROR (MainThread) [homeassistant.components.sharkiq] Error fetching sharkiq data: Ayla Networks API authentication expired.  Re-authenticate and retry.


Additional information

Since this is seemingly an issue with Ayla Networks and not HA, perhaps adding a service to reload the integration without visiting the integrations page would be a good workaround. Then I could simply automate that if my vacuums become unavailable the integration is reloaded.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 77 (14 by maintainers)

Most upvoted comments

Fixed it with automation that reloads integration once robot becomes unavailable

shell_command:
  shark_restart: "/usr/bin/curl -X 'POST' -H 'authorization: Bearer <token>' http://localhost:8123/api/config/config_entries/entry/<entry>/reload"
alias: SharkIQ
description: ''
trigger:
  - platform: state
    entity_id: vacuum.baby_shark
    to: unavailable
    for: '00:05:00'
condition: []
action:
  - service: shell_command.shark_restart
    data: {}
mode: single

<token> is long lived token I’ve generated in profile section) <entry> is integration id I’ve captured using chrome inspector while reloading integration from gui

Hi guys, sorry again for not fixing this yet, but I wanted to at least give everybody an update. The issue is in the authentication flow. The login credentials are good for 24 hours, and then they need to be refreshed. That refresh is what’s not working, but it is why the workaround of restarting the integration fixes it. I’ve been slammed with a new job the past few months, but I feel really bad that this is still broken, and I’m going to fix this as soon as I can.

This still happens every day for me, and makes automations around the Shark integration unreliable

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 #89357

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

I cannot find the ID when searching integrations with F12.

I found ha-card outline class=“single” but there is no ID attached anywhere. I’m under Elements, is there somewhere else I should be looking?

@roborobp open up the “Network” tab after hitting F12, then navigate to the integrations screen in Home Assistant, select the 3-dot menu for the Shark integration, then click “Reload”. You should see that request appear in the network tab. Look for the ID as part of the URL. image

Is there an ETA on the fix going to release?

I mentioned this in the PR that is intended to resolve this issue, but unless other folks jump in to help test the token expiration issue, this is entirely dependent on how quickly the water damage in my house is repaired. With materials shortages it has been painstakingly slow.

If you would like to accelerate this to release please help out by helping debug as I have no way to test it at the moment. I know it’s not ideal, but it’s the situation I’m in at the moment.

Edit: PR in question is #75676

Sorry to be a bother, but I’d like to hear how your house is coming and how close the update is to being merged. I finally figured out one issue, but only to realize that the integration looses sync every day. Would also love to see that per room mode as mentioned in the PR

The code for all (including room-level support) has been written, but the HA maintainers want it divided up into multiple PRs. Which is understandable as it is a lot of changes. Hoping to have that done this weekend.

This fix will be available in the 2023.4.5 minor release.

Any update when this is going to get put into production

The code is written, but we need some help testing the new integration as we don’t want to merge this and end up breaking stuff. You’re welcome to help us test at the PR linked above if you’d like to help speed up testing.

I don’t know wether I’m the only one having the issue but ever since 2022.8.x the integration has been broken anyways.

it works for a few hours then go unavailable and it’s no longer just a reload I have to delete and run the setup again : Error fetching sharkiq data: 0, message=‘Attempt to decode JSON with unexpected mimetype: text/html;charset=utf-8’, url=URL(‘https://ads-field-39a9391a.aylanetworks.com/apiv1/devices.json’)

Is there an ETA on the fix going to release?

I mentioned this in the PR that is intended to resolve this issue, but unless other folks jump in to help test the token expiration issue, this is entirely dependent on how quickly the water damage in my house is repaired. With materials shortages it has been painstakingly slow.

If you would like to accelerate this to release please help out by helping debug as I have no way to test it at the moment. I know it’s not ideal, but it’s the situation I’m in at the moment.

Edit: PR in question is #75676

Sorry to be a bother, but I’d like to hear how your house is coming and how close the update is to being merged. I finally figured out one issue, but only to realize that the integration looses sync every day. Would also love to see that per room mode as mentioned in the PR

The code for all (including room-level support) has been written, but the HA maintainers want it divided up into multiple PRs. Which is understandable as it is a lot of changes. Hoping to have that done this weekend.

Hi there, how is this coming?

I would really like to get my vacuum working consistently.

The integration does not seem to be fixed however home assistant has made quite a lot of progress since the start of this issue and I just want to put in my 2 cents on the workaround. Instead of calling a shell command you can just call the service: homeassistant.reload_config_entry. So the automation would look something like this.

alias: Shark Robot not responding
description: ''
trigger:
  - platform: state
    entity_id: vacuum.shark2
    to: unavailable
    for:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
condition: []
action:
  - service: homeassistant.reload_config_entry
    data:
      entry_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
mode: single

p.s. the automation look so weird because i created it with the ui.

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 #89357

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

Thanks and glad you found a job! Looking forward to the next PR where you introduce the ability to clean by room!

bump - happy to help

@proactivematter I think I’ve resolved the latest issue for now, but I’ll need the project owner @ajmarks to merge my super simple PR. At a lower level, I was able to reproduce this error just by manual invokation of functions in the sharkiq library, and my fixes resolved those issues. I suspect they should do the same for the HA integration itself.

Yes. You will have to generate a long term token to insert in the curl string.

I understand the part about the long term token. That wasn’t lost on me, where I’m lost is what to do with the entirety of this solution.

It took me a bit, too. You have to open the inspector in your browser by F12. Then click on the icon in the inspector that looks like a mouse cursor over a pad (at least that’s what it looks like for me). Then you will see different areas in the integration card hightlight as you hover over them. Click on a portion of the card, and find the part that looks like this:

< ha-card outlined=“” class=“single integration” id=“xxxxxxxxxxxxxxxxxxxxxxxxxxxx” >

Where ‘x’ will be your specific ID number. Then enter this command, substituting your long term for ‘y’ and ID. This all goes in the configuration.yaml file.

Shell commands

shell_command: shark_restart: “/usr/bin/curl -X ‘POST’ -H ‘authorization: Bearer yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy’ http://localhost:8123/api/config/config_entries/entry/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx/reload

Hope this helps a little more

Forgive the noob in the room. I’m having the same issue, and while a manual reload does solve it, I’d like to figure out how to automate it. I’m not sure as to how to create the service? Reading the output in Inspector isn’t helping much. I appreciate the help!

Let me try and help.

1. From the integrations page press F12

2. Click the inspection icon in the inspection window (mouse cursor on a window)

3. Click anywhere on the SharkIQ integration

4. Look in the inspection window for a line similar to:

5. This is the ID you want to use in entry

Hope this makes sense.

Hi Kafer It does, except your example in step 4 was cut off. This is the output I captured when executing the reload. Capture

EDIT: I think I got it!! Thanks for the help!