leikoilja / ha-google-home

Home Assistant Google Home custom component
MIT License
445 stars 75 forks source link

Integration is not loaded, cannot be deleted, or installed #330

Closed gary-reyes closed 3 years ago

gary-reyes commented 3 years ago

Describe the bug

Updated to 1.8.0 and immediately saw these problems. I had to downgrade to 1.7.0

Logs

This error originated from a custom integration.

Logger: aiohttp.server
Source: custom_components/google_home/api.py:10
Integration: Google Home (documentation, issues)
First occurred: 12:03:49 PM (1 occurrences)
Last logged: 12:03:49 PM

Error handling request
Traceback (most recent call last):
  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 89, 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/google_home/__init__.py", line 17, in <module>
    from .api import GlocaltokensApiClient
  File "/config/custom_components/google_home/api.py", line 10, in <module>
    from glocaltokens.client import Device, GLocalAuthenticationTokens
  File "/usr/local/lib/python3.9/site-packages/glocaltokens/client.py", line 23, in <module>
    from .google.internal.home.foyer.v1_pb2 import GetHomeGraphRequest, GetHomeGraphResponse
  File "/usr/local/lib/python3.9/site-packages/glocaltokens/google/internal/home/foyer/v1_pb2.py", line 5579, 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 "glocaltokens/google/internal/home/foyer/v1.proto": google.internal.home.foyer.v1.None is already defined in file "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.
KapJI commented 3 years ago

I've tried to reproduce it locally with no luck.

Have you restarted your HA instance? It seems old file descriptor "google/internal/home/foyer/v1.proto" is still registered in protobuf. But in new glocaltokens it was changes to "glocaltokens/google/internal/home/foyer/v1.proto".

gary-reyes commented 3 years ago

Yes of course I restated instance. I've even downgrade, removed the integration, then upgraded, restarted, and tried to setup. Same thing. For now the only thing that works is staying in 1.7.0

KapJI commented 3 years ago

On which platform are you running HA? It appears you're using python implementation of protobuf while I'm using C++ implementation:

>>> from google.protobuf.internal import api_implementation
>>> api_implementation.Type()
'cpp'

This codepath is unreachable with my implementation.

gary-reyes commented 3 years ago

I'm using with home assistant OS (the default install, no container, not core only)

System Health

version core-2021.9.3
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.9.6
os_name Linux
os_version 5.10.61
arch x86_64
timezone America/Chicago
Home Assistant Community Store GitHub API | ok -- | -- Github API Calls Remaining | 4860 Installed Version | 1.15.2 Stage | running Available Repositories | 951 Installed Repositories | 22
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | September 12, 2021, 7:00 PM relayer_connected | true remote_enabled | true remote_connected | true alexa_enabled | false google_enabled | true can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 6.3 -- | -- update_channel | beta supervisor_version | supervisor-2021.09.0 docker_version | 20.10.7 disk_total | 48.5 GB disk_used | 12.7 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | Samba share (9.5.1), Home Assistant Google Drive Backup (0.103.1), AdGuard Home (4.1.9), Visual Studio Code (3.6.2), Assistant Relay (0.7.4), AppDaemon 4 (0.7.0), ESPHome (2021.8.2), Z-Wave JS (0.1.38), Mosquitto broker (6.0.1)
Lovelace dashboards | 3 -- | -- resources | 15 views | 10 mode | storage
Spotify api_endpoint_reachable | ok -- | --
KapJI commented 3 years ago

Maybe you can help to figure out where these old descriptors are coming from?

For that you need to modify /usr/local/lib/python3.9/site-packages/google/protobuf/symbol_database.py.

In the imports section on the top add:

import logging
import traceback
logging.basicConfig(level=logging.ERROR)
LOGGER = logging.getLogger(__name__)

And in RegisterMessageDescriptor (line ~100):

    LOGGER.error("TESTTEST1 api implementation type: %s, descriptor name: %s, file: %s", api_implementation.Type(), message_descriptor.full_name, message_descriptor.file.name)
    LOGGER.error("TESTTEST2 %s", ''.join(traceback.format_stack()))
    if api_implementation.Type() == 'python':

Then restart HA and you should see quite many stacktraces and extra logs which will be helpful.

After that revert these changes back.

gary-reyes commented 3 years ago

I have no idea how I would be able to do that this type of install. It was my belief that with this type of installation, users would be unable to do what you are asking

KapJI commented 3 years ago

Well, it's possible, although needs some extra configuration: https://developers.home-assistant.io/docs/operating-system/debugging/

KapJI commented 3 years ago

I installed Home Assistant OS on VM and installed google_home v1.8.0 from HACS. It still works fine for me. It also has Python implementation of Protobuf API.

Btw, I found this is an easier way to enable SSH on 22222: https://community.home-assistant.io/t/add-on-hassos-ssh-port-22222-configurator/264109

Or if you have display and keyboard attached to your box you can just type "login" and will be in the host shell. Then docker exec -it homeassistant /bin/bash will get you inside the container.

It'll be interesting if you can run find / -name v1.proto there. I suspect you may have another copy somewhere else.

Another thing you can do is just get fresh clean installation of Home Assistant OS, install only this integration there and see if this issue persists.

DerekF35 commented 3 years ago

@gary-reyes Do you have the Google Wifi Integration installed (https://github.com/djtimca/hagooglewifi)? I was receiving a similar error with that integration. When I uninstalled the ha-google-home integration and setup the hagooglewifi integration, the issue flipped to ha-google-home not being able to start up with this error. These integrations seem to not be playing nice together.

gary-reyes commented 3 years ago

Yes I have the google wifi integration

KapJI commented 3 years ago

Should be fixed in 1.8.1. Please open new issue if this is not the case.