mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Add iot brightness feature (#808)
This commit is contained in:
@@ -4,6 +4,7 @@ from typing import Any, Dict, Optional
|
||||
|
||||
from ..device_type import DeviceType
|
||||
from ..deviceconfig import DeviceConfig
|
||||
from ..feature import Feature, FeatureType
|
||||
from ..protocol import BaseProtocol
|
||||
from .iotdevice import KasaException, requires_update
|
||||
from .iotplug import IotPlug
|
||||
@@ -80,6 +81,22 @@ class IotDimmer(IotPlug):
|
||||
self.add_module("motion", Motion(self, "smartlife.iot.PIR"))
|
||||
self.add_module("ambient", AmbientLight(self, "smartlife.iot.LAS"))
|
||||
|
||||
async def _initialize_features(self):
|
||||
await super()._initialize_features()
|
||||
|
||||
if "brightness" in self.sys_info: # 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 brightness(self) -> int:
|
||||
|
Reference in New Issue
Block a user