fsaris / home-assistant-zonneplan-one

Unofficial Zonneplan integration for Home Assistant
https://github.com/fsaris/home-assistant-zonneplan-one
MIT License
108 stars 18 forks source link

State becoming unavailable and won't recover until Home Assistant is restarted #16

Closed arnoldpistorius closed 2 years ago

arnoldpistorius commented 2 years ago

Hi,

I have the issue that at some time (after few days) the states of the integration become "unavailable" and won't recover until I restart Home Assistant.

I don't see anything in HA logs, but I also don't have the debug log of this integration enabled. I have used same e-mail address as the Zonneplan app on my phone uses, could that be a problem?

I will enable the debug logging and let you know when it happens again

arnoldpistorius commented 2 years ago

The issue started this morning again. Now having some logging. Seems that at some point the service returns 503 Service Unavailable and then the integration does not recover from that:

2022-03-18 10:16:55 INFO (MainThread) [custom_components.zonneplan_one.coordinator] _async_update_data: start
2022-03-18 10:16:55 DEBUG (MainThread) [custom_components.zonneplan_one.api] ZonneplanAPI response header: <CIMultiDictProxy('Date': 'Fri, 18 Mar 2022 09:16:55 GMT', 'Server': 'Apache', 'Content-Length': '299', 'Connection': 'close', 'Content-Type': 'text/html; charset=iso-8859-1')>
2022-03-18 10:16:55 DEBUG (MainThread) [custom_components.zonneplan_one.api] ZonneplanAPI response status: 503
2022-03-18 10:16:55 ERROR (MainThread) [custom_components.zonneplan_one.coordinator] Authentication failed while fetching zonneplan_one data: 503, message='Service Unavailable', url=URL('https://app-api.zonneplan.nl/user-accounts/me')
2022-03-18 10:16:55 DEBUG (MainThread) [custom_components.zonneplan_one.coordinator] Finished fetching zonneplan_one data in 0.346 seconds (success: False)
2022-03-18 10:16:55 INFO (MainThread) [custom_components.zonneplan_one.config_flow] __init__
2022-03-18 10:16:55 DEBUG (MainThread) [custom_components.zonneplan_one.config_flow] reauth {'auth_implementation': 'zonneplan_one', 'token': {'token_type': 'Bearer', 'expires_in': 28800, 'access_token': '**REDACTED**', 'refresh_token': '**REDACTED**', 'expires_at': 1647598975.465228}, 'email': '**REDACTED**'}

After this happens, the zonneplan_one component doesn't log anything anymore (it happened almost 4 hours ago).

arnoldpistorius commented 2 years ago

Tagging you @fsaris :)

fsaris commented 2 years ago

don't you get an notification to re-authenticate the app in this case? With version 0.0.10 this should be improved

arnoldpistorius commented 2 years ago

Yes I get that, but it happens not in a consequent interval sometimes a few weeks, sometimes a few hours. The mobile app doesnt have to reauthenticate. So I guess something can be improved in refreshing the access token?

fsaris commented 2 years ago

Can you test version 0.0.10 to see if it's still happens?

arnoldpistorius commented 2 years ago

I’ve just installed it via HACS, let’s see how it goes! 👏

arnoldpistorius commented 2 years ago

@fsaris looks like the issue is not happening anymore. Thanks for the update!!