From f3ebb02b1017121c54ece2c027d0729f6abb3bc5 Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Thu, 5 Dec 2024 17:59:50 +0100 Subject: [PATCH] Add _check_supported --- kasa/smart/modules/powerprotection.py | 7 +++++++ tests/smart/modules/test_powerprotection.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/kasa/smart/modules/powerprotection.py b/kasa/smart/modules/powerprotection.py index 5e371b89..095bfbe1 100644 --- a/kasa/smart/modules/powerprotection.py +++ b/kasa/smart/modules/powerprotection.py @@ -96,3 +96,10 @@ class PowerProtection(SmartModule): "protection_power": threshold, } return await self.call("set_protection_power", params) + + async def _check_supported(self) -> bool: + """Return True if module is supported. + + This is needed, as strips like P304M report the status only for children. + """ + return "power_protection_status" in self._device.sys_info diff --git a/tests/smart/modules/test_powerprotection.py b/tests/smart/modules/test_powerprotection.py index 8db89721..10e94ede 100644 --- a/tests/smart/modules/test_powerprotection.py +++ b/tests/smart/modules/test_powerprotection.py @@ -22,7 +22,7 @@ def _skip_on_unavailable(dev: SmartDevice): @pytest.mark.parametrize( ("feature", "prop_name", "type"), [ - ("overloaded", "overloaded", bool | None), + ("overloaded", "overloaded", bool), ("power_protection_enabled", "enabled", bool), ("power_protection_threshold", "protection_threshold", int), ],