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

Crashes if no hw_ver present #1084

Closed
fokcuk opened this issue Jun 25, 2021 · 5 comments
Closed

Crashes if no hw_ver present #1084

fokcuk opened this issue Jun 25, 2021 · 5 comments
Labels

Comments

@fokcuk
Copy link

fokcuk commented Jun 25, 2021

Describe the bug
When executing miiocli for the device that does not support hw_ver information, it errors out:
File "/usr/local/lib/python3.9/dist-packages/miio/device.py", line 88, in hardware_version
if self.data["hw_ver"] is not None:
KeyError: 'hw_ver'

Version information (please complete the following information):

  • OS: Linux
  • python-miio: miiocli, version 0.5.6

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

  • Model: Viomi S9 viomi-v18:1
  • Hardware version:
  • Firmware version:

To Reproduce
Steps to reproduce the behavior:

  1. Cannot even run info command

Expected behavior
Information should be displayed

Console output
INFO:miio.cli:Debug mode active
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\x16\x8e\xb5~\x00\x01\xd9\xd6' (total 16)
value = Container:
length = 32
unknown = 0
device_id = unhexlify('168eb57e')
ts = 1970-01-02 09:41:42
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 168eb57e with ts: 1970-01-02 09:41:42, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.1.124:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}
DEBUG:miio.miioprotocol:192.168.1.124:54321 (ts: 1970-01-02 09:41:43, id: 1) << {'id': 1, 'result': {'life': 121303, 'uid': 6153637412, 'model': 'viomi.vacuum.v18', 'token': '78326372527135556c6a444a4a6c3744', 'miio_ver': '0.0.7', 'mac': '5c:6b:d7:17:04:fb', 'fw_ver': '1.6.2_2251', 'VmPeak': 46752, 'VmRSS': 1608, 'MemFree': 24584, 'ap': {'ssid': 'Home', 'bssid': 'e0:3f:49:72:5e:58', 'rssi': '-20'}, 'netif': {'localIp': '192.168.1.124', 'mask': '255.255.255.0', 'gw': '192.168.1.1'}, 'config_type': 'app', 'miio_times': [121302, 0, 2, 120619]}}
Traceback (most recent call last):
File "/usr/local/bin/miiocli", line 8, in
sys.exit(create_cli())
File "/usr/local/lib/python3.9/dist-packages/miio/cli.py", line 63, in create_cli
return cli(auto_envvar_prefix="MIIO")
File "/usr/local/lib/python3.9/dist-packages/miio/click_common.py", line 59, in call
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/miio/click_common.py", line 285, in wrap
result_msg = result_msg_fmt.format(**kwargs)
File "/usr/local/lib/python3.9/dist-packages/miio/device.py", line 88, in hardware_version
if self.data["hw_ver"] is not None:
KeyError: 'hw_ver'

@fokcuk fokcuk added the bug label Jun 25, 2021
@fokcuk
Copy link
Author

fokcuk commented Jun 25, 2021

as a workaround, I have commented out the section where it looks for hw_ver. Same issue is present in Home assistant - no integrations work unless a workaround is applied

@rytilahti
Copy link
Owner

This should be fixed in the master branch (#1083), can you confirm?

@fokcuk
Copy link
Author

fokcuk commented Jun 25, 2021

wish I knew how =)

@rytilahti
Copy link
Owner

Simply git clone the repository, and run:

poetry install
poetry run miiocli --ip <addr> --token <token> info

This will create a separate virtual environment that is separate from your regular installation :)

@rytilahti
Copy link
Owner

Please reopen if that doesn't work after a new python-miio release is done :-)

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

No branches or pull requests

2 participants