syssi / xiaomi_airpurifier

Xiaomi Mi Air Purifier and Xiaomi Mi Air Humidifier integration for Home Assistant
Apache License 2.0
447 stars 110 forks source link

Integration not work #296

Closed pticavorobey closed 2 years ago

pticavorobey commented 2 years ago

Stable system after a scheduled reboot gives an error on all my humidifiers and air purifiers

Platform error fan.xiaomi_miio_airpurifier - cannot import name 'DeviceInfo' from 'miio' (/usr/local/lib/python3.10/site-packages/miio/__init__.py)

Reinstalling the component does not help

Home Assistant 2022.8.2 Supervisor 2022.07.0 Frontend 20220802.0 - latest

pticavorobey commented 2 years ago

After reboot:

Platform error fan.xiaomi_miio_airpurifier - No module named 'miio.integrations.airpurifier'
Platform error fan.xiaomi_miio_airpurifier - No module named 'miio.integrations.airpurifier'
Platform error fan.xiaomi_miio_airpurifier - No module named 'miio.integrations.airpurifier
pticavorobey commented 2 years ago

Rolling back to 2022.4 helped. However, only after removing the component completely.

pticavorobey commented 2 years ago

If you update again to version 2022.8 via HAСS, the same error occurs.

syssi commented 2 years ago

Could you check the errors carefully? Please provide the log again. I assume it's a new/another error.

syssi commented 2 years ago

I have an idea: Could you provide a list of all custom components you are using?

ls -l config/custom_components

And if you have access to the folder please provide the output of:

grep -r 'python-miio' * | grep manifest

I assume there is another custom component which downgrades python-miio on startup. It's important all custom components requiring python-miio must require python-miio>=0.5.12.

pticavorobey commented 2 years ago

Could you check the errors carefully? Please provide the log again. I assume it's a new/another error.

No problem. I did a clean install of the component via HACS. I add a description of my devices to my configuration.yaml. I have two humidifiers and one air purifier. I go to check the configuration and get the following message:

Platform error fan.xiaomi_miio_airpurifier - cannot import name 'DeviceInfo' from 'miio' (/usr/local/lib/python3.10/site-packages/miio/__init__.py)
Platform error fan.xiaomi_miio_airpurifier - cannot import name 'DeviceInfo' from 'miio' (/usr/local/lib/python3.10/site-packages/miio/__init__.py)
Platform error fan.xiaomi_miio_airpurifier - cannot import name 'DeviceInfo' from 'miio' (/usr/local/lib/python3.10/site-packages/miio/__init__.py)

I assume there is another custom component which downgrades python-miio on startup. It's important all custom components requiring python-miio must require python-miio>=0.5.12.

Command output:

bash-5.1# ls -l /config/custom_components
total 44
drwxr-xr-x    3 root     root          4096 Aug  5 18:55 composite
-rwxrwxrwx    1 root     root           567 May 19  2021 decorators.py
drwxr-xr-x    3 root     root          4096 Aug  9 08:51 floureon
drwxr-xr-x    9 root     root          4096 Jul 14 15:58 hacs
drwxr-xr-x    5 root     root          4096 Jun 27 23:00 localtuya
drwxr-xr-x    3 root     root          4096 Aug  5 18:55 miio2
drwxr-xr-x    4 root     root          4096 Jul 21 22:10 ready4sky
drwxr-xr-x    5 root     root          4096 Jul  7 14:32 sonoff
drwxrwxrwx    6 root     root          4096 May 13 16:20 xiaomi_gateway3
drwxr-xr-x    3 root     root          4096 Aug  9 11:09 xiaomi_miio_airpurifier
drwxr-xr-x    4 root     root          4096 Jul  5 22:10 yandex_smart_home
bash-5.1# grep -r 'python-miio' * | grep manifest
custom_components/xiaomi_miio_airpurifier/manifest.json:    "python-miio>=0.5.12"
custom_components/miio2/manifest.json:    "python-miio==0.5.11"

I seem to understand what you mean. I have another component that also uses the miio library, which is loaded instead of your authored component. However, there can be only one such for a system. It seems to me that I can contact the author of another component and ask to update the miio version to the one that suits everyone.

Or can you suggest me something else?

pticavorobey commented 2 years ago

@KrzysztofHajdamowicz, look at it.

KrzysztofHajdamowicz commented 2 years ago

@KrzysztofHajdamowicz, look at it.

Sorry, my Python skills end here. STYJ02YM integration is abandoned for a few days and new maintainer will be welcomed!

syssi commented 2 years ago

Correct. If you start Home Assistant all manifest.json files are parsed and requirements are collected. Home Assistant uses pip install to install these requirements. It's not possible to install multiple versions of one library at the same time. At the moment python-miio==0.5.11 of miio2 wins the race and xiaomi_miio_airpurifier is unable to start because important packages of the 0.5.12 release are missing.

syssi commented 2 years ago

@KrzysztofHajdamowicz Do you still accept pull requests?

KrzysztofHajdamowicz commented 2 years ago

@KrzysztofHajdamowicz Do you still accept pull requests?

Sure!

syssi commented 2 years ago

@pticavorobey I would provide some instructions how to manually edit/change the miio2 component to be python-miio==0.5.12 compatible. In best case the number of changes is pretty small. Are you able to edit the files of miio2 manually? As soon we know the required changes you or I can prepare a pull request.

syssi commented 2 years ago

Preparation:

  1. We need a Home Assistant >=2022.8.0 instance.
  2. Change custom_components/miio2/manifest.json to python-miio==0.5.12
  3. Restart Home Assistant

Please provide all errors the miio2 throws now.

pticavorobey commented 2 years ago

miio2

Oh sure. I guess I can just replace the miio library requirements in the miio2 component.

pticavorobey commented 2 years ago

I made changes to the manifest. Restarted assistant. The configuration has been accepted, the devices of these two components are available and working! Ready to do PR.

syssi commented 2 years ago

This was easy. I would be happy if you could do the PR. If you don't know how to do it I can take over.

pticavorobey commented 2 years ago

@syssi @KrzysztofHajdamowicz Hope I did the right thing https://github.com/nqkdev/home-assistant-vacuum-styj02ym/pull/58

syssi commented 2 years ago

Do you use / did you fix the nqkdev version or the KrzysztofHajdamowicz fork?

syssi commented 2 years ago

If you see deprecation warnings at your log you could apply these changes (locally) too:

https://github.com/nqkdev/home-assistant-vacuum-styj02ym/pull/56/files

pticavorobey commented 2 years ago

Do you use / did you fix the nqkdev version or the KrzysztofHajdamowicz fork?

Ouch! My mistake. I have withdrawn my nqkdev version change request. Here is the correct PR https://github.com/KrzysztofHajdamowicz/home-assistant-vacuum-styj02ym/pull/40

pticavorobey commented 2 years ago

Now it remains to wait for my local HACS to see this update. Thanks friends!