Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HA fails to start with custom version of existing component #21579

Closed
uchagani opened this issue Mar 2, 2019 · 26 comments · Fixed by #22370
Closed

HA fails to start with custom version of existing component #21579

uchagani opened this issue Mar 2, 2019 · 26 comments · Fixed by #22370

Comments

@uchagani
Copy link
Contributor

uchagani commented Mar 2, 2019

Home Assistant release with the issue:
0.88.2

Operating environment (Hass.io/Docker/Windows/etc.):
Debian 9

Component/platform:
https://www.home-assistant.io/components/zwave/

Description of problem:
HA fails to start when customizing an existing component. With Logger set to Debug no errors are printed to the logs. See traceback section for where it gets stuck.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):
I'm using the Zwave Integration and not using the YAML in configuration.yaml

Traceback (if applicable):

Mar 01 22:28:55 hass systemd[1]: Started Home Assistant.
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded system_health from homeassistant.components.system_health
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded http from homeassistant.components.http
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded tts from homeassistant.components.tts
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded group from homeassistant.components.group
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded frontend from homeassistant.components.frontend
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded api from homeassistant.components.api
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded websocket_api from homeassistant.components.websocket_api
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded system_log from homeassistant.components.system_log
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded auth from homeassistant.components.auth
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded onboarding from homeassistant.components.onboarding
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded lovelace from homeassistant.components.lovelace
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded ios from homeassistant.components.ios
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded device_tracker from homeassistant.components.device_tracker
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded zone from homeassistant.components.zone
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded zeroconf from homeassistant.components.zeroconf
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded automation from homeassistant.components.automation
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded bmw_connected_drive from homeassistant.components.bmw_connected_drive
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded config from homeassistant.components.config
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded neato from homeassistant.components.neato
Mar 01 22:28:56 hass hass[2317]: 2019-03-01 22:28:56 INFO (MainThread) [homeassistant.loader] Loaded logger from homeassistant.components.logger
Mar 01 22:28:56 hass hass[2317]: Config directory: /home/homeassistant/.homeassistant

Additional information:
I copied over all the files from from the components/zwave directory into custom_components/zwave, changed const.py and node_entity.py to fire a new event. This has worked just fine before the re-org of the codebase. The changes i'm making to those two files are in this PR that we decided not to merge: #10865. To reiterate, this worked before the code re-org and i will try other components to see if they exhibit the same issue.

@balloob
Copy link
Member

balloob commented Mar 2, 2019

How does your zwave folder in custom components look?

@uchagani
Copy link
Contributor Author

uchagani commented Mar 2, 2019

@balloob
Copy link
Member

balloob commented Mar 2, 2019

That looks alright. Your logs don't show any error nor have any mention of zwave. You copied wrong part?

@uchagani
Copy link
Contributor Author

uchagani commented Mar 2, 2019

@balloob HA seems to get stuck right there when all the files are copied over. There are no errors at all that I can see even after setting the logger level to debug. When trying to access the HA through the browser I can't connect. If I only copy __init__.py, const.py, and node_entity.py into custom_components\zwave HA starts up but I get errors about missing dependencies.

@balloob
Copy link
Member

balloob commented Mar 2, 2019

what kind of errors?

@uchagani
Copy link
Contributor Author

uchagani commented Mar 2, 2019

@balloob If I copy only __init__.py, const.py, and node_entity.py into zwave/custom_components I get the following error:

Mar 02 00:17:52 hass hass[2562]: 2019-03-02 00:17:52 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.zwave.sensor. Make sure all dependencies are installed
Mar 02 00:17:52 hass hass[2562]: Traceback (most recent call last):
Mar 02 00:17:52 hass hass[2562]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/loader.py", line 147, in _load_file
Mar 02 00:17:52 hass hass[2562]:     module = importlib.import_module(path)
Mar 02 00:17:52 hass hass[2562]:   File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
Mar 02 00:17:52 hass hass[2562]:     return _bootstrap._gcd_import(name[level:], package, level)
Mar 02 00:17:52 hass hass[2562]:   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
Mar 02 00:17:52 hass hass[2562]:   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
Mar 02 00:17:52 hass hass[2562]:   File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
Mar 02 00:17:52 hass hass[2562]:   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
Mar 02 00:17:52 hass hass[2562]:   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
Mar 02 00:17:52 hass hass[2562]:   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
Mar 02 00:17:52 hass hass[2562]:   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
Mar 02 00:17:52 hass hass[2562]:   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
Mar 02 00:17:52 hass hass[2562]:   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
Mar 02 00:17:52 hass hass[2562]:   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
Mar 02 00:17:52 hass hass[2562]:   File "/home/homeassistant/.homeassistant/custom_components/zwave/__init__.py", line 27, in <module>
Mar 02 00:17:52 hass hass[2562]:     from . import config_flow  # noqa pylint: disable=unused-import
Mar 02 00:17:52 hass hass[2562]: ImportError: cannot import name 'config_flow'

If I copy all the zwave files, I get no errors but HA won't start at all. Here are the full logs from start to where it gets stuck: https://hastebin.com/ejohinodip.cs

@balloob
Copy link
Member

balloob commented Mar 2, 2019

So when you're copying the files, are you copying the files from 0.88.2 or from dev ?

@uchagani
Copy link
Contributor Author

uchagani commented Mar 2, 2019

I downloaded the zip file of the release and then copied it over @balloob that's been my standard workflow whenever I updated HA and put back the custom code.

@uchagani
Copy link
Contributor Author

uchagani commented Mar 2, 2019

@balloob I just tried this with lifx, and rainmachine components as "custom_components" and they worked just fine so something with zwave specifically is causing some issues. Could it have to do with config_flow?

@balloob
Copy link
Member

balloob commented Mar 2, 2019

Nah, it's complaining about config_flow because you didn't copy that.

Can you try updating these lines to be relative:

› git grep "components.zwave"
components/zwave/binary_sensor.py:9:from homeassistant.components.zwave import workaround
components/zwave/climate.py:10:from homeassistant.components.zwave import ZWaveDeviceEntity
components/zwave/cover.py:7:from homeassistant.components.zwave import (

To make relative: from homeassistant.components.zwave import workaround -> from . import workaround`

@uchagani
Copy link
Contributor Author

uchagani commented Mar 2, 2019

i made the changes to those files and same issue:

Mar 02 11:37:01 hass systemd[1]: Stopped Home Assistant.
Mar 02 11:37:01 hass systemd[1]: Started Home Assistant.
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded logbook from homeassistant.components.logbook
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded recorder from homeassistant.components.recorder
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded frontend from homeassistant.components.frontend
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded api from homeassistant.components.api
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded http from homeassistant.components.http
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded websocket_api from homeassistant.components.websocket_api
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded system_log from homeassistant.components.system_log
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded auth from homeassistant.components.auth
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded onboarding from homeassistant.components.onboarding
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded lovelace from homeassistant.components.lovelace
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded script from homeassistant.components.script
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded group from homeassistant.components.group
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded automation from homeassistant.components.automation
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded tts from homeassistant.components.tts
Mar 02 11:37:02 hass hass[4971]: 2019-03-02 11:37:02 INFO (MainThread) [homeassistant.loader] Loaded rainmachine from homeassistant.components.rainmachine
Mar 02 11:37:02 hass hass[4971]: Config directory: /home/homeassistant/.homeassistant

@uchagani
Copy link
Contributor Author

uchagani commented Mar 2, 2019

@balloob just tried this on a brand new install and I got the same issue.

@uchagani
Copy link
Contributor Author

uchagani commented Mar 2, 2019

Steps I did on the new install:

1.  Install HA in a Python3 venv
2.  Setup up zwave via Integrations
3.  Start HA and ensure zwave is working correctly
4.  Stop HA
5.  wget https://github.com/home-assistant/home-assistant/archive/0.88.2.zip 
6.  unzip archive and recursively copy zwave directory into `.homeassistant/custom_components`
7.  edit `const.py` and `node_entity.py` with the code from #10865
8.  Start HA

@balloob
Copy link
Member

balloob commented Mar 5, 2019

Added a PR to fix the relative imports. I am unable to reproduce it locally, but then I also don't have a Z-Wave stick to test with. So I am just running until it hits async_setup and that's fine, which indicates the custom component works.

@uchagani
Copy link
Contributor Author

uchagani commented Mar 5, 2019

Thanks @balloob I'll test it as soon as it's in.

@beatified
Copy link

I know it hasn't been too long since you last posted but...

Is this still an issue you are experiencing? Can you please try upgrading to the latest version of Home Assistant (0.90) and report back if this is still a problem? Thanks!

@uchagani
Copy link
Contributor Author

uchagani commented Mar 22, 2019 via email

@uchagani
Copy link
Contributor Author

uchagani commented Mar 23, 2019

So I rechecked with the latest version 0.90.1 and there's still an issue but this time with the translations. @balloob I think translations, at least for the zwave component isn't working when used with custom_components.

I have a .translations inside my custom_components dir:

(homeassistant) homeassistant@hass-test:/srv/homeassistant$ ls -lah ~/.homeassistant/custom_components/zwave/.translations/
total 261K
drwxr-xr-x 2 homeassistant homeassistant   28 Mar 22 22:59 .
drwxr-xr-x 4 homeassistant homeassistant   21 Mar 23 00:00 ..
-rw-r--r-- 1 homeassistant homeassistant 1.9K Mar 22 22:59 bg.json
-rw-r--r-- 1 homeassistant homeassistant  905 Mar 22 22:59 ca.json
-rw-r--r-- 1 homeassistant homeassistant  910 Mar 22 22:59 cs.json
-rw-r--r-- 1 homeassistant homeassistant  808 Mar 22 22:59 da.json
-rw-r--r-- 1 homeassistant homeassistant  823 Mar 22 22:59 de.json
-rw-r--r-- 1 homeassistant homeassistant  766 Mar 22 22:59 en.json
-rw-r--r-- 1 homeassistant homeassistant  691 Mar 22 22:59 es-419.json
-rw-r--r-- 1 homeassistant homeassistant  859 Mar 22 22:59 es.json
-rw-r--r-- 1 homeassistant homeassistant   45 Mar 22 22:59 et.json
-rw-r--r-- 1 homeassistant homeassistant  887 Mar 22 22:59 fr.json
-rw-r--r-- 1 homeassistant homeassistant 1000 Mar 22 22:59 hu.json
-rw-r--r-- 1 homeassistant homeassistant  821 Mar 22 22:59 it.json
-rw-r--r-- 1 homeassistant homeassistant 1.2K Mar 22 22:59 ko.json
-rw-r--r-- 1 homeassistant homeassistant  865 Mar 22 22:59 lb.json
-rw-r--r-- 1 homeassistant homeassistant  794 Mar 22 22:59 nl.json
-rw-r--r-- 1 homeassistant homeassistant  849 Mar 22 22:59 no.json
-rw-r--r-- 1 homeassistant homeassistant  926 Mar 22 22:59 pl.json
-rw-r--r-- 1 homeassistant homeassistant  868 Mar 22 22:59 pt-BR.json
-rw-r--r-- 1 homeassistant homeassistant  880 Mar 22 22:59 pt.json
-rw-r--r-- 1 homeassistant homeassistant  855 Mar 22 22:59 ro.json
-rw-r--r-- 1 homeassistant homeassistant 2.1K Mar 22 22:59 ru.json
-rw-r--r-- 1 homeassistant homeassistant  807 Mar 22 22:59 sl.json
-rw-r--r-- 1 homeassistant homeassistant  845 Mar 22 22:59 sv.json
-rw-r--r-- 1 homeassistant homeassistant  263 Mar 22 22:59 tr.json
-rw-r--r-- 1 homeassistant homeassistant  893 Mar 22 22:59 zh-Hans.json
-rw-r--r-- 1 homeassistant homeassistant  935 Mar 22 22:59 zh-Hant.json

Here is the error:

2019-03-23 00:06:02 ERROR (MainThread) [homeassistant.loader] Unable to find platform zwave. Search path was limited to path of component: custom_components
2019-03-23 00:06:02 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.139636232755184] Error handling message: {'id': 14, 'language': 'en', 'type': 'frontend/get_translations'}
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/websocket_api/decorators.py", line 17, in _handle_async_response
    await func(hass, connection, msg)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/frontend/__init__.py", line 507, in websocket_get_translations
    resources = await async_get_translations(hass, msg['language'])
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/translation.py", line 157, in async_get_translations
    resources = await async_get_component_resources(hass, language)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/translation.py", line 134, in async_get_component_resources
    hass, component, language)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/translation.py", line 65, in component_translation_file
    assert module is not None
AssertionError

@uchagani
Copy link
Contributor Author

Also, this error shows up once you load the frontend so you won't see anything in the logs if you just start the service. but once you load the frontend this error shows up.

@balloob
Copy link
Member

balloob commented Mar 24, 2019

@balloob
Copy link
Member

balloob commented Mar 24, 2019

So that you can see which one failed.

@balloob
Copy link
Member

balloob commented Mar 24, 2019

Feel free to put that in a PR too, would be good to know for future reports too.

@uchagani
Copy link
Contributor Author

@balloob here is the result: AssertionError: config.zwave

@balloob
Copy link
Member

balloob commented Mar 24, 2019

Ah I know what's going on. We add config sections to hass.config.components for the frontend, but our translation helper can't handle that. We should remove this line https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/config/__init__.py#L49

PR welcome again 👍

@balloob
Copy link
Member

balloob commented Mar 24, 2019

And that PR would fix this issue.

@uchagani
Copy link
Contributor Author

Thanks @balloob I verified that that fixes it and submitted #22370

@ghost ghost removed the in progress label Mar 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants