mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-11 09:58:01 +00:00
Implement feature categories (#846)
Initial implementation for feature categories to help downstreams and our cli tool to categorize the data for more user-friendly manner. As more and more information is being exposed through the generic features interface, it is necessary to give some hints to downstreams about how might want to present the information to users. This is not a 1:1 mapping to the homeassistant's mental model, and it will be necessary to fine-tune homeassistant-specific parameters by other means to polish the presentation.
This commit is contained in:
@@ -318,10 +318,10 @@ class Device(ABC):
|
||||
|
||||
def _add_feature(self, feature: Feature):
|
||||
"""Add a new feature to the device."""
|
||||
desc_name = feature.name.lower().replace(" ", "_")
|
||||
if desc_name in self._features:
|
||||
raise KasaException("Duplicate feature name %s" % desc_name)
|
||||
self._features[desc_name] = feature
|
||||
if feature.id in self._features:
|
||||
raise KasaException("Duplicate feature id %s" % feature.id)
|
||||
assert feature.id is not None # TODO: hack for typing # noqa: S101
|
||||
self._features[feature.id] = feature
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
|
Reference in New Issue
Block a user