JeffResc / sharkiq

Unofficial SDK for Shark IQ robot vacuums, designed primarily to support an integration for Home Assistant.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shark IQ integration goes "Unavailable" every day

AkaMrBill opened this issue · comments

After the "fix" was applied back in March/April, the integration worked well for a few weeks. In the last 2 months, the integration has begun going "Unavailable" every day.
"Disabling" and then "Enabling" the integration restores operation for an additional day, then it goes unavailable again.

Not being a Dev myself, I will need some guidance to help provide what you need to look into this issue.

From my logs:
Logger: homeassistant.components.sharkiq
Source: helpers/update_coordinator.py:231
Integration: Shark IQ (documentation, issues)
First occurred: June 24, 2022 at 1:14:43 PM (5 occurrences)
Last logged: June 28, 2022 at 1:30:38 PM

Authentication failed while fetching sharkiq data: Ayla Networks API authentication expired. Re-authenticate and retry.

@AkaMrBill Have you been using an automation to reload the automation? When I upgraded my Home Assistant version last month it reset the entry id, so I had to update that in my automation that reloads the integration automatically. The refresh token is a known issue that we're tracking in #5 and unfortunately have not had a chance to tackle yet.

A temporary workaround people (including myself) have been using is an automation like this. Others have also had success making NodeRed automations to do essentially the same thing as the automation YAML below:

alias: Watcher - Shark Availability
description: ''
trigger:
  - platform: state
    entity_id: vacuum.shark
    for:
      hours: 0
      minutes: 2
      seconds: 0
    to: unavailable
condition: []
action:
  - service: homeassistant.reload_config_entry
    data:
      entry_id: <SOME_HASH_STRING>
mode: single

Put in the entity_id of your vacuum under the trigger, and the entry_id of your integration under the action data. You can get the entry id by opening up dev tools to the network tab and navigating to your devices & services page where it lists out all of your integrations. Click the context menu for the SharkIQ integration (with dev tools still open to the network tab) and click "Reload". The XHR request that shows up in dev tools should look something like this:

<YOUR_HASS_URL>/api/config/config_entries/entry/<SOME_HASH_STRING>/reload

That SOME_HASH_STRING is your entry_id. If this gets your integration working again, then we know for sure that you're hitting the refresh token issue. If thats the case please close out this issue so we can direct all discussion to #5. I'll also post this automation in that issue for reference until a fix is merged.

These instructions are EXACTLY what I needed. This has resolved the issue for me.

Thanks @AkaMrBill!

I'm hoping to have a chance to finally look at the auth token issue this weekend. So hopefully an automation like this won't be necessary sooner rather than later.