Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Air priefier H3 doasn't work in 0.5.1 #730

Closed
1igeza opened this issue Jun 16, 2020 · 11 comments · Fixed by #745
Closed

Air priefier H3 doasn't work in 0.5.1 #730

1igeza opened this issue Jun 16, 2020 · 11 comments · Fixed by #745
Labels

Comments

@1igeza
Copy link

1igeza commented Jun 16, 2020

In version 0.5.1 Air purifier H3 doasn't work.

root@HomeAssistant:~# miiocli airpurifiermiot --ip 192.168.5.51 --token 6f48a2cc604c61603f42bc31924dd4aa status
Error: {'code': -5001, 'message': 'command error'}

root@HomeAssistant:~# pip3 install python-miio==0.5.0
Collecting python-miio==0.5.0
  Downloading python_miio-0.5.0-py3-none-any.whl (192 kB)
     |████████████████████████████████| 192 kB 1.2 MB/s 
Requirement already satisfied: zeroconf in /usr/local/lib/python3.8/dist-packages (from python-miio==0.5.0) (0.25.1)
Requirement already satisfied: tqdm in /usr/local/lib/python3.8/dist-packages (from python-miio==0.5.0) (4.46.1)
Requirement already satisfied: appdirs in /usr/local/lib/python3.8/dist-packages (from python-miio==0.5.0) (1.4.3)
Requirement already satisfied: netifaces in /usr/local/lib/python3.8/dist-packages (from python-miio==0.5.0) (0.10.9)
Requirement already satisfied: cryptography in /usr/local/lib/python3.8/dist-packages (from python-miio==0.5.0) (2.9.2)
Requirement already satisfied: pytz in /usr/local/lib/python3.8/dist-packages (from python-miio==0.5.0) (2019.3)
Requirement already satisfied: construct in /usr/local/lib/python3.8/dist-packages (from python-miio==0.5.0) (2.10.56)
Requirement already satisfied: click>=7 in /usr/local/lib/python3.8/dist-packages (from python-miio==0.5.0) (7.1.1)
Requirement already satisfied: attrs in /usr/local/lib/python3.8/dist-packages (from python-miio==0.5.0) (19.3.0)
Requirement already satisfied: ifaddr in /usr/local/lib/python3.8/dist-packages (from zeroconf->python-miio==0.5.0) (0.1.6)
Requirement already satisfied: cffi!=1.11.3,>=1.8 in /usr/local/lib/python3.8/dist-packages (from cryptography->python-miio==0.5.0) (1.14.0)
Requirement already satisfied: six>=1.4.1 in /usr/local/lib/python3.8/dist-packages (from cryptography->python-miio==0.5.0) (1.14.0)
Requirement already satisfied: pycparser in /usr/local/lib/python3.8/dist-packages (from cffi!=1.11.3,>=1.8->cryptography->python-miio==0.5.0) (2.20)
Installing collected packages: python-miio
  Attempting uninstall: python-miio
    Found existing installation: python-miio 0.5.1
    Uninstalling python-miio-0.5.1:
      Successfully uninstalled python-miio-0.5.1
Successfully installed python-miio-0.5.0
root@HomeAssistant:~# miiocli airpurifiermiot --ip 192.168.5.51 --token 6f48a2cc604c61603f42bc31924dd4aa status
Power: off
AQI: 2 μg/m³
Average AQI: 9 μg/m³
Humidity: 68 %
Temperature: 19.6 °C
Fan Level: 1
Mode: OperationMode.Auto
LED: True
LED brightness: LedBrightness.Dim
Buzzer: True
Buzzer vol.: None
Child lock: False
Favorite level: 14
Filter life remaining: 92 %
Filter hours used: 266
Use time: 961200 s
Purify volume: 10885 m³
Motor speed: 0 rpm
Filter RFID product id: 0:0:31:31
Filter RFID tag: 80:66:5f:82:21:59:4
Filter type: FilterType.Regular

@ehn
Copy link

ehn commented Jun 22, 2020

Same issue with the Xiaomi Air Purifier 3 (zhimi.airpurifier.ma4):

python-miio        0.5.1
% miiocli -d airpurifier --ip 192.168.2.163 --token XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX info
INFO:miio.cli:Debug mode active
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol:Got a response: Container: 
    data = Container: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x07`\xd2\xcc\x00\r\x9c!' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = unhexlify('0760d2cc')
            ts = 1970-01-11 07:45:37
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 0760d2cc with ts: 1970-01-11 07:45:37, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.2.163:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}
DEBUG:miio.miioprotocol:192.168.2.163:54321 (ts: 1970-01-11 07:45:37, id: 1) << {'id': 1, 'result': {'life': 891937, 'uid': 1703897985, 'model': 'zhimi.airpurifier.ma4', 'token': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'ipflag': 1, 'fw_ver': '2.0.8', 'mcu_fw_ver': '0022', 'miio_ver': '0.0.8', 'hw_ver': 'esp32', 'mmfree': 64064, 'mac': 'XX:XX:XX:XX:XX:XX', 'wifi_fw_ver': 'cef6c09-dirty', 'ap': {'ssid': 'Xxx', 'bssid': 'XX:XX:XX:XX:XX:XX', 'rssi': -68, 'primary': 1}, 'netif': {'localIp': '192.168.2.163', 'mask': '255.255.255.0', 'gw': '192.168.2.1'}}, 'exe_time': 30}
Model: zhimi.airpurifier.ma4
Hardware version: esp32
Firmware version: 2.0.8
Network: {'localIp': '192.168.2.163', 'mask': '255.255.255.0', 'gw': '192.168.2.1'}
AP: {'ssid': 'Xxx', 'bssid': 'XX:XX:XX:XX:XX:XX', 'rssi': -68, 'primary': 1}
% miiocli -d airpurifier --ip 192.168.2.163 --token XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX status
INFO:miio.cli:Debug mode active
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol:Got a response: Container: 
    data = Container: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x07`\xd2\xcc\x00\r\x9c\xa8' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = unhexlify('0760d2cc')
            ts = 1970-01-11 07:47:52
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 0760d2cc with ts: 1970-01-11 07:47:52, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.2.163:54321 >>: {'id': 1, 'method': 'get_prop', 'params': ['power', 'aqi', 'average_aqi', 'humidity', 'temp_dec', 'mode', 'favorite_level', 'filter1_life', 'f1_hour_used', 'use_time', 'motor1_speed', 'motor2_speed', 'purify_volume', 'f1_hour', 'led']}
DEBUG:miio.miioprotocol:192.168.2.163:54321 (ts: 1970-01-11 07:47:52, id: 1) << {'id': 1, 'error': {'code': -5001, 'message': 'command error'}, 'exe_time': 170}
DEBUG:miio.click_common:Exception: {'code': -5001, 'message': 'command error'}
Traceback (most recent call last):
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/click_common.py", line 280, in wrap
    kwargs["result"] = func(*args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/click_common.py", line 245, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/click_common.py", line 193, in call
    return method(*args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/airpurifier.py", line 412, in status
    values = self.get_properties(properties, max_properties=15)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/device.py", line 230, in get_properties
    values.extend(self.send("get_prop", _props[:max_properties]))
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/device.py", line 146, in send
    return self._protocol.send(
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/miioprotocol.py", line 203, in send
    self._handle_error(payload["error"])
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/miioprotocol.py", line 263, in _handle_error
    raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -5001, 'message': 'command error'}
Error: {'code': -5001, 'message': 'command error'}
% miiocli -d airpurifiermiot --ip 192.168.2.163 --token XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX status
INFO:miio.cli:Debug mode active
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol:Got a response: Container: 
    data = Container: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x07`\xd2\xcc\x00\r\xa0\n' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = unhexlify('0760d2cc')
            ts = 1970-01-11 08:02:18
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 0760d2cc with ts: 1970-01-11 08:02:18, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.2.163:54321 >>: {'id': 1, 'method': 'get_prop', 'params': [{'did': 'power', 'siid': 2, 'piid': 2}, {'did': 'fan_level', 'siid': 2, 'piid': 4}, {'did': 'mode', 'siid': 2, 'piid': 5}, {'did': 'humidity', 'siid': 3, 'piid': 7}, {'did': 'temperature', 'siid': 3, 'piid': 8}, {'did': 'aqi', 'siid': 3, 'piid': 6}, {'did': 'filter_life_remaining', 'siid': 4, 'piid': 3}, {'did': 'filter_hours_used', 'siid': 4, 'piid': 5}, {'did': 'buzzer', 'siid': 5, 'piid': 1}, {'did': 'buzzer_volume', 'siid': 5, 'piid': 2}, {'did': 'led_brightness', 'siid': 6, 'piid': 1}, {'did': 'led', 'siid': 6, 'piid': 6}, {'did': 'child_lock', 'siid': 7, 'piid': 1}, {'did': 'favorite_level', 'siid': 10, 'piid': 10}, {'did': 'favorite_rpm', 'siid': 10, 'piid': 7}]}
DEBUG:miio.miioprotocol:192.168.2.163:54321 (ts: 1970-01-11 08:02:19, id: 1) << {'id': 1, 'error': {'code': -5001, 'message': 'command error'}, 'exe_time': 260}
DEBUG:miio.click_common:Exception: {'code': -5001, 'message': 'command error'}
Traceback (most recent call last):
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/click_common.py", line 280, in wrap
    kwargs["result"] = func(*args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/click_common.py", line 245, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/click_common.py", line 193, in call
    return method(*args, **kwargs)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/airpurifier_miot.py", line 300, in status
    for prop in self.get_properties_for_mapping()
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/miot_device.py", line 29, in get_properties_for_mapping
    return self.get_properties(properties, max_properties=15)
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/device.py", line 230, in get_properties
    values.extend(self.send("get_prop", _props[:max_properties]))
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/device.py", line 146, in send
    return self._protocol.send(
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/miioprotocol.py", line 203, in send
    self._handle_error(payload["error"])
  File "/Users/ehn/.pyenv/versions/3.8.3/lib/python3.8/site-packages/miio/miioprotocol.py", line 263, in _handle_error
    raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -5001, 'message': 'command error'}
Error: {'code': -5001, 'message': 'command error'}

@mouth4war
Copy link
Contributor

mouth4war commented Jul 2, 2020

+1 here.

Is "did" meant to be passed for get_properties now? There has been a change in device.py send function that may be responsible.

@rytilahti
Copy link
Owner

@1igeza could you please post both working and non-working with the debug mode activated (-d or --debug)? Do the queries match?

Also, please check the miiocli device info for the device model.

@ehn you are using two different types of devices (airpurifier, airpurifiermiot) for your commands. Does one of those commands work with 0.5.0?

@ehn
Copy link

ehn commented Jul 2, 2020

@ehn you are using two different types of devices (airpurifier, airpurifiermiot) for your commands. Does one of those commands work with 0.5.0?

@rytilahti I'd be happy to give it a try. What's the recommended way to install 0.5.0 next to 0.5.1? I used brew, pyenv and pip to install 0.5.1 on a Mac.

@1igeza
Copy link
Author

1igeza commented Jul 2, 2020

@1igeza could you please post both working and non-working with the debug mode activated (-d or --debug)? Do the queries match?

Also, please check the miiocli device info for the device model.

root@HomeAssistant:~# miiocli -d airpurifiermiot --ip 192.168.5.51 --token 6f48a2cc604c61603f42bc31924dd4aa status
INFO:miio.cli:Debug mode active
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol:Got a response: Container: 
    data = Container: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x10\x1b#\xe3\x00\x02f\x8f' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = unhexlify('101b23e3')
            ts = 1970-01-02 19:42:07
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 101b23e3 with ts: 1970-01-02 19:42:07, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.5.51:54321 >>: {'id': 1, 'method': 'get_properties', 'params': [{'did': 'power', 'siid': 2, 'piid': 2}, {'did': 'fan_level', 'siid': 2, 'piid': 4}, {'did': 'mode', 'siid': 2, 'piid': 5}, {'did': 'humidity', 'siid': 3, 'piid': 7}, {'did': 'temperature', 'siid': 3, 'piid': 8}, {'did': 'aqi', 'siid': 3, 'piid': 6}, {'did': 'filter_life_remaining', 'siid': 4, 'piid': 3}, {'did': 'filter_hours_used', 'siid': 4, 'piid': 5}, {'did': 'buzzer', 'siid': 5, 'piid': 1}, {'did': 'buzzer_volume', 'siid': 5, 'piid': 2}, {'did': 'led_brightness', 'siid': 6, 'piid': 1}, {'did': 'led', 'siid': 6, 'piid': 6}, {'did': 'child_lock', 'siid': 7, 'piid': 1}, {'did': 'favorite_level', 'siid': 10, 'piid': 10}, {'did': 'favorite_rpm', 'siid': 10, 'piid': 7}]}
DEBUG:miio.miioprotocol:192.168.5.51:54321 (ts: 1970-01-02 19:42:08, id: 1) << {'id': 1, 'result': [{'did': 'power', 'siid': 2, 'piid': 2, 'code': 0, 'value': False}, {'did': 'fan_level', 'siid': 2, 'piid': 4, 'code': 0, 'value': 1}, {'did': 'mode', 'siid': 2, 'piid': 5, 'code': 0, 'value': 0}, {'did': 'humidity', 'siid': 3, 'piid': 7, 'code': 0, 'value': 70}, {'did': 'temperature', 'siid': 3, 'piid': 8, 'code': 0, 'value': 23.299999}, {'did': 'aqi', 'siid': 3, 'piid': 6, 'code': 0, 'value': 8}, {'did': 'filter_life_remaining', 'siid': 4, 'piid': 3, 'code': 0, 'value': 92}, {'did': 'filter_hours_used', 'siid': 4, 'piid': 5, 'code': 0, 'value': 266}, {'did': 'buzzer', 'siid': 5, 'piid': 1, 'code': 0, 'value': True}, {'did': 'buzzer_volume', 'siid': 5, 'piid': 2, 'code': -4001}, {'did': 'led_brightness', 'siid': 6, 'piid': 1, 'code': 0, 'value': 1}, {'did': 'led', 'siid': 6, 'piid': 6, 'code': 0, 'value': True}, {'did': 'child_lock', 'siid': 7, 'piid': 1, 'code': 0, 'value': False}, {'did': 'favorite_level', 'siid': 10, 'piid': 10, 'code': 0, 'value': 14}, {'did': 'favorite_rpm', 'siid': 10, 'piid': 7, 'code': 0, 'value': 2150}], 'exe_time': 190}
DEBUG:miio.miioprotocol:192.168.5.51:54321 >>: {'id': 2, 'method': 'get_properties', 'params': [{'did': 'motor_speed', 'siid': 10, 'piid': 8}, {'did': 'use_time', 'siid': 12, 'piid': 1}, {'did': 'purify_volume', 'siid': 13, 'piid': 1}, {'did': 'average_aqi', 'siid': 13, 'piid': 2}, {'did': 'filter_rfid_tag', 'siid': 14, 'piid': 1}, {'did': 'filter_rfid_product_id', 'siid': 14, 'piid': 3}, {'did': 'app_extra', 'siid': 15, 'piid': 1}]}
DEBUG:miio.miioprotocol:192.168.5.51:54321 (ts: 1970-01-02 19:42:08, id: 2) << {'id': 2, 'result': [{'did': 'motor_speed', 'siid': 10, 'piid': 8, 'code': 0, 'value': 0}, {'did': 'use_time', 'siid': 12, 'piid': 1, 'code': 0, 'value': 961200}, {'did': 'purify_volume', 'siid': 13, 'piid': 1, 'code': 0, 'value': 10885}, {'did': 'average_aqi', 'siid': 13, 'piid': 2, 'code': 0, 'value': 9}, {'did': 'filter_rfid_tag', 'siid': 14, 'piid': 1, 'code': 0, 'value': '80:66:5f:82:21:59:4'}, {'did': 'filter_rfid_product_id', 'siid': 14, 'piid': 3, 'code': 0, 'value': '0:0:31:31'}, {'did': 'app_extra', 'siid': 15, 'piid': 1, 'code': 0, 'value': 0}], 'exe_time': 320}
Power: off
AQI: 8 μg/m³
Average AQI: 9 μg/m³
Humidity: 70 %
Temperature: 23.299999 °C
Fan Level: 1
Mode: OperationMode.Auto
LED: True
LED brightness: LedBrightness.Dim
Buzzer: True
Buzzer vol.: None
Child lock: False
Favorite level: 14
Filter life remaining: 92 %
Filter hours used: 266
Use time: 961200 s
Purify volume: 10885 m³
Motor speed: 0 rpm
Filter RFID product id: 0:0:31:31
Filter RFID tag: 80:66:5f:82:21:59:4
Filter type: FilterType.Regular

.....................................................

Successfully installed python-miio-0.5.1 pytz-2019.3
root@HomeAssistant:~# miiocli -d airpurifiermiot --ip 192.168.5.51 --token 6f48a2cc604c61603f42bc31924dd4aa status
INFO:miio.cli:Debug mode active
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol:Got a response: Container: 
    data = Container: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x10\x1b#\xe3\x00\x02g\xae' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = unhexlify('101b23e3')
            ts = 1970-01-02 19:46:54
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 101b23e3 with ts: 1970-01-02 19:46:54, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.5.51:54321 >>: {'id': 1, 'method': 'get_prop', 'params': [{'did': 'power', 'siid': 2, 'piid': 2}, {'did': 'fan_level', 'siid': 2, 'piid': 4}, {'did': 'mode', 'siid': 2, 'piid': 5}, {'did': 'humidity', 'siid': 3, 'piid': 7}, {'did': 'temperature', 'siid': 3, 'piid': 8}, {'did': 'aqi', 'siid': 3, 'piid': 6}, {'did': 'filter_life_remaining', 'siid': 4, 'piid': 3}, {'did': 'filter_hours_used', 'siid': 4, 'piid': 5}, {'did': 'buzzer', 'siid': 5, 'piid': 1}, {'did': 'buzzer_volume', 'siid': 5, 'piid': 2}, {'did': 'led_brightness', 'siid': 6, 'piid': 1}, {'did': 'led', 'siid': 6, 'piid': 6}, {'did': 'child_lock', 'siid': 7, 'piid': 1}, {'did': 'favorite_level', 'siid': 10, 'piid': 10}, {'did': 'favorite_rpm', 'siid': 10, 'piid': 7}]}
DEBUG:miio.miioprotocol:192.168.5.51:54321 (ts: 1970-01-02 19:46:55, id: 1) << {'id': 1, 'error': {'code': -5001, 'message': 'command error'}, 'exe_time': 360}
DEBUG:miio.click_common:Exception: {'code': -5001, 'message': 'command error'}
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/miio/click_common.py", line 280, in wrap
    kwargs["result"] = func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/miio/click_common.py", line 245, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/miio/click_common.py", line 193, in call
    return method(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/miio/airpurifier_miot.py", line 300, in status
    for prop in self.get_properties_for_mapping()
  File "/usr/local/lib/python3.8/dist-packages/miio/miot_device.py", line 29, in get_properties_for_mapping
    return self.get_properties(properties, max_properties=15)
  File "/usr/local/lib/python3.8/dist-packages/miio/device.py", line 230, in get_properties
    values.extend(self.send("get_prop", _props[:max_properties]))
  File "/usr/local/lib/python3.8/dist-packages/miio/device.py", line 146, in send
    return self._protocol.send(
  File "/usr/local/lib/python3.8/dist-packages/miio/miioprotocol.py", line 203, in send
    self._handle_error(payload["error"])
  File "/usr/local/lib/python3.8/dist-packages/miio/miioprotocol.py", line 263, in _handle_error
    raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -5001, 'message': 'command error'}
Error: {'code': -5001, 'message': 'command error'}
root@HomeAssistant:~# 

root@HomeAssistant:~# miiocli airpurifiermiot --ip 192.168.5.51 --token 6f48a2cc604c61603f42bc31924dd4aa info
Model: zhimi.airpurifier.mb3
Hardware version: esp32
Firmware version: 2.0.9
Network: {'localIp': '192.168.5.51', 'mask': '255.255.255.0', 'gw': '192.168.5.1'}
AP: {'ssid': 'Rafal', 'bssid': 'xxxxxxxxxxxxx', 'rssi': -55, 'primary': 6}

@rytilahti
Copy link
Owner

@ehn if you have separate virtual environments, you can simply use pip install to install a specific version (like shown by @1igeza earlier above). However, I hope the linked PR will fix the issue, so you don't really need to do that testing.

@1igeza great, thanks! Looks like some refactoring introduced a regression which caused this bug :-( I created a PR to fix it, please give it a try to see if it is working with that.

@1igeza
Copy link
Author

1igeza commented Jul 2, 2020

I replaced this two changed files and it's working correctly now.

root@HomeAssistant:~# miiocli -d airpurifiermiot --ip 192.168.5.51 --token 6f48a2cc604c61603f42bc31924dd4aa status
INFO:miio.cli:Debug mode active
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol:Got a response: Container: 
    data = Container: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x10\x1b#\xe3\x00\x02r ' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = unhexlify('101b23e3')
            ts = 1970-01-02 20:31:28
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 101b23e3 with ts: 1970-01-02 20:31:28, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.5.51:54321 >>: {'id': 1, 'method': 'get_properties', 'params': [{'did': 'power', 'siid': 2, 'piid': 2}, {'did': 'fan_level', 'siid': 2, 'piid': 4}, {'did': 'mode', 'siid': 2, 'piid': 5}, {'did': 'humidity', 'siid': 3, 'piid': 7}, {'did': 'temperature', 'siid': 3, 'piid': 8}, {'did': 'aqi', 'siid': 3, 'piid': 6}, {'did': 'filter_life_remaining', 'siid': 4, 'piid': 3}, {'did': 'filter_hours_used', 'siid': 4, 'piid': 5}, {'did': 'buzzer', 'siid': 5, 'piid': 1}, {'did': 'buzzer_volume', 'siid': 5, 'piid': 2}, {'did': 'led_brightness', 'siid': 6, 'piid': 1}, {'did': 'led', 'siid': 6, 'piid': 6}, {'did': 'child_lock', 'siid': 7, 'piid': 1}, {'did': 'favorite_level', 'siid': 10, 'piid': 10}, {'did': 'favorite_rpm', 'siid': 10, 'piid': 7}]}
DEBUG:miio.miioprotocol:192.168.5.51:54321 (ts: 1970-01-02 20:31:29, id: 1) << {'id': 1, 'result': [{'did': 'power', 'siid': 2, 'piid': 2, 'code': 0, 'value': False}, {'did': 'fan_level', 'siid': 2, 'piid': 4, 'code': 0, 'value': 1}, {'did': 'mode', 'siid': 2, 'piid': 5, 'code': 0, 'value': 0}, {'did': 'humidity', 'siid': 3, 'piid': 7, 'code': 0, 'value': 70}, {'did': 'temperature', 'siid': 3, 'piid': 8, 'code': 0, 'value': 23.299999}, {'did': 'aqi', 'siid': 3, 'piid': 6, 'code': 0, 'value': 9}, {'did': 'filter_life_remaining', 'siid': 4, 'piid': 3, 'code': 0, 'value': 92}, {'did': 'filter_hours_used', 'siid': 4, 'piid': 5, 'code': 0, 'value': 266}, {'did': 'buzzer', 'siid': 5, 'piid': 1, 'code': 0, 'value': True}, {'did': 'buzzer_volume', 'siid': 5, 'piid': 2, 'code': -4001}, {'did': 'led_brightness', 'siid': 6, 'piid': 1, 'code': 0, 'value': 1}, {'did': 'led', 'siid': 6, 'piid': 6, 'code': 0, 'value': True}, {'did': 'child_lock', 'siid': 7, 'piid': 1, 'code': 0, 'value': False}, {'did': 'favorite_level', 'siid': 10, 'piid': 10, 'code': 0, 'value': 14}, {'did': 'favorite_rpm', 'siid': 10, 'piid': 7, 'code': 0, 'value': 2150}], 'exe_time': 250}
DEBUG:miio.miioprotocol:192.168.5.51:54321 >>: {'id': 2, 'method': 'get_properties', 'params': [{'did': 'motor_speed', 'siid': 10, 'piid': 8}, {'did': 'use_time', 'siid': 12, 'piid': 1}, {'did': 'purify_volume', 'siid': 13, 'piid': 1}, {'did': 'average_aqi', 'siid': 13, 'piid': 2}, {'did': 'filter_rfid_tag', 'siid': 14, 'piid': 1}, {'did': 'filter_rfid_product_id', 'siid': 14, 'piid': 3}, {'did': 'app_extra', 'siid': 15, 'piid': 1}]}
DEBUG:miio.miioprotocol:192.168.5.51:54321 (ts: 1970-01-02 20:31:29, id: 2) << {'id': 2, 'result': [{'did': 'motor_speed', 'siid': 10, 'piid': 8, 'code': 0, 'value': 0}, {'did': 'use_time', 'siid': 12, 'piid': 1, 'code': 0, 'value': 961200}, {'did': 'purify_volume', 'siid': 13, 'piid': 1, 'code': 0, 'value': 10885}, {'did': 'average_aqi', 'siid': 13, 'piid': 2, 'code': 0, 'value': 9}, {'did': 'filter_rfid_tag', 'siid': 14, 'piid': 1, 'code': 0, 'value': '80:66:5f:82:21:59:4'}, {'did': 'filter_rfid_product_id', 'siid': 14, 'piid': 3, 'code': 0, 'value': '0:0:31:31'}, {'did': 'app_extra', 'siid': 15, 'piid': 1, 'code': 0, 'value': 0}], 'exe_time': 320}
Power: off
AQI: 9 μg/m³
Average AQI: 9 μg/m³
Humidity: 70 %
Temperature: 23.299999 °C
Fan Level: 1
Mode: OperationMode.Auto
LED: True
LED brightness: LedBrightness.Dim
Buzzer: True
Buzzer vol.: None
Child lock: False
Favorite level: 14
Filter life remaining: 92 %
Filter hours used: 266
Use time: 961200 s
Purify volume: 10885 m³
Motor speed: 0 rpm
Filter RFID product id: 0:0:31:31
Filter RFID tag: 80:66:5f:82:21:59:4
Filter type: FilterType.Regular

@rytilahti
Copy link
Owner

Great, let's get it merged then. I'll see if I can prepare a release containing the fix next weekend.

rytilahti added a commit that referenced this issue Jul 2, 2020
This regression was caused by clean-up done in #657

Fixes #730
@ehn
Copy link

ehn commented Jul 3, 2020

#745 fixed the issue for me as well. Thanks!

@matteos1
Copy link

matteos1 commented Jul 3, 2020

How could I fix the problem in hassio? Air purifier 3 h and home assistant 0.105

@pkishino
Copy link

pkishino commented Jul 8, 2020

How could I fix the problem in hassio? Air purifier 3 h and home assistant 0.105

You need to update..105 is way old

xvlady pushed a commit to xvlady/python-miio that referenced this issue May 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants