h4 / LYWSD02-home-assistant

Home-Assistant sensor for LYWSD02 Thermometer
75 stars 12 forks source link

Package lywsd02 setup failed. Component lywsd02 unable to import #5

Open jintytam opened 5 years ago

jintytam commented 5 years ago

Upgraded lywsd02 firmware and homeassistant,component lywsd02 unable to import

h4 commented 5 years ago

Could you name version of lywsd02 and HA both, please?

Also logs output will be helpful.

jintytam commented 5 years ago

lywsd02 firmware version 1.1.2_0042 HA version 0.97.2 When I run the following command: hass -- script check_config Output error log: Testing configuration at /root/.homeassistant Failed config homeassistant.packages.th_calc.lywsd02:

And when I run “hass”:

WARNING (MainThread) [homeassistant.components.template.sensor] Could not render template Entrance Humidity, the state is unknown. WARNING (MainThread) [homeassistant.components.template.sensor] Could not render template Entrance Temperature, the state is unknown.

uk4pyc commented 5 years ago

I had the same issue until I copied the folder contents both to /custom_components/ and custom_components/lywsd02/. If its only one or the other - it doesnt work. Obviously there an address mistake somewhere in there. Sorry im new to this, is there anyway to fix this issue?

h4 commented 5 years ago

@uk4pyc thanks a lot for workaround! I fix it soon, maybe tonight.

h4 commented 5 years ago

@uk4pyc so, I've check everything, there are no import issues in code. I tried to add more details into Readme, to make it more obvious.

I HA ecosystem you should place content of your custom components into directory inside custom_components directory. So, correct file structure will looks like this example:

custom_components
  |- lywsd02
  |  |- client
  |  |  |- __init__.py 
  |  |  |- client.py
  |  |
  |  |- __init__.py
  |  |- const.py
  |  |- manifest.json
  |  |- sensor.py
  |
  |- automations.yaml
  |- secrets.yaml
  |- configuration.yaml
  |- customize.yaml
  |- groups.yaml
JJussi commented 4 years ago

At Home Assistant (0.101.3) hass.io (192), I get error: 2019-11-14 16:26:30 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.lywsd02. Make sure all dependencies are installed Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 346, in _load_file module = importlib.import_module(path) File "/usr/local/lib/python3.7/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "/config/custom_components/lywsd02/init.py", line 10, in from lywsd02 import Lywsd02Client as Client ModuleNotFoundError: No module named 'lywsd02'

So, Lywsd02Client is missing?!?

h4 commented 4 years ago

@JJussi this error means that HomeAssistant did not load library which needs to my component. In most cases HomeAssistant loads it automatically.

MiguelAngelLV commented 4 years ago

Same problem:

2020-01-27 12:27:53 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.lywsd02. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 379, in _load_file
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/lywsd02/__init__.py", line 11, in <module>
    from lywsd02 import Lywsd02Client as Client
ModuleNotFoundError: No module named 'lywsd02'
h4 commented 4 years ago

@MiguelAngelLV please try to rename custom_components/lywsd02 directory to custom_components/lywsd02_component. I guess that we have naming resolution conflict in some cases.

MiguelAngelLV commented 4 years ago

Now the component is not found:

2020-01-29 13:09:00 ERROR (MainThread) [homeassistant.components.hassio] Component error: lywsd02 - Integration 'lywsd02' not found.

vsimanin commented 3 years ago

@MiguelAngelLV please try to rename custom_components/lywsd02 directory to custom_components/lywsd02_component. I guess that we have naming resolution conflict in some cases.

No =( It's not work. I check rename folder.... ogger: homeassistant.loader Source: custom_components/lywsd02/init.py:11 First occurred: 23:30:52 (1 occurrences) Last logged: 23:30:52 Error loading custom_components.lywsd02. Make sure all dependencies are installed

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 601, in _load_file module = importlib.import_module(path) File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 783, in exec_module File "", line 219, in _call_with_frames_removed File "/config/custom_components/lywsd02/init.py", line 11, in from lywsd02 import Lywsd02Client as Client ModuleNotFoundError: No module named 'lywsd02'

linesquarecube commented 1 year ago

Hi, did anyone got the LYWSD02 integration working with a current version of HA? When I follow the instructions given, I end up with the same failure as @MiguelAngelLV Integration error: lywsd02_sensor - Integration 'lywsd02_sensor' not found I'm happy for any help :smiley:

JJussi commented 1 year ago

Yes, it works fine currently.

Xiaomi BLE integration.

Home Assistant 2023.3.6 Supervisor 2023.04.0 Operating System 9.5 Frontend 20230309.1 - latest

linesquarecube commented 1 year ago

@JJussi Thanks for your reply! I'm using the same version of HA as you, but unfortunately the Xiaomi BLE integration is telling me that there was no broadcast from the LYWSD02 in the last minutes when I want to add it. If I add it anyway, I end up with an integration tile without any entities. grafik

linesquarecube commented 1 year ago

After updating the Passive BLE monitor this morning to the current version, the LYWSD02 is detected without any issues now. As it is supported for some time already, I'm confused why it didn't work before :man_shrugging: Nevertheless, thanks for your reply @JJussi