Add iot brightness feature (#808)

This commit is contained in:
Steven B
2024-03-06 16:45:08 +00:00
committed by GitHub
parent 42080bd954
commit adce92a761
4 changed files with 61 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ except ImportError:
from ..bulb import HSV, Bulb, BulbPreset, ColorTempRange
from ..device_type import DeviceType
from ..deviceconfig import DeviceConfig
from ..feature import Feature, FeatureType
from ..protocol import BaseProtocol
from .iotdevice import IotDevice, KasaException, requires_update
from .modules import Antitheft, Cloud, Countdown, Emeter, Schedule, Time, Usage
@@ -204,6 +205,22 @@ class IotBulb(IotDevice, Bulb):
self.add_module("countdown", Countdown(self, "countdown"))
self.add_module("cloud", Cloud(self, "smartlife.iot.common.cloud"))
async def _initialize_features(self):
await super()._initialize_features()
if bool(self.sys_info["is_dimmable"]): # pragma: no branch
self._add_feature(
Feature(
device=self,
name="Brightness",
attribute_getter="brightness",
attribute_setter="set_brightness",
minimum_value=1,
maximum_value=100,
type=FeatureType.Number,
)
)
@property # type: ignore
@requires_update
def is_color(self) -> bool: