djtimca / hagooglewifi

Home Assistant integration for Google Wifi systems.
Apache License 2.0
81 stars 27 forks source link

Unable to reinstall via HACS #44

Closed DerekF35 closed 2 years ago

DerekF35 commented 3 years ago

After today's round of fixing, I am attempting to reinstall via HACS but on startup the following error appears in the logs. I've tried removing and reinstalling. Not sure what else to try.


  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 119, 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 211, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 24, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 144, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 135, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 128, in post
    return await super().post(request)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 63, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 72, in post
    result = await self._flow_mgr.async_init(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 153, in async_init
    flow, result = await task
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 171, in _async_init
    flow = await self.async_create_flow(handler, context=context, data=data)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 710, in async_create_flow
    integration.get_platform("config_flow")
  File "/usr/src/homeassistant/homeassistant/loader.py", line 524, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 529, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/config/custom_components/googlewifi/__init__.py", line 8, in <module>
    from googlewifi import GoogleHomeIgnoreDevice, GoogleWifi, GoogleWifiException
  File "/usr/local/lib/python3.9/site-packages/googlewifi/__init__.py", line 8, in <module>
    from .v1_pb2 import GetHomeGraphRequest
  File "/usr/local/lib/python3.9/site-packages/googlewifi/v1_pb2.py", line 2677, in <module>
    _sym_db.RegisterMessage(globals()['None'])
  File "/usr/local/lib/python3.9/site-packages/google/protobuf/symbol_database.py", line 84, in RegisterMessage
    self.RegisterMessageDescriptor(desc)
  File "/usr/local/lib/python3.9/site-packages/google/protobuf/symbol_database.py", line 95, in RegisterMessageDescriptor
    self.pool._AddDescriptor(message_descriptor)
  File "/usr/local/lib/python3.9/site-packages/google/protobuf/descriptor_pool.py", line 238, in _AddDescriptor
    self._CheckConflictRegister(desc, desc.full_name, desc.file.name)
  File "/usr/local/lib/python3.9/site-packages/google/protobuf/descriptor_pool.py", line 191, in _CheckConflictRegister
    raise TypeError(error_msg)
TypeError: Conflict register for file "google/internal/home/foyer/v1.proto": google.internal.home.foyer.v1.None is already defined in file "glocaltokens/google/internal/home/foyer/v1.proto". Please fix the conflict by adding package name on the proto file, or use different name for the duplication.```
DerekF35 commented 3 years ago

I forgot to mention that when I attempt to Add Integration I get a "Config flow could not be loaded" error as well.

DerekF35 commented 3 years ago

This was reported by the ha-google-home integration also. (https://github.com/leikoilja/ha-google-home/issues/330) . My instance has both installed, however the error on my end if being reported by Google Wifi Integration

DerekF35 commented 3 years ago

Confirmed it is an issue with Google Wifi integration and Google Home integration v1.8.0 both being installed. When Gogole Home integration was downgraded to 1.7.0 the conflict disappeared. The error will be reported for whichever integration is installed second.

KapJI commented 3 years ago

Thanks for the debugging, I'll fix it on ha-google-home side.

But better solution will be using glocaltokens in googlewifi-api for fetching local auth tokens. This will help to dedup generated protobuf stubs which may conflict with each other.

KapJI commented 3 years ago

I found that it didn't always work even with older version of ha-google-home.

Protobuf has 2 API implementations depending on the platform: C++ and Python. C++ implementation doesn't allow registering multiple proto files with the same name:

Invalid proto descriptor for file "google/internal/home/foyer/v1.proto":
  google/internal/home/foyer/v1.proto: A file with this name is already in the pool.

While Python implementation allows that.

Right now in glocaltokens that file was renamed to glocaltokens/google/internal/home/foyer/v1.proto, and it doesn't work with any implementation.

KapJI commented 3 years ago

@djtimca I noticed that this integration has quite complex instructions for obtaining refresh token.

Maybe you can use glocaltokens (actually that will be gpsoauth) for that? And instead of self._api_token you can use GLocalAuthenticationTokens.get_access_token(). It might have different scope than current one, not sure if all endpoints will work with it.

If it works, authorization can be changed to simple login/app_password as we do in ha-google-home.

djtimca commented 3 years ago

@KapJI I like that solution - will try to look at it at some point when I have time again.

djtimca commented 2 years ago

This should be resolved in the January release