Simplify impl by removing featurecategory and show_in_hass

This commit is contained in:
Teemu Rytilahti 2024-02-14 20:18:01 +01:00
parent 231a3e4dc5
commit 69108cea7d
5 changed files with 3 additions and 26 deletions

View File

@ -33,7 +33,7 @@ from kasa.exceptions import (
TimeoutException, TimeoutException,
UnsupportedDeviceException, UnsupportedDeviceException,
) )
from kasa.feature import Feature, FeatureCategory, FeatureType from kasa.feature import Feature, FeatureType
from kasa.iot.iotbulb import BulbPreset, TurnOnBehavior, TurnOnBehaviors from kasa.iot.iotbulb import BulbPreset, TurnOnBehavior, TurnOnBehaviors
from kasa.iotprotocol import ( from kasa.iotprotocol import (
IotProtocol, IotProtocol,
@ -57,7 +57,6 @@ __all__ = [
"DeviceType", "DeviceType",
"Feature", "Feature",
"FeatureType", "FeatureType",
"FeatureCategory",
"EmeterStatus", "EmeterStatus",
"Device", "Device",
"Bulb", "Bulb",

View File

@ -7,14 +7,6 @@ if TYPE_CHECKING:
from .device import Device from .device import Device
class FeatureCategory(Enum):
"""Feature category."""
# TODO: we could probably do better than using the scheme homeassistant is using
Config = auto()
Diagnostic = auto()
class FeatureType(Enum): class FeatureType(Enum):
"""Type to help decide how to present the feature.""" """Type to help decide how to present the feature."""
@ -40,10 +32,7 @@ class Feature:
container: Any = None container: Any = None
#: Icon suggestion #: Icon suggestion
icon: str | None = None icon: str | None = None
#: Hint for homeassistant #: Type of the feature
#: TODO: Replace with a set of flags to allow homeassistant make its own decision?
show_in_hass: bool = True
category: FeatureCategory = FeatureCategory.Diagnostic
type: FeatureType = FeatureType.Sensor type: FeatureType = FeatureType.Sensor
@property @property

View File

@ -313,11 +313,6 @@ class IotDevice(Device):
device=self, name="RSSI", attribute_getter="rssi", icon="mdi:signal" device=self, name="RSSI", attribute_getter="rssi", icon="mdi:signal"
) )
) )
self._add_feature(
Feature(
device=self, name="Time", attribute_getter="time", show_in_hass=False
)
)
if "on_time" in self._sys_info: if "on_time" in self._sys_info:
self._add_feature( self._add_feature(
Feature( Feature(

View File

@ -4,7 +4,7 @@ from typing import Any, Dict, Optional
from ..device_type import DeviceType from ..device_type import DeviceType
from ..deviceconfig import DeviceConfig from ..deviceconfig import DeviceConfig
from ..feature import Feature, FeatureCategory, FeatureType from ..feature import Feature, FeatureType
from ..protocol import BaseProtocol from ..protocol import BaseProtocol
from .iotdevice import IotDevice, requires_update from .iotdevice import IotDevice, requires_update
from .modules import Antitheft, Cloud, Schedule, Time, Usage from .modules import Antitheft, Cloud, Schedule, Time, Usage
@ -64,7 +64,6 @@ class IotPlug(IotDevice):
icon="mdi:led-{state}", icon="mdi:led-{state}",
attribute_getter="led", attribute_getter="led",
attribute_setter="set_led", attribute_setter="set_led",
category=FeatureCategory.Config,
type=FeatureType.Switch, type=FeatureType.Switch,
) )
) )

View File

@ -149,11 +149,6 @@ class SmartDevice(Device):
icon="mdi:signal", icon="mdi:signal",
) )
) )
self._add_feature(
Feature(
device=self, name="Time", attribute_getter="time", show_in_hass=False
)
)
self._add_feature( self._add_feature(
Feature(device=self, name="SSID", attribute_getter="ssid", icon="mdi:wifi") Feature(device=self, name="SSID", attribute_getter="ssid", icon="mdi:wifi")
) )