miio.devicestatus module

class miio.devicestatus.DeviceStatus[source]

Bases: object

Base class for status containers.

All status container classes should inherit from this class:

  • This class allows downstream users to access the available information in an introspectable way. See @sensor() and @setting().

  • embed() allows embedding other status containers.

  • The __repr__ implementation returns all defined properties and their values.

descriptors() DescriptorCollection[PropertyDescriptor][source]

Return the dict of sensors exposed by the status container.

Use @sensor and @setting decorators to define properties.

embed(name: str, other: DeviceStatus)[source]

Embed another status container to current one.

This makes it easy to provide a single status response for cases where responses from multiple I/O calls is wanted to provide a simple interface for downstreams.

Internally, this will prepend the name of the other class to the attribute names, and override the __getattribute__ to lookup attributes in the embedded containers.

miio.devicestatus.action(name: str, *, id: str | StandardIdentifier | None = None, **kwargs)[source]

Syntactic sugar to create ActionDescriptor objects.

The information can be used by users of the library to programmatically find out what types of actions are available for the device.

The interface is kept minimal, but you can pass any extra keyword arguments. These extras are made accessible over extras, and can be interpreted downstream users as they wish.

miio.devicestatus.sensor(name: str, *, id: str | StandardIdentifier | None = None, unit: str | None = None, **kwargs)[source]

Syntactic sugar to create SensorDescriptor objects.

The information can be used by users of the library to programmatically find out what types of sensors are available for the device.

The interface is kept minimal, but you can pass any extra keyword arguments. These extras are made accessible over extras, and can be interpreted downstream users as they wish.

miio.devicestatus.setting(name: str, *, id: str | StandardIdentifier | None = None, setter: Callable | None = None, setter_name: str | None = None, unit: str | None = None, min_value: int | None = None, max_value: int | None = None, step: int | None = None, range_attribute: str | None = None, choices: Type[Enum] | None = None, choices_attribute: str | None = None, **kwargs)[source]

Syntactic sugar to create SettingDescriptor objects.

The information can be used by users of the library to programmatically find out what types of sensors are available for the device.

The interface is kept minimal, but you can pass any extra keyword arguments. These extras are made accessible over extras, and can be interpreted downstream users as they wish.

The _attribute suffixed options allow defining a property to be used to return the information dynamically.