diff --git a/kasa/smartdevice.py b/kasa/smartdevice.py index 25b91631..7a66a864 100755 --- a/kasa/smartdevice.py +++ b/kasa/smartdevice.py @@ -262,7 +262,11 @@ class SmartDevice: @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 diff --git a/kasa/tests/test_smartdevice.py b/kasa/tests/test_smartdevice.py index 2dfd9634..d977daeb 100644 --- a/kasa/tests/test_smartdevice.py +++ b/kasa/tests/test_smartdevice.py @@ -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()