rytilahti / python-miio

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

get_properties method does not work for multiply items for Air Humidifier v2 and for temperature #861

Open alive-corpse opened 3 years ago

alive-corpse commented 3 years ago

Describe the bug I can't get list of properties using get_properties method, also temperature request always returning null instead of value for Air Humidifier v2:

>>> import miio
>>> hum=miio.AirHumidifierCA1(ip='10.11.11.190', token="f54f5ba9640c964e27083fd9cec19a49", lazy_discover=False, debug=1)
>>> hum.info()
zhimi.humidifier.ca1 v2.0.6 (04:CF:8C:AE:7D:71) @ 10.11.11.190 - token: f54f5ba9640c964e27083fd9cec19a49
>>> hum.status()
<AirHumidiferStatus power=off, mode=OperationMode.High, temperature=22.6, humidity=43%, led_brightness=LedBrightness.Off, buzzer=False, child_lock=False, target_humidity=70%, trans_level=
None, motor_speed=0, depth=125, dry=True, use_time=5730898, hardware_version=0001, button_pressed=None, strong_mode_enabled=False, firmware_version_major=2.0.6, firmware_version_minor=0>
>>> 
>>> hum.get_properties(['humidity'])
[42]
>>> hum.get_properties(['temperature'])
['null']
>>> hum.get_properties(['power'])
['off']
>>> hum.get_properties(['power', 'humidity'])
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    hum.get_properties(['power', 'humidity'])
  File "/home/corpse/temp/miio/python-miio/miio/device.py", line 232, in get_properties
    values.extend(self.send(property_getter, _props[:max_properties]))
  File "/home/corpse/temp/miio/python-miio/miio/device.py", line 143, in send
    return self._protocol.send(
  File "/home/corpse/temp/miio/python-miio/miio/miioprotocol.py", line 213, in send
    self._handle_error(payload["error"])
  File "/home/corpse/temp/miio/python-miio/miio/miioprotocol.py", line 273, in _handle_error
    raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -9999, 'message': 'user ack timeout'}

Version information (please complete the following information):

First configuratoin:

Second configuration:

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

To Reproduce Steps to reproduce the behavior:

  1. pip3 install python-miio
  2. I've put code example at the beginnig of message.

Expected behavior

  1. hum.get_properties(['temperature']) should return float value instead of int
  2. hum.get_properties(['power', 'humidity']) should return list of values instead of error. Also this broke integration of AirHumidifier v2 for Home Assistant.
syssi commented 3 years ago

Please use hum.get_properties(['power', 'humidity'], 1) if you want to request a single property per call.

Does a hum.status() call provides a proper status?

syssi commented 3 years ago

The status method will return a status object providing the temperature as float f.e.