-
-
Notifications
You must be signed in to change notification settings - Fork 239
Closed
Description
This is actually two issues.
- Discovery with
--aliasfails when any device without alias is discovered. (see stacktrace below)
python-kasa/kasa/cli/discover.py
Line 247 in 6213b90
| if dev.alias.lower() == alias.lower(): |
should be:
dev.alias and dev.alias.lower() == alias.lower()aliasis not in the discovery result (at least forSmartDevice).
I guessupdate()is never called and should be added to theon_discoveredoption to thediscovercall?
python-kasa/kasa/cli/discover.py
Line 245 in 6213b90
| found_devs = await Discover.discover(target=target, timeout=timeout) |
Stacktrace
❯ kasa --host 192.168.178.149 alias
Discovering device 192.168.178.149 for 10 seconds
Alias: Tapo1
❯ kasa --alias Tapo1 --debug
Alias is given, using discovery to find host Tapo1
DEBUG:kasa.discover:[DISCOVERY] 255.255.255.255 >> {'system': {'get_sysinfo': {}}}
DEBUG:kasa.discover:Waiting 5 seconds for responses...
DEBUG:kasa.klaptransport:Created KLAP transport for 192.168.178.149
DEBUG:kasa.discover:[DISCOVERY] 192.168.178.149 << {'error_code': 0,
'result': {'device_id': 'REDACTED_788d5dccb2d89e6bd1dbd23',
'device_model': 'P110M(EU)',
'device_type': 'SMART.TAPOPLUG',
'factory_default': False,
'ip': '192.168.178.149',
'is_support_iot_cloud': True,
'mac': 'F0-A7-31-00-00-00',
'mgt_encrypt_schm': {'encrypt_type': 'KLAP',
'http_port': 80,
'is_support_https': False,
'lv': 2},
'obd_src': 'matter',
'owner': '',
'protocol_version': 1}}
DEBUG:kasa.device:Initializing 192.168.178.149 of type <class 'kasa.smart.smartdevice.SmartDevice'>
DEBUG:kasa.discover:Discovered 1 devices
Raised error: 'NoneType' object has no attribute 'lower'
Traceback (most recent call last):
File "/Users/bjebb/.local/bin/kasa", line 10, in <module>
sys.exit(cli())
^^^^^
File "/Users/bjebb/Library/Application Support/pipx/venvs/python-kasa/lib/python3.12/site-packages/asyncclick/core.py", line 1205, in __call__
return anyio.run(self._main, main, args, kwargs, **opts)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Application Support/pipx/venvs/python-kasa/lib/python3.12/site-packages/anyio/_core/_eventloop.py", line 74, in run
return async_backend.run(func, args, {}, backend_options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Application Support/pipx/venvs/python-kasa/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 2034, in run
return runner.run(wrapper())
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.12/3.12.7_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.12/3.12.7_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Application Support/pipx/venvs/python-kasa/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 2022, in wrapper
return await func(*args)
^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Application Support/pipx/venvs/python-kasa/lib/python3.12/site-packages/asyncclick/core.py", line 1208, in _main
return await main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Application Support/pipx/venvs/python-kasa/lib/python3.12/site-packages/asyncclick/core.py", line 1120, in main
rv = await self.invoke(ctx)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Application Support/pipx/venvs/python-kasa/lib/python3.12/site-packages/kasa/cli/common.py", line 231, in invoke
_handle_exception(self._debug, exc)
File "/Users/bjebb/Library/Application Support/pipx/venvs/python-kasa/lib/python3.12/site-packages/kasa/cli/common.py", line 229, in invoke
return await super().invoke(ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Application Support/pipx/venvs/python-kasa/lib/python3.12/site-packages/asyncclick/core.py", line 1717, in invoke
rv = await super().invoke(ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Application Support/pipx/venvs/python-kasa/lib/python3.12/site-packages/asyncclick/core.py", line 1485, in invoke
return await ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Application Support/pipx/venvs/python-kasa/lib/python3.12/site-packages/asyncclick/core.py", line 824, in invoke
rv = await rv
^^^^^^^^
File "/Users/bjebb/Library/Application Support/pipx/venvs/python-kasa/lib/python3.12/site-packages/kasa/cli/main.py", line 299, in cli
host = await find_host_from_alias(alias=alias, target=target)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Application Support/pipx/venvs/python-kasa/lib/python3.12/site-packages/kasa/cli/discover.py", line 247, in find_host_from_alias
if dev.alias.lower() == alias.lower():
^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'lower'Metadata
Metadata
Assignees
Labels
No labels