Remove last remnants from 'descriptor'

This commit is contained in:
Teemu Rytilahti 2024-02-14 19:14:35 +01:00
parent 5dc190837c
commit fc29d2456e
5 changed files with 13 additions and 15 deletions

View File

@ -1110,10 +1110,10 @@ async def shell(dev: Device):
@click.argument("value", required=False) @click.argument("value", required=False)
@pass_dev @pass_dev
async def feature(dev, name: str, value): 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 no *name* is given, lists available features and their values.
If only *name* is given, the value of named descriptor is returned. 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 both *name* and *value* are set, the described setting is changed.
""" """
if not name: if not name:
@ -1123,7 +1123,7 @@ async def feature(dev, name: str, value):
return return
if name not in dev.features: if name not in dev.features:
echo(f"No descriptor by name {name}") echo(f"No feature by name {name}")
return return
feat = dev.features[name] feat = dev.features[name]

View File

@ -8,7 +8,7 @@ if TYPE_CHECKING:
class FeatureCategory(Enum): class FeatureCategory(Enum):
"""Descriptor category.""" """Feature category."""
# TODO: we could probably do better than using the scheme homeassistant is using # TODO: we could probably do better than using the scheme homeassistant is using
Config = auto() Config = auto()
@ -40,8 +40,6 @@ class Feature:
container: Any = None container: Any = None
#: Icon suggestion #: Icon suggestion
icon: str | None = None icon: str | None = None
#: Unit of the descriptor
unit: str | None = None
#: Hint for homeassistant #: Hint for homeassistant
#: TODO: Replace with a set of flags to allow homeassistant make its own decision? #: TODO: Replace with a set of flags to allow homeassistant make its own decision?
show_in_hass: bool = True show_in_hass: bool = True

View File

@ -302,12 +302,12 @@ class IotDevice(Device):
self._set_sys_info(response["system"]["get_sysinfo"]) self._set_sys_info(response["system"]["get_sysinfo"])
if not self._features: if not self._features:
await self._initialize_descriptors() await self._initialize_features()
await self._modular_update(req) await self._modular_update(req)
self._set_sys_info(self._last_update["system"]["get_sysinfo"]) self._set_sys_info(self._last_update["system"]["get_sysinfo"])
async def _initialize_descriptors(self): async def _initialize_features(self):
self.add_feature( self.add_feature(
Feature( Feature(
device=self, name="RSSI", attribute_getter="rssi", icon="mdi:signal" device=self, name="RSSI", attribute_getter="rssi", icon="mdi:signal"

View File

@ -38,7 +38,7 @@ class IotModule(ABC):
self._module_features: Dict[str, Feature] = {} self._module_features: Dict[str, Feature] = {}
def add_feature(self, feature: Feature): def add_feature(self, feature: Feature):
"""Add module descriptor.""" """Add module feature."""
feature_name = f"{self._module}_{feature.name}" feature_name = f"{self._module}_{feature.name}"
if feature_name in self._module_features: if feature_name in self._module_features:
raise SmartDeviceException("Duplicate name detected %s" % feature_name) raise SmartDeviceException("Duplicate name detected %s" % feature_name)

View File

@ -119,10 +119,10 @@ class SmartDevice(Device):
for info in child_info["child_device_list"]: for info in child_info["child_device_list"]:
self._children[info["device_id"]].update_internal_state(info) self._children[info["device_id"]].update_internal_state(info)
# We can first initialize the descriptors after the first update. # We can first initialize the features after the first update.
# We make here an assumption that every device has at least a single descriptor. # We make here an assumption that every device has at least a single feature.
if not self._features: if not self._features:
await self._initialize_descriptors() await self._initialize_features()
_LOGGER.debug("Got an update: %s", self._last_update) _LOGGER.debug("Got an update: %s", self._last_update)
@ -131,8 +131,8 @@ class SmartDevice(Device):
if "energy_monitoring" in self._components: if "energy_monitoring" in self._components:
self.emeter_type = "emeter" self.emeter_type = "emeter"
async def _initialize_descriptors(self): async def _initialize_features(self):
"""Initialize device descriptors.""" """Initialize device features."""
self.add_feature( self.add_feature(
Feature( Feature(
self, self,