米家设备接入 Home Assistant 实战 – 小米智能家居统一管理

为什么将米家接入 Home Assistant

米家 App 虽然方便,但如果你有多个品牌(小米、宜家、飞利浦等)的智能设备,每个 App 管理会很麻烦。Home Assistant 可以将所有设备统一管理,实现跨品牌联动。

接入方式选择

方式 难度 功能 推荐度
官方集成 简单 基础控制 入门推荐
Xiaomi Gateway 3 中等 本地控制,无需云端 进阶推荐
HAXiaomiGateway3 中等 本地+蓝牙 推荐

方式一:官方集成(推荐新手)

前提条件

  • 米家账号
  • Home Assistant 已安装
  • 米家设备已在米家 App 中添加

配置步骤

  1. 打开 Home Assistant
  2. 配置 → 设备与服务 → 添加集成
  3. 搜索「Xiaomi」
  4. 选择「Xiaomi Miio」
  5. 按照提示绑定小米账号

方式二:Xiaomi Gateway 3 集成(推荐进阶用户)

优势

  • 完全本地控制,不依赖云端
  • 响应更快,不受网络影响
  • 支持更多设备型号
  • 支持蓝牙设备

支持的设备

  • 米家网关 3
  • 米家空调伴侣
  • 米家灯泡
  • 米家传感器
  • 米家开关/插座

安装集成

1. 安装 HACS(Home Assistant 社区商店)
2. 在 HACS 中搜索「Xiaomi Gateway 3」
3. 安装并重启 Home Assistant
4. 添加集成 → Xiaomi Gateway 3

常用自动化示例

场景 1:人体传感器 + 灯联动

automation:
  - alias: 有人移动开灯
    trigger:
      - platform: state
        entity_id: binary_sensor.motion_sensor
        to: 'on'
    condition:
      - condition: time
        after: '18:00:00'
    action:
      - service: light.turn_on
        entity_id: light.living_room
        data:
          brightness: 150

场景 2:门窗传感器 + 警报

automation:
  - alias: 门被打开时发送通知
    trigger:
      platform: state
      entity_id: binary_sensor.door_sensor
      to: 'on'
    action:
      - service: notify.notify
        data:
          message: "门被打开了!"

场景 3:温湿度超标自动开空调

automation:
  - alias: 温度过高开空调
    trigger:
      - platform: numeric_state
        entity_id: sensor.temperature
        above: 28
    action:
      - service: climate.turn_on
        entity_id: climate.air_conditioner

常见问题

Q: 设备不在线怎么办?

确保设备在米家 App 中正常工作,然后重启 Home Assistant。

Q: 集成添加失败?

检查 Home Assistant 版本,尝试更新到最新版本。

Q: 命令发送延迟?

建议使用 Xiaomi Gateway 3 集成,本地控制延迟更低。

总结

将米家设备接入 Home Assistant 后,你可以用一个界面控制所有设备,还能实现复杂的自动化场景。建议从官方集成开始,熟悉后再尝试本地控制方案。

Comments

No comments yet. Why don’t you start the discussion?

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注