python-miio icon indicating copy to clipboard operation
python-miio copied to clipboard

dmaker.airfresh.t2017 not accessible via LAN

Open ursval opened this issue 2 years ago • 2 comments

I have a dmaker.airfresh.t2017 (xiaomi MJXFJ-300-G1).

After token retrieval I cut off any internet access from this airfresh using router's capabilities. This is the error I got when tried to get status from the device using miiocti

$ miiocli airfresht2017 --ip <ip> --token <token> status
Error: {'code': -9999, 'message': 'user ack timeout'}

Any control attempts (turn on/off the device, display) resulted in same error

However, info can be recieved

This issue is definitely caused by internet blockade. If I allow internet access, then status retrieval can be done

$ miiocli -d airfresht2017 --ip <ip> --token <token> status
<debug output>
Power: on
Mode: OperationMode.Sleep
PM2.5: 0
CO2: 530
Temperature: 9
Favorite speed: 300
Control speed: 60
Dust filter life: 99 %, 89 days
PTC: False
PTC status: False
Child lock: False
Buzzer: True
Display: False

The question is why I am not able to get status from airfresh when it is offline?

Version information

  • Linux Fedora 5.8.18-100.fc31.x86_64
  • python-miio: 0.5.11

Device information:

  • Model: dmaker.airfresh.t2017
  • Hardware version: esp32
  • Firmware version: 2.2.1

To Reproduce

  1. Setup device
  2. Cut off internet access
  3. Try to get device status

Expected behavior State is returned (same as with internet access)

Console output Additional info (failed status command with debug output)

$ miiocli -d airfresht2017 --ip 192.168.50.50 --token <token> status
INFO:miio.cli:Debug mode active
DEBUG:miio.click_common:Unknown model, trying autodetection. None None
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\x07f\xf0\x1d\x00\x00\x00\xac' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = unhexlify('0766f01d')
            ts = 1970-01-01 00:02: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 0766f01d with ts: 1970-01-01 00:02:52, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.50.50:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}
DEBUG:miio.miioprotocol:192.168.50.50:54321 (ts: 1970-01-01 00:02:53, id: 1) << {'id': 1, 'result': {'life': 173, 'uid': 2663313642, 'model': 'dmaker.airfresh.t2017', 'token': '<token>', 'ipflag': 1, 'fw_ver': '2.2.1', 'mcu_fw_ver': '0016', 'miio_ver': '0.0.9', 'hw_ver': 'esp32', 'mmfree': 48912, 'mac': '04:CF:8C:1A:63:34', 'wifi_fw_ver': '', 'ap': {'ssid': 'Home Network', 'bssid': 'F0:2F:74:E3:5A:40', 'rssi': -47, 'primary': 6}, 'netif': {'localIp': '192.168.50.50', 'mask': '255.255.255.0', 'gw': '192.168.50.1'}}, 'exe_time': 50}
DEBUG:miio.device:Detected model dmaker.airfresh.t2017
DEBUG:miio.miioprotocol:192.168.50.50:54321 >>: {'id': 2, 'method': 'get_prop', 'params': ['power', 'mode', 'pm25', 'co2', 'temperature_outside', 'favourite_speed', 'control_speed', 'ptc_on', 'ptc_status', 'child_lock', 'sound', 'display', 'filter_intermediate', 'filter_inter_day', 'filter_efficient']}
DEBUG:miio.miioprotocol:192.168.50.50:54321 (ts: 1970-01-01 00:02:57, id: 2) << {'id': 2, 'error': {'code': -9999, 'message': 'user ack timeout'}, 'exe_time': 4010}
DEBUG:miio.click_common:Exception: {'code': -9999, 'message': 'user ack timeout'}
Traceback (most recent call last):
  File "/path/to/venv/venv/lib64/python3.7/site-packages/miio/click_common.py", line 51, in __call__
    return self.main(*args, **kwargs)
  File "/path/to/venv/venv/lib64/python3.7/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/path/to/venv/venv/lib64/python3.7/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/path/to/venv/venv/lib64/python3.7/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/path/to/venv/venv/lib64/python3.7/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/path/to/venv/venv/lib64/python3.7/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/path/to/venv/venv/lib64/python3.7/site-packages/miio/click_common.py", line 300, in wrap
    kwargs["result"] = func(*args, **kwargs)
  File "/path/to/venv/venv/lib64/python3.7/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/path/to/venv/venv/lib64/python3.7/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/path/to/venv/venv/lib64/python3.7/site-packages/miio/click_common.py", line 265, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/path/to/venv/venv/lib64/python3.7/site-packages/miio/click_common.py", line 212, in call
    return method(*args, **kwargs)
  File "/path/to/venv/venv/lib64/python3.7/site-packages/miio/click_common.py", line 179, in _wrap
    return func(self, *args, **kwargs)
  File "/path/to/venv/venv/lib64/python3.7/site-packages/miio/airfresh_t2017.py", line 254, in status
    values = self.get_properties(properties, max_properties=15)
  File "/path/to/venv/venv/lib64/python3.7/site-packages/miio/device.py", line 232, in get_properties
    values.extend(self.send(property_getter, _props[:max_properties]))
  File "/path/to/venv/venv/lib64/python3.7/site-packages/miio/device.py", line 107, in send
    command, parameters, retry_count, extra_parameters=extra_parameters
  File "/path/to/venv/venv/lib64/python3.7/site-packages/miio/miioprotocol.py", line 214, in send
    self._handle_error(payload["error"])
  File "/path/to/venv/venv/lib64/python3.7/site-packages/miio/miioprotocol.py", line 274, in _handle_error
    raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -9999, 'message': 'user ack timeout'}
Error: {'code': -9999, 'message': 'user ack timeout'}

Thanks!

ursval avatar Apr 14 '22 22:04 ursval

I tried setting up micloudfaker (https://github.com/unrelentingtech/micloudfaker). I see logspam on port 8053, but still can not get status info from device with exactly same result (user ack timeout )

Logspam:

UDP client hello
UDP 0x766f01d ping
....

ursval avatar Apr 19 '22 13:04 ursval

I haven't found any workarounds, so I switched to openHAB where described setup (blocked internet access for xiaomi device) works right out of the box. I guess it proves that there is some bug in python-miio

UPD: Conducted another experiment: connected openHAB and xiaomi to another router (without any connection to global network) and xiaomi does not respond to control commands. Guess, problem is more dmaker.airfresh.t2017 - related then python-miio - related, but still, if anyone has solutions to my problem, welcome)

ursval avatar Apr 19 '22 15:04 ursval