Pyhass / Hive-Custom-Component

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

2022.6.1 - 'HiveAuthAsync' object has no attribute 'get_device_data' #117

Closed geftactics closed 2 years ago

geftactics commented 2 years ago

Home Assistant: 2022.7.0 Hive component: 2022.6.1

Had some issues after upgrading, so removed integration from HA and restarted. Then enabled 2FA in Hive app, deleted the 'Home Assistant' device listed in the hive account settings. Finally tried adding the integration back... UI requested 2FA code, then showed the word 'Home Assistant' in a text input box..

UI - Unknown error occurred. Logs:

File "/usr/src/homeassistant/homeassistant/components/hive/config_flow.py", line 113, in async_step_configuration
    self.data["device_data"] = await self.hive_auth.get_device_data()
AttributeError: 'HiveAuthAsync' object has no attribute 'get_device_data'
geftactics commented 2 years ago

At this stage, I can see a Home Assistant device shown in the Hive app under: Account -> Account Security -> Trusted Devices

gricey commented 2 years ago

I have precisely the same issue. The issue that lead me to upgrade was some REFRESH_TOKEN that was invalid if I recall.

KJonline commented 2 years ago

@gricey this indicates the new version of pyhiveapi hasn’t been installed

gricey commented 2 years ago

Hi @KJonline

I was prompted for the latest upgrade in HACS after the refresh token error. I noted it referred to fixing Auth. I upgraded but the error persisted. I tried downgrading, same thing. I then went into hive and enabled 2fa, and tried to add both old and new integrations back in. No dice (and now the HiveAuthSync error rather than the refresh_token one)...

KJonline commented 2 years ago

Yep that all makes sense. Can I confirm your also on home assistant version 2022.6.6 or higher

this error still prompts me to believe that your instance doesn’t have the library required for some reason.

If that method get_device_data didn’t exist in the library then this would be an issue for all users.

If you run HA OS I would advise a host restart

gricey commented 2 years ago

Hi @KJonline I am on 2022.7 as I was offered that at the same time, I updated everything!

I didn't realise that the host OS was relevant (thought the library would live in a container somewhere), still new to the internals of HA but I am indeed running HAOS so shall give it a restart.

gricey commented 2 years ago

Unfortunately a host reboot didn't do anything. When trying to re-add the integration, it prompts me for my OTP (2fa from hive), asks me to create a name and then when I click continue it says Unknown Error. The 'name' I created shows as a trusted device in my hive app from that point, but the integration isn't created.

The log shows:

Logger: aiohttp.server Source: components/hive/config_flow.py:113 First occurred: 11:12:50 (1 occurrences) Last logged: 11:12:50

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 79, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 177, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper result = await method(view, request, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 109, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 277, in async_configure result = await self._async_handle_step( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 359, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/usr/src/homeassistant/homeassistant/components/hive/config_flow.py", line 113, in async_step_configuration self.data["device_data"] = await self.hive_auth.get_device_data() AttributeError: 'HiveAuthAsync' object has no attribute 'get_device_data'

geftactics commented 2 years ago

@KJonline - Is there a way to easily validate version of pyhiveapi via ssh to HA?

KJonline commented 2 years ago

What setup are you running HA OS?

gricey commented 2 years ago

I am just running it from the official installer on a rpi4, booted from an external m2.sata drive (over usb).

geftactics commented 2 years ago

I'm running latest supervised Home Assistant OS on generic x86 PC... Installing via HACS

Tried rolling back to 2022.5.4... Saw pyhiveapi 0.4.2 installed... Then receive the following error:

AttributeError: 'HiveAuthAsync' object has no attribute 'device_registration'

Re-installed 2022.6.1 - see pyhiveapi 0.5.10 being installed... but then we are back to error:

AttributeError: 'HiveAuthAsync' object has no attribute 'get_device_data'

Are there any suggested troubleshooting/diagnostic steps I should be following? Thankyouplease.

adamparratt87 commented 2 years ago

I'm getting the same issue. Running HA core-2022.7.1 in Docker, hive component 2022.6.1. On configuration of the component after entering 2FA code, clicking submit on the next page with "Home Assistant" in the text box presents the same error message in the logs. I see "Home Assistant" as a trusted device in the Hive app, but the integration doesn't get added to HA as its not possible to finish the configuration

KJonline commented 2 years ago

Please can you update to the newly released custom component version (2022.7.1) and re-test

geftactics commented 2 years ago

Back in the game! It works!

thanks!!

gricey commented 2 years ago

Fixed for me also, thankyou!