Deprecate is_something attributes (#912)

Deprecates the is_something attributes like is_bulb and is_dimmable in favour of the modular approach.
This commit is contained in:
Steven B
2024-05-13 18:52:08 +01:00
committed by GitHub
parent 33d839866e
commit ef49f44eac
8 changed files with 142 additions and 93 deletions

View File

@@ -96,7 +96,7 @@ class IotDimmer(IotPlug):
Will return a range between 0 - 100.
"""
if not self.is_dimmable:
if not self._is_dimmable:
raise KasaException("Device is not dimmable.")
sys_info = self.sys_info
@@ -109,7 +109,7 @@ class IotDimmer(IotPlug):
:param int transition: transition duration in milliseconds.
Using a transition will cause the dimmer to turn on.
"""
if not self.is_dimmable:
if not self._is_dimmable:
raise KasaException("Device is not dimmable.")
if not isinstance(brightness, int):
@@ -218,7 +218,7 @@ class IotDimmer(IotPlug):
@property # type: ignore
@requires_update
def is_dimmable(self) -> bool:
def _is_dimmable(self) -> bool:
"""Whether the switch supports brightness changes."""
sys_info = self.sys_info
return "brightness" in sys_info