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.
Method 1: HACS
- First installation
HACS > Integrations > โ EXPLORE & DOWNLOAD REPOSITORIES >
Xiaomi Miot Auto
> DOWNLOAD THIS REPOSITORY - Update component
HACS > Integrations >
Xiaomi Miot Auto
> UPDATE / Redownload
Download and copy
custom_components/xiaomi_miot
folder tocustom_components
folder in your HomeAssistant config folder
wget -q -O - https://raw.githubusercontent.com/al-one/hass-xiaomi-miot/master/install.sh | ARCHIVE_TAG=latest bash -
- Copy this code to file
configuration.yaml
shell_command: update_xiaomi_miot: |- wget -q -O - https://raw.githubusercontent.com/al-one/hass-xiaomi-miot/master/install.sh | ARCHIVE_TAG=latest bash -
- Restart HA core
- Call this
service: shell_command.update_xiaomi_miot
in Developer Tools
โ๏ธ Configuration > Devices and Services > ๐งฉ Integrations > โ Add Integration > ๐ Search
Xiaomi Miot Auto
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
Suitable for devices support miot-spec protocol in LAN
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, tw, us
# http_timeout: 15 # Timeout (seconds) for requesting the xiaomi apis
โ๏ธ Configuration > Devices and Services > ๐งฉ Integrations > Xiaomi Miot Auto > Options > โ๏ธ Enable miot cloud
Looking forward to your contribution.
# 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: '็นๅนฒ'
# 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
select_properties: mode
fan_properties: mode,fan_level
cover_properties: motor_control
light.your_entity_id:
color_temp_reverse: false # Reverse color temperature (Requires reload config entry)
yeelight_smooth_on: 2000 # milliseconds (Only for Yeelights in local mode)
yeelight_smooth_off: 3000 # milliseconds (Only for Yeelights in local mode)
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 (Requires reload config entry)
position_reverse: true # Reverse motor position (Requires reload config entry)
open_texts: Open,Up
close_texts: Close,Down
media_player.mitv_entity_id:
bind_xiaoai: media_player.xiaoai_entity_id # Bind xiaoai speaker for turn on TV
domain.your_entity_id_xxxx:
interval_seconds: 30 # Seconds between each update state (Requires reload config entry)
chunk_properties: 10 # Chunk miot properties on update state (LAN)
reverse_state: true # Reverse the On/Off state of a binary sensor
Too many entity attributes will make your HA's database very large. If some entity attributes are useless to you, you can configure
exclude_state_attributes
to ignore them.
# configuration.yaml
xiaomi_miot:
exclude_state_attributes:
- miot_type
- stream_address
- motion_video_latest
This component has added support for configuration reloading (to avoid having to restart HomeAssistant instance after a YAML configuration change):
๐จ Developer tools > YAML Configuration > YAML configuration reloading > ๐ Look for
Xiaomi Miot Auto
(almost at the bottom of the list)
- ๐ outlet / switch
- ๐ก light
- โ๏ธ air-conditioner / air-conditioner-outlet / ir-aircondition-control
- ๐ fan / ceiling-fan
- ๐ bath-heater / ๐ฅ heater / thermostat
- ๐ท camera / video-doorbell โ๏ธ
- ๐บ television / ๐ฝ๏ธ projector / tv-box
- ๐ฃ๏ธ intelligent-speaker โ๏ธ
- ๐ฎ๏ธ ir-remote-control โ๏ธ
- ๐ lock / ๐ช door
- ๐ washer / dryer / fridge
- ๐ฐ water-purifier / kettle
- โป๏ธ air-purifier / air-fresh / hood
- ๐ก temperature-humidity-sensor / submersion-sensor / smoke-sensor
- ๐ฅ cooker / pressure-cooker
- ๐ฒ induction-cooker / oven / microwave
- ๐ air-fryer / multifunction-cooking-pot
- ๐ต health-pot / โ๏ธ coffee-machine
- ๐น juicer / fruit-vegetable-purifier
- โจ๏ธ water-heater / dishwasher / foot-bath
- ๐ฆ steriliser
- ๐ช curtain / window-opener / airer
- ๐งน vacuum / mopping-machine
- ๐ฆ humidifier / dehumidifier / diffuser
- ๐ air-monitor / ๐ชด plant-monitor
- ๐ bed / blanket / ๐ด sleep-monitor
- ๐บ chair / table
- ๐ massager / magic-touch
- ๐ walking-pad / treadmill
- ๐ฝ toilet /๏ธ towel-rack /๏ธ ๐ชฅ toothbrush
- ๐ฑ pet-feeder / โฒ pet-drinking-fountain / ๐ fish-tank
- ๐ฆ mosquito-dispeller / germicidal-lamp
- ๐ rearview-mirror / head-up-display
- โ๏ธ watch / bracelet
- ๐ถ motion-sensor / ๐งฒ magnet-sensor โ๏ธ
- ๐ณ vibration-sensor
- ๐ router / ๐จ printer
This component uses the polling method to obtain the device state, so it cannot listen the events of some devices in real time.
- Wireless Switch (like: lumi.sensor_switch.v1 / lumi.remote.b686opcn01)
- Motion Sensor (like: lumi.sensor_motion.v1)
- Window and Door Sensor (like: lumi.sensor_magnet.v1)
service: xiaomi_miot.set_property
data:
entity_id: camera.isa_hlc7_xxxx
field: camera_control.on
value: true
service: xiaomi_miot.set_miot_property
data:
entity_id: camera.isa_hlc7_xxxx
siid: 2
piid: 1
value: true
service: xiaomi_miot.get_properties
data:
entity_id: camera.isa_hlc7_1ab7
mapping:
- siid: 2
piid: 1
- siid: 3
piid: 2
update_entity: true # Update to entity state attributes
throw: true # Throw result to HA notifications
With event
xiaomi_miot.got_miot_properties
service: xiaomi_miot.call_action
data:
entity_id: vacuum.dreame_p2259_entity_id
siid: 4 # vacuum-extend
aiid: 1 # start-clean
params:
- 18 # piid: 1 - work-mode
- '{"selects":[[7,1,0,2,1]]}' # piid: 10 - clean-extend-data
throw: true # throw result to HA notifications
With event
xiaomi_miot.call_miot_action
service: xiaomi_miot.send_command
data:
entity_id: switch.your_entity_id
method: set_power
params:
- on
throw: true # throw result to HA notifications
With event
xiaomi_miot.send_miio_command
service: xiaomi_miot.get_token
data:
name: Light # Keyword of device name in Mihome / IP / Model.
service: xiaomi_miot.intelligent_speaker
data:
entity_id: media_player.xiaoai_lx04_xxxx
text: Turn on the light
execute: true # Execute text directive.
silent: true # Silent execution.
service: xiaomi_miot.xiaoai_wakeup
data:
entity_id: media_player.xiaoai_lx04_xxxx
service: xiaomi_miot.renew_devices
data:
username: 80001234 # Xiaomi Account ID / Email / Phone
With event
xiaomi_miot.renew_devices
service: xiaomi_miot.request_xiaomi_api
data:
entity_id: sensor.your_entity_id
api: /v2/plugin/fetch_plugin
data:
latest_req:
api_version: 10070
plugins:
- model: brand.device.model
With event
xiaomi_miot.request_xiaomi_api
๐จ Developer tools > โน๏ธ State > ๐ Filter Entity
# configuration.yaml
logger:
default: warning
logs:
custom_components.xiaomi_miot: debug
- 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
- 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