miio package

Submodules

miio.airconditioningcompanion module

class miio.airconditioningcompanion.AirConditioningCompanion(ip=None, token=None, start_id=0, debug=0, lazy_discover=True, model='lumi.acpartner.v2')[source]

Bases: miio.device.Device

Main class representing Xiaomi Air Conditioning Companion V1 and V2.

classmethod get_device_group()
learn(slot=30)[source]

Learn an infrared command.

learn_result()[source]

Read the learned command.

learn_stop(slot=30)[source]

Stop learning of a infrared command.

off()[source]

Turn the air condition off by infrared.

on()[source]

Turn the air condition on by infrared.

send_command(command)[source]

Send a command to the air conditioner.

Parameters:command (str) – Command to execute
send_configuration(model, power, operation_mode, target_temperature, fan_speed, swing_mode, led)[source]
send_ir_code(model, code, slot=0)[source]

Play a captured command.

Parameters:
  • model (str) – Air condition model
  • code (str) – Command to execute
  • slot (int) – Unknown internal register or slot
status()[source]

Return device status.

Return type:AirConditioningCompanionStatus
exception miio.airconditioningcompanion.AirConditioningCompanionException[source]

Bases: miio.exceptions.DeviceException

class miio.airconditioningcompanion.AirConditioningCompanionStatus(data)[source]

Bases: object

Container for status reports of the Xiaomi AC Companion.

air_condition_brand

Brand of the air conditioner.

Known brand ids are 0x0182, 0x0097, 0x0037, 0x0202, 0x02782, 0x0197, 0x0192.

Return type:int
air_condition_configuration
Return type:int
air_condition_model

Model of the air conditioner.

Return type:bytes
air_condition_remote

Known remote ids:

0x80111111, 0x80111112 (brand: 0x0182) 0x80222221 (brand: 0x0097) 0x80333331 (brand: 0x0037) 0x80444441 (brand: 0x0202) 0x80555551 (brand: 0x2782) 0x80777771 (brand: 0x0197) 0x80666661 (brand: 0x0192)

Return type:int
device_type

Device type identifier.

Return type:int
fan_speed

Current fan speed.

Return type:Optional[FanSpeed]
is_on

True if the device is turned on.

Return type:bool
led

Current LED state.

Return type:Optional[bool]
load_power

Current power load of the air conditioner.

Return type:int
mode

Current operation mode.

Return type:Optional[OperationMode]
model_format

Version number of the model format.

Return type:int
power

Current power state.

Return type:str
power_socket

Current socket power state.

Return type:Optional[str]
state_format

Version number of the state format.

Known values are: 1, 2, 3

Return type:int
swing_mode

Current swing mode.

Return type:Optional[SwingMode]
target_temperature

Target temperature.

Return type:Optional[int]
class miio.airconditioningcompanion.AirConditioningCompanionV3(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.airconditioningcompanion.AirConditioningCompanion

classmethod get_device_group()
socket_off()[source]

Socket power off.

socket_on()[source]

Socket power on.

status()[source]

Return device status.

Return type:AirConditioningCompanionStatus
class miio.airconditioningcompanion.FanSpeed[source]

Bases: enum.Enum

An enumeration.

Auto = 3
High = 2
Low = 0
Medium = 1
class miio.airconditioningcompanion.Led[source]

Bases: enum.Enum

An enumeration.

Off = 'A'
On = '0'
class miio.airconditioningcompanion.OperationMode[source]

Bases: enum.Enum

An enumeration.

Auto = 2
Cool = 1
Dehumidify = 3
Heat = 0
Ventilate = 4
class miio.airconditioningcompanion.Power[source]

Bases: enum.Enum

An enumeration.

Off = 0
On = 1
class miio.airconditioningcompanion.SwingMode[source]

Bases: enum.Enum

An enumeration.

ChigoOff = 'D'
ChigoOn = 'C'
Off = '1'
On = '0'
Unknown2 = '2'
Unknown7 = '7'

miio.airfresh module

class miio.airfresh.AirFresh(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.device.Device

Main class representing the air fresh.

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

reset_filter()[source]

Resets filter hours used and remaining life.

set_buzzer(buzzer)[source]

Set buzzer on/off.

set_child_lock(lock)[source]

Set child lock on/off.

set_extra_features(value)[source]

Storage register to enable extra features at the app.

set_led(led)[source]

Turn led on/off.

set_led_brightness(brightness)[source]

Set led brightness.

set_mode(mode)[source]

Set mode.

status()[source]

Retrieve properties.

Return type:AirFreshStatus
exception miio.airfresh.AirFreshException[source]

Bases: miio.exceptions.DeviceException

class miio.airfresh.AirFreshStatus(data)[source]

Bases: object

Container for status reports from the air fresh.

aqi

Air quality index.

Return type:int
average_aqi

Average of the air quality index.

Return type:int
buzzer

Return True if buzzer is on.

Return type:Optional[bool]
child_lock

Return True if child lock is on.

Return type:bool
co2

Carbon dioxide.

Return type:int
extra_features
Return type:Optional[int]
filter_hours_used

How long the filter has been in use.

Return type:int
filter_life_remaining

Time until the filter should be changed.

Return type:int
humidity

Current humidity.

Return type:int
is_on

Return True if device is on.

Return type:bool
led

Return True if LED is on.

Return type:bool
led_brightness

Brightness of the LED.

Return type:Optional[LedBrightness]
mode

Current operation mode.

Return type:OperationMode
motor_speed

Speed of the motor.

Return type:int
power

Power state.

Return type:str
temperature

Current temperature, if available.

Return type:Optional[float]
use_time

How long the device has been active in seconds.

Return type:int
class miio.airfresh.LedBrightness[source]

Bases: enum.Enum

An enumeration.

Bright = 0
Dim = 1
Off = 2
class miio.airfresh.OperationMode[source]

Bases: enum.Enum

An enumeration.

Auto = 'auto'
Interval = 'interval'
Low = 'low'
Middle = 'middle'
Silent = 'silent'
Strong = 'strong'

miio.airhumidifier module

class miio.airhumidifier.AirHumidifier(ip=None, token=None, start_id=0, debug=0, lazy_discover=True, model='zhimi.humidifier.v1')[source]

Bases: miio.device.Device

Implementation of Xiaomi Mi Air Humidifier.

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

set_buzzer(buzzer)[source]

Set buzzer on/off.

set_child_lock(lock)[source]

Set child lock on/off.

set_dry(dry)[source]

Set dry mode on/off.

set_led(led)[source]

Turn led on/off.

set_led_brightness(brightness)[source]

Set led brightness.

set_mode(mode)[source]

Set mode.

set_target_humidity(humidity)[source]

Set the target humidity.

status()[source]

Retrieve properties.

Return type:AirHumidifierStatus
class miio.airhumidifier.AirHumidifierCA1(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.airhumidifier.AirHumidifier

classmethod get_device_group()
class miio.airhumidifier.AirHumidifierCB1(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.airhumidifier.AirHumidifier

classmethod get_device_group()
exception miio.airhumidifier.AirHumidifierException[source]

Bases: miio.exceptions.DeviceException

class miio.airhumidifier.AirHumidifierStatus(data, device_info)[source]

Bases: object

Container for status reports from the air humidifier.

button_pressed

Last pressed button.

Return type:Optional[str]
buzzer

True if buzzer is turned on.

Return type:bool
child_lock

Return True if child lock is on.

Return type:bool
depth

The remaining amount of water in percent.

Return type:Optional[int]
dry

Dry mode: The amount of water is not enough to continue to work for about 8 hours.

Return True if dry mode is on if available.

Return type:Optional[bool]
firmware_version

Returns the fw_ver of miIO.info. For example 1.2.9_5033.

Return type:str
firmware_version_major
Return type:str
firmware_version_minor
Return type:int
hardware_version

The hardware version.

Return type:Optional[str]
humidity

Current humidity.

Return type:int
is_on

True if device is turned on.

Return type:bool
led_brightness

LED brightness if available.

Return type:Optional[LedBrightness]
mode

Operation mode. Can be either silent, medium or high.

Return type:OperationMode
motor_speed

Current fan speed.

Return type:Optional[int]
power

Power state.

Return type:str
strong_mode_enabled
Return type:bool
target_humidity

Target humidity. Can be either 30, 40, 50, 60, 70, 80 percent.

Return type:int
temperature

Current temperature, if available.

Return type:Optional[float]
trans_level

The meaning of the property is unknown.

The property is used to determine the strong mode is enabled on old firmware.

Return type:Optional[int]
use_time

How long the device has been active in seconds.

Return type:Optional[int]
class miio.airhumidifier.LedBrightness[source]

Bases: enum.Enum

An enumeration.

Bright = 0
Dim = 1
Off = 2
class miio.airhumidifier.OperationMode[source]

Bases: enum.Enum

An enumeration.

Auto = 'auto'
High = 'high'
Medium = 'medium'
Silent = 'silent'
Strong = 'strong'

miio.airpurifier module

class miio.airpurifier.AirPurifier(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.device.Device

Main class representing the air purifier.

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

reset_filter()[source]

Resets filter hours used and remaining life.

set_auto_detect(auto_detect)[source]

Set auto detect on/off. It’s a feature of the AirPurifier V1 & V3

set_buzzer(buzzer)[source]

Set buzzer on/off.

set_child_lock(lock)[source]

Set child lock on/off.

set_extra_features(value)[source]

Storage register to enable extra features at the app.

app_extra=1 unlocks a turbo mode supported feature

set_favorite_level(level)[source]

Set favorite level.

set_learn_mode(learn_mode)[source]

Set the Learn Mode on/off.

set_led(led)[source]

Turn led on/off.

set_led_brightness(brightness)[source]

Set led brightness.

set_mode(mode)[source]

Set mode.

set_volume(volume)[source]

Set volume of sound notifications [0-100].

status()[source]

Retrieve properties.

Return type:AirPurifierStatus
exception miio.airpurifier.AirPurifierException[source]

Bases: miio.exceptions.DeviceException

class miio.airpurifier.AirPurifierStatus(data)[source]

Bases: object

Container for status reports from the air purifier.

aqi

Air quality index.

Return type:int
auto_detect

Return True if auto detect is enabled.

Return type:Optional[bool]
average_aqi

Average of the air quality index.

Return type:int
button_pressed

Last pressed button.

Return type:Optional[str]
buzzer

Return True if buzzer is on.

Return type:Optional[bool]
child_lock

Return True if child lock is on.

Return type:bool
extra_features
Return type:Optional[int]
favorite_level

Return favorite level, which is used if the mode is favorite.

Return type:int
filter_hours_used

How long the filter has been in use.

Return type:int
filter_life_remaining

Time until the filter should be changed.

Return type:int
filter_rfid_product_id

RFID product ID of installed filter.

Return type:Optional[str]
filter_rfid_tag

RFID tag ID of installed filter.

Return type:Optional[str]
filter_type

Type of installed filter.

Return type:Optional[FilterType]
humidity

Current humidity.

Return type:int
illuminance

Environment illuminance level in lux [0-200]. Sensor value is updated only when device is turned on.

Return type:Optional[int]
is_on

Return True if device is on.

Return type:bool
learn_mode

Return True if Learn Mode is enabled.

Return type:bool
led

Return True if LED is on.

Return type:bool
led_brightness

Brightness of the LED.

Return type:Optional[LedBrightness]
mode

Current operation mode.

Return type:OperationMode
motor2_speed

Speed of the 2nd motor.

Return type:Optional[int]
motor_speed

Speed of the motor.

Return type:int
power

Power state.

Return type:str
purify_volume

The volume of purified air in cubic meter.

Return type:int
sleep_mode

Operation mode of the sleep state. (Idle vs. Silent)

Return type:Optional[SleepMode]
sleep_mode_learn_count
Return type:Optional[int]
sleep_time
Return type:Optional[int]
temperature

Current temperature, if available.

Return type:Optional[float]
turbo_mode_supported
Return type:Optional[bool]
use_time

How long the device has been active in seconds.

Return type:int
volume

Volume of sound notifications [0-100].

Return type:Optional[int]
class miio.airpurifier.LedBrightness[source]

Bases: enum.Enum

An enumeration.

Bright = 0
Dim = 1
Off = 2
class miio.airpurifier.OperationMode[source]

Bases: enum.Enum

An enumeration.

Auto = 'auto'
Favorite = 'favorite'
High = 'high'
Idle = 'idle'
Medium = 'medium'
Silent = 'silent'
Strong = 'strong'
class miio.airpurifier.SleepMode[source]

Bases: enum.Enum

An enumeration.

Idle = 'idle'
Off = 'poweroff'
Silent = 'silent'

miio.airpurifier_miot module

class miio.airpurifier_miot.AirPurifierMiot(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.miot_device.MiotDevice

Main class representing the air purifier which uses MIoT protocol.

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

set_buzzer(buzzer)[source]

Set buzzer on/off.

set_child_lock(lock)[source]

Set child lock on/off.

set_fan_level(level)[source]

Set fan level.

set_favorite_level(level)[source]

Set the favorite level used when the mode is favorite, should be between 0 and 14.

set_favorite_rpm(rpm)[source]

Set favorite motor speed.

set_led(led)[source]

Turn led on/off.

set_led_brightness(brightness)[source]

Set led brightness.

set_mode(mode)[source]

Set mode.

set_volume(volume)[source]

Set buzzer volume.

status()[source]

Retrieve properties.

Return type:AirPurifierMiotStatus
exception miio.airpurifier_miot.AirPurifierMiotException[source]

Bases: miio.exceptions.DeviceException

class miio.airpurifier_miot.AirPurifierMiotStatus(data)[source]

Bases: object

Container for status reports from the air purifier.

aqi

Air quality index.

Return type:int
average_aqi

Average of the air quality index.

Return type:int
buzzer

Return True if buzzer is on.

Return type:Optional[bool]
buzzer_volume

Return buzzer volume.

Return type:Optional[int]
child_lock

Return True if child lock is on.

Return type:bool
fan_level

Current fan level.

Return type:int
favorite_level

Return favorite level, which is used if the mode is favorite.

Return type:int
filter_hours_used

How long the filter has been in use.

Return type:int
filter_life_remaining

Time until the filter should be changed.

Return type:int
filter_rfid_product_id

RFID product ID of installed filter.

Return type:Optional[str]
filter_rfid_tag

RFID tag ID of installed filter.

Return type:Optional[str]
filter_type

Type of installed filter.

Return type:Optional[FilterType]
humidity

Current humidity.

Return type:int
is_on

Return True if device is on.

Return type:bool
led

Return True if LED is on.

Return type:bool
led_brightness

Brightness of the LED.

Return type:Optional[LedBrightness]
mode

Current operation mode.

Return type:OperationMode
motor_speed

Speed of the motor.

Return type:int
power

Power state.

Return type:str
purify_volume

The volume of purified air in cubic meter.

Return type:int
temperature

Current temperature, if available.

Return type:Optional[float]
use_time

How long the device has been active in seconds.

Return type:int
class miio.airpurifier_miot.LedBrightness[source]

Bases: enum.Enum

An enumeration.

Bright = 0
Dim = 1
Off = 2
class miio.airpurifier_miot.OperationMode[source]

Bases: enum.Enum

An enumeration.

Auto = 0
Fan = 3
Favorite = 2
Silent = 1

miio.airqualitymonitor module

class miio.airqualitymonitor.AirQualityMonitor(ip=None, token=None, start_id=0, debug=0, lazy_discover=True, model='zhimi.airmonitor.v1')[source]

Bases: miio.device.Device

Xiaomi PM2.5 Air Quality Monitor.

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

set_auto_close(auto_close)[source]

Purpose unknown.

set_display_clock(display_clock)[source]

Enable/disable displaying a clock instead the AQI.

set_night_mode(night_mode)[source]

Decrease the brightness of the display.

set_night_time(begin_hour, begin_minute, end_hour, end_minute)[source]

Enable night mode daily at bedtime.

status()[source]

Return device status.

Return type:AirQualityMonitorStatus
exception miio.airqualitymonitor.AirQualityMonitorException[source]

Bases: miio.exceptions.DeviceException

class miio.airqualitymonitor.AirQualityMonitorStatus(data)[source]

Bases: object

Container of air quality monitor status.

aqi

Air quality index value. (0…600).

Return type:Optional[int]
battery

Current battery level (0…100).

Return type:Optional[int]
co2

Return co2 value (400…9999ppm).

Return type:Optional[int]
co2e

Return co2e value (400…9999ppm).

Return type:Optional[int]
display_clock

Display a clock instead the AQI.

Return type:Optional[bool]
humidity

Return humidity value (0…100%).

Return type:Optional[float]
is_on

Return True if the device is turned on.

Return type:bool
night_mode

Return True if the night mode is on.

Return type:Optional[bool]
night_time_begin

Return the begin of the night time.

Return type:Optional[str]
night_time_end

Return the end of the night time.

Return type:Optional[str]
pm25

Return pm2.5 value (0…999μg/m³).

Return type:Optional[float]
power

Current power state.

Return type:Optional[str]
sensor_state

Sensor state.

Return type:Optional[str]
temperature

Return temperature value (-10…50°C).

Return type:Optional[float]
tvoc

Return tvoc value.

Return type:Optional[int]
usb_power

Return True if the device’s usb is on.

Return type:Optional[bool]

miio.aqaracamera module

Aqara camera support.

Support for lumi.camera.aq1

Todo

add alarm/sound parts (get_music_info, {get,set}_alarming_volume, set_default_music, play_music_new, set_sound_playing)

Todo

add sdcard status & fix all TODOS

Todo

add tests

class miio.aqaracamera.AqaraCamera(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.device.Device

Main class representing the Xiaomi Aqara Camera.

alarm_sound(sound_id)[source]

List or set the alarm sound.

arm()[source]

Arm the camera?

arm_status()[source]

Return arming information.

disarm()[source]

Disarm the camera?

flip_off()[source]

Flip off.

flip_on()[source]

Flip on.

fullstop_off()[source]

Fullstop off.

fullstop_on()[source]

Fullstop on.

classmethod get_device_group()
ir_off()[source]

IR off.

ir_on()[source]

IR on.

led_off()[source]

LED off.

led_on()[source]

LED on.

md_off()[source]

MD off.

md_on()[source]

IR on.

md_sensitivity(sensitivity)[source]

Get or set the motion detection sensitivity.

off()[source]

Camera off.

on()[source]

Camera on.

pair(timeout)[source]

Start (or stop with “0”) pairing.

sd_format()[source]

Format the SD card.

Returns True when formating has started successfully.

sd_status()[source]

SD card status.

set_alarm_volume(volume)[source]

Set alarm volume.

status()[source]

Camera status.

Return type:CameraStatus
class miio.aqaracamera.ArmStatus(is_armed, arm_wait_time, alarm_volume)[source]

Bases: object

Container for arm statuses.

exception miio.aqaracamera.CameraException[source]

Bases: miio.exceptions.DeviceException

class miio.aqaracamera.CameraOffset(x, y, radius)[source]

Bases: object

Container for camera offset data.

class miio.aqaracamera.CameraStatus(data)[source]

Bases: object

Container for status reports from the Aqara Camera.

av_id

TODO: What is this? ID for the cloud?

Return type:str
av_password

TODO: What is this? Password for the cloud?

Return type:str
channel_id

TODO: Zigbee channel?

Return type:int
flipped

TODO: If camera is flipped?

Return type:bool
fullstop

Is alarm triggered by MD.

Return type:bool
ir

IR mode.

is_on

True if device is currently on.

Return type:bool
led

LED status.

md

Motion detection state.

Return type:bool
md_sensitivity

Motion detection sensitivity.

offsets

Camera offset information.

Return type:CameraOffset
p2p_id

P2P ID for video and audio.

Return type:str
type

TODO: Type of the camera? Name?

Return type:str
video_status

Video state.

Return type:bool
class miio.aqaracamera.MotionDetectionSensitivity[source]

Bases: enum.IntEnum

‘Default’ values for md sensitivity. Currently unused as the value can also be set arbitrarily.

High = 6000000
Low = 11000000
Medium = 10000000
class miio.aqaracamera.SDCardStatus[source]

Bases: enum.IntEnum

State of the SD card.

FormatRequired = 2
Formating = 3
NoCardInserted = 0
Ok = 1

miio.ceil module

class miio.ceil.Ceil(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.device.Device

Main class representing Xiaomi Philips LED Ceiling Lamp.

automatic_color_temperature_off()[source]

Automatic color temperature off.

automatic_color_temperature_on()[source]

Automatic color temperature on.

delay_off(seconds)[source]

Turn off delay in seconds.

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

set_brightness(level)[source]

Set brightness level.

set_brightness_and_color_temperature(brightness, cct)[source]

Set brightness level and the correlated color temperature.

set_color_temperature(level)[source]

Set Correlated Color Temperature.

set_scene(number)[source]

Set a fixed scene. 4 fixed scenes are available (1-4)

smart_night_light_off()[source]

Smart Night Light off.

smart_night_light_on()[source]

Smart Night Light On.

status()[source]

Retrieve properties.

Return type:CeilStatus
exception miio.ceil.CeilException[source]

Bases: miio.exceptions.DeviceException

class miio.ceil.CeilStatus(data)[source]

Bases: object

Container for status reports from Xiaomi Philips LED Ceiling Lamp.

automatic_color_temperature

Automatic color temperature state.

Return type:bool
brightness

Current brightness.

Return type:int
color_temperature

Current color temperature.

Return type:int
delay_off_countdown

Countdown until turning off in seconds.

Return type:int
is_on

True if the device is turned on.

Return type:bool
power

Power state.

Return type:str
scene

Current fixed scene (brightness & colortemp).

Return type:int
smart_night_light

Smart night mode state.

Return type:bool

miio.chuangmi_camera module

Xiaomi Chuangmi camera (chuangmi.camera.ipc009, ipc019) support.

class miio.chuangmi_camera.CameraStatus(data)[source]

Bases: object

Container for status reports from the Xiaomi Chuangmi Camera.

flip

Image 180 degrees flip status.

Return type:bool
full_color

Full color with bad lighting conditions.

Return type:bool
improve_program

Customer experience improvement program status.

Return type:bool
light

Camera light status.

Return type:bool
max_client

Unknown.

Return type:int
mini_level

Unknown.

Return type:int
motion_record

Motion record status.

Return type:bool
night_mode

Night mode.

Return type:int
power

Camera power.

Return type:bool
sdcard_status

SD card status.

Return type:int
track

Tracking status.

Return type:bool
watermark

Apply watermark to video.

Return type:bool
wdr

Wide dynamic range status.

Return type:bool
class miio.chuangmi_camera.ChuangmiCamera(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.device.Device

Main class representing the Xiaomi Chuangmi Camera.

alarm()[source]

Sound a loud alarm for 10 seconds.

flip_off()[source]

Flip image 180 degrees off.

flip_on()[source]

Flip image 180 degrees on.

full_color_off()[source]

Full color off.

full_color_on()[source]

Full color on.

classmethod get_device_group()
improve_program_off()[source]

Improve program off.

improve_program_on()[source]

Improve program on.

light_off()[source]

Light off.

light_on()[source]

Light on.

motion_record_off()[source]

Motion record off, always record video.

motion_record_on()[source]

Start recording when motion detected.

motion_record_stop()[source]

Motion record off, video recording stopped.

night_mode_auto()[source]

Auto switch to night mode.

night_mode_off()[source]

Night mode off.

night_mode_on()[source]

Night mode always on.

off()[source]

Power off.

on()[source]

Power on.

rotate(direction)[source]

Rotate camera to given direction (left, right, up, down).

status()[source]

Retrieve properties.

Return type:CameraStatus
watermark_off()[source]

Watermark off.

watermark_on()[source]

Watermark on.

wdr_off()[source]

Wide dynamic range off.

wdr_on()[source]

Wide dynamic range on.

class miio.chuangmi_camera.Direction[source]

Bases: enum.Enum

Rotation direction.

Down = 4
Left = 1
Right = 2
Up = 3

miio.chuangmi_ir module

class miio.chuangmi_ir.ChuangmiIr(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.device.Device

Main class representing Chuangmi IR Remote Controller.

PRONTO_RE = re.compile('^([\\da-f]{4}\\s?){3,}([\\da-f]{4})$', re.IGNORECASE)
classmethod get_device_group()
get_indicator_led()[source]

Get the indicator led status.

learn(key=1)[source]

Learn an infrared command.

Parameters:key (int) – Storage slot, must be between 1 and 1000000
play(command)[source]

Plays a command in one of the supported formats.

play_pronto(pronto, repeats=1)[source]

Play a Pronto Hex encoded IR command. Supports only raw Pronto format, starting with 0000.

Parameters:
  • pronto (str) – Pronto Hex string.
  • repeats (int) – Number of extra signal repeats.
play_raw(command, frequency=38400)[source]

Play a captured command.

Parameters:
  • command (str) – Command to execute
  • frequency (int) – Execution frequency
classmethod pronto_to_raw(pronto, repeats=1)[source]

Play a Pronto Hex encoded IR command. Supports only raw Pronto format, starting with 0000.

Parameters:
  • pronto (str) – Pronto Hex string.
  • repeats (int) – Number of extra signal repeats.
read(key=1)[source]

Read a learned command.

Positive response (chuangmi.ir.v2): {‘key’: ‘1’, ‘code’: ‘Z6WPAasBAAA3BQAA4AwJAEA….AAABAAEBAQAAAQAA==’}

Negative response (chuangmi.ir.v2): {‘error’: {‘code’: -5002, ‘message’: ‘no code for this key’}, ‘id’: 5}

Negative response (chuangmi.ir.v2): {‘error’: {‘code’: -5003, ‘message’: ‘learn timeout’}, ‘id’: 17}

Parameters:key (int) – Slot to read from
set_indicator_led(indicator_led)[source]

Set the indicator led on/off.

exception miio.chuangmi_ir.ChuangmiIrException[source]

Bases: miio.exceptions.DeviceException

class miio.chuangmi_ir.ProntoPulseAdapter(subcon)[source]

Bases: construct.core.Adapter

miio.cooker module

class miio.cooker.Cooker(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.device.Device

Main class representing the cooker.

classmethod get_device_group()
get_temperature_history()[source]

Retrieves a temperature history.

The temperature is only available while cooking. Approx. six data points per minute.

Return type:TemperatureHistory
set_acknowledge()[source]

Enable warnings?

set_interaction(settings, timeouts)[source]

Set interaction. Supported by all cookers except MODEL_PRESS1

set_menu(profile)[source]

Select one of the default(?) cooking profiles

set_no_warnings()[source]

Disable warnings.

start(profile)[source]

Start cooking a profile.

status()[source]

Retrieve properties.

Return type:CookerStatus
stop()[source]

Stop cooking.

stop_outdated_firmware()[source]

Stop cooking (obsolete).

class miio.cooker.CookerCustomizations(custom)[source]

Bases: object

favorite_appointment
Return type:time
favorite_cooking
Return type:time
jingzhu_appointment
Return type:time
kuaizhu_appointment
Return type:time
zhuzhou_appointment
Return type:time
zhuzhou_cooking
Return type:time
exception miio.cooker.CookerException[source]

Bases: miio.exceptions.DeviceException

class miio.cooker.CookerSettings(settings=None)[source]

Bases: object

auto_keep_warm
Return type:bool
favorite_auto_keep_warm
Return type:bool
jingzhu_auto_keep_warm
Return type:bool
kuaizhu_auto_keep_warm
Return type:bool
led_on
Return type:bool
lid_open_warning
Return type:bool
lid_open_warning_delayed
Return type:bool
pressure_supported
Return type:bool
zhuzhou_auto_keep_warm
Return type:bool
class miio.cooker.CookerStatus(data)[source]

Bases: object

cooking_delayed

Wait n minutes before cooking / scheduled cooking.

Return type:Optional[int]
custom
Return type:Optional[CookerCustomizations]
duration

Duration of the cooking process.

Return type:int
favorite

Favored recipe id. Can be compared with the menu property.

Return type:int
firmware_version

Firmware version.

Return type:int
hardware_version

Hardware version.

Return type:int
interaction_timeouts

Interaction timeouts.

Return type:InteractionTimeouts
menu

Selected recipe id.

Return type:int
mode

Current operation mode.

Return type:OperationMode
remaining

Remaining minutes of the cooking process.

Return type:int
settings

Settings of the cooker.

Return type:CookerSettings
stage

Current stage if cooking.

Return type:Optional[CookingStage]
start_time

Start time of cooking?

The property “temp” is used for different purposes. Example values: 29, 031e0b23, 031e0b23031e

Return type:Optional[time]
temperature

Current temperature, if idle.

Example values: 29, 031e0b23, 031e0b23031e

Return type:Optional[int]
class miio.cooker.CookingStage(stage)[source]

Bases: object

description
Return type:str
name
Return type:str
raw
Return type:str
rice_id
Return type:int
state

10: Cooking finished 11: Cooking finished 12: Cooking finished

Return type:int
taste
Return type:int
taste_phase
Return type:int
class miio.cooker.InteractionTimeouts(timeouts=None)[source]

Bases: object

led_off
Return type:int
lid_open
Return type:int
lid_open_warning
Return type:int
class miio.cooker.OperationMode[source]

Bases: enum.Enum

An enumeration.

AutoKeepWarm = 'autokeepwarm'
Cancel = 'Отмена'
Cooking = 'cooking'
Finish = 'finish'
FinishA = 'finisha'
KeepTemp = 'keep_temp'
KeepWarm = 'keepwarm'
Notice = 'notice'
Offline = 'offline'
Online = 'online'
PreCook = 'precook'
Resume = 'resume'
ResumeP = 'resumep'
Running = 'running'
Start = 'start'
StartP = 'startp'
Waiting = 'waiting'
class miio.cooker.TemperatureHistory(data)[source]

Bases: object

raw
Return type:str
temperatures
Return type:List[int]

miio.device module

class miio.device.Device(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: object

Base class for all device implementations. This is the main class providing the basic protocol handling for devices using the miIO protocol. This class should not be initialized directly but a device-specific class inheriting it should be used instead of it.

configure_wifi(ssid, password, uid=0, extra_params=None)[source]

Configure the wifi settings.

classmethod get_device_group()
get_properties(properties, *, max_properties=None)[source]

Request properties in slices based on given max_properties.

This is necessary as some devices have limitation on how many properties can be queried at once.

If max_properties is None, all properties are requested at once.

Parameters:
  • properties (list) – List of properties to query from the device.
  • max_properties (int) – Number of properties that can be requested at once.

:return List of property values.

info()[source]

Get miIO protocol information from the device. This includes information about connected wlan network, and hardware and software versions.

Return type:DeviceInfo
raw_command(command, parameters)[source]

Send a raw command to the device. This is mostly useful when trying out commands which are not implemented by a given device instance.

Parameters:
  • command (str) – Command to send
  • parameters (dict) – Parameters to send
send(command, parameters=None, retry_count=3, *, extra_parameters=None)[source]

Send a command to the device.

Basic format of the request: {“id”: 1234, “method”: command, “parameters”: parameters}

extra_parameters allows passing elements to the top-level of the request. This is necessary for some devices, such as gateway devices, which expect the sub-device identifier to be on the top-level.

Parameters:
  • command (str) – Command to send
  • parameters (dict) – Parameters to send
  • retry_count (int) – How many times to retry on error
  • extra_parameters (dict) – Extra top-level parameters
Return type:

Any

send_handshake()[source]

Send initial handshake to the device.

update(url, md5)[source]

Start an OTA update.

update_progress()[source]

Return current update progress [0-100].

Return type:int
update_state()[source]

Return current update state.

class miio.device.DeviceInfo(data)[source]

Bases: object

Container of miIO device information. Hardware properties such as device model, MAC address, memory information, and hardware and software information is contained here.

accesspoint

Information about connected wlan accesspoint.

firmware_version

Firmware version if available.

Return type:Optional[str]
hardware_version

Hardware version if available.

Return type:Optional[str]
mac_address

MAC address if available.

Return type:Optional[str]
model

Model string if available.

Return type:Optional[str]
network_interface

Information about network configuration.

raw

Raw data as returned by the device.

class miio.device.UpdateState[source]

Bases: enum.Enum

An enumeration.

Downloading = 'downloading'
Failed = 'failed'
Idle = 'idle'
Installing = 'installing'

miio.miot_device module

class miio.miot_device.MiotDevice(mapping, ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.device.Device

Main class representing a MIoT device.

classmethod get_device_group()
get_properties_for_mapping()[source]

Retrieve raw properties based on mapping.

Return type:list
set_property(property_key, value)[source]

Sets property value.

miio.discovery module

class miio.discovery.Discovery[source]

Bases: object

mDNS discoverer for miIO based devices (_miio._udp.local). Calling discover_mdns() will cause this to subscribe for updates on _miio._udp.local until any key is pressed, after which a dict of detected devices is returned.

static discover_mdns()[source]

Discover devices with mdns until

Return type:Dict[str, Device]
class miio.discovery.Listener[source]

Bases: object

mDNS listener creating Device objects based on detected devices.

add_service(zeroconf, type, name)[source]
check_and_create_device(info, addr)[source]

Create a corresponding Device implementation for a given info and address..

Return type:Optional[Device]
miio.discovery.create_device(name, addr, device_cls)[source]

Return a device object for a zeroconf entry.

Return type:Device
miio.discovery.other_package_info(info, desc)[source]

Return information about another package supporting the device.

miio.discovery.pretty_token(token)[source]

Return a pretty string presentation for a token.

miio.extract_tokens module

class miio.extract_tokens.BackupDatabaseReader(dump_raw=False)[source]

Bases: object

Main class for reading backup files. The main usage is following:

r = BackupDatabaseReader()
devices = r.read_tokens("/tmp/database.sqlite")
for dev in devices:
    print("Got %s with token %s" % (dev.ip, dev.token)
static decrypt_ztoken(ztoken)[source]

Decrypt the given ztoken, used by apple.

static dump_raw(dev)[source]

Dump whole database.

read_android()[source]

Read Android-specific database file.

Return type:Iterator[DeviceConfig]
read_apple()[source]

Read Apple-specific database file.

Return type:Iterator[DeviceConfig]
read_tokens(db)[source]

Read device information out from a given database file.

Parameters:db (str) – Database file
Return type:Iterator[DeviceConfig]
class miio.extract_tokens.DeviceConfig(name, mac, ip, token, model, everything=None)[source]

Bases: object

A presentation of a device including its name, model, ip etc.

miio.extract_tokens.read_android_yeelight(db)[source]

Read tokens from Yeelight’s android backup.

Return type:Iterator[DeviceConfig]

miio.fan module

class miio.fan.Fan(ip=None, token=None, start_id=0, debug=0, lazy_discover=True, model='zhimi.fan.v3')[source]

Bases: miio.device.Device

Main class representing the Xiaomi Mi Smart Pedestal Fan.

delay_off(seconds)[source]

Set delay off seconds.

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

set_angle(angle)[source]

Set the oscillation angle.

set_buzzer(buzzer)[source]

Set buzzer on/off.

set_child_lock(lock)[source]

Set child lock on/off.

set_direct_speed(speed)[source]

Set speed of the direct mode.

set_led(led)[source]

Turn led on/off. Not supported by model SA1.

set_led_brightness(brightness)[source]

Set led brightness.

set_natural_speed(speed)[source]

Set natural level.

set_oscillate(oscillate)[source]

Set oscillate on/off.

set_rotate(direction)[source]

Rotate the fan by -5/+5 degrees left/right.

status()[source]

Retrieve properties.

Return type:FanStatus
exception miio.fan.FanException[source]

Bases: miio.exceptions.DeviceException

class miio.fan.FanP5(ip=None, token=None, start_id=0, debug=0, lazy_discover=True, model='dmaker.fan.p5')[source]

Bases: miio.device.Device

delay_off(minutes)[source]

Set delay off minutes.

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

set_angle(angle)[source]

Set the oscillation angle.

set_buzzer(buzzer)[source]

Set buzzer on/off.

set_child_lock(lock)[source]

Set child lock on/off.

set_led(led)[source]

Turn led on/off.

set_mode(mode)[source]

Set mode.

set_oscillate(oscillate)[source]

Set oscillate on/off.

set_rotate(direction)[source]

Rotate the fan by -5/+5 degrees left/right.

set_speed(speed)[source]

Set speed.

status()[source]

Retrieve properties.

Return type:FanStatusP5
class miio.fan.FanSA1(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.fan.Fan

classmethod get_device_group()
class miio.fan.FanStatus(data)[source]

Bases: object

Container for status reports from the Xiaomi Mi Smart Pedestal Fan.

ac_power

True if powered by AC.

Return type:bool
angle

Current angle.

Return type:int
battery

Current battery level.

Return type:Optional[int]
battery_charge

State of the battery charger, if available.

Return type:Optional[str]
battery_state

State of the battery, if available.

Return type:Optional[str]
button_pressed

Last pressed button.

Return type:Optional[str]
buzzer

True if buzzer is turned on.

Return type:bool
child_lock

True if child lock is on.

Return type:bool
delay_off_countdown

Countdown until turning off in seconds.

Return type:int
direct_speed

Speed level in direct mode.

Return type:Optional[int]
humidity

Current humidity.

Return type:Optional[int]
is_on

True if device is currently on.

Return type:bool
led

True if LED is turned on, if available.

Return type:Optional[bool]
led_brightness

LED brightness, if available.

Return type:Optional[LedBrightness]
natural_speed

Speed level in natural mode.

Return type:Optional[int]
oscillate

True if oscillation is enabled.

Return type:bool
power

Power state.

Return type:str
speed

Speed of the motor.

Return type:int
temperature

Current temperature, if available.

Return type:Optional[float]
use_time

How long the device has been active in seconds.

Return type:int
class miio.fan.FanStatusP5(data)[source]

Bases: object

Container for status reports from the Xiaomi Mi Smart Pedestal Fan DMaker P5.

angle

Oscillation angle.

Return type:int
buzzer

True if buzzer is turned on.

Return type:bool
child_lock

True if child lock is on.

Return type:bool
delay_off_countdown

Countdown until turning off in seconds.

Return type:int
is_on

True if device is currently on.

Return type:bool
led

True if LED is turned on, if available.

Return type:bool
mode

Operation mode.

Return type:OperationMode
oscillate

True if oscillation is enabled.

Return type:bool
power

Power state.

Return type:str
speed

Speed of the motor.

Return type:int
class miio.fan.FanV2(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.fan.Fan

classmethod get_device_group()
class miio.fan.FanZA1(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.fan.Fan

classmethod get_device_group()
class miio.fan.FanZA3(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.fan.Fan

classmethod get_device_group()
class miio.fan.FanZA4(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.fan.Fan

classmethod get_device_group()
class miio.fan.LedBrightness[source]

Bases: enum.Enum

An enumeration.

Bright = 0
Dim = 1
Off = 2
class miio.fan.MoveDirection[source]

Bases: enum.Enum

An enumeration.

Left = 'left'
Right = 'right'
class miio.fan.OperationMode[source]

Bases: enum.Enum

An enumeration.

Nature = 'nature'
Normal = 'normal'

miio.philips_bulb module

class miio.philips_bulb.PhilipsBulb(ip=None, token=None, start_id=0, debug=0, lazy_discover=True, model='philips.light.bulb')[source]

Bases: miio.philips_bulb.PhilipsWhiteBulb

classmethod get_device_group()
set_brightness_and_color_temperature(brightness, cct)[source]

Set brightness level and the correlated color temperature.

set_color_temperature(level)[source]

Set Correlated Color Temperature.

set_scene(number)[source]

Set scene number.

exception miio.philips_bulb.PhilipsBulbException[source]

Bases: miio.exceptions.DeviceException

class miio.philips_bulb.PhilipsBulbStatus(data)[source]

Bases: object

Container for status reports from Xiaomi Philips LED Ceiling Lamp

brightness
Return type:Optional[int]
color_temperature
Return type:Optional[int]
delay_off_countdown
Return type:int
is_on
Return type:bool
power
Return type:str
scene
Return type:Optional[int]
class miio.philips_bulb.PhilipsWhiteBulb(ip=None, token=None, start_id=0, debug=0, lazy_discover=True, model='philips.light.hbulb')[source]

Bases: miio.device.Device

Main class representing Xiaomi Philips White LED Ball Lamp.

delay_off(seconds)[source]

Set delay off seconds.

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

set_brightness(level)[source]

Set brightness level.

status()[source]

Retrieve properties.

Return type:PhilipsBulbStatus

miio.philips_eyecare module

class miio.philips_eyecare.PhilipsEyecare(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.device.Device

Main class representing Xiaomi Philips Eyecare Smart Lamp 2.

ambient_off()[source]

Turn the ambient light off.

ambient_on()[source]

Turn the ambient light on.

delay_off(minutes)[source]

Set delay off minutes.

eyecare_off()[source]

Turn the eyecare mode off.

eyecare_on()[source]

Turn the eyecare mode on.

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

reminder_off()[source]

Disable the eye fatigue reminder / notification.

reminder_on()[source]

Enable the eye fatigue reminder / notification.

set_ambient_brightness(level)[source]

Set the brightness of the ambient light.

set_brightness(level)[source]

Set brightness level of the primary light.

set_scene(number)[source]

Set one of the fixed eyecare user scenes.

smart_night_light_off()[source]

Turn the smart night light mode off.

smart_night_light_on()[source]

Turn the smart night light mode on.

status()[source]

Retrieve properties.

Return type:PhilipsEyecareStatus
exception miio.philips_eyecare.PhilipsEyecareException[source]

Bases: miio.exceptions.DeviceException

class miio.philips_eyecare.PhilipsEyecareStatus(data)[source]

Bases: object

Container for status reports from Xiaomi Philips Eyecare Smart Lamp 2

ambient

True if the ambient light (second light source) is on.

Return type:bool
ambient_brightness

Brightness of the ambient light.

Return type:int
brightness

Current brightness of the primary light.

Return type:int
delay_off_countdown

Countdown until turning off in minutes.

Return type:int
eyecare

True if the eyecare mode is on.

Return type:bool
is_on

True if the device is turned on.

Return type:bool
power

Power state.

Return type:str
reminder

Indicates the eye fatigue notification is enabled or not.

Return type:bool
scene

Current fixed scene.

Return type:int
smart_night_light

True if the smart night light mode is on.

Return type:bool

miio.philips_moonlight module

class miio.philips_moonlight.PhilipsMoonlight(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.device.Device

Main class representing Xiaomi Philips Zhirui Bedside Lamp.

Not yet implemented features/methods:

add_mb # Add miband get_band_period # Bracelet work time get_mb_rssi # Miband RSSI get_mb_mac # Miband MAC address enable_mibs set_band_period miIO.bleStartSearchBand miIO.bleGetNearbyBandList

enable_sub_voice # Sub voice control? enable_voice # Voice control

skip_breath set_sleep_time set_wakeup_time en_sleep en_wakeup go_night # Night light / read mode get_wakeup_time enable_bl # Night light

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

set_brightness(level)[source]

Set brightness level.

set_brightness_and_color_temperature(brightness, cct)[source]

Set brightness level and the correlated color temperature.

set_brightness_and_rgb(brightness, rgb)[source]

Set brightness level and the color.

set_color_temperature(level)[source]

Set Correlated Color Temperature.

set_rgb(rgb)[source]

Set color in RGB.

set_scene(number)[source]

Set scene number.

status()[source]

Retrieve properties.

Return type:PhilipsMoonlightStatus
exception miio.philips_moonlight.PhilipsMoonlightException[source]

Bases: miio.exceptions.DeviceException

class miio.philips_moonlight.PhilipsMoonlightStatus(data)[source]

Bases: object

Container for status reports from Xiaomi Philips Zhirui Bedside Lamp.

brand
Return type:bool
brand_sleep
Return type:bool
brightness
Return type:int
color_temperature
Return type:int
is_on
Return type:bool
power
Return type:str
rgb

Return color in RGB.

Return type:Tuple[int, int, int]
scene
Return type:int
sleep_assistant

Example values:

0: Unknown 1: Unknown 2: Sleep assistant enabled 3: Awake

Return type:int
sleep_off_time
Return type:int
total_assistant_sleep_time
Return type:int
wake_up_time
Return type:[<class ‘int’>, <class ‘int’>, <class ‘int’>]

miio.chuangmi_plug module

class miio.chuangmi_plug.ChuangmiPlug(ip=None, token=None, start_id=0, debug=0, lazy_discover=True, model='chuangmi.plug.m1')[source]

Bases: miio.device.Device

Main class representing the Chuangmi Plug.

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

set_wifi_led(wifi_led)[source]

Set the wifi led on/off.

status()[source]

Retrieve properties.

Return type:ChuangmiPlugStatus
usb_off()[source]

Power off.

usb_on()[source]

Power on.

class miio.chuangmi_plug.ChuangmiPlugStatus(data)[source]

Bases: object

Container for status reports from the plug.

is_on

True if device is on.

Return type:bool
load_power

Current power load, if available.

Return type:Optional[float]
power

Current power state.

Return type:bool
temperature
Return type:int
usb_power

True if USB is on.

Return type:Optional[bool]
wifi_led

True if the wifi led is turned on.

Return type:Optional[bool]
miio.chuangmi_plug.Plug(ip: str = None, token: str = None, start_id: int = 0, debug: int = 0, lazy_discover: bool = True) → None[source]
miio.chuangmi_plug.PlugV1(ip: str = None, token: str = None, start_id: int = 0, debug: int = 0, lazy_discover: bool = True) → None[source]
miio.chuangmi_plug.PlugV3(ip: str = None, token: str = None, start_id: int = 0, debug: int = 0, lazy_discover: bool = True) → None[source]

miio.protocol module

miIO protocol implementation

This module contains the implementation of the routines to encrypt and decrypt miIO payloads with a device-specific token.

The payloads to be encrypted (to be passed to a device) are expected to be JSON objects, the same applies for decryption where they are converted automatically to JSON objects. If the decryption fails, raw bytes as returned by the device are returned.

An usage example can be seen in the source of miio.Device.send(). If the decryption fails, raw bytes as returned by the device are returned.

class miio.protocol.EncryptionAdapter(subcon)[source]

Bases: construct.core.Adapter

Adapter to handle communication encryption.

class miio.protocol.TimeAdapter(subcon)[source]

Bases: construct.core.Adapter

Adapter for timestamp conversion.

class miio.protocol.Utils[source]

Bases: object

This class is adapted from the original xpn.py code by gst666

static checksum_field_bytes(ctx)[source]

Gather bytes for checksum calculation

Return type:bytearray
static decrypt(ciphertext, token)[source]

Decrypt ciphertext with a given token.

Parameters:
  • ciphertext (bytes) – Ciphertext to decrypt
  • token (bytes) – Token to use
Return type:

bytes

Returns:

Decrypted bytes object

static encrypt(plaintext, token)[source]

Encrypt plaintext with a given token.

Parameters:
  • plaintext (bytes) – Plaintext (json) to encrypt
  • token (bytes) – Token to use
Return type:

bytes

Returns:

Encrypted bytes

static get_length(x)[source]

Return total packet length.

Return type:int
static is_hello(x)[source]

Return if packet is a hello packet.

Return type:bool
static key_iv(token)[source]

Generate an IV used for encryption based on given token.

Return type:Tuple[bytes, bytes]
static md5(data)[source]

Calculates a md5 hashsum for the given bytes object.

Return type:bytes
static verify_token(token)[source]

Checks if the given token is of correct type and length.

miio.powerstrip module

class miio.powerstrip.PowerMode[source]

Bases: enum.Enum

An enumeration.

Eco = 'green'
Normal = 'normal'
class miio.powerstrip.PowerStrip(ip=None, token=None, start_id=0, debug=0, lazy_discover=True, model='qmi.powerstrip.v1')[source]

Bases: miio.device.Device

Main class representing the smart power strip.

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

set_power_mode(mode)[source]

Set the power mode.

set_power_price(price)[source]

Set the power price.

set_realtime_power(power)[source]

Set the realtime power on/off.

set_wifi_led(led)[source]

Set the wifi led on/off.

status()[source]

Retrieve properties.

Return type:PowerStripStatus
exception miio.powerstrip.PowerStripException[source]

Bases: miio.exceptions.DeviceException

class miio.powerstrip.PowerStripStatus(data)[source]

Bases: object

Container for status reports from the power strip.

current

Current, if available. Meaning and voltage reference unknown.

Return type:Optional[float]
is_on

True if the device is turned on.

Return type:bool
leakage_current

The leakage current, if available.

Return type:Optional[int]
load_power

Current power load, if available.

Return type:Optional[float]
mode

Current operation mode, can be either green or normal.

Return type:Optional[PowerMode]
power

Current power state.

Return type:str
power_factor

The power factor, if available.

Return type:Optional[float]
power_price

The stored power price, if available.

Return type:Optional[int]
temperature

Current temperature.

Return type:float
voltage

The voltage, if available.

Return type:Optional[float]
wifi_led

True if the wifi led is turned on.

Return type:Optional[bool]

miio.vacuum module

class miio.vacuum.Consumable[source]

Bases: enum.Enum

An enumeration.

Filter = 'filter_work_time'
MainBrush = 'main_brush_work_time'
SensorDirty = 'sensor_dirty_time'
SideBrush = 'side_brush_work_time'
class miio.vacuum.FanspeedV1[source]

Bases: enum.Enum

An enumeration.

Medium = 77
Silent = 38
Standard = 60
Turbo = 90
class miio.vacuum.FanspeedV2[source]

Bases: enum.Enum

An enumeration.

Gentle = 105
Medium = 103
Silent = 101
Standard = 102
Turbo = 104
class miio.vacuum.TimerState[source]

Bases: enum.Enum

An enumeration.

Off = 'off'
On = 'on'
class miio.vacuum.Vacuum(ip, token=None, start_id=0, debug=0)[source]

Bases: miio.device.Device

Main class representing the vacuum.

add_timer(cron, command, parameters)[source]

Add a timer.

Parameters:
  • cron (str) – schedule in cron format
  • command (str) – ignored by the vacuum.
  • parameters (str) – ignored by the vacuum.
carpet_mode()[source]

Get carpet mode settings

clean_details(id_, return_list=True)[source]

Return details about specific cleaning.

Return type:Union[List[CleaningDetails], CleaningDetails, None]
clean_history()[source]

Return generic cleaning history.

Return type:CleaningSummary
configure_wifi(ssid, password, uid=0, timezone=None)[source]

Configure the wifi settings.

consumable_reset(consumable)[source]

Reset consumable information.

consumable_status()[source]

Return information about consumables.

Return type:ConsumableStatus
create_nogo_zone(x1, y1, x2, y2, x3, y3, x4, y4)[source]

Create a rectangular no-go zone (gen2 only?).

NOTE: Multiple nogo zones and barriers could be added by passing a list of them to save_map.

Requires new fw version. 3.3.9_001633+?

create_software_barrier(x1, y1, x2, y2)[source]

Create software barrier (gen2 only?).

NOTE: Multiple nogo zones and barriers could be added by passing a list of them to save_map.

Requires new fw version. 3.3.9_001633+?

delete_timer(timer_id)[source]

Delete a timer with given ID.

Parameters:timer_id (int) – Timer ID
disable_dnd()[source]

Disable do-not-disturb.

dnd_status()[source]

Returns do-not-disturb status.

edit_map(start)[source]

Start map editing?

enable_lab_mode(enable)[source]

Enable persistent maps and software barriers.

This is required to use create_nogo_zone and create_software_barrier commands.

enable_log_upload()[source]
fan_speed()[source]

Return fan speed.

fan_speed_presets()[source]

Return dictionary containing supported fan speeds.

Return type:Dict[str, int]
find()[source]

Find the robot.

fresh_map(version)[source]

Return fresh map?

get_backup_maps()[source]

Get backup maps.

classmethod get_device_group()[source]
get_room_mapping()[source]

Retrieves a list of segments.

get_segment_status()[source]

Get the status of a segment.

goto(x_coord, y_coord)[source]

Go to specific target. :param int x_coord: x coordinate :param int y_coord: y coordinate

home()[source]

Stop cleaning and return home.

install_sound(url, md5sum, sound_id)[source]

Install sound from the given url.

last_clean_details()[source]

Return details from the last cleaning.

Returns None if there has been no cleanups.

Return type:Optional[CleaningDetails]
locale()[source]

Return locale information.

log_upload_status()[source]
manual_control(rotation, velocity, duration=1500)[source]

Give a command over manual control interface.

manual_control_once(rotation, velocity, duration=1500)[source]

Starts the remote control mode and executes the action once before deactivating the mode.

manual_start()[source]

Start manual control mode.

manual_stop()[source]

Stop manual control mode.

map()[source]

Return map token.

merge_segment()[source]
name_segment()[source]
pause()[source]

Pause cleaning.

persist_map(version)[source]

Return fresh map?

raw_id
resume_or_start()[source]

A shortcut for resuming or starting cleaning.

resume_segment_clean()[source]

Resuming cleaning a segment.

resume_zoned_clean()[source]

Resume zone cleaning after being paused.

segment_clean(segments)[source]

Clean segments. :param List segments: List of segments to clean: [16,17,18]

serial_number()[source]

Get serial number.

set_carpet_mode(enabled, stall_time=10, low=400, high=500, integral=450)[source]

Set the carpet mode.

set_dnd(start_hr, start_min, end_hr, end_min)[source]

Set do-not-disturb.

Parameters:
  • start_hr (int) – Start hour
  • start_min (int) – Start minute
  • end_hr (int) – End hour
  • end_min (int) – End minute
set_fan_speed(speed)[source]

Set fan speed.

Parameters:speed (int) – Fan speed to set
set_sound_volume(vol)[source]

Set sound volume [0-100].

set_timezone(new_zone)[source]

Set the timezone.

sound_info()[source]

Get voice settings.

sound_install_progress()[source]

Get sound installation progress.

sound_volume()[source]

Get sound volume.

Return type:int
split_segment()[source]
spot()[source]

Start spot cleaning.

start()[source]

Start cleaning.

status()[source]

Return status of the vacuum.

Return type:VacuumStatus
stop()[source]

Stop cleaning.

Note, prefer ‘pause’ instead of this for wider support. Some newer vacuum models do not support this command.

stop_segment_clean()[source]

Stop cleaning a segment.

stop_zoned_clean()[source]

Stop cleaning a zone.

test_sound_volume()[source]

Test current sound volume.

timer()[source]

Return a list of timers.

Return type:List[Timer]
timezone()[source]

Get the timezone.

update_timer(timer_id, mode)[source]

Update a timer with given ID.

Parameters:
  • timer_id (int) – Timer ID
  • mode (TimerStae) – either On or Off
use_backup_map(id)[source]

Set backup map.

zoned_clean(zones)[source]

Clean zones. :param List zones: List of zones to clean: [[x1,y1,x2,y2, iterations],[x1,y1,x2,y2, iterations]]

exception miio.vacuum.VacuumException[source]

Bases: miio.exceptions.DeviceException

miio.vacuumcontainers module

class miio.vacuumcontainers.CarpetModeStatus(data)[source]

Bases: object

Container for carpet mode status.

current_high
Return type:int
current_integral
Return type:int
current_low
Return type:int
enabled

True if carpet mode is enabled.

Return type:bool
stall_time
Return type:int
class miio.vacuumcontainers.CleaningDetails(data)[source]

Bases: object

Contains details about a specific cleaning run.

area

Total cleaned area.

Return type:float
complete

Return True if the cleaning run was complete (e.g. without errors).

see also error().

Return type:bool
duration

Total duration of the cleaning run.

Return type:timedelta
end

When cleaning was finished.

Return type:datetime
error

Error state of this cleaning run.

Return type:str
error_code

Error code.

Return type:int
start

When cleaning was started.

Return type:datetime
class miio.vacuumcontainers.CleaningSummary(data)[source]

Bases: object

Contains summarized information about available cleaning runs.

count

Number of cleaning runs.

Return type:int
ids

A list of available cleaning IDs, see also CleaningDetails.

Return type:List[int]
total_area

Total cleaned area.

Return type:float
total_duration

Total cleaning duration.

Return type:timedelta
class miio.vacuumcontainers.ConsumableStatus(data)[source]

Bases: object

Container for consumable status information, including information about brushes and duration until they should be changed. The methods returning time left are based on the following lifetimes:

  • Sensor cleanup time: XXX FIXME
  • Main brush: 300 hours
  • Side brush: 200 hours
  • Filter: 150 hours
filter

Filter usage time.

Return type:timedelta
filter_left

How long until the filter should be changed.

Return type:timedelta
main_brush

Main brush usage time.

Return type:timedelta
main_brush_left

How long until the main brush should be changed.

Return type:timedelta
sensor_dirty

Return sensor_dirty_time

Return type:timedelta
sensor_dirty_left
Return type:timedelta
side_brush

Side brush usage time.

Return type:timedelta
side_brush_left

How long until the side brush should be changed.

Return type:timedelta
class miio.vacuumcontainers.DNDStatus(data)[source]

Bases: object

A container for the do-not-disturb status.

enabled

True if DnD is enabled.

Return type:bool
end

End time of DnD.

Return type:time
start

Start time of DnD.

Return type:time
class miio.vacuumcontainers.SoundInstallState[source]

Bases: enum.IntEnum

An enumeration.

Downloading = 1
Error = 4
Installed = 3
Installing = 2
Unknown = 0
class miio.vacuumcontainers.SoundInstallStatus(data)[source]

Bases: object

Container for sound installation status.

error

Error code, 0 is no error, other values unknown.

Return type:int
is_errored

True if the state has an error, use error to access it.

Return type:bool
is_installing

True if install is in progress.

Return type:bool
progress

Progress in percentages.

Return type:int
sid

Sound ID for the sound being installed.

Return type:int
state

Installation state.

Return type:SoundInstallState
class miio.vacuumcontainers.SoundStatus(data)[source]

Bases: object

Container for sound status.

being_installed
current
class miio.vacuumcontainers.Timer(data)[source]

Bases: object

A container for scheduling. The timers are accessed using an integer ID, which is based on the unix timestamp of the creation time.

action

The action to be taken on the given time. Note, this seems to be always ‘start’.

Return type:str
cron

Cron-formated timer string.

Return type:str
enabled

True if the timer is active.

Return type:bool
id

ID which can be used to point to this timer.

Return type:int
ts

Pretty-printed ID (timestamp) presentation as time.

Return type:datetime
class miio.vacuumcontainers.VacuumStatus(data)[source]

Bases: object

Container for status reports from the vacuum.

battery

Remaining battery in percentage.

Return type:int
clean_area

Cleaned area in m2.

Return type:float
clean_time

Time used for cleaning (if finished, shows how long it took).

Return type:timedelta
error

Human readable error description, see also error_code().

Return type:str
error_code

Error code as returned by the device.

Return type:int
fanspeed

Current fan speed.

Return type:int
got_error

True if an error has occured.

Return type:bool
in_segment_cleaning

Return True if the vacuum is in segment cleaning mode.

Return type:bool
in_zone_cleaning

Return True if the vacuum is in zone cleaning mode.

Return type:bool
is_on

True if device is currently cleaning in any mode.

Return type:bool
is_paused

Return True if vacuum is paused.

Return type:bool
is_water_box_attached

Return True is water box is installed.

Return type:bool
map

Map token.

Return type:bool
state

Human readable state description, see also state_code().

Return type:str
state_code

State code as returned by the device.

Return type:int
miio.vacuumcontainers.pretty_area(x)[source]
Return type:float

miio.version module

miio.waterpurifier module

class miio.waterpurifier.WaterPurifier(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.device.Device

Main class representing the waiter purifier.

classmethod get_device_group()
off()[source]

Power off.

on()[source]

Power on.

status()[source]

Retrieve properties.

Return type:WaterPurifierStatus
class miio.waterpurifier.WaterPurifierStatus(data)[source]

Bases: object

Container for status reports from the water purifier.

filter
Return type:str
filter2_life_remaining

Time until the filter should be changed.

Return type:int
filter2_state
Return type:str
filter_life_remaining

Time until the filter should be changed.

Return type:int
filter_state
Return type:str
is_on
Return type:bool
level
Return type:str
life
Return type:str
mode

Current operation mode.

Return type:str
power
Return type:str
state
Return type:str
tds
Return type:str
temperature
Return type:str
usage
Return type:str
uv_filter_life_remaining

Time until the filter should be changed.

Return type:int
uv_filter_state
Return type:str
valve
Return type:str
volume
Return type:str

miio.wifirepeater module

class miio.wifirepeater.WifiRepeater(ip=None, token=None, start_id=0, debug=0, lazy_discover=True)[source]

Bases: miio.device.Device

Device class for Xiaomi Mi WiFi Repeater 2.

configuration()[source]

Return the configuration of the accesspoint.

Return type:WifiRepeaterConfiguration
classmethod get_device_group()
rssi_accesspoint()[source]

Received signal strength indicator of the accesspoint.

Return type:int
set_configuration(ssid, password, ssid_hidden=False)[source]

Update the configuration of the accesspoint.

set_wifi_roaming(wifi_roaming)[source]

Turn the WiFi roaming on/off.

status()[source]

Return the associated stations.

Return type:WifiRepeaterStatus
wifi_roaming()[source]

Return the roaming setting.

Return type:bool
class miio.wifirepeater.WifiRepeaterConfiguration(data)[source]

Bases: object

password
Return type:str
ssid
Return type:str
ssid_hidden
Return type:bool
exception miio.wifirepeater.WifiRepeaterException[source]

Bases: miio.exceptions.DeviceException

class miio.wifirepeater.WifiRepeaterStatus(data)[source]

Bases: object

access_policy

Access policy of the associated stations.

Return type:int
associated_stations

List of associated stations.

Return type:dict

miio.wifispeaker module

class miio.wifispeaker.PlayState[source]

Bases: enum.Enum

An enumeration.

NoMedia = 'NO_MEDIA_PRESENT'
Paused = 'PAUSED_PLAYBACK'
Playing = 'PLAYING'
Stopped = 'STOPPED'
Transitioning = 'TRANSITIONING'
class miio.wifispeaker.TransportChannel[source]

Bases: enum.Enum

An enumeration.

Air = 'AIR'
Auxiliary = 'AUX'
Bluetooth = 'BT'
OneTime = 'ONETIME'
Playlist = 'PLAYLIST'
Qplay = 'QPLAY'
Radio = 'RADIO'
class miio.wifispeaker.WifiSpeaker(*args, **kwargs)[source]

Bases: miio.device.Device

Device class for Xiaomi Smart Wifi Speaker.

channel_next()[source]

Change transport channel.

classmethod get_device_group()
power()[source]

Toggle power on and off.

status()[source]

Return device status.

Return type:WifiSpeakerStatus
toggle()[source]

Toggle play.

track_next()[source]

Move to next track.

track_position()[source]

Return current track position.

track_previous()[source]

Move to previous track.

volume()[source]

Speaker volume.

volume_down(amount=5)[source]

Set volume down.

volume_up(amount=5)[source]

Set volume up.

class miio.wifispeaker.WifiSpeakerStatus(data)[source]

Bases: object

Container of a speaker state. This contains information such as the name of the device, and what is currently being played by it.

channel

Name of the channel.

Return type:str
device_name

Name of the device.

Return type:str
hardware_version
Return type:str
play_mode

Play mode such as REPEAT_ALL.

state

State of the device, e.g. PLAYING.

Return type:PlayState
track_artist

Artist of the current track.

Return type:str
track_duration

Total duration of the current track.

Return type:str
track_title

Title of the current track.

Return type:str
transport_channel

Transport channel, e.g. PLAYLIST

Return type:TransportChannel

miio.yeelight module

class miio.yeelight.Yeelight(*args, **kwargs)[source]

Bases: miio.device.Device

A rudimentary support for Yeelight bulbs.

The API is the same as defined in https://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf and only partially implmented here.

For a more complete implementation please refer to python-yeelight package (https://yeelight.readthedocs.io/en/latest/), which however requires enabling the developer mode on the bulbs.

classmethod get_device_group()
off(transition=0)[source]

Power off.

on(transition=0, mode=0)[source]

Power on.

set_brightness(level, transition=0)[source]

Set brightness.

set_color_temp(level, transition=500)[source]

Set color temp in kelvin.

set_default()[source]

Set current state as default.

set_developer_mode(enable)[source]

Enable or disable the developer mode.

Return type:bool
set_hsv(hsv)[source]

Set color in HSV.

set_name(name)[source]

Set an internal name for the bulb.

Return type:bool
set_rgb(rgb)[source]

Set color in RGB.

set_save_state_on_change(enable)[source]

Enable or disable saving the state on changes.

Return type:bool
set_scene(scene, *vals)[source]

Set the scene.

status()[source]

Retrieve properties.

Return type:YeelightStatus
toggle()[source]

Toggle bulb state.

exception miio.yeelight.YeelightException[source]

Bases: miio.exceptions.DeviceException

class miio.yeelight.YeelightMode[source]

Bases: enum.IntEnum

An enumeration.

ColorTemperature = 2
HSV = 3
RGB = 1
class miio.yeelight.YeelightStatus(data)[source]

Bases: object

brightness

Return current brightness.

Return type:int
color_mode

Return current color mode.

Return type:YeelightMode
color_temp

Return current color temperature, if applicable.

Return type:Optional[int]
developer_mode

Return whether the developer mode is active.

Return type:bool
hsv

Return current color in HSV if HSV mode is active.

Return type:Optional[Tuple[int, int, int]]
is_on

Return whether the bulb is on or off.

Return type:bool
name

Return the internal name of the bulb.

Return type:str
rgb

Return color in RGB if RGB mode is active.

Return type:Optional[Tuple[int, int, int]]
save_state_on_change

Return whether the bulb state is saved on change.

Return type:bool

Module contents