Xiaomi Miot For HomeAssistant
English | 简体中文
MIoT-Spec: The protocol specification for Xiaomi IoT devices, is a standard designed by the Xiaomi IoT platform to describe the function definition of hardware products according to the networking mode of hardware products, the characteristics of product functions, the characteristics of user usage scenarios and the user's requirements for hardware product use experience specification.
This component uses the miot protocol to automatically integrate Xiaomi devices into HomeAssistant, and currently supports most Xiaomi IoT devices. And it supports HA Web UI, and you can easily integrate Xiaomi devices into HA without configuring yaml.
Installing
Download and copy
custom_components/xiaomi_miot
folder tocustom_components
folder in your HomeAssistant config folder
# Auto install via terminal shell
wget -q -O - https://cdn.jsdelivr.net/gh/al-one/hass-xiaomi-miot/install.sh | bash -
Or you can install component with HACS
Config
⚙️ Configuration >🧩 Integrations >➕ Add Integration >🔍 SearchXiaomi Miot Auto
Add devices using Mi Account:
Starting from the v0.4.4 version, the component has added support for selecting the connection device mode when integrated by account:
- Automatic: The component will regularly update the devices that support miot-spec in LAN, and automatically use the local connection for the supported devices (recommended)
- Local: All devices filtered by the integrated configuration will use local connection. If you check the devices that do not support miot in LAN, they will be unavailable
- Cloud: All devices filtered by the integrated configuration will use cloud connection. It is recommended that miio, BLE, ZigBee devices use this mode
Add device using host/token:
Suitable for devices support miot-spec protocol in LAN
Config Xiaomi Cloud:
Config Xiaomi cloud for the devices integrated by host/token
# configuration.yaml
xiaomi_miot:
username: xiaomi_username
password: xiaomi_password
# server_country: cn # location of xiaomi cloud: cn(default), de, i2, ru, sg, us
⚙️ Configuration >🧩 Integrations > Xiaomi Miot Auto > Options >☑️ Enable miot cloud
Config translation languages:
# configuration.yaml
xiaomi_miot:
language: zh # Using the built-in dictionary, currently only `zh` is supported
# https://github.com/al-one/hass-xiaomi-miot/blob/master/custom_components/xiaomi_miot/core/translation_languages.py
translations:
# Global dictionary
idle: '空闲'
busy: '工作中'
# Dictionary for specifying fan modes
fan.mode:
'straight wind': '直吹模式'
'natural wind': '自然风'
# Dictionary for specifying the drying modes of the washer
washer.drying_level:
moist: '微湿'
extra: '特干'
Customize entity
# configuration.yaml
homeassistant:
customize: !include customize.yaml
# Customize via device model
xiaomi_miot:
# https://github.com/al-one/hass-xiaomi-miot/blob/master/custom_components/xiaomi_miot/core/device_customizes.py
device_customizes:
'chuangmi.plug.212a01':
miot_local: true
chunk_properties: 7
# Customize via parent entity
# customize.yaml
domain.your_entity_id:
miot_local: true # Force to read and write data in LAN (integrate by account)
miot_cloud: true # Enable miot cloud for entity (read, write, action)
miot_cloud_write: true # Enable miot cloud (only write)
miot_cloud_action: true # Enable miot cloud (only action)
check_lan: true # Check LAN connection in cloud mode
miio_properties: power,battery # Get miio properties to state attributes
miio_cloud_props: prop.power,event.dev_online
# Custom sub entities
domain.parent_entity_id:
sensor_properties: temperature,humidity,illumination # Miot properties
binary_sensor_properties: is_volume_muted,any_boolen_property
switch_properties: on,power
number_properties: volume
fan_properties: mode,fan_level
cover_properties: motor_control
climate.your_entity_id:
bind_sensor: sensor.temperature_entity,sensor.humidity_entity # Sensor entities
camera.your_entity_id:
video_attribute: 1 # https://github.com/al-one/hass-xiaomi-miot/issues/11#issuecomment-773054167
keep_streaming: true # Continuously update stream address
cover.your_entity_id:
closed_position: 5 # Change cover state to closed when position <= 5%
deviated_position: 2 # Current position deviation 2% -> 0%, 98% -> 100%
motor_reverse: true # Reverse motor state
open_texts: Open,Up
close_texts: Close,Down
doamin.your_entity_id:
interval_seconds: 30 # Seconds between each update state (Requires reload config entry)
chunk_properties: 10 # Chunk miot properties on update state (LAN)
Recommended Customization Using The UI:
⚙️ Configuration >🖌 Customize >🔍 Select Entity > Add Other Attribute
Supported Devices
- outlet / switch
- light
- air-conditioner / air-conditioner-outlet / thermostat
- fan / ceiling-fan
- bath-heater / heater
- camera / video-doorbell
❓️ - television / projector / tv-box
- intelligent-speaker
❓️ - ir-remote-control
❓️ - lock / door
- washer / fridge
- water-purifier / kettle
- air-purifier / air-fresh
- temperature-humidity-sensor / submersion-sensor / smoke-sensor
- cooker / pressure-cooker
- induction-cooker / oven / microwave
- air-fryer / multifunction-cooking-pot
- health-pot / coffee-machine
- juicer
- water-heater / hood / dishwasher
- curtain / window-opener / airer
- vacuum
- humidifier / dehumidifier
- air-monitor / plant-monitor
- bed / blanket / sleep-monitor
- massager / magic-touch
- walking-pad
- toilet
- towel-rack
- pet-feeder / pet-drinking-fountain
- fish-tank
- mosquito-dispeller / germicidal-lamp
- rearview-mirror
- watch
- motion-sensor / magnet-sensor
❓️ - vibration-sensor
- router
- printer
Debug
Get Entity State Attributes
🔨 Developer tools >ℹ️ State >🔍 Filter Entity
Get Debug Logs
# configuration.yaml
logger:
default: warning
logs:
custom_components.xiaomi_miot: debug
Obtain miio token
- Use HomeAssistant Service
- Goto HomeAssistant service developer tool
- Select
xiaomi_miot.get_token
, Enter the keyword of device name - Find the token from the HA notifications
- Goto HomeAssistant service developer tool
- Use MiHome mod by @vevsvevs
- Down apk from СКАЧАТЬ ВЕРСИЮ 6.x.x and install
- Start Mihome APP > Profile > Experimental features
- Check on
Write custom log files
andEnable app's debug mode
- Find the token from
vevs/logs/misc/devices.txt
after restart app
- Xiaomi Cloud Tokens Extractor
- Download and run token_extractor.exe for Windows or install for Python
- Enter username, password and your server region
- Extracts tokens from your cloud account. Also reveals the bind_key for BT devices