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.

embed(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 property names, and override the __getattribute__ to lookup attributes in the embedded containers.

sensors() Dict[str, SensorDescriptor][source]

Return the dict of sensors exposed by the status container.

You can use @sensor decorator to define sensors inside your status class.

settings() Dict[str, SettingDescriptor][source]

Return the dict of settings exposed by the status container.

You can use @setting decorator to define settings inside your status class.

miio.devicestatus.action(name: str, **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, *, unit: Optional[str] = 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, *, setter: Optional[Callable] = None, setter_name: Optional[str] = None, unit: Optional[str] = None, min_value: Optional[int] = None, max_value: Optional[int] = None, step: Optional[int] = None, range_attribute: Optional[str] = None, choices: Optional[Type[Enum]] = None, choices_attribute: Optional[str] = None, type: Optional[SettingType] = 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.