rytilahti / python-miio

Python library & console tool for controlling Xiaomi smart appliances
https://python-miio.readthedocs.io
GNU General Public License v3.0
3.82k stars 563 forks source link

zhimi.humidifier.ca4 seems to no longer work #1631

Closed Kurairaito closed 1 year ago

Kurairaito commented 1 year ago

Describe the bug I can't find any command that support my zhimi.humidifier.ca4 but the readme clearly state that it is supported

Version information (please complete the following information):

Device information: If the issue is specific to a device [Use miiocli device --ip <ip address> --token <token> info]:

To Reproduce Steps to reproduce the behavior: miiocli airhumidifier --ip $MIHUMI_IP --token $MIHUMI_TOKEN status miiocli airhumidifierca1 --ip $MIHUMI_IP --token $MIHUMI_TOKEN status miiocli airhumidifiercb1 --ip $MIHUMI_IP --token $MIHUMI_TOKEN status miiocli airhumidifierjsq --ip $MIHUMI_IP --token $MIHUMI_TOKEN status miiocli airhumidifiermjjsq --ip $MIHUMI_IP --token $MIHUMI_TOKEN status returns : Error: {'code': -5001, 'message': 'command error'}

Expected behavior Should get an actual answer with at least one command as device is considered supported.

Console output

miiocli --debug airhumidifier --ip $MIHUMI_IP --token $MIHUMI_TOKEN 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\x13\xf0\xc4\xc6\x00\x00\x12\xcf' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = unhexlify('13f0c4c6')
            ts = 1970-01-01 01:20:15
        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 13f0c4c6 with ts: 1970-01-01 01:20:15, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.2.23:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}
DEBUG:miio.miioprotocol:192.168.2.23:54321 (ts: 1970-01-01 01:20:15, id: 1) << {'id': 1, 'result': {'life': 4815, 'model': 'zhimi.humidifier.ca4', 'token': 'XXXX', 'ipflag': 1, 'fw_ver': '2.2.6', 'mcu_fw_ver': '0017', 'miio_ver': '0.0.9', 'hw_ver': 'esp32', 'mmfree': 64580, 'min_mmfree': 56748, 'mac': '64:90:C1:93:46:99', 'wifi_fw_ver': '61d9af5fc', 'ap': {'ssid': 'XXXX', 'bssid': 'XXXX', 'rssi': -25, 'primary': 11}, 'netif': {'localIp': '192.168.2.23', 'mask': '255.255.255.0', 'gw': '192.168.2.254'}, 'uid': 1808747009, 'ipv6': True, 'config_type': 'app'}, 'exe_time': 10}
DEBUG:miio.miioprotocol:192.168.2.23:54321 >>: {'id': 2, 'method': 'get_prop', 'params': ['power', 'mode', 'humidity', 'buzzer', 'led_b', 'child_lock', 'limit_hum', 'use_time', 'hw_version', 'temp_dec', 'trans_level', 'button_pressed']}
DEBUG:miio.miioprotocol:192.168.2.23:54321 (ts: 1970-01-01 01:20:15, id: 2) << {'id': 2, 'error': {'code': -5001, 'message': 'command error'}, 'exe_time': 160}
DEBUG:miio.click_common:Exception: {'code': -5001, 'message': 'command error'}
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 280, in wrap
    kwargs["result"] = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 245, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 193, in call
    return method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/airhumidifier.py", line 315, in status
    values.extend(self.send("get_prop", _props[:_props_per_request]))
  File "/usr/lib/python3/dist-packages/miio/device.py", line 124, in send
    return self._protocol.send(command, parameters, retry_count)
  File "/usr/lib/python3/dist-packages/miio/miioprotocol.py", line 196, in send
    raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -5001, 'message': 'command error'}
Error: {'code': -5001, 'message': 'command error'}
miiocli --debug airhumidifierca1 --ip $MIHUMI_IP --token $MIHUMI_TOKEN 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\x13\xf0\xc4\xc6\x00\x00\x13"' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = unhexlify('13f0c4c6')
            ts = 1970-01-01 01:21:38
        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 13f0c4c6 with ts: 1970-01-01 01:21:38, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.2.23:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}
DEBUG:miio.miioprotocol:192.168.2.23:54321 (ts: 1970-01-01 01:21:38, id: 1) << {'id': 1, 'result': {'life': 4898, 'model': 'zhimi.humidifier.ca4', 'token': 'XXXX', 'ipflag': 1, 'fw_ver': '2.2.6', 'mcu_fw_ver': '0017', 'miio_ver': '0.0.9', 'hw_ver': 'esp32', 'mmfree': 64580, 'min_mmfree': 56748, 'mac': '64:90:C1:93:46:99', 'wifi_fw_ver': '61d9af5fc', 'ap': {'ssid': 'XXXX', 'bssid': 'XXXX', 'rssi': -26, 'primary': 11}, 'netif': {'localIp': '192.168.2.23', 'mask': '255.255.255.0', 'gw': '192.168.2.254'}, 'uid': 1808747009, 'ipv6': True, 'config_type': 'app'}, 'exe_time': 10}
DEBUG:miio.miioprotocol:192.168.2.23:54321 >>: {'id': 2, 'method': 'get_prop', 'params': ['power']}
DEBUG:miio.miioprotocol:192.168.2.23:54321 (ts: 1970-01-01 01:21:38, id: 2) << {'id': 2, 'error': {'code': -5001, 'message': 'command error'}, 'exe_time': 90}
DEBUG:miio.click_common:Exception: {'code': -5001, 'message': 'command error'}
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 280, in wrap
    kwargs["result"] = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 245, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 193, in call
    return method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/airhumidifier.py", line 315, in status
    values.extend(self.send("get_prop", _props[:_props_per_request]))
  File "/usr/lib/python3/dist-packages/miio/device.py", line 124, in send
    return self._protocol.send(command, parameters, retry_count)
  File "/usr/lib/python3/dist-packages/miio/miioprotocol.py", line 196, in send
    raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -5001, 'message': 'command error'}
Error: {'code': -5001, 'message': 'command error'}
miiocli --debug airhumidifiercb1 --ip $MIHUMI_IP --token $MIHUMI_TOKEN 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\x13\xf0\xc4\xc6\x00\x00\x13]' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = unhexlify('13f0c4c6')
            ts = 1970-01-01 01:22: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 13f0c4c6 with ts: 1970-01-01 01:22:37, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.2.23:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}
DEBUG:miio.miioprotocol:192.168.2.23:54321 (ts: 1970-01-01 01:22:37, id: 1) << {'id': 1, 'result': {'life': 4957, 'model': 'zhimi.humidifier.ca4', 'token': 'XXXX', 'ipflag': 1, 'fw_ver': '2.2.6', 'mcu_fw_ver': '0017', 'miio_ver': '0.0.9', 'hw_ver': 'esp32', 'mmfree': 64580, 'min_mmfree': 56748, 'mac': '64:90:C1:93:46:99', 'wifi_fw_ver': '61d9af5fc', 'ap': {'ssid': 'XXXX', 'bssid': 'XXXX', 'rssi': -25, 'primary': 11}, 'netif': {'localIp': '192.168.2.23', 'mask': '255.255.255.0', 'gw': '192.168.2.254'}, 'uid': 1808747009, 'ipv6': True, 'config_type': 'app'}, 'exe_time': 10}
DEBUG:miio.miioprotocol:192.168.2.23:54321 >>: {'id': 2, 'method': 'get_prop', 'params': ['power']}
DEBUG:miio.miioprotocol:192.168.2.23:54321 (ts: 1970-01-01 01:22:37, id: 2) << {'id': 2, 'error': {'code': -5001, 'message': 'command error'}, 'exe_time': 40}
DEBUG:miio.click_common:Exception: {'code': -5001, 'message': 'command error'}
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 280, in wrap
    kwargs["result"] = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 245, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 193, in call
    return method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/airhumidifier.py", line 315, in status
    values.extend(self.send("get_prop", _props[:_props_per_request]))
  File "/usr/lib/python3/dist-packages/miio/device.py", line 124, in send
    return self._protocol.send(command, parameters, retry_count)
  File "/usr/lib/python3/dist-packages/miio/miioprotocol.py", line 196, in send
    raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -5001, 'message': 'command error'}
Error: {'code': -5001, 'message': 'command error'}
miiocli --debug airhumidifierjsq --ip $MIHUMI_IP --token $MIHUMI_TOKEN 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\x13\xf0\xc4\xc6\x00\x00\x13x' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = unhexlify('13f0c4c6')
            ts = 1970-01-01 01:23:04
        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 13f0c4c6 with ts: 1970-01-01 01:23:04, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.2.23:54321 >>: {'id': 1, 'method': 'get_props', 'params': []}
DEBUG:miio.miioprotocol:192.168.2.23:54321 (ts: 1970-01-01 01:23:04, id: 1) << {'id': 1, 'error': {'code': -5001, 'message': 'command error'}, 'exe_time': 120}
DEBUG:miio.click_common:Exception: {'code': -5001, 'message': 'command error'}
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 280, in wrap
    kwargs["result"] = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 245, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 193, in call
    return method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/airhumidifier_jsq.py", line 193, in status
    values = self.send("get_props")
  File "/usr/lib/python3/dist-packages/miio/device.py", line 124, in send
    return self._protocol.send(command, parameters, retry_count)
  File "/usr/lib/python3/dist-packages/miio/miioprotocol.py", line 196, in send
    raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -5001, 'message': 'command error'}
Error: {'code': -5001, 'message': 'command error'}
miiocli --debug airhumidifiermjjsq --ip $MIHUMI_IP --token $MIHUMI_TOKEN 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\x13\xf0\xc4\xc6\x00\x00\x13\x9b' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = unhexlify('13f0c4c6')
            ts = 1970-01-01 01:23:39
        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 13f0c4c6 with ts: 1970-01-01 01:23:39, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.2.23:54321 >>: {'id': 1, 'method': 'get_prop', 'params': ['OnOff_State']}
DEBUG:miio.miioprotocol:192.168.2.23:54321 (ts: 1970-01-01 01:23:39, id: 1) << {'id': 1, 'error': {'code': -5001, 'message': 'command error'}, 'exe_time': 160}
DEBUG:miio.click_common:Exception: {'code': -5001, 'message': 'command error'}
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 280, in wrap
    kwargs["result"] = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 245, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/click_common.py", line 193, in call
    return method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/miio/airhumidifier_mjjsq.py", line 173, in status
    values.extend(self.send("get_prop", _props[:1]))
  File "/usr/lib/python3/dist-packages/miio/device.py", line 124, in send
    return self._protocol.send(command, parameters, retry_count)
  File "/usr/lib/python3/dist-packages/miio/miioprotocol.py", line 196, in send
    raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -5001, 'message': 'command error'}
Error: {'code': -5001, 'message': 'command error'}
Kurairaito commented 1 year ago

Well I tried in the real environment with the V0.5.12 and with command airhumidifiermiot it actually return real values.

I'm dumb, but it can help others.

Tldr, Ubuntu version is out of date

rytilahti commented 1 year ago

Glad you got it working, I created #1633 as a todo to make it easier to find out which command to use.