python-miio
python-miio copied to clipboard
get_properties of xiaomi.vacuum.c107 timeout falsely if max_properties >= 4 when get property `vacuum-map:clean-record`
Describe the bug
the get_properties() call raises timeout if max_properties >= 4 (xiaomi.vacuum.c107).
Version information (please complete the following information):
- OS: Linux nixos 6.8.12
- python-miio: miiocli, version 0.6.0.dev0 (rev 35b1ab22ff0716a3507b9703c5f790d389793d38)
Device information:
- Model: xiaomi.vacuum.c107
- Hardware version: Linux
- Firmware version: 4.3.9_0106
To Reproduce Run
miiocli genericmiot --ip <ip> --token <token> status
fails.
Changing the max_properties in status() call from 10 to 1,2,3 will fix this. max_properties >= 4 will cause the error.
from miio import DeviceFactory, GenericMiot
from miio.integrations.genericmiot.status import GenericMiotStatus
from typing import cast
dev = cast(GenericMiot, DeviceFactory.create("192.168.xxx.xxx", "xxx"))
if not dev._initialized:
dev._initialize_descriptors()
dev.timeout = 10000
# max_properties = 3 # succeed
max_properties = 4 # fail
response = dev.get_properties(
dev._status_query, property_getter="get_properties", max_properties=max_properties
)
status = GenericMiotStatus(response, dev)
Above code always fails at 22nd loop of
while _props:
values.extend(self.send(property_getter, _props[:max_properties]))
if max_properties is None:
break
_props[:] = _props[max_properties:]
which is processing
[{'siid': 10, 'piid': 3, 'did': 'vacuum-map:clean-record'}, {'siid': 10, 'piid': 4, 'did': 'vacuum-map:vacuum-position'}, {'siid': 10, 'piid': 5, 'did': 'vacuum-map:map-management'}, {'siid': 10, 'piid': 6, 'did': 'vacuum-map:current-map-id'}]
changing max_properties to 5, it fails at 17th loop when processing
[{'siid': 9, 'piid': 1, 'did': 'mop:mop-life-level'}, {'siid': 9, 'piid': 2, 'did': 'mop:mop-left-time'}, {'siid': 10, 'piid': 1, 'did': 'vacuum-map:map-obj-name'}, {'siid': 10, 'piid': 2, 'did': 'vacuum-map:trajectory-obj-name'}, {'siid': 10, 'piid': 3, 'did': 'vacuum-map:clean-record'}]
so the cause should be
{'siid': 10, 'piid': 3, 'did': 'vacuum-map:clean-record'}
Expected behavior Should not raise a timeout error
Console output
Got error when receiving: timed out
Traceback (most recent call last):
File "/nix/store/j8h1i152rh4z58i78lfq2nnc7qbk69wb-python3-3.12.3-env/lib/python3.12/site-packages/miio/miioprotocol.py", line 200, in send
data, addr = s.recvfrom(4096)
^^^^^^^^^^^^^^^^
TimeoutError: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/nix/store/j8h1i152rh4z58i78lfq2nnc7qbk69wb-python3-3.12.3-env/lib/python3.12/site-packages/miio/miioprotocol.py", line 200, in send
data, addr = s.recvfrom(4096)
^^^^^^^^^^^^^^^^
TimeoutError: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/nix/store/j8h1i152rh4z58i78lfq2nnc7qbk69wb-python3-3.12.3-env/lib/python3.12/site-packages/miio/miioprotocol.py", line 200, in send
data, addr = s.recvfrom(4096)
^^^^^^^^^^^^^^^^
TimeoutError: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/nix/store/j8h1i152rh4z58i78lfq2nnc7qbk69wb-python3-3.12.3-env/lib/python3.12/site-packages/miio/miioprotocol.py", line 200, in send
data, addr = s.recvfrom(4096)
^^^^^^^^^^^^^^^^
TimeoutError: timed out
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/nix/store/c7ycrgwv039nqglbif98yggx211sdbcl-python3-3.12.3/lib/python3.12/runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/c7ycrgwv039nqglbif98yggx211sdbcl-python3-3.12.3/lib/python3.12/runpy.py", line 88, in _run_code
exec(code, run_globals)
File "/home/antares/.vscode/extensions/ms-python.debugpy-2024.6.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
cli.main()
File "/home/antares/.vscode/extensions/ms-python.debugpy-2024.6.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/home/antares/.vscode/extensions/ms-python.debugpy-2024.6.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
runpy.run_path(target, run_name="__main__")
File "/home/antares/.vscode/extensions/ms-python.debugpy-2024.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/antares/.vscode/extensions/ms-python.debugpy-2024.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/home/antares/.vscode/extensions/ms-python.debugpy-2024.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "/home/antares/Documents/GitHub/scripts/miiotest.py", line 11, in <module>
response = dev.get_properties(
^^^^^^^^^^^^^^^^^^^
File "/nix/store/j8h1i152rh4z58i78lfq2nnc7qbk69wb-python3-3.12.3-env/lib/python3.12/site-packages/miio/device.py", line 241, in get_properties
values.extend(self.send(property_getter, _props[:max_properties]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/j8h1i152rh4z58i78lfq2nnc7qbk69wb-python3-3.12.3-env/lib/python3.12/site-packages/miio/device.py", line 98, in send
return self._protocol.send(
^^^^^^^^^^^^^^^^^^^^
File "/nix/store/j8h1i152rh4z58i78lfq2nnc7qbk69wb-python3-3.12.3-env/lib/python3.12/site-packages/miio/miioprotocol.py", line 240, in send
return self.send(
^^^^^^^^^^
File "/nix/store/j8h1i152rh4z58i78lfq2nnc7qbk69wb-python3-3.12.3-env/lib/python3.12/site-packages/miio/miioprotocol.py", line 240, in send
return self.send(
^^^^^^^^^^
File "/nix/store/j8h1i152rh4z58i78lfq2nnc7qbk69wb-python3-3.12.3-env/lib/python3.12/site-packages/miio/miioprotocol.py", line 240, in send
return self.send(
^^^^^^^^^^
File "/nix/store/j8h1i152rh4z58i78lfq2nnc7qbk69wb-python3-3.12.3-env/lib/python3.12/site-packages/miio/miioprotocol.py", line 248, in send
raise DeviceException("No response from the device") from ex
miio.exceptions.DeviceException: No response from the device