Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the support of the Air Humidifier CA1 (Closes: #383) #388

Merged
merged 2 commits into from
Oct 8, 2018

Conversation

syssi
Copy link
Collaborator

@syssi syssi commented Oct 7, 2018

No description provided.

'cfg_time': 0,
'life': 575661,
'ap': {'rssi': -35, 'ssid': 'ap',
'bssid': 'FF:FF:FF:FF:FF:FF'},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line under-indented for visual indent


assert self.state().firmware_version == device_info.firmware_version
assert self.state().firmware_version_major == device_info.firmware_version.rsplit('_', 1)[0]
assert self.state().firmware_version_minor == int(device_info.firmware_version.rsplit('_', 1)[1])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (105 > 100 characters)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 73.1% when pulling 15d93d8 on syssi:feature/fix-air-humidifier-ca1 into e3da229 on rytilahti:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 73.1% when pulling 15d93d8 on syssi:feature/fix-air-humidifier-ca1 into e3da229 on rytilahti:master.

@syssi syssi merged commit 8569e75 into rytilahti:master Oct 8, 2018
@pieonboard
Copy link

Hi. Is it possible to create the release with this PR included? Thanks in advance.

@syssi
Copy link
Collaborator Author

syssi commented Oct 8, 2018

@SmaginPV Are you able to test these changes?

@pieonboard
Copy link

pieonboard commented Oct 8, 2018

Yah, just thought about it after left the comment. I did the install of this package from the repo with
python3 setup.py install
Then I tried to turn on the device and it works.
Then tried to fetch the status, but see the same 'UART timeout' error

miiocli -d airhumidifier --ip 192.168.1.116 --token 8d503f8fe4cd0486ea235bda3d6d72bb status
....
DEBUG:miio.device:192.168.1.116:54321 >>: {'id': 2, 'method': 'get_prop', 'params': ['power', 'mode', 'temp_dec', 'humidity', 'buzzer', 'led_b', 'child_lock', 'limit_hum', 'use_time', 'hw_version', 'trans_level', 'button_pressed']}
DEBUG:miio.device:192.168.1.116:54321 (ts: 1970-01-09 05:26:42, id: 2) << {'error': {'code': -9999, 'message': 'UART timeout'}, 'id': 2}
DEBUG:miio.click_common:Exception: {'code': -9999, 'message': 'UART timeout'}
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/python_miio-0.4.2-py3.6.egg/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/python_miio-0.4.2-py3.6.egg/miio/click_common.py", line 262, in wrap
    kwargs['result'] = func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/python_miio-0.4.2-py3.6.egg/miio/click_common.py", line 229, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/python_miio-0.4.2-py3.6.egg/miio/click_common.py", line 191, in call
    return method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/python_miio-0.4.2-py3.6.egg/miio/airhumidifier.py", line 295, in status
    values.extend(self.send("get_prop", _props[:_props_per_request]))
  File "/usr/local/lib/python3.6/site-packages/python_miio-0.4.2-py3.6.egg/miio/device.py", line 270, in send
    raise DeviceError(m.data.value["error"])
miio.exceptions.DeviceError: {'code': -9999, 'message': 'UART timeout'}
Error: {'code': -9999, 'message': 'UART timeout'}

@pieonboard
Copy link

What's interesting, is that get_prop with just single parameter works:

iiocli -d airhumidifier --ip 192.168.1.116 --token 8d503f8fe4cd0486ea235bda3d6d72bb raw_command get_prop "['humidity']"
INFO:miio.cli:Debug mode active
Running command raw_command
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device: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\x03\xb8,V\x00\n\xdb\xfb' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x03\xb8,V' (total 4)
            ts = 1970-01-09 05:41:15
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' (total 16)
DEBUG:miio.device:Discovered 03b82c56 with ts: 1970-01-09 05:41:15, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.1.116:54321 >>: {'id': 1, 'method': 'get_prop', 'params': ['humidity']}
DEBUG:miio.device:192.168.1.116:54321 (ts: 1970-01-09 05:41:15, id: 1) << {'result': [45], 'id': 1}
[45]

@rytilahti
Copy link
Owner

Can you try if get_prop works with two, three and so on, or is it just working with a single one? Anyway, the fix @syssi just merged limits the amount of properties to be requested to one, so either you are not using the updated code or there is some other issue there.

@syssi
Copy link
Collaborator Author

syssi commented Oct 8, 2018

miiocli airhumidifier uses the default implementation. The CA1 code path isn't used.

@pieonboard
Copy link

miiocli airhumidifier uses the default implementation. The CA1 code path isn't used.

That means I can't test you change with miiocli, or I need to use some additional option?

@pieonboard
Copy link

Ok, got your latest change from feature/airhumidifier-ca1-cli and it works!!

miiocli airhumidifierca1 --ip 192.168.1.116 --token 8d503f8fe4cd0486ea235bda3d6d72bb status
Power: off
Mode: OperationMode.Silent
Temperature: 23.9 °C
Humidity: 42 %
LED brightness: LedBrightness.Off
Buzzer: False
Child lock: False
Target humidity: 70 %
Trans level: None
Speed: 0
Depth: 43
Dry: True
Use time: 121210
Hardware version: 0001
Button pressed: None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants