Pyhass / Hive-Custom-Component

A custom version of the home assistant hive component
MIT License
33 stars 17 forks source link

[BUG] Failed to setup #156

Open djdarlo opened 6 months ago

djdarlo commented 6 months ago

Describe the bug I am getting the failed to setup error message on the integrations screen

To Reproduce Steps to reproduce the behaviour:

Same error message every time I restart and try reloading.

Expected behaviour A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Here is a copy of the error from the logs.

Logger: homeassistant.config_entries Source: config_entries.py:444 First occurred: 6:05:25 AM (3 occurrences) Last logged: 8:51:05 AM

Error setting up entry david.j.darlington@gmail.com for hive Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/apyhiveapi/api/hive_auth_async.py", line 548, in refresh_token result = await self.loop.run_in_executor( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/botocore/client.py", line 553, in _api_call return self._make_api_call(operation_name, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/botocore/client.py", line 1009, in _make_api_call raise error_class(parsed_response, operation_name) botocore.errorfactory.NotAuthorizedException: An error occurred (NotAuthorizedException) when calling the InitiateAuth operation: Invalid Refresh Token.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 444, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/hive/init.py", line 89, in async_setup_entry devices = await hive.session.startSession(hive_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/apyhiveapi/session.py", line 502, in startSession await self.getDevices("No_ID") File "/usr/local/lib/python3.12/site-packages/apyhiveapi/session.py", line 425, in getDevices await self.hiveRefreshTokens() File "/usr/local/lib/python3.12/site-packages/apyhiveapi/session.py", line 304, in hiveRefreshTokens result = await self.auth.refresh_token( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/apyhiveapi/api/hive_auth_async.py", line 562, in refresh_token raise HiveInvalid2FACode from err apyhiveapi.helper.hive_exceptions.HiveInvalid2FACode

DavidBSteele commented 5 months ago

I solved this issue by doing the following:

1) deleting the integration in HA. 2) Then deleting the 'trusted device' for HA in the hive app (mine was called 'home' but your could be different) 3) readding the hive integration in HA and following the 2FA steps

I've not recently changed my hive account in any way or altered anything in HA.

Mossi777 commented 5 months ago

I have the same issue where the Hive integration 'Failed to setup' message is displayed every time the system reboots.

Selecting the Reload option brings the integration back to normal.

I have tried deleting the integration and removing the trusted device in the Hive App. The condition is still present following another system reboot.

Here is a copy of the log files for further information;

Logger: homeassistant.config_entries Source: config_entries.py:504 First occurred: 12:21:29 (1 occurrences) Last logged: 12:21:29

Error setting up entry xxxxxxx@hotmail.co.uk for hive Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/hive/init.py", line 89, in async_setup_entry devices = await hive.session.startSession(hive_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/apyhiveapi/session.py", line 502, in startSession await self.getDevices("No_ID") File "/usr/local/lib/python3.12/site-packages/apyhiveapi/session.py", line 425, in getDevices await self.hiveRefreshTokens() File "/usr/local/lib/python3.12/site-packages/apyhiveapi/session.py", line 304, in hiveRefreshTokens result = await self.auth.refresh_token( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/apyhiveapi/api/hive_auth_async.py", line 538, in refresh_token await self.async_init() File "/usr/local/lib/python3.12/site-packages/apyhiveapi/api/hive_auth_async.py", line 104, in async_init self.__pool_id = self.data.get("UPID") ^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get'

Mossi777 commented 5 months ago

Further to my above comment, following a system reboot, not a home assistant restart, the integration Failed to setup appears. Sometimes this can de cleared by selecting the reload integration option. This is not the case every time though and then requires the integration to be deleted and reloaded.