diff --git a/miio/devicestatus.py b/miio/devicestatus.py index c5918ac5e..1819c92cb 100644 --- a/miio/devicestatus.py +++ b/miio/devicestatus.py @@ -86,7 +86,7 @@ def __repr__(self): s += ">" return s - def properties(self) -> Dict[str, PropertyDescriptor]: + def descriptors(self) -> Dict[str, PropertyDescriptor]: """Return the dict of sensors exposed by the status container. Use @sensor and @setting decorators to define properties. @@ -101,7 +101,7 @@ def settings(self) -> Dict[str, PropertyDescriptor]: # TODO: this is not probably worth having, remove? return { prop.id: prop - for prop in self.properties().values() + for prop in self.descriptors().values() if prop.access & AccessFlags.Write } @@ -117,7 +117,7 @@ def embed(self, name: str, other: "DeviceStatus"): self._embedded[name] = other other._parent = self # type: ignore[attr-defined] - for property_name, prop in other.properties().items(): + for property_name, prop in other.descriptors().items(): final_name = f"{name}__{property_name}" self._descriptors[final_name] = attr.evolve( @@ -132,7 +132,7 @@ def __dir__(self) -> Iterable[str]: def __cli_output__(self) -> str: """Return a CLI formatted output of the status.""" out = "" - for descriptor in self.properties().values(): + for descriptor in self.descriptors().values(): try: value = getattr(self, descriptor.status_attribute) except KeyError: diff --git a/miio/tests/test_devicestatus.py b/miio/tests/test_devicestatus.py index 32bd06ac5..89df77775 100644 --- a/miio/tests/test_devicestatus.py +++ b/miio/tests/test_devicestatus.py @@ -109,7 +109,7 @@ def unknown(self): pass status = DecoratedProps() - sensors = status.properties() + sensors = status.descriptors() assert len(sensors) == 3 all_kwargs = sensors["all_kwargs"] @@ -274,11 +274,11 @@ def sub_sensor(self): return "sub" main = MainStatus() - assert len(main.properties()) == 1 + assert len(main.descriptors()) == 1 sub = SubStatus() main.embed("SubStatus", sub) - sensors = main.properties() + sensors = main.descriptors() assert len(sensors) == 2 assert sub._parent == main @@ -286,7 +286,7 @@ def sub_sensor(self): assert getattr(main, sensors["SubStatus__sub_sensor"].status_attribute) == "sub" with pytest.raises(KeyError): - main.properties()["nonexisting_sensor"] + main.descriptors()["nonexisting_sensor"] assert ( repr(main)