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

Fetching non-readables still return a success but no value (dreame.vacuum.mc1808)

Open Lixander78 opened this issue 2 years ago • 11 comments

Describe the bug Trying to get status of the device with miiocli it generates a runtime error bug report

Version information (please complete the following information):

  • OS: Windows & Linux
  • python-miio: miiocli, version 0.5.11

Device information: If the issue is specific to a device [Use miiocli device --ip <ip address> --token <token> info]: Model: dreame.vacuum.mc1808 Hardware version: Linux Firmware version: 4.3.3_1122

To Reproduce Steps to reproduce the behavior: 1. run command miiocli dreamevacuum --ip 192.168.1.217 --token xxxxxxxxxxxxxxxxxxxxxxxxxxx status , generates error bellow: File "...\lib\site-packages\miio\integrations\vacuum\dreame\dreamevacuum_miot.py", line 447, in status for prop in self.get_properties_for_mapping(max_properties=10) File "...\lib\site-packages\miio\integrations\vacuum\dreame\dreamevacuum_miot.py", line 447, in for prop in self.get_properties_for_mapping(max_properties=10) KeyError: 'value'

Expected behavior Status of device to be shown like this: Battery level: 100 Brush life level: 75 Brush left time: 225 Charging state: Charging2 Cleaning mode: Default Device fault: NoFaults Device status: Idle Filter left level: 75 Filter life level: 50....

Console output If applicable, add console output to help explain your problem. If the issue is about communication with a specific device, consider including the output using the --debug flag.

Proposed solution this have worked for me to solve the error. replace line: prop["did"]: prop["value"] if prop["code"] == 0 else None with line: prop["did"]: prop.get("value", "empty")

Lixander78 avatar Mar 28 '22 18:03 Lixander78

@rytilahti I have the same problem and can confirm that this fix works. Is it valid fix? Can we actually implement it?

chekalsky avatar Jul 24 '22 22:07 chekalsky

Could you please use --debug and show how the response payload looks like?

rytilahti avatar Jul 25 '22 12:07 rytilahti

See the attached file with the output with the -d flag

miiocli_debug.txt

Lixander78 avatar Jul 26 '22 12:07 Lixander78

Thanks! Looks like {'siid': 18, 'did': 'first_clean_time', 'piid': 12, 'code': 0}, is the culprit, I'll look into getting it fixed soon.

rytilahti avatar Jul 27 '22 16:07 rytilahti

Sorry for the delay, life happened. The linked PR should fix this for good, could you please give it a try? If you also have some other miot devices, it would be great if you could confirm that they keep working as expected, thanks!

rytilahti avatar Sep 14 '22 21:09 rytilahti

Still the same. 0.5.12.

grkhr avatar Sep 27 '22 10:09 grkhr

There has been no new release with the fix, so you need to install the git master to test this.

rytilahti avatar Sep 27 '22 16:09 rytilahti

Sure, I've tried already, still the same.

>> pip install git+https://github.com/rytilahti/python-miio
>> miiocli dreamevacuum --ip XXX --token XXX status

...
    prop["did"]: prop["value"] if prop["code"] == 0 else None
KeyError: 'value'

grkhr avatar Sep 28 '22 13:09 grkhr

Uhh, that's odd but without seeing more information it is hard to know what is the cause. My initial assumption was that the original issue was due to non-readable (actions, write-only properties) were part of the request, and the firmware did not handle the error reporting properly.

Cleaning up get_properties and get_properties_for_mapping has been a long due, so I opened this to keep track on that. The methods to be used by integration should rather return pre-filtered dictionaries that can be directly passed to the status containers.

rytilahti avatar Oct 19 '22 00:10 rytilahti

@Lixander78 Thanks for the workaround, works like a charm here 👍

bdaase avatar Nov 03 '22 21:11 bdaase

@rytilahti This is also an issue for my vacuum... The first_clean_time prop does not have a value. It is also not filtered out by this PR. Please can we get an update here.

BlindChickens avatar Jan 12 '23 21:01 BlindChickens