Refresh Authentication Token
funkybunch opened this issue · comments
The legacy code seems to support auth token refreshing but there is no usage of the method used to actually do the token refresh. As a result, the integration becomes unavailable after the original auth token expires.
See
Line 99 in 4136e64
I was wondering if it ended up resolving itself, or if Shark extended the time auth tokens are valid, but I thought too soon and mine became disabled last night requiring an integration reload.
Seems to still be an issue for at leas some users so I think we should prioritize this as well. Adding a Help Wanted
tag in case anyone in the community has time to put towards this.
Yup, that's it. There was another discussion on the legacy repo on a PR that seemed to suggest fixing it but it was just a URL change which isn't going to solve the token refresh issue.
I have created a Node-Red script that looks at the Shark Integration Identity ID once a minute, If it returns "unavailable", it then triggers an API call to reload. This has worked flawlessly up until a couple weeks ago. Now even this fails to make the vacuums appear. Thus my automations now fail to run. The Shark(s) are always "unavailable".
Now even this fails to make the vacuums appear. Thus my automations now fail to run. The Shark(s) are always "unavailable".
The reason they're unavailable now is SharkIQ changed the API endpoint. A PR has already been merged to the Home Assistant dev
branch to fix that. Once it is merged into production
your NodeRed automation will work again once you update to the release that patch is included with.
I have a similar automation in my instance, but it's a hacky workaround hence this issue to build in token refreshes.
Hi @AkaMrBill. The change to fix the Shark integration has been accepted into Home Assistant, but is not yet available in the stable
release. I believe it should be added, next Wednesday, but that up to the Home Assistant development team. In the meantime, if you'd like access to the fix, you can update to the beta version of Home Assistant Core, but I'd advise you to take a backup before the update as the beta branch is not guaranteed to be stable.
@AkaMrBill the updated API endpoint is included in the 2022.4 release that is out now. Update to this version and your NodeRed automation should start working again.
Unfortunately the 2022.4 release doesn't solve the need to have the reload automation.
@funkybunch Hi Mark, I just opened an issue on this as my "Reload Automation" has been failing for a couple months now. I need to manually disable and re-enable the integration to make it work.
So, any suggestions on how to set up "Reload Automation"?
@AkaMrBill sorry just saw you also posted here. Check that your entry_id
is still the same. My Shark Integration's entry_id
changed during the last major Home Assistant update and I had to go grab it from dev tools again. Seems like you do have a reload automation already so you probably don't need this, but for other folks who might find it useful, here is an example reload automation as promised in the other thread.
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
.
@funkybunch ,
Thanks! This indeed did resolve my issue. I will close out the issue I raised.
BK
Closing this issue as it is already supported in this library and resolved in a PR on the HA repo.