klatka / nc-talk-bot-component

Custom component for Home Assistant to communicate between Home Assistant and Nextcloud Talk
Apache License 2.0
11 stars 0 forks source link

Integration Setup fails: module 'custom_components.cloud' has no attribute 'async_active_subscription' #13

Closed MartinAirN closed 6 months ago

MartinAirN commented 7 months ago

When adding the integration with the Nextcloud URL it gives an unknown error. The System log however states this:

Logger: aiohttp.server
Source: /usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py:421
First occurred: 6:28:33 PM (2 occurrences)
Last logged: 6:32:09 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, 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 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 233, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 149, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 320, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 416, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nctalkbot/config_flow.py", line 64, in async_step_user
    and self.hass.components.cloud.async_active_subscription()
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1075, in __getattr__
    value = getattr(self._module, attr)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'custom_components.cloud' has no attribute 'async_active_subscription'

Nextcloud 27.1.5 (docker) HomeAssistant 2024.1.5 (docker)

Using valid certificates behind a Nginx reverse proxy.

klatka commented 7 months ago

Do you use default_config: in your configuration,yaml?

MartinAirN commented 7 months ago

Do you use default_config: in your configuration,yaml?

That indeed seems to be present.

MartinAirN commented 6 months ago

Had a quick look at the codebase. Seems it checks if "cloud" is loaded. Which then does not check if it is the right one.

https://github.com/benquan/cloud then conflicts with the desired capabilities.

This could instead therefore be seen as a feature request to be able to manually set the method (as well [auto/cloud/local] with auto being current behaviour).

klatka commented 6 months ago

I never thought of anyone replacing the cloud component. Please try the fix in branch hotfix-cloud-component.

MartinAirN commented 6 months ago

I never thought of anyone replacing the cloud component. Please try the fix in branch hotfix-cloud-component.

Great fix!

This indeed lets one create the integration without a working cloud active.