Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion kasa/smartdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ async def _query_helper(
@requires_update
def features(self) -> Set[str]:
"""Return a set of features that the device supports."""
return set(self.sys_info["feature"].split(":"))
try:
return set(self.sys_info["feature"].split(":"))
except KeyError:
_LOGGER.debug("Device does not have feature information")
return set()

@property # type: ignore
@requires_update
Expand Down
9 changes: 9 additions & 0 deletions kasa/tests/test_smartdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,12 @@ async def test_childrens(dev):
async def test_internal_state(dev):
"""Make sure the internal state returns the last update results."""
assert dev.internal_state == dev._last_update


async def test_features(dev):
"""Make sure features is always accessible."""
sysinfo = dev._last_update["system"]["get_sysinfo"]
if "feature" in sysinfo:
assert dev.features == set(sysinfo["feature"].split(":"))
else:
assert dev.features == set()