fdebrus / hayward-ha

10 stars 1 forks source link

401 Missing or invalid authentication. #3

Closed fdebrus closed 4 months ago

fdebrus commented 4 months ago

After the token expiration time, token is not getting refreshed leading to 401 error. You can only restart HA to resolve.

regular way of refreshing token will not work here. open for idea and suggestion.

fdebrus commented 4 months ago

some progress on https://github.com/fdebrus/hayward-ha/tree/0.0.5.4 enable debuglog and monitor for token check and token refresh events

Hans1205 commented 4 months ago

Which version is without logging /debugging? After using 0.0.5.3 microSD Card on RASPI was 100% full in hours ...

fdebrus commented 4 months ago

if "enable debug logging" is not activated at integration level, you should not get a lot of message in the log. if you could report to me what was in the log ? so I can try to find the source.

image

Hans1205 commented 4 months ago

No, unfortunately I can't. I have already deleted the log and commented out everything that is related to logging in aquarite.py.

However, the disk space is still much fuller than yesterday. Before setting up Aquarite I had 59% occupied. This morning at 9 o'clock 100% and after deleting the homeassistant.log still 90%

Von meinem iPhone gesendet

Hans Moggert

Am 22.04.2024 um 16:09 schrieb fdebrus @.***>:



Could you tell me what message was filling the log ? without debugging enabled, it should not happen

— Reply to this email directly, view it on GitHubhttps://github.com/fdebrus/hayward-ha/issues/3#issuecomment-2069587208, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BFFSQBH23D5CQSXTK3W6FSDY6UK2ZAVCNFSM6AAAAABGRVUSBOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRZGU4DOMRQHA. You are receiving this because you commented.Message ID: @.***>

fdebrus commented 4 months ago

ok, I've opened a new issue to track that disk getting full https://github.com/fdebrus/hayward-ha/issues/4

fdebrus commented 4 months ago

Refresh of the token is working now, but I still need to work on the firestore document handling after refreshing the token

aka, if token expires it get refreshed and you can keep sending command to pool, but pool updates are not reflected in HA; WIP

fdebrus commented 4 months ago

I've changed the subscription to firestore to re-auth in case a new token is created. code below

But I will change this code moving away from realtime updates towards scheduled refresh in the next release. This generates too many datapoints

    async def subscribe(self, pool_id, handler) -> None:
        await self.ensure_active_token()
        doc_ref = self.client.collection("pools").document(pool_id)
        def on_snapshot(doc_snapshot, changes, read_time):
            """Handles document snapshots."""
            for doc in doc_snapshot:
                handler(doc)
        doc_ref.on_snapshot(on_snapshot)
        self.handlers.append(handler)

    async def auto_resubscribe(self, pool_id, handler):
        try:
            await self.subscribe(pool_id, handler)
        except Exception as e:
            _LOGGER.error("Subscription failed, attempting to resubscribe...")
            await asyncio.sleep(10)
            await self.auto_resubscribe(pool_id, handler) 
fdebrus commented 4 months ago

solved in 0.0.6

fdebrus commented 4 months ago

While the command are sent to the pool after token refresh, the pool updates are no longer received by the integration following a token refresh. I suspect the coordinator not to receive the updated client following token refresh. to be investigated...

fdebrus commented 4 months ago

closed in 0.0.7