Xiaomi mi wifi plug & air purifier

@syssi is this part of the new Xiaomi component added to HA recently in 0.50

No. The new component is about the xiaomi gateway (zigbee) and sub devices (sensors & actors). The devices (air purifier & wifi plug != zigbee plug) mentioned here are WiFi devices and won’t official supported right now.

@syssi, wouldn’t it make sense (or wouldn’t it be possible) to merge support of both lines of Xiaomi products, Zigbee and non-Zigbee, in a common component? Here we’re talking about air purifier and sockets, but there are others that are only WiFi: IR remote, Vacuum robot, etc…

Let’s assume both devices (xiaomi gateway and f.e. the air purifier) has nothing in common. Do you still want to merge both lines?

Well, I don’t know. I still have no gateway (is on the way), but I supposed it would make sense to have a common platform with maybe optional parameters on the configuration, based on the type of device… It was just a suggestion… :wink:

I’m still seeking for good reasons to merge the WiFi components into one platform. I don’t recommend a merge into the xiaomi gateway platform because of the different network protocol (multicast) and the different token/key handling. IMHO the xiaomi gateway and the WiFi devices doesn’t have much in common.

1 Like

Since @teprrr introduced the “-d info” command it looks like we are able to identify the different devices by a nice model name (f.e. philips.light.bulb, philips.light.ceiling, zhimi.airpurifier.m1). A common component for switches and lights with network discovery and device/feature detection would be awesome. :slight_smile:

2 Likes

Did you manage to make it work?
I followed all the steps but when I run the manual to learn a command it gives me a timeout error
File “/config/custom_components/switch/chuangmi_ir.py”, line 67, in _learn_command
Ir_remote.send (“miIO.ir_learn”, {‘key’: str (key)})
File “/config/deps/lib/python3.6/site-packages/miio/miio.py”, line 128, in send
Date, addr = s.recvfrom (1024)
Socket.timeout: timed out

Yes, I made it work. All you have to do is specify a “timeout” parameter, the same you would use with the broadlink RM switch component. It means the time that the device will wait for you to send it a code from your remote.

Once you put that parameter, everything works as indicated.

@syssi: Hi, can we install this component using hass.io?

I don’t know hass.io. I will check it.

If anyone is interested, i made a Sensor who gets the Air Quality and the current state from the air Purifier:

sensor:
  - platform: command_line
    command: sudo miio --control 192.168.1.215 --method get_prop --params '["mode"]' | awk 'NR==5' | cut -d "\"" -f2
  - platform: command_line
    name: "Xiaomi Airquality"
    command: sudo miio --control 192.168.1.215 --method get_prop --params '["aqi"]' | sed -n '5p' | cut -d " " -f3
    unit_of_measurement: "PM2.5"

Just change the IP

2 Likes

I’ve updated my xiaomi plug component. It’s called “xiaomi_plug” now as preparation for the future merge into home assistant. Furthermore it uses asyncio now and reacts better on state changes (the switch doesn’t flip back anymore):

4 Likes

Could you post a graph showing air quality? Does it have significant effect on air quality (dust) running the purifier? I am considering buying one myself…

Hi syssi. Thank you so much for the good work.

This component is not working yet?

fan:

  • platform: xiaomi_airpurifier
    name: Air
    host: 192.168.31.33
    token: 7811b06e2f616a1d0f6d7898f24ecd46

It’s just an untested draft. Do you own the device and willing to test the component? I fixed some glitches. Just give it a try and please provide a screenshot if the fan will be shown in the frontend. :slight_smile: I’m interested in the provided attributes.

hi
im getting ImportError: No module named ‘zeroconf’`
What can I do? I am running the venv on raspi3
Thanks

Traceback (most recent call last): File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step result = coro.throw(exc) 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 212, in async_add_entity yield from self.hass.async_add_job(entity.update) File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__ yield self # This tells Task to wait for completion. File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup value = future.result() File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result raise self._exception File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run result = self.fn(*self.args, **self.kwargs) File "/home/homeassistant/.homeassistant/custom_components/switch/xiaomiplug.py", line 115, in update from mirobo import DeviceException File "/srv/homeassistant/lib/python3.4/site-packages/mirobo/__init__.py", line 12, in <module> from mirobo.discovery import Discovery File "/srv/homeassistant/lib/python3.4/site-packages/mirobo/discovery.py", line 2, in <module> import zeroconf ImportError: No module named 'zeroconf'

There is a dependency missing unfortunately. Enter your virtualenv and install zeroconf manually

su - homeassistant
source /srv/homeassistant/bin/activate
pip3 install zeroconf

and restart home assistant. If “pip install” fails please post the error message. I assume there will be another dependency missing.

1 Like

ehi @syssi i’ve the chuangmi_ir remote control and i’ve found a beta custom component to use in homeassistant… this is the url of the component: https://github.com/homeassistantchina/custom_components/tree/master/custom_components/switch

but it doesn’t work… can you please take a look? sorry but i know you are very good :slight_smile:

Are there any error messages (home-assistant.log)? Could you provide some more details about your issue. What did you try?