Xiaomi mi wifi plug & air purifier

I’ve no clue/idea. My code should do the same like the CLI call. There is no big difference. Also strange: There should be the output of "_LOGGER.debug(“Set fan speed to: " + speed)” somewhere in your logs.

Got it. Please check out the new revision and give it a try! :slight_smile:

1 Like

Hi to all again! i can turn on and off, see the air quality indice, but i can’t change the speed mode, no options available.

In this case you don’t use the develop branch. Please try this one:

https://github.com/syssi/xiaomi_airpurifier/archive/develop.zip

thanks :slight_smile: now i can change between modes and i get this “dump” in the log file:

2017-08-29 19:55:31 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 235, in _step
result = coro.send(value)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py”, line 1025, in _event_to_service_call
yield from service_handler.func(service_call)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/fan/init.py”, line 219, in async_handle_fan_service
yield from getattr(fan, method[‘method’])(**params)
File “/home/homeassistant/.homeassistant/custom_components/fan/xiaomi_airpurifier.py”, line 150, in async_turn_on
yield from self.async_set_speed(speed)
File “/home/homeassistant/.homeassistant/custom_components/fan/xiaomi_airpurifier.py”, line 227, in async_set_speed
if speed == OperationMode.idle.name:
File “/usr/lib/python3.4/enum.py”, line 255, in getattr
raise AttributeError(name) from None
AttributeError: idle

regards

Fixed! :slight_smile:

1 Like

Perfect, you rock :slight_smile:

I made some assumptions. If you can read python code please verify:

https://github.com/syssi/xiaomi_airpurifier/blob/develop/custom_components/fan/xiaomi_airpurifier.py#L149
https://github.com/syssi/xiaomi_airpurifier/blob/develop/custom_components/fan/xiaomi_airpurifier.py#L228

i confirm :wink: you rock :slight_smile:

Power strip component works good so far! Kudos.

So I’m trying to get the air purifier component to work. Getting this error:

2017-08-29 20:39:02 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 235, in _step
result = coro.send(value)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 210, in async_add_entity
yield from entity.async_update()
File “/home/homeassistant/.homeassistant/custom_components/fan/xiaomi_airpurifier.py”, line 176, in async_update
ATTR_MOTOR_SPEED: state.motor_speed
File “/srv/homeassistant/lib/python3.4/site-packages/mirobo/airpurifier.py”, line 166, in motor_speed
return self.data[“motor1_speed”]
KeyError: ‘motor1_speed’

Which air purifier generation do you own? It behaves different.

zhimi.airpurifier.m1 from the db file. It is the second generation (Mi Air Purifier 2).

EDIT: tried discover using mirobo.

WARNING:mirobo.discovery:Found unsupported device zhimi-airpurifier-m1_miio47104613._miio._udp.local. at 192.168.1.12, please report to developers

Okay in this case your python-mirobo version is too old again. :wink: You need a very recent version because of several fixes. You should try:

pip3 install 'https://github.com/rytilahti/python-mirobo/archive/168f5c0ff381b3b02cedd0917597195b3c521a20.zip#python-mirobo'

I will try to resync all components in future again. The recent changes aren’t released yet.

Haha, I just updated to 0.1.4. Guess this is what happens when you’re on the bleeding edge :smile:

Now, it works fine.

EDIT. Except there is no fan speed to choose from in the UI. Apparently, another mirobo component downgraded to 0,1,3. Fun times.

Do you use the componet from the development branch?

yes. it works now again. im able to set fan speed and turn on and off. now, can i use the aqi property to run some automations or will it have to be made a sensor?

I didn’t plan to implement sensors so far. A service to set the led, led brightness and the buzzer will follow. Please use sensor templates if you need the air quality index as sensor value.

Could you check the two cases mentioned here? Does the air purifier (the device!) turn off if you select the operation mode “idle”? If your air purifier is “off” and you change the operation mode to something not equal “silent” will the air purifier be turned on or does it stay off with a changed operation mode?

works as expected in both cases :+1:

1 Like

Hi,

I added your develop branch and got the below error in HA.
2017-08-30 13:43:40 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 235, in _step
result = coro.send(value)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 210, in async_add_entity
yield from entity.async_update()
File “/home/homeassistant/.homeassistant/custom_components/fan/xiaomi_airpurifier.py”, line 189, in async_update
ATTR_LED_BRIGHTNESS: state.led_brightness.value,
AttributeError: ‘NoneType’ object has no attribute ‘value’

I removed the value at the line 189 and then It works well (I am using a Mi Air Pro)
Trun on/off and mode change is really good~
Thank you so much :slight_smile: