miio.descriptors module

This module contains descriptors.

The descriptors contain information that can be used to provide generic, dynamic user-interfaces.

If you are a downstream developer, use sensors(), settings(), and actions() to access the functionality exposed by the integration developer.

If you are developing an integration, prefer sensor(), setting(), and action() decorators over creating the descriptors manually. If needed, you can override the methods listed to add more descriptors to your integration.

class miio.descriptors.ActionDescriptor(id: str, name: str, method_name: Optional[str] = None, method: Optional[Callable] = None, extras: Dict = NOTHING)[source]

Bases: object

Describes a button exposed by the device.

extras: Dict
id: str
method: Optional[Callable]
method_name: Optional[str]
name: str
class miio.descriptors.BooleanSettingDescriptor(*, id: str, name: str, property: str, unit: Optional[str] = None, setter: Optional[Callable] = None, setter_name: Optional[str] = None, extras: Dict = NOTHING, type: SettingType = SettingType.Boolean)[source]

Bases: SettingDescriptor

Presents a settable boolean value.

cast_value(value: int)

Casts value to the expected type.

extras: Dict
id: str
name: str
property: str
setter: Optional[Callable]
setter_name: Optional[str]
type: SettingType = 1
unit: Optional[str]
class miio.descriptors.EnumSettingDescriptor(*, id: str, name: str, property: str, unit: Optional[str] = None, setter: Optional[Callable] = None, setter_name: Optional[str] = None, extras: Dict = NOTHING, type: SettingType = SettingType.Enum, choices_attribute: Optional[str] = None, choices: Optional[Type[Enum]] = None)[source]

Bases: SettingDescriptor

Presents a settable, enum-based value.

cast_value(value: int)

Casts value to the expected type.

choices: Optional[Type[Enum]]
choices_attribute: Optional[str]
extras: Dict
id: str
name: str
property: str
setter: Optional[Callable]
setter_name: Optional[str]
type: SettingType = 1
unit: Optional[str]
class miio.descriptors.NumberSettingDescriptor(*, id: str, name: str, property: str, unit: Optional[str] = None, setter: Optional[Callable] = None, setter_name: Optional[str] = None, extras: Dict = NOTHING, min_value: int, max_value: int, step: int, range_attribute: Optional[str] = None, type: SettingType = SettingType.Number)[source]

Bases: SettingDescriptor

Presents a settable, numerical value.

If range_attribute is set, the named property that should return :class:ValidSettingRange will be used to obtain {min,max}_value and step.

cast_value(value: int)

Casts value to the expected type.

extras: Dict
id: str
max_value: int
min_value: int
name: str
property: str
range_attribute: Optional[str]
setter: Optional[Callable]
setter_name: Optional[str]
step: int
type: SettingType = 1
unit: Optional[str]
class miio.descriptors.SensorDescriptor(id: str, type: type, name: str, property: str, unit: Optional[str] = None, extras: Dict = NOTHING)[source]

Bases: object

Describes a sensor exposed by the device.

This information can be used by library users to programatically access information what types of data is available to display to users.

Prefer @sensor for constructing these.

extras: Dict
id: str
name: str
property: str
type: type
unit: Optional[str]
class miio.descriptors.SettingDescriptor(*, id: str, name: str, property: str, unit: Optional[str] = None, setter: Optional[Callable] = None, setter_name: Optional[str] = None, extras: Dict = NOTHING)[source]

Bases: object

Presents a settable value.

cast_value(value: int)[source]

Casts value to the expected type.

extras: Dict
id: str
name: str
property: str
setter: Optional[Callable]
setter_name: Optional[str]
type = 1
unit: Optional[str]
class miio.descriptors.SettingType(value)[source]

Bases: Enum

An enumeration.

Boolean = 3
Enum = 4
Number = 2
Undefined = 1
class miio.descriptors.ValidSettingRange(min_value: int, max_value: int, step: int = 1)[source]

Bases: object

Describes a valid input range for a setting.

max_value: int
min_value: int
step: int