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 properties()
,
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.
- class miio.descriptors.AccessFlags(value)[source]
Bases:
Flag
Defines the access rights for the property behind the descriptor.
- Execute = 4
- Read = 1
- Write = 2
- class miio.descriptors.ActionDescriptor(id: str, name: str, type: None = None, unit: str | None = None, status_attribute: str | None = None, extras: Dict = _Nothing.NOTHING, method: Callable | None = None, method_name: str | None = None, inputs: List[Any] | None = None, access: AccessFlags = AccessFlags.Execute)[source]
Bases:
Descriptor
Describes a button exposed by the device.
- access: AccessFlags
Access flags (read, write, execute) for the described item.
- method_name: str | None
Name of the method in the device class that can be used to execute the action.
- class miio.descriptors.Descriptor(id: str, name: str, type: None = None, unit: str | None = None, status_attribute: str | None = None, extras: ~typing.Dict = _Nothing.NOTHING, access: ~miio.descriptors.AccessFlags = AccessFlags.None)[source]
Bases:
object
Base class for all descriptors.
- access: AccessFlags
Access flags (read, write, execute) for the described item.
- class miio.descriptors.EnumDescriptor(*, id: str, name: str, type: None = None, unit: str | None = None, extras: Dict = _Nothing.NOTHING, status_attribute: str, access: AccessFlags = AccessFlags.Read, setter: Callable | None = None, setter_name: str | None = None, constraint: PropertyConstraint = PropertyConstraint.Choice, choices_attribute: str | None = None, choices: Type[Enum] | None = None)[source]
Bases:
PropertyDescriptor
Presents a settable, enum-based value.
- access: AccessFlags
Sensors are read-only and settings are (usually) read-write.
- constraint: PropertyConstraint
Constraint type defining the allowed values for an integer property.
- class miio.descriptors.PropertyConstraint(value)[source]
Bases:
Enum
Defines constraints for integer based properties.
- Choice = 3
- Range = 2
- Unset = 1
- class miio.descriptors.PropertyDescriptor(*, id: str, name: str, type: None = None, unit: str | None = None, extras: Dict = _Nothing.NOTHING, status_attribute: str, access: AccessFlags = AccessFlags.Read, constraint: PropertyConstraint = PropertyConstraint.Unset, setter: Callable | None = None, setter_name: str | None = None)[source]
Bases:
Descriptor
Describes a property exposed by the device.
This information can be used by library users to programmatically access information what types of data is available to display to users.
- access: AccessFlags
Sensors are read-only and settings are (usually) read-write.
- constraint: PropertyConstraint
Constraint type defining the allowed values for an integer property.
- class miio.descriptors.RangeDescriptor(*, id: str, name: str, unit: str | None = None, extras: ~typing.Dict = _Nothing.NOTHING, status_attribute: str, access: ~miio.descriptors.AccessFlags = AccessFlags.Read, setter: ~typing.Callable | None = None, setter_name: str | None = None, min_value: int, max_value: int, step: int, range_attribute: str | None = None, type: int = <class 'int'>, constraint: ~miio.descriptors.PropertyConstraint = PropertyConstraint.Range)[source]
Bases:
PropertyDescriptor
Presents a settable, numerical value constrained by min, max, and step.
If range_attribute is set, the named property that should return a
ValidSettingRange
object to override the {min,max}_value and step values.- access: AccessFlags
Sensors are read-only and settings are (usually) read-write.
- constraint: PropertyConstraint
Constraint type defining the allowed values for an integer property.
- range_attribute: str | None
Name of the attribute in the device class that returns the range. If set, this will override the individual min/max/step values.