Xiaomi mi wifi plug & air purifier

Please kindly help me this error:
ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 241, in _step
result = coro.throw(exc)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/setup.py”, line 61, in async_setup_component
return (yield from task)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/setup.py”, line 160, in _async_setup_component
conf_util.async_process_component_config(hass, config, domain)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/config.py”, line 619, in async_process_component_config
platform = get_platform(domain, p_name)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/loader.py”, line 104, in get_platform
return get_component(PLATFORM_FORMAT.format(domain, platform))
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/loader.py”, line 142, in get_component
module = importlib.import_module(path)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 986, in _gcd_import
File “”, line 969, in _find_and_load
File “”, line 958, in _find_and_load_unlocked
File “”, line 673, in _load_unlocked
File “”, line 669, in exec_module
File “”, line 775, in get_code
File “”, line 735, in source_to_code
File “”, line 222, in _call_with_frames_removed
File “/home/homeassistant/.homeassistant/custom_components/switch/xiaomi_plug.py”, line 292
_LOGGER.error(“Got exception while fetching the state: %s”, ex)

Please remove the xiaomi_plug from your custom components folder and use the official component called switch.xiaomi_miio. Your configuration needs to be updated.

The Xiaomi Air Purifier 2 is now official supported by HA. The component is called fan.xiaomi_miio. The underlying library was renamed from python-mirobo to python-miio. The commandline tool called “mirobo” is still available.

1 Like

@syssi Hi! Thanks for your awesome componnt. WOuld u think it is possible to create a AC Controller for this ?

This is already done for broadlink… would really be interested… unfortunately i am not able as i am not a coder or famiiar with python :frowning:

I did receive your messages. It will be hard to implement a climate device without owning the hardware (ir remote & air condition / thermostat with IR receiver). There is another Xiaomi device called Xiaomi Air Conditioner Companion, which will be supported by HA soon: https://github.com/home-assistant/home-assistant/pull/10761

Please explain in a few words what you are trying to achieve. Do you own a air condition? Which IR commands does the air condition support? Is there a message structure? Can you provide the IR commands?

hey… great having a feedback :slight_smile: well… I own an ac here which is controlled very easy with IR signals. It works perfect with broadlink ac component but i don’t wanna use broadlink (design is not my taste) so i replaced everything by the Xiami devices.

well.

I would like having a “complete” compnent" to control my 4 Air conditionings via frontend but also via automations.

automation wont need nice frontend style that’s clear.

The Xiaomi is the same princiü loike the broadlink… so i thought it would be easier to just use the broadlink ac component and “port” it to xiaomi. Sorry as mentioneed… i am absoltely nit familiar with coding.

but let me throw an eye the mentioned component. i might use dev branch to test if it work for my needs. I will give feedback asap.

Could you provide your broadlink configuration?

Hi, syssi. For IR code learn, there is another file called xiaomi_ir.py. Do you need it as well? And actually AC Controller is the same product as Xiaomi AC Partner. The difference are appearance and brand. Both products are made by Aqara but square one is branded Aqara and Round one is branded Xiaomi. Just like other Zigbee products such as temperature sensor and windows/door binary sensors. Furthermore, I notice that only Aqara one is official sold abroad, which means that overseas customers may only be familiar with this one.

@thundergreen We are working on AC Partner component. Right now, you can follow this repository and add it as custom_component. You can check markdown file, which is English Doc. Since PR at home-assistant official repository is quite a chaos now.

@cxlwill I alredy tried AC Partner but it won’t work for the Chuang Mi IR Remote Controller unfortunately.

so we will have to pick up the xiaomi_ir.py to build this AC component

@syssi here is the link to the braodlink:

Config would look something like:

climate:
  - platform: broadlink
    name: Toyotomi Akira
    host: 192.168.1.85
    mac: 'BB:BB:BB:BB:BB:BB'
    ircodes_ini: 'broadlink_climate_codes/toyotomi_akira.ini'
    min_temp: 16
    max_temp: 30
    target_temp: 20
    temp_sensor: sensor.living_room_temperature
    default_operation: idle
    default_fan_mode: mid
    customize:
      operations:
        - idle
        - cool
        - heat
      fan_modes:
        - low
        - mid
        - high
        - auto

Hi everyone, I have a Xiaomi Air Purifier Gen 1, and have tried to use the plugin. So far it doesn’t seem to detect it, although my Xiaomi Robot Vacuum detects fine and can be controlled. Would that be because the Xiaomi Air Purifier Gen 1 is not supported? So far, the discussions seem to be focused on the latter models of the Xiaomi Air Purifier.

If the Xiaomi Air Purifier Gen 1 isn’t supported in this plugin, is there anything that supports it?

Thank you everyone!

Please use this component: https://home-assistant.io/components/fan.xiaomi_miio/

Yes, that’s the component that I’m using, and the guide that I used as well. My configuration is below:

Xiaomi Air Purifier

fan:

  • platform: xiaomi_miio
    name: Xiaomi Air Purifier
    host: 10.168.48.243
    token: [my token removed]

I’ve added the Xiaomi Robot Vacuum successfully as well, so I’m fairly sure I used the right process to extract the tokens. However, the component isn’t turning up in my Home Assistant page.

My Air Purifier is a Gen 1 (not Xiaomi Air Purifier 2, Air Purifier 2S or Air Purifier Pro) so I’m wondering if that is the reason why the component isn’t turning in my Home Assistant page? If the Gen 1 is supported, then not sure what I’m doing incorrectly? Any advice appreciated! Thank you!

@syssi Any ideas with this one?

Thanks for all your work on the xiaomi purifier! Any future plans on supporting the humidifier through HA?

Not yet. Do you like to provide some testing?

hi raty,
just trying to achieve what you’ve done, however it doesnt seem to work. It doesnt change the fan speed, any idea what I am doing wrong?

I pretty much copied and pasted your settings and just changing the IP address to my purifier.

Thanks

image

Hi kwetiaw,
since 0.60 the AirPurifier component isn’t working anymore in Home-Assistant (at least for me it isn’t).
I’ve read on github, that syssi is working on the solution.

Also, since there is an official component, the miio command has been replaced by the mirobo command.
But luckily it isn’t necessary anymore to do it the way I described.

Now, with the official component you can just use input_number and an automation like this:

Automation:

- id: xiaomi_fav_speed
  alias: Xiaomi Favorite Speed
  trigger:
    platform: state
    entity_id: input_number.xiaomi_fav_speed
  action:
    - service: fan.xiaomi_miio_set_favorite_level
      data_template:
        entity_id: fan.xiaomi_air_purifier_2
        level: '{{ states.input_number.xiaomi_fav_speed.state | int }}'

input_number:

xiaomi_fav_speed:
  name: Xiaomi Air Purifier Favorite Level
  initial: 5
  min: 1
  max: 16
  step: 1

But, as I said earlier, at the moment, it doesn’t work at all.

I have the humidifier and would be more than happy to test for you

It’s fixed and will be part of the next homeassistant release: python-miio version bumped by syssi · Pull Request #11837 · home-assistant/core · GitHub

1 Like

I wrote a custom component as first step:

Please give it a try. If it works fine I will merge the code into fan/xiaomi_miio.