syssi / xiaomi_airpurifier

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

Add zhimi.airpurifier.za1 support #181

Closed orionowy closed 3 years ago

orionowy commented 3 years ago

Request Smartmi zhimi.airpurifer.za1 - Air Purifier support

Xiaomi App Detalis details:

ID: 393002509
IP: 192.168.0.xx
MODEL: zhimi.airpurifer.za1

Current config:

  - platform: xiaomi_miio_airpurifier
    name: Smartmi Air Purifer
    host: 192.168.0.XX
    token: e42bxxxxxxxxxxxxxxxxxxx2502
    model: zhimi.airpurifier.mb3

Current states:

preset_modes:
  - Auto
  - Silent
  - Favorite
  - Fan
preset_mode: null
model: zhimi.airpurifier.mb3
temperature: 22.8
humidity: 49
aqi: 19
mode: 0
filter_hours_used: 5
filter_life_remaining: 99
favorite_level: 14
child_lock: false
led: null
motor_speed: null
average_aqi: 31
purify_volume: 126
use_time: 37986
buzzer: true
led_brightness: 0
filter_rfid_product_id: '31:33:0:0'
filter_rfid_tag: '81:70:1e:aa:ca:71:4'
filter_type: regular
fan_level: null
friendly_name: Smartmi Air Purifer
supported_features: 8

image

syssi commented 3 years ago

Is my interpretation correct: The zhimi.airpurifer.za1 is 100% feature compatible to the zhimi.airpurifier.mb3. If not: What's missing?

syssi commented 3 years ago

Could you provide some specs (product name, model no, specs) of your device? I would like to extend the list of supported devices as soon the device support is merged: https://github.com/syssi/xiaomi_airpurifier/pull/183

orionowy commented 3 years ago

Thank you for your response:

Name Smartmi Air Purifier Model: KQJHQ01ZM Spec: https://www.aze.com.pl/pl/p/Oczyszczacz-powietrza-Smartmi-Air-Purifier/2483, https://www.smartmiglobal.com/collections/air-purifier/products/smartmi-air-purifier

Coverage 9-48m², 400m³/h CADR, 30 dB - 64 dB, 40 W (max.)
Sensors: Temperature, laser particle sensor, Total VOC, humidity.

Some things are compatible with zhimi.airpurifier.mb3, but some functionalities are missing:

holygrolli commented 3 years ago

Did it work for you? I can see values but I cannot switch on or off through this integration

pphomesmart commented 3 years ago

Did it work for you? I can see values but I cannot switch on or off through this integration

Got the same issue, the sensors are displaying the data (temperature, humidity etc.) but I'm unable to turn it on or off.

Additionally I'm getting error after leaving zhimi.airpurifier.za1 reference in configuration.yaml file, currently using zhimi.airpurifier.mb3 value: 2021-07-10 23_03_31-Window

holygrolli commented 3 years ago

what a coincidence today I had some time to play around a bit. I got it to work locally. I extended the miio package for ZA1 support and put it next to the custom_component. And it works :-) You can just test it from this branch: https://github.com/holygrolli/xiaomi_airpurifier/tree/local_smartmi

I have to find some time to check for the TVOC value, but everything else seems to work. And finally I need to cleanup and then create a merge request to miio and to this very repo here

dameq1 commented 3 years ago

@holygrolli Thank you for your work. I'm using it and it is almost ok. I've a problem with setting favourite level. The method with calling service: xiaomi_miio_airpurifier.fan_set_favorite_level doesn't work for me. Could you help? I'm receiving a fail message with an unknown error reason.

FabFaeb commented 2 years ago

Unfortunately, the airpurifier.za1 is still not working for me in HA without using the local fix of @holygrolli .

Is there still a chance for the pull request to the official repos, some time in the future, Andreas? Would be very much appreciated by a lot of people I think!

pniewiadowski commented 2 years ago

I am trying to run @holygrolli local fix but I get below error:

This error originated from a custom integration.

Logger: homeassistant.config
Source: custom_components/xiaomi_miio_airpurifier/fan.py:8
Integration: xiaomi_miio_airpurifier (documentation, issues)
First occurred: 8:57:05 PM (2 occurrences)
Last logged: 8:57:05 PM

Platform error: fan
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config.py", line 877, in async_process_component_config
    platform = p_integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 572, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 589, 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 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/xiaomi_miio_airpurifier/fan.py", line 8, in <module>
    from miio import (  # pylint: disable=import-error
ImportError: cannot import name 'AirDogX5' from 'miio' (/usr/local/lib/python3.9/site-packages/miio/__init__.py)

Do you know how to solve it? Maybe @FabFaeb can help?

syssi commented 2 years ago

Please update the custom component (xiaomi_airpurifier). Recent versions of the component doesn't access the AirDogX5 class anymore.

pniewiadowski commented 2 years ago

@syssi so it means I can not use @holygrolli local solution anymore?

syssi commented 2 years ago

The solution must be updated first. The fork isn't python-miio compatible anymore.

an0nfunc commented 2 years ago

I updated @holygrolli's branch to be compatible again: https://github.com/an0nfunc/xiaomi_airpurifier/tree/local_smartmi

PhilippBaumgarten commented 2 years ago

@an0nfunc thanks for your update! Unfortunately it doesnt work for me for Smartmi Air Purifier. Installed your latest dev and configured via yaml.

/usr/local/lib/python3.9/site-packages/miio/device.py:158 Found an unsupported model 'zhimi.airpurifier.za1' for class 'AirPurifierMiot'. If this is working for you, please open an issue at https://github.com/rytilahti/python-miio/

/usr/local/lib/python3.9/site-packages/miio/miot_device.py:172 Unable to find mapping for zhimi.airpurifier.za1, falling back to zhimi.airpurifier.ma4

an0nfunc commented 2 years ago

@Phreet Did you use the local_smartmi branch?

FabFaeb commented 2 years ago

@an0nfunc would it be possible to create a PR with your updates back to this repo so that the zhimi.airpurifier.za1 could be supported by default?

an0nfunc commented 2 years ago

@FabFaeb As far as I understand, these changes would need to go into python-miio. https://github.com/rytilahti/python-miio/issues/1025 already requests support for the za1, but there seems to be no activity so far. I'll check later what exactly I would need to do to get it upstreamed.

PhilippBaumgarten commented 2 years ago

@Phreet Did you use the local_smartmi branch?

You are so right. HACS didnt offer me branch selection - therefore it took your dev branch, not the local_smartmi. Right branch selected and voila - it works, thanks for your code,

dameq1 commented 2 years ago

If someone will be interested I will share my fork of @holygrolli's branch https://github.com/dameq1/xiaomi_airpurifier_fork. I'm using this purifier so I'm updating it when it is needed. I also fixed problems which oryginal @holygrolli's mod had, like no possibility to set favorite speed or change lcd brightness. I modified my version using default branch so it will work also from hacs.

an0nfunc commented 2 years ago

For anyone interested, I just submitted a PR to get the za1 supported by HA's existing xiaomi_miio integration: https://github.com/home-assistant/core/pull/80387