English | 简体中文
MIoT-Spec 是小米IoT平台根据硬件产品的联网方式、产品功能的特点、用户使用场景的特征和用户对硬件产品使用体验的要求,设计的描述硬件产品功能定义的标准规范。
本插件利用了miot协议的规范,可将小米设备自动接入HomeAssistant,目前已支持大部分小米米家智能设备。且该插件支持HA后台界面集成,无需配置yaml即可轻松将小米设备接入HA。

Xiaomi Miot > 下载此存储库Xiaomi Miot > 更新 / 重新下载Samba或SFTP手动安装下载并复制
custom_components/xiaomi_miot文件夹到HA根目录下的custom_components文件夹
SSH或Terminal & SSH加载项执行一键安装命令wget -O - https://get.hacs.vip | DOMAIN=xiaomi_miot bash -
shell_command服务configuration.yaml
yaml
shell_command:
update_xiaomi_miot: |-
wget -O - https://get.hacs.vip | DOMAIN=xiaomi_miot bash -service: shell_command.update_xiaomi_miot自v0.4.4版本开始,插件新增支持账号集成时选择连接设备的模式: - 自动模式:插件定期更新支持本地miot协议的设备,并自动将用户筛选的设备中符合条件的型号使用本地连接(推荐) - 本地模式:集成配置所筛选的设备都将使用本地连接,如勾选了不支持本地miot协议的设备将不可用 - 云端模式:集成配置所筛选的设备都将使用云端连接,建议旧版miio、蓝牙、ZigBee设备使用
通过host/token接入设备,适用于在局域网环境下支持miot协议的设备
为通过token集成的设备开启云端模式
# configuration.yaml
xiaomi_miot:
username: xiaomi_username
password: xiaomi_password
# server_country: cn # 小米云服务器位置: cn(默认), de, i2, ru, sg, tw, us
# http_timeout: 15 # 请求小米接口的超时时间(秒)
可以通过配置文件将大部分miot属性的选项描述(如:模式、风速等)翻译成你想要的语言,当然也欢迎你贡献你的词典给其他人👏🏻。
# configuration.yaml
xiaomi_miot:
language: zh # 使用内置词典,目前仅支持`zh`
# https://github.com/al-one/hass-xiaomi-miot/blob/master/custom_components/xiaomi_miot/core/translation_languages.py
translations:
# 全局词典,对所有实体生效
idle: '空闲'
busy: '工作中'
# 指定风扇模式的词典
fan.mode:
straight wind: '直吹模式'
natural wind: '自然风'
# 指定洗衣机烘干模式的词典
washer.drying_level:
moist: '微湿'
extra: '特干'
# configuration.yaml
homeassistant:
customize: !include customize.yaml
# 通过设备型号自定义
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.yaml
domain.your_entity_id:
miot_local: true # 使用本地模式 (通过账号接入的设备)
miot_cloud: true # 为该实体开启云端模式 (read, write, action)
miot_cloud_write: true # 仅写属性使用云端模式
miot_cloud_action: true # 仅action使用云端模式
check_lan: true # 云端模式下检查设备在局域网是否可用
miio_properties: power,battery # 获取miio属性到实体的属性中
miio_cloud_props: prop.power,event.dev_online
# 自定义子实体
domain.parent_entity_id:
sensor_properties: temperature,humidity,illumination # Miot属性
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 # 反转色温(需重载集成配置)
yeelight_smooth_on: 2000 # 毫秒 (仅支持本地接入的易来灯)
yeelight_smooth_off: 3000 # 毫秒 (仅支持本地接入的易来灯)
climate.your_entity_id:
bind_sensor: sensor.temperature_entity,sensor.humidity_entity # 绑定传感器实体
camera.your_entity_id:
video_attribute: 1 # https://github.com/al-one/hass-xiaomi-miot/issues/11#issuecomment-773054167
keep_streaming: true # 持续更新流地址
cover.your_entity_id:
closed_position: 5 # 当实体位置值小于等于此值时为关闭状态
deviated_position: 2 # 位置偏差值 2% -> 0%, 98% -> 100%
motor_reverse: true # 反转电机状态(需重载集成配置)
position_reverse: true # 反转电机进程(需重载集成配置)
open_texts: 打开,升
close_texts: 关闭,降
media_player.mitv_entity_id:
bind_xiaoai: media_player.xiaoai_entity_id # 绑定小爱音箱以打开电视
turn_off_screen: true # 关闭电视/投影时发送熄屏指令
screenshot_compress: 20 # 指定电视/投影屏幕截图的压缩率 默认为50%,100时质量最高
sources_via_apps: 桌面,米家,百度网盘,设置 # 将电视内的APP添加到输入源列表
sources_via_keycodes: menu,enter,back # 将电视遥控按键添加到输入源列表
mitv_lan_host: 192.168.31.66 # 指定小米电视的局域网IP
domain.your_entity_id_xxxx:
interval_seconds: 30 # 每次更新状态间隔秒数(需重载集成配置)
chunk_properties: 10 # 单次查询设备属性的最大个数(LAN)
reverse_state: true # 反转开关状态(仅作用于Binary Sensor)
过多的实体属性会导致你的HA数据库变得很庞大,如果某些实体属性对你没有用处,你可以配置
exclude_state_attributes来忽略它们
# configuration.yaml
xiaomi_miot:
exclude_state_attributes:
- miot_type
- stream_address
- motion_video_latest
本插件支持配置重载(修改YAML配置后无需重启HomeAssistant):
本插件使用轮询的方式获取设备状态,因此无法实时监听部分设备的事件
由于HA支持服务响应已经有一段时间了,本组件自v0.7.18开始不再触发事件。
$ claude mcp add hass-xiaomi-miot \
-- python -m otcore.mcp_server <graph>