Xiaomi mi wifi plug & air purifier

ERROR:mirobo.vacuum_cli:Unable to read the stored msgid: [Errno 2] No such file or directory: '/tmp/python-mirobo.seq’
Sending cmd get_prop with params [‘power’, ‘aqi’, ‘humidity’, ‘temp_dec’, ‘mode’, ‘led’, ‘led_b’, ‘buzzer’, ‘child_lock’, ‘bright’, ‘favorite_level’, ‘filter1_life’, ‘f1_hour_used’, ‘use_time’, ‘motor1_speed’]
[‘off’, 0, None, None, ‘idle’, ‘off’, 10, ‘on’, ‘off’, 43, None, 26, 2573, None, 0]

and

INFO:mirobo.vacuum_cli:Debug mode active
DEBUG:mirobo.vacuum_cli:Read stored sequence ids: {‘manual_seq’: 0, ‘seq’: 1}
DEBUG:mirobo.vacuum_cli:Connecting to 192.168.x.x with token my-token
DEBUG:mirobo.protocol:Unable to decrypt, returning raw bytes.
DEBUG:mirobo.device:Got a response: Container:
data = Container:
offset2 = 32
offset1 = 32
length = 0
value = (total 0)
data = (total 0)
header = Container:
offset2 = 16
offset1 = 0
length = 16
value = Container:
length = 32
unknown = 0
devtype = 7
serial = 16835
ts = 1970-01-01 18:52:00
data = !1\x00 \x00\x00\x00\x00\x00\x07A\xc3\x00\x01\tP (total 16)
checksum = \n9\xbf6-\x84\x84\xec\xf8F\xe0\x05k\x08+\x1b (total 16)
DEBUG:mirobo.device:Discovered 7 16835 with ts: 1970-01-01 18:52:00, token: b’my-token’
DEBUG:mirobo.device:192.168.1.140:54321 >>: {‘params’: , ‘method’: ‘miIO.info’, ‘id’: 2}
DEBUG:mirobo.device:192.168.1.140:54321 (ts: 1970-01-01 18:52:01, id: 2) << {‘id’: 2, ‘result’: {‘mmfree’: 99856, ‘wifi_fw_ver’: ‘SD878x-14.76.36.p79-702.1.0-WM’, ‘life’: 67921, ‘fw_ver’: ‘1.4.0’, ‘netif’: {‘mask’: ‘255.255.255.0’, ‘gw_mac’: ‘AC:9E:17:93:2A:xx’, ‘localIp’: ‘192.168.x.x’, ‘gw’: ‘192.168.x.x’}, ‘hw_ver’: ‘MC200’, ‘model’: ‘zhimi.airpurifier.v3’, ‘mcu_fw_ver’: ‘2209’, ‘cfg_time’: 0, ‘token’: ‘my-token’, ‘mac’: ‘64:09:80:25:49:xx’, ‘ap’: {‘bssid’: ‘AC:9E:17:93:xx:xx’, ‘ssid’: ‘home’, ‘rssi’: -31}, ‘otu_stat’: [28, 28, 124, 3, 119, 381], ‘ot’: ‘otu’, ‘ott_stat’: [0, 0, 0, 0]}}
zhimi.airpurifier.v3 v1.4.0 (64:09:80:25:49:xx) @ 192.168.x.x - token: my-token
DEBUG:mirobo.vacuum_cli:Full response: {‘ap’: {‘bssid’: ‘AC:9E:17:93:xx:xx’, ‘rssi’: -31, ‘ssid’: ‘home’},
‘cfg_time’: 0,
‘fw_ver’: ‘1.4.0’,
‘hw_ver’: ‘MC200’,
‘life’: 67921,
‘mac’: ‘64:09:80:25:49:xx’,
‘mcu_fw_ver’: ‘2209’,
‘mmfree’: 99856,
‘model’: ‘zhimi.airpurifier.v3’,
‘netif’: {‘gw’: ‘192.168.x.x’,
‘gw_mac’: ‘AC:9E:17:93:2A:xx’,
‘localIp’: ‘192.168.x.x’,
‘mask’: ‘255.255.255.0’},
‘ot’: ‘otu’,
‘ott_stat’: [0, 0, 0, 0],
‘otu_stat’: [28, 28, 124, 3, 119, 381],
‘token’: ‘my-token’,
‘wifi_fw_ver’: ‘SD878x-14.76.36.p79-702.1.0-WM’}
DEBUG:mirobo.vacuum_cli:Writing {‘manual_seq’: 0, ‘seq’: 2} to /tmp/python-mirobo.seq

Sending cmd set_mode with params [‘auto’]
[‘ok’]

Sending cmd set_mode with params [‘silent’]
[‘ok’]

Sending cmd set_mode with params [‘favorite’]
[‘ok’]

Sending cmd set_mode with params [‘medium’]
[‘ok’]

Sending cmd set_mode with params [‘high’]
[‘ok’]

Sending cmd set_mode with params [‘strong’]
[‘ok’]

Sending cmd set_mode with params [‘idle’]
[‘ok’]

1 Like

Thanks a lot! The output helps enormously.

I’m sorry. Could you turn on the device and request the properties again?

mirobo --ip 192.168.x.x --token your-token raw_command  get_prop '["power", "aqi", "humidity", "temp_dec", "mode", "led", "led_b", "buzzer", "child_lock", "bright", "favorite_level", "filter1_life", "f1_hour_used", "use_time", "motor1_speed"]'

Thanks!

Sending cmd get_prop with params [‘power’, ‘aqi’, ‘humidity’, ‘temp_dec’, ‘mode’, ‘led’, ‘led_b’, ‘buzzer’, ‘child_lock’, ‘bright’, ‘favorite_level’, ‘filter1_life’, ‘f1_hour_used’, ‘use_time’, ‘motor1_speed’]
[‘off’, 0, None, None, ‘idle’, ‘off’, 10, ‘on’, ‘off’, 12, None, 26, 2574, None, 0]

This is strange. The device claims (‘power’: ‘off’) it’s turned off. The first item of the list should show “on”.

at power on send cmd is on

Sending cmd get_prop with params [‘power’, ‘aqi’, ‘humidity’, ‘temp_dec’, ‘mode’, ‘led’, ‘led_b’, ‘buzzer’, ‘child_lock’, ‘bright’, ‘favorite_level’, ‘filter1_life’, ‘f1_hour_used’, ‘use_time’, ‘motor1_speed’]
[‘on’, 18, None, None, ‘silent’, ‘off’, 10, ‘on’, ‘off’, 4, None, 26, 2574, None, 648]

Perfect! This looks good.

mirobo discover

INFO:mirobo.discovery:Discovering devices with mDNS, press any key to quit…
INFO:mirobo.discovery:Found supported ‘AirPurifier’ at 192.168.x.x:54321 (zhimi-airpurifier-v3_miio475587._miio._udp.local.) token: b’xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’

Home Assistant log

2017-09-19 14:47:56 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 271, in async_update
if state.led_brightness:
File “/srv/homeassistant/lib/python3.4/site-packages/mirobo/airpurifier.py”, line 138, in led_brightness
return LedBrightness(self.data[“led_b”])
File “/usr/lib/python3.4/enum.py”, line 222, in call
return cls.new(cls, value)
File “/usr/lib/python3.4/enum.py”, line 457, in new
raise ValueError(“%r is not a valid %s” % (value, cls.name))
ValueError: 10 is not a valid LedBrightness

I will fix it. The other air purifiers just supports a led brightness of bright, dim and off. Your device reports the value “10”. Could you change the brightness of your led by the Hi Home app and provide the output of

mirobo --ip 192.168.x.x --token your-token raw_command  get_prop '["power", "led", "led_b"]'

for the different settings?

ERROR:mirobo.vacuum_cli:Unable to read the stored msgid: [Errno 2] No such file or directory: ‘/tmp/python-mirobo.seq’
Sending cmd get_prop with params [‘power’, ‘led’, ‘led_b’]
[‘on’, ‘off’, 10]

@opalhair It’s possible to control the brightness of the led?

No,only on or off.

Hi, I managed to get the Socket working for Xiaomi Mi Smart Socket Plug. How do I control the USB on the same Xiaomi Mi Smart Socket Plug? It has the same IP, would that be different token code?

No it’s a different command set. I’m preparing the feature right now:

https://github.com/syssi/xiaomiplug/tree/feature/chuangmiv1-support

thanks syssi!

after updating the component and homeassistant to 0.54 the strip plugs are not showed anymore…

2017-09-23 16:43:40 INFO (MainThread) [homeassistant.loader] Loaded switch.xiaomi_plug from custom_components.switch.xiaomi_plug
2017-09-23 16:43:58 INFO (MainThread) [homeassistant.components.switch] Setting up switch.xiaomi_plug
2017-09-23 16:43:58 INFO (MainThread) [custom_components.switch.xiaomi_plug] Initializing with host 192.168.1.136 (token d1993...)
2017-09-23 16:43:59 INFO (MainThread) [custom_components.switch.xiaomi_plug] zimi.powerstrip.v2 1.2.4_50 MW300 initialized
2017-09-23 16:43:59 INFO (MainThread) [homeassistant.components.switch] Setting up switch.xiaomi_plug
2017-09-23 16:43:59 INFO (MainThread) [custom_components.switch.xiaomi_plug] Initializing with host 192.168.1.135 (token cc49a...)
2017-09-23 16:43:59 INFO (MainThread) [custom_components.switch.xiaomi_plug] zimi.powerstrip.v2 1.2.4_50 MW300 initialized
  File "/home/homeassistant/.homeassistant/custom_components/switch/xiaomi_plug.py", line 227, in async_update
  File "/home/homeassistant/.homeassistant/custom_components/switch/xiaomi_plug.py", line 227, in async_update

Please update the custom component to the latest version and make sure python-mirobo was installed correctly. Just tell me if you need more support in detail.

2017-09-25 15:08:29 INFO (Thread-4) [custom_components.switch.chuangmi_ir] Initializing with host 192.168.1.189 (token 48d71...)
2017-09-25 15:08:29 INFO (MainThread) [homeassistant.components.switch] Setting up switch.xiaomi_plug
2017-09-25 15:08:29 INFO (MainThread) [custom_components.switch.xiaomi_plug] Initializing with host 192.168.1.135 (token cc49a...)
2017-09-25 15:08:29 DEBUG (Thread-5) [mirobo.protocol] Unable to decrypt, returning raw bytes.
2017-09-25 15:08:29 DEBUG (Thread-5) [mirobo.device] Got a response: Container:
    data = Container:
        length = 0
        data =  (total 0)
        offset1 = 32
        offset2 = 32
        value =  (total 0)
    header = Container:
        length = 16
        data = !1\x00 \x00\x00\x00\x00\x02\xc4k\x1f\x00:P\xe4 (total 16)
        offset1 = 0
        offset2 = 16
        value = Container:
            length = 32
            unknown = 0
            devtype = 708
            serial = 27423
            ts = 1970-02-14 05:36:36
    checksum = \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (total 16)
2017-09-25 15:08:29 DEBUG (Thread-5) [mirobo.device] Discovered 708 27423 with ts: 1970-02-14 05:36:36, token: b'00000000000000000000000000000000'
2017-09-25 15:08:30 DEBUG (Thread-5) [mirobo.device] 192.168.1.135:54321 >>: {'id': 1, 'params': ['power', 'temperature', 'current'], 'method': 'get_prop'}
2017-09-25 15:08:30 DEBUG (Thread-5) [mirobo.device] 192.168.1.135:54321 (ts: 1970-02-14 05:36:37, id: 1) << {'result': ['on', 49.06, 0.27], 'id': 1}
2017-09-25 15:08:30 DEBUG (MainThread) [custom_components.switch.xiaomi_plug] Got new state: <PlugStatus power=on, temperature=49.06, load_power=29.700000000000003>
2017-09-25 15:08:30 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/switch/xiaomi_plug.py", line 159, in async_update
    ATTR_CURRENT: state.current,
AttributeError: 'PlugStatus' object has no attribute 'current'

component and mirobo on latest versions.

(homeassistant) homeassistant@raspberrypi:~ $ pip3 show python-mirobo
Name: python-mirobo
Version: 0.2.0
Summary: Python library for interfacing with Xiaomi Vacuum cleaner robot
Home-page: https://github.com/rytilahti/python-mirobo
Author: Teemu Rytilahti
Author-email: [email protected]
License: GPLv3
Location: /srv/homeassistant/lib/python3.4/site-packages
Requires: pretty-cron, cryptography, construct, click, zeroconf, typing

Wow. You are right. This cannot work. I have identified the bug.

1 Like