mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-01-08 22:07:06 +00:00
Remove last remnants from 'descriptor'
This commit is contained in:
parent
5dc190837c
commit
fc29d2456e
@ -1110,10 +1110,10 @@ async def shell(dev: Device):
|
||||
@click.argument("value", required=False)
|
||||
@pass_dev
|
||||
async def feature(dev, name: str, value):
|
||||
"""Access and modify descriptor values.
|
||||
"""Access and modify features.
|
||||
|
||||
If no *name* is given, lists available descriptors and their values.
|
||||
If only *name* is given, the value of named descriptor is returned.
|
||||
If no *name* is given, lists available features and their values.
|
||||
If only *name* is given, the value of named feature is returned.
|
||||
If both *name* and *value* are set, the described setting is changed.
|
||||
"""
|
||||
if not name:
|
||||
@ -1123,7 +1123,7 @@ async def feature(dev, name: str, value):
|
||||
return
|
||||
|
||||
if name not in dev.features:
|
||||
echo(f"No descriptor by name {name}")
|
||||
echo(f"No feature by name {name}")
|
||||
return
|
||||
|
||||
feat = dev.features[name]
|
||||
|
@ -8,7 +8,7 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
class FeatureCategory(Enum):
|
||||
"""Descriptor category."""
|
||||
"""Feature category."""
|
||||
|
||||
# TODO: we could probably do better than using the scheme homeassistant is using
|
||||
Config = auto()
|
||||
@ -40,8 +40,6 @@ class Feature:
|
||||
container: Any = None
|
||||
#: Icon suggestion
|
||||
icon: str | None = None
|
||||
#: Unit of the descriptor
|
||||
unit: str | None = None
|
||||
#: Hint for homeassistant
|
||||
#: TODO: Replace with a set of flags to allow homeassistant make its own decision?
|
||||
show_in_hass: bool = True
|
||||
|
@ -302,12 +302,12 @@ class IotDevice(Device):
|
||||
self._set_sys_info(response["system"]["get_sysinfo"])
|
||||
|
||||
if not self._features:
|
||||
await self._initialize_descriptors()
|
||||
await self._initialize_features()
|
||||
|
||||
await self._modular_update(req)
|
||||
self._set_sys_info(self._last_update["system"]["get_sysinfo"])
|
||||
|
||||
async def _initialize_descriptors(self):
|
||||
async def _initialize_features(self):
|
||||
self.add_feature(
|
||||
Feature(
|
||||
device=self, name="RSSI", attribute_getter="rssi", icon="mdi:signal"
|
||||
|
@ -38,7 +38,7 @@ class IotModule(ABC):
|
||||
self._module_features: Dict[str, Feature] = {}
|
||||
|
||||
def add_feature(self, feature: Feature):
|
||||
"""Add module descriptor."""
|
||||
"""Add module feature."""
|
||||
feature_name = f"{self._module}_{feature.name}"
|
||||
if feature_name in self._module_features:
|
||||
raise SmartDeviceException("Duplicate name detected %s" % feature_name)
|
||||
|
@ -119,10 +119,10 @@ class SmartDevice(Device):
|
||||
for info in child_info["child_device_list"]:
|
||||
self._children[info["device_id"]].update_internal_state(info)
|
||||
|
||||
# We can first initialize the descriptors after the first update.
|
||||
# We make here an assumption that every device has at least a single descriptor.
|
||||
# We can first initialize the features after the first update.
|
||||
# We make here an assumption that every device has at least a single feature.
|
||||
if not self._features:
|
||||
await self._initialize_descriptors()
|
||||
await self._initialize_features()
|
||||
|
||||
_LOGGER.debug("Got an update: %s", self._last_update)
|
||||
|
||||
@ -131,8 +131,8 @@ class SmartDevice(Device):
|
||||
if "energy_monitoring" in self._components:
|
||||
self.emeter_type = "emeter"
|
||||
|
||||
async def _initialize_descriptors(self):
|
||||
"""Initialize device descriptors."""
|
||||
async def _initialize_features(self):
|
||||
"""Initialize device features."""
|
||||
self.add_feature(
|
||||
Feature(
|
||||
self,
|
||||
|
Loading…
Reference in New Issue
Block a user