Package: python-miio
This library (and its accompanying cli tool) can be used to interface with devices using Xiaomi’smiIOand MIoT protocols.Getting startedIf you already have a token for your device and the device type, you can directly start usingmiioclitool.
If you don’t have a token for your device, refer toGetting startedsection ofthe manualfor instructions how to obtain it.Themiiocliis the main way to execute commands from command line.
You can always use–helpto get more information about the available commands.
For example, executing it without any extra arguments will print out options and available commands:$ miiocli --help
Usage: miiocli [OPTIONS] COMMAND [ARGS]...

Options:
  -d, --debug
  -o, --output [default|json|json_pretty]
  --help                          Show this message and exit.

Commands:
  airconditioningcompanion
  ..You can get some information from any miIO/MIoT device, including its device model, using theinfocommand:miiocli device --ip <ip> --token <token> info

Model: some.device.model1
Hardware version: esp8285
Firmware version: 1.0.1_0012
Network: {'localIp': '<ip>', 'mask': '255.255.255.0', 'gw': '<ip>'}
AP: {'rssi': -73, 'ssid': '<nnetwork>', 'primary': 11, 'bssid': '<bssid>'}Different devices are supported by their corresponding modules (e.g.,roborockvacuumorfan).
You can get the list of available commands for any given module by passing–helpargument to it:$ miiocli roborockvacuum --help

Usage: miiocli roborockvacuum [OPTIONS] COMMAND [ARGS]...

Options:
  --ip TEXT       [required]
  --token TEXT    [required]
  --id-file FILE
  --help          Show this message and exit.

Commands:
  add_timer                Add a timer.
  ..Each command invocation will automatically detect the device model necessary for some actions by querying the device.
You can avoid this by specifying the model manually:miiocli roborockvacuum --model roborock.vacuum.s5 --ip <ip> --token <token> startAPI usageAll functionality is accessible through themiiomodule:from miio import RoborockVacuum

vac = RoborockVacuum("<ip address>", "<token>")
vac.start()Each separate device type inherits frommiio.Device(and in case of MIoT devices,miio.MiotDevice) which provides a common API.Each command invocation will automatically detect (and cache) the device model necessary for some actions
by querying the device.
You can avoid this by specifying the model manually:from miio import RoborockVacuum

vac = RoborockVacuum("<ip address>", "<token>", model="roborock.vacuum.s5")Please refer toAPI documentationfor more information.TroubleshootingYou can find some solutions for the most common problems can be found inTroubleshootingsection.If you have any questions, or simply want to join up for a chat, checkour Matrix room.ContributingWe welcome all sorts of contributions from patches to add improvements or fixing bugs to improving the documentation.
To ease the process of setting up a development environment we have prepareda short guidefor getting you started.Supported devicesXiaomi Mi Robot Vacuum V1, S4, S4 MAX, S5, S5 MAX, S6 Pure, M1S, S7Xiaomi Mi Home Air Conditioner CompanionXiaomi Mi Smart Air Conditioner A (xiaomi.aircondition.mc1, mc2, mc4, mc5)Xiaomi Mi Air Purifier 2, 3H, 3C, 4, Pro, Pro H, 4 Pro (zhimi.airpurifier.m2, mb3, mb4, mb5, v7, vb2, va2), 4 LiteXiaomi Mi Air (Purifier) Dog X3, X5, X7SM (airdog.airpurifier.x3, airdog.airpurifier.x5, airdog.airpurifier.x7sm)Xiaomi Mi Air HumidifierSmartmi Air PurifierXiaomi Aqara CameraXiaomi Aqara Gateway (basic implementation, alarm, lights)Xiaomi Mijia 360 1080pXiaomi Mijia STYJ02YM (Viomi)Xiaomi Mijia 1C STYTJ01ZHM (Dreame)Dreame F9, D9, Z10 ProXiaomi Mi Home (Mijia) G1 Robot Vacuum Mop MJSTG1Xiaomi Roidmi EveXiaomi Mi Smart WiFi SocketXiaomi Chuangmi Plug V1 (1 Socket, 1 USB Port)Xiaomi Chuangmi Plug V3 (1 Socket, 2 USB Ports)Xiaomi Smart Power Strip V1 and V2 (WiFi, 6 Ports)Xiaomi Philips Eyecare Smart Lamp 2Xiaomi Philips RW Read (philips.light.rwread)Xiaomi Philips LED Ceiling LampXiaomi Philips LED Ball Lamp (philips.light.bulb)Xiaomi Philips LED Ball Lamp White (philips.light.hbulb)Xiaomi Philips Zhirui Smart LED Bulb E14 Candle LampXiaomi Philips Zhirui Bedroom Smart LampHuayi Huizuo LampsXiaomi Universal IR Remote Controller (Chuangmi IR)Xiaomi Mi Smart Pedestal Fan V2, V3, SA1, ZA1, ZA3, ZA4, ZA5 1C, P5, P9, P10, P11, P33Xiaomi Rosou SS4 Ventilator (leshow.fan.ss4)Xiaomi Mi Air Humidifier V1, CA1, CA4, CB1, MJJSQ, JSQ, JSQ1, JSQ001Xiaomi Mi Water Purifier (Basic support: Turn on & off)Xiaomi Mi Water Purifier D1, C1 (Triple Setting)Xiaomi PM2.5 Air Quality Monitor V1, B1, S1Xiaomi Smart WiFi SpeakerXiaomi Mi WiFi Repeater 2Xiaomi Mi Smart Rice CookerXiaomi Smartmi Fresh Air System VA2 (zhimi.airfresh.va2), VA4 (zhimi.airfresh.va4),
A1 (dmaker.airfresh.a1), T2017 (dmaker.airfresh.t2017)Yeelight lights (basic support, we recommend usingpython-yeelight)Xiaomi Mi Air DehumidifierXiaomi Tinymu Smart Toilet CoverXiaomi 16 Relays ModuleXiaomi Xiao AI Smart Alarm ClockSmartmi Radiant Heater Smart Version (ZA1 version)Xiaomi Mi Smart Space HeaterXiaomiyoupin Curtain Controller (Wi-Fi) (lumi.curtain.hagl05)Xiaomi Xiaomi Mi Smart Space Heater S (zhimi.heater.mc2)Xiaomi Xiaomi Mi Smart Space Heater 1S (zhimi.heater.za2)Yeelight Dual Control Module (yeelink.switch.sw1)Scishare coffee maker (scishare.coffee.s1102)Qingping Air Monitor Lite (cgllc.airm.cgdn1)Xiaomi Walkingpad A1 (ksmb.walkingpad.v3)Xiaomi Smart Pet Water Dispenser (mmgg.pet_waterer.s1, s4)Xiaomi Mi Smart Humidifer S (jsqs, jsq5)Xiaomi Mi Robot Vacuum Mop 2 (Pro+, Ultra)Feel free to create a pull request to add support for new devices as
well as additional features for supported devices.Projects using this libraryThis library is used by various projects to support MiIO/MiOT devices.
If you are using this library for your project, feel free to open a PR to get it listed here!Home Assistant (official)Home Assistant uses this library to support several platforms out-of-the-box.
This list is incomplete as the platforms (in parentheses) may also support other devices listed above.Xiaomi Mi Robot Vacuum(vacuum)Xiaomi Philips Light(light)Xiaomi Mi Air Purifier and Air Humidifier(fan)Xiaomi Smart WiFi Socket and Smart Power Strip(switch)Xiaomi Universal IR Remote Controller(remote)Xiaomi Mi Air Quality Monitor (PM2.5)(sensor)Xiaomi Aqara Gateway Alarm(alarm_control_panel)Xiaomi Mi WiFi Repeater 2(device_tracker)Home Assistant (custom)Xiaomi Mi Home Air Conditioner CompanionXiaomi Mi Smart Pedestal FanXiaomi Mi Smart Rice CookerXiaomi Raw SensorXiaomi MIoT DevicesXiaomi Miot AutoOther related projectsThis is a list of other projects around the Xiaomi ecosystem that you can find interesting.
Feel free to submit more related projects.dustcloud(reverse engineering and rooting xiaomi devices)Valetudo(cloud free vacuum firmware)micloud(library to access xiaomi cloud services, can be used to obtain device tokens)micloudfaker(dummy cloud server, can be used to fix powerstrip status requests when without internet access)Your project here? Feel free to open a PR!