跳至内容

Smart Home

Xiaomi Officially Integrates Open Source Home Assistant - A New Smart Home Experience

mi-home-assistant

1. Brief Introduction

Hello everyone! Today we are going to talk about an exciting project for smart home enthusiasts: Xiaomi Official Home Assistant Integration (ha_xiaomi_home). This project is developed and maintained by Xiaomi, aiming to provide Home Assistant users with a smoother and more reliable control experience for Xiaomi IoT devices.

In the past, while there were some third-party integrations for Xiaomi devices on the market, they had various issues, such as delayed device status responses. Now, with official support, we can expect better performance and stronger security.

Home Assistant is an open-source home automation platform known for its powerful compatibility and flexibility, loved by DIY enthusiasts. Now, with Xiaomi, a giant in the smart home field, joining the Home Assistant ecosystem, it is undoubtedly something to look forward to.

Main Features:

  • Official Support: Developed and maintained by Xiaomi, providing better stability and compatibility.
  • Home Assistant Integration: Allows users to control and manage Xiaomi smart devices within Home Assistant.
  • Enhanced User Experience: Aims to provide faster device status responses, addressing delays present in third-party integrations.
  • Wide Device Support: Supports most Xiaomi IoT devices, except for Bluetooth, infrared, and virtual devices.
  • Multi-account and Regional Support: Supports multiple Xiaomi accounts and allows devices from different regions to be added to the same Home Assistant area.

2. Core Features

  • Multiple Installation Methods: Supports various installation methods, including Git clone, HACS, and manual installation. The official recommendation is to use Git clone for easier version management and updates.
    • Git clone installation: cd config; git clone https://github.com/XiaoMi/ha_xiaomi_home.git; cd ha_xiaomi_home; ./install.sh /config.
  • OAuth 2.0 Login: Adopts OAuth 2.0 login method, not storing user passwords directly in Home Assistant, enhancing security.
  • Cloud Control and Local Control: Primarily controlled through Xiaomi Cloud. For devices that support local control, communication can occur through Xiaomi gateways or local area networks.
    • Cloud Control: Communication and control through Xiaomi cloud servers.
    • Local Control: Direct communication within the local network via Xiaomi central gateway or LAN, but local control is not available in all regions.
      • Central Gateway: Available only in mainland China.
      • LAN Control: Available in all regions but limited to IP devices and is experimental, not recommended for use.
  • Device Message Subscription Mechanism: Uses a message subscription mechanism to push messages to Home Assistant in real-time when device properties change or events occur, reducing polling pressure on the cloud.
  • MIoT-Spec-V2 Mapping: Uses the Xiaomi IoT protocol MIoT-Spec-V2 to map devices, services, properties, events, and actions to entities in Home Assistant, ensuring device functionality.

3. Usage Tips

  • Multi-account Management: After logging in and configuring one Xiaomi account, you can add other Xiaomi accounts by clicking "Add HUB".
  • Region Selection: When importing Xiaomi devices, be sure to select the correct region, as data from different regions is isolated.
  • Debug Mode: Enabling debug mode for actions allows you to manually send action commands with parameters.
  • Entity Conversion Rule Updates: If you modify the specv2entity.py, spec_filter.json, or multi_lang.json files, you need to update the entity conversion rules in the integration configuration page for changes to take effect.
  • Custom Filtering: Use the spec_filter.json file to filter out MIoT-Spec-V2 instances that do not need to be converted to Home Assistant.
  • Localization: The multi_lang.json file is used to provide localized translations of device names and other text elements, taking precedence over cloud translations.

4. Application Cases

  • Smart Lighting Control: Control the brightness, color, and switch status of Xiaomi smart bulbs through Home Assistant.
  • Smart Security: Combine Xiaomi smart cameras and sensors to achieve home security automation, such as sending alerts when abnormal movement is detected.
  • Environmental Monitoring: Use Xiaomi temperature and humidity sensors to monitor indoor environments in real-time and automatically adjust air conditioning or heating based on temperature.
  • Automated Scenarios: Utilize Home Assistant's automation features to set various scenarios, such as "Home Mode," "Away Mode," etc., to achieve smart home automation control.

5. Security Concerns

Although the Xiaomi official integration uses OAuth 2.0 login methods to enhance security, there are still some security risks:

  • Plaintext Storage of User Data: Sensitive information such as device information, certificates, and tokens are stored in plaintext in Home Assistant's configuration files. This means that if the configuration file is leaked, others may access your Xiaomi devices.
  • Protecting Configuration Files: You need to ensure that your Home Assistant configuration files are well protected to prevent leaks.
  • Revoking Authorization: If you suspect that the OAuth token has been leaked, you can revoke login authorization through the Xiaomi Home App.

Therefore, it is essential to properly safeguard your Home Assistant configuration files to prevent leaks!

6. Frequently Asked Questions

  • Which devices are not supported?
    • Currently, Bluetooth devices, infrared devices, and virtual devices are not supported.
  • How to add multiple Xiaomi accounts?
    • In the configured Xiaomi Home integration page, click "Add HUB" to add other Xiaomi accounts.
  • Is local control available in all regions?
    • Local control through the central gateway is only available in mainland China, while LAN control is available in all regions but limited to IP devices and is not recommended for use.
  • Why does the official recommend Git clone installation?
    • Git clone is convenient for version switching and updates, making management easier.
  • How to update the integration?
    • You can switch to a specified version through Git clone or use HACS for updates.
  • How to use custom configurations?
    • You can edit the spec_filter.json and multi_lang.json files for filtering and translation, and update entity conversion rules.