gdgib / span

SPAN Integration for HomeAssistant/HACS
Other
20 stars 4 forks source link

New OS update just rolled out, now requries API access tokens. #20

Closed sargonas closed 1 year ago

sargonas commented 1 year ago

My panel just went red on my monitoring dashboard (I have it checking /api/v1/panel for the PANEL_ON_GRID text to be present) and when checking the endpoint I monitor I got the same json API as usual but instead of data it now reads "Access to protected HTTP endpoints require an API token passed as a HTTP bearer header."

Looking at my home assistant logs, it also now has errors for this integration being unable to communicate with the panel as well: Failed to serialize to JSON: /config/.storage/core.config_entries. Bad data at $.data.entries[40].data.access_token=<coroutine object SpanPanelApi.get_access_token at 0x7f748583dc60>(<class 'coroutine'>

I think an update may have just rolled out that changed things? In the app it says my current software version is spanos2/r202333/10 but HA's logs show that I was reporting version spanos/r202327/08 up until an hour ago when everything went dark at 10:41 pst.

maybe @mbbush has some insights? :) I checked the SPAN support website, but it shows no updates to the OS with release notes yet, since the previous 202327 release in July, so I can't find any data to reference what was changed or how one should be obtaining these new API tokens. (https://support.span.io/hc/en-us/articles/4405983002519-Software-Updates)

sargonas commented 1 year ago

So this is odd... I rebooted my HA system for totally unrelated reasons and it appears that the integration is pulling data from the panel again just fine. I still can no longer access the API manually like I used to, but whatever the update did to break the integration after it was applied, a HA reboot at least got the integration back up and running so I guess the update is far less impactful than I at first thought?

mbbush commented 1 year ago

How am I supposed to get an access token

Follow the directions I posted all the way back in February https://github.com/galak/span-hacs/issues/11

This integration was updated a long time ago to do that, and should already be authenticating its requests. I have noticed that if the panel is unavailable for a short period, such as during a software update, the integration gets into a broken state, and needs the homeassistant integration to be restarted to fix it. I haven't had the time to dig into why this happens, but it looks like a bug in the integration, not the panel's API.

If you've got something other than this integration polling the panel's API for checking PANEL_ON_GRID, you can just follow those directions to get a second token, and pass it as a bearer header in your request.

sargonas commented 1 year ago

How curious! I actually had no idea that was a "thing" before now. Hitting the API endpoint in a browser has always "just worked" for me, with data visible, so I had no idea tokens already existed before now or that I should be expecting to normally need one.

Thanks for the token guide though, will update my uptime kuma to now rely on that method instead of just calling the api directly without a token!