mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Embed FeatureType inside Feature (#860)
Moves `FeatureType` into `Feature` to make it easier to use the API. This also enforces that no invalid types are accepted (i.e., `Category.Config` cannot be a `Sensor`) If `--verbose` is used with the cli tool, some extra information is displayed for features when in the state command.
This commit is contained in:
@@ -15,7 +15,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 ..feature import Feature
|
||||
from ..protocol import BaseProtocol
|
||||
from .iotdevice import IotDevice, KasaException, requires_update
|
||||
from .modules import Antitheft, Cloud, Countdown, Emeter, Schedule, Time, Usage
|
||||
@@ -221,7 +221,7 @@ class IotBulb(IotDevice, Bulb):
|
||||
attribute_setter="set_brightness",
|
||||
minimum_value=1,
|
||||
maximum_value=100,
|
||||
type=FeatureType.Number,
|
||||
type=Feature.Type.Number,
|
||||
category=Feature.Category.Primary,
|
||||
)
|
||||
)
|
||||
|
@@ -7,7 +7,7 @@ from typing import Any
|
||||
|
||||
from ..device_type import DeviceType
|
||||
from ..deviceconfig import DeviceConfig
|
||||
from ..feature import Feature, FeatureType
|
||||
from ..feature import Feature
|
||||
from ..protocol import BaseProtocol
|
||||
from .iotdevice import KasaException, requires_update
|
||||
from .iotplug import IotPlug
|
||||
@@ -96,7 +96,7 @@ class IotDimmer(IotPlug):
|
||||
attribute_setter="set_brightness",
|
||||
minimum_value=1,
|
||||
maximum_value=100,
|
||||
type=FeatureType.Number,
|
||||
type=Feature.Type.Number,
|
||||
)
|
||||
)
|
||||
|
||||
|
@@ -6,7 +6,7 @@ import logging
|
||||
|
||||
from ..device_type import DeviceType
|
||||
from ..deviceconfig import DeviceConfig
|
||||
from ..feature import Feature, FeatureType
|
||||
from ..feature import Feature
|
||||
from ..protocol import BaseProtocol
|
||||
from .iotdevice import IotDevice, requires_update
|
||||
from .modules import Antitheft, Cloud, Schedule, Time, Usage
|
||||
@@ -69,7 +69,7 @@ class IotPlug(IotDevice):
|
||||
icon="mdi:led-{state}",
|
||||
attribute_getter="led",
|
||||
attribute_setter="set_led",
|
||||
type=FeatureType.Switch,
|
||||
type=Feature.Type.Switch,
|
||||
)
|
||||
)
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
"""Implementation of the ambient light (LAS) module found in some dimmers."""
|
||||
|
||||
from ...feature import Feature, FeatureType
|
||||
from ...feature import Feature
|
||||
from ..iotmodule import IotModule, merge
|
||||
|
||||
# TODO create tests and use the config reply there
|
||||
@@ -25,7 +25,7 @@ class AmbientLight(IotModule):
|
||||
name="Ambient Light",
|
||||
icon="mdi:brightness-percent",
|
||||
attribute_getter="ambientlight_brightness",
|
||||
type=FeatureType.Sensor,
|
||||
type=Feature.Type.Sensor,
|
||||
)
|
||||
)
|
||||
|
||||
|
@@ -5,7 +5,7 @@ try:
|
||||
except ImportError:
|
||||
from pydantic import BaseModel
|
||||
|
||||
from ...feature import Feature, FeatureType
|
||||
from ...feature import Feature
|
||||
from ..iotmodule import IotModule
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class Cloud(IotModule):
|
||||
name="Cloud connection",
|
||||
icon="mdi:cloud",
|
||||
attribute_getter="is_connected",
|
||||
type=FeatureType.BinarySensor,
|
||||
type=Feature.Type.BinarySensor,
|
||||
)
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user