MCPcopy Index your code
hub / github.com/al-one/hass-xiaomi-miot

github.com/al-one/hass-xiaomi-miot @v1.1.4 sqlite

repository ↗ · DeepWiki ↗ · release v1.1.4 ↗
1,035 symbols 3,548 edges 42 files 105 documented · 10%
README

version releases stars issues HACS

Xiaomi Miot For HomeAssistant

English | 简体中文

MIoT-Spec 是小米IoT平台根据硬件产品的联网方式、产品功能的特点、用户使用场景的特征和用户对硬件产品使用体验的要求,设计的描述硬件产品功能定义的标准规范。

本插件利用了miot协议的规范,可将小米设备自动接入HomeAssistant,目前已支持大部分小米米家智能设备。且该插件支持HA后台界面集成,无需配置yaml即可轻松将小米设备接入HA。

hass-xiaomi-miot-configs

常见问题

安装/更新

方法1: HACS

  • 首次安装 > HACS > 集成 > ➕ 浏览并下载存储库 > Xiaomi Miot > 下载此存储库
  • 升级插件 > HACS > 集成 > Xiaomi Miot > 更新 / 重新下载

方法2: 通过SambaSFTP手动安装

下载并复制custom_components/xiaomi_miot文件夹到HA根目录下的custom_components文件夹

方法3: 通过SSHTerminal & SSH加载项执行一键安装命令

wget -O - https://get.hacs.vip | DOMAIN=xiaomi_miot bash -

方法4: shell_command服务

  1. 复制下面的代码到HA配置文件configuration.yaml yaml shell_command: update_xiaomi_miot: |- wget -O - https://get.hacs.vip | DOMAIN=xiaomi_miot bash -
  2. 重启HA使配置生效
  3. 在HA开发者工具中调用此服务service: shell_command.update_xiaomi_miot
  4. 再次重启HA使新版插件生效

视频教程

配置

⚙️ 配置 > 设备与服务 > 🧩 集成 > ➕ 添加集成 > 🔍 搜索 Xiaomi Miot

或者点击: 添加集成

账号集成 (Add devices using Mi Account):

自v0.4.4版本开始,插件新增支持账号集成时选择连接设备的模式: - 自动模式:插件定期更新支持本地miot协议的设备,并自动将用户筛选的设备中符合条件的型号使用本地连接(推荐) - 本地模式:集成配置所筛选的设备都将使用本地连接,如勾选了不支持本地miot协议的设备将不可用 - 云端模式:集成配置所筛选的设备都将使用云端连接,建议旧版miio、蓝牙、ZigBee设备使用

本地集成 (Add device using host/token):

通过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   # 请求小米接口的超时时间(秒)

⚙️ 配置 > 设备与服务 > 🧩 集成 > Xiaomi Miot > 选项 > ☑️ 开启云端模式

配置翻译词典:

可以通过配置文件将大部分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配置重载

本插件支持配置重载(修改YAML配置后无需重启HomeAssistant):

🔨 开发者工具 > YAML 重载 > 配置重载 > 🔍 重载 XIAOMI MIOT

支持的设备

不支持的设备

本插件使用轮询的方式获取设备状态,因此无法实时监听部分设备的事件

服务

由于HA支持服务响应已经有一段时间了,本组件自v0.7.18开始不再触发事件。

[`xiaomi_miot.set_propert

Core symbols most depended-on inside this repo

get
called by 812
custom_components/xiaomi_miot/core/device.py
update
called by 83
custom_components/xiaomi_miot/select.py
get
called by 75
custom_components/xiaomi_miot/core/miot_spec.py
info
called by 53
custom_components/xiaomi_miot/core/mini_miio.py
get_property
called by 48
custom_components/xiaomi_miot/core/miot_spec.py
get_action
called by 46
custom_components/xiaomi_miot/core/miot_spec.py
custom_config_bool
called by 41
custom_components/xiaomi_miot/core/utils.py
async_call_action
called by 39
custom_components/xiaomi_miot/core/device.py

Shape

Method 819
Class 113
Function 102
Route 1

Languages

Python100%

Modules by API surface

custom_components/xiaomi_miot/__init__.py119 symbols
custom_components/xiaomi_miot/core/device.py109 symbols
custom_components/xiaomi_miot/core/miot_spec.py104 symbols
custom_components/xiaomi_miot/media_player.py70 symbols
custom_components/xiaomi_miot/core/xiaomi_cloud.py60 symbols
custom_components/xiaomi_miot/core/converters.py57 symbols
custom_components/xiaomi_miot/camera.py49 symbols
custom_components/xiaomi_miot/sensor.py40 symbols
custom_components/xiaomi_miot/vacuum.py37 symbols
custom_components/xiaomi_miot/core/utils.py36 symbols
custom_components/xiaomi_miot/climate.py32 symbols
custom_components/xiaomi_miot/device_tracker.py25 symbols

Dependencies from manifests, versioned

fastmcp2.0.0 · 1×

For agents

$ claude mcp add hass-xiaomi-miot \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact