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

Some errors in miio/airdehumidifier.py #960

Closed
ssp2 opened this issue Mar 5, 2021 · 2 comments · Fixed by #963
Closed

Some errors in miio/airdehumidifier.py #960

ssp2 opened this issue Mar 5, 2021 · 2 comments · Fixed by #963
Labels

Comments

@ssp2
Copy link

ssp2 commented Mar 5, 2021

Started testing my widetech dehumidifier 318 and found "undefine variable fan_level error" on line 274 in airdehumidifier.py

@command(
    click.argument("fan_speed", type=EnumType(FanSpeed)),
    default_output=format_output("Setting fan level to {fan_level}"),
)

I used command
miiocli -d airdehumidifier --ip 192.168.1.69 --token 8a7649142efa7a76c46833c7fe3b2c3a set_fan_speed low

If I change "fan_level" to "fan_speed", then program passes further and returns more global error, which I can't correct. Here is my output:

miiocli -d airdehumidifier --ip 192.168.1.69 --token 8a7649142efa7a76c46833c7fe3b2c3a set_fan_speed low
INFO:miio.cli:Debug mode active
Setting fan level to FanSpeed.Low
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
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\x06Vb!\x00\x00\xac;' (total 16)
value = Container:
length = 32
unknown = 0
device_id = unhexlify('06566221')
ts = 1970-01-01 12:14:51
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 06566221 with ts: 1970-01-01 12:14:51, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.1.69:54321 >>: {'id': 1, 'method': 'set_fan_level', 'params': [1]}
DEBUG:miio.miioprotocol:192.168.1.69:54321 (ts: 1970-01-01 12:14:51, id: 1) << {'id': 1, 'error': {'code': -10000, 'message': 'invalid operation'}}
DEBUG:miio.click_common:Exception: {'code': -10000, 'message': 'invalid operation'}
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/miio/click_common.py", line 59, in call
return self.main(*args, kwargs)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, ctx.params)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 610, in invoke
return callback(*args, kwargs)
File "/usr/local/lib/python3.7/dist-packages/miio/click_common.py", line 280, in wrap
kwargs["result"] = func(*args, kwargs)
File "/usr/local/lib/python3.7/dist-packages/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, kwargs)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 610, in invoke
return callback(*args, kwargs)
File "/usr/local/lib/python3.7/dist-packages/miio/click_common.py", line 245, in command_callback
return miio_command.call(miio_device, *args, kwargs)
File "/usr/local/lib/python3.7/dist-packages/miio/click_common.py", line 193, in call
return method(*args, kwargs)
File "/usr/local/lib/python3.7/dist-packages/miio/airdehumidifier.py", line 273, in set_fan_speed
return self.send("set_fan_level", [fan_speed.value])
File "/usr/local/lib/python3.7/dist-packages/miio/device.py", line 144, in send
command, parameters, retry_count, extra_parameters=extra_parameters
File "/usr/local/lib/python3.7/dist-packages/miio/miioprotocol.py", line 213, in send
self._handle_error(payload["error"])
File "/usr/local/lib/python3.7/dist-packages/miio/miioprotocol.py", line 273, in _handle_error
raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -10000, 'message': 'invalid operation'}
Error: {'code': -10000, 'message': 'invalid operation'}

I tryed all possible variants, but nothing helps. The same error repeats when I try to set mode (set_mode on).

But the rest commands (status, on/off, set_led) work fine, return valid values and set valid operations.

I use last python-miio 0.5.4, python 3.7.3, on raspberry 4b (last os).
Also I have Air Humidifier ca1, which ideally functions in Domoticz with python-miio support.

@ssp2 ssp2 added the bug label Mar 5, 2021
@ssp2
Copy link
Author

ssp2 commented Mar 6, 2021

I have solved "the problem"

Set_fan_speed command generates error, when dehumidifier is "off". When it is "on" everything works well. So it is only nessecery to correct the above mentioned syntax error (change "fan_level" to "fan_speed").

I am a newbie on github and dont know, how to change primary plugin here. Please check and do it somebody!

rytilahti added a commit that referenced this issue Mar 8, 2021
* Also, fix incorrect variable use for cli
* Fixes #960
@rytilahti
Copy link
Owner

Thanks for the report @ssp2! The linked PR fixes the incorrect variable name & adds a more specific exception when the device is off (i.e., when the code -10000 is returned).

rytilahti added a commit that referenced this issue Mar 9, 2021
* Also, fix incorrect variable use for cli
* Fixes #960
xvlady pushed a commit to xvlady/python-miio that referenced this issue May 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants