Xiaomi

This section shows you how to integrate a Xiaomi router or a Xiaomi camera into Home Assistant.

Camera

The Xiaomi camera integration allows you to utilize Xiaomi cameras within Home Assistant.

Prerequisites

  • To successfully implement this integration, the Home Assistant host should be capable of multiple simultaneous reads.
    • For every concurrent Home Assistant user, a connection will be made to the camera every 10 seconds. This should normally not be a problem.

Preparing the device

  1. In order to integrate the camera with Home Assistant, it is necessary to install a custom firmware on the device.
  2. Once installed, make sure you have enabled FTP.

Warning

Currently, version 0.1.4-beta2 of the custom firmware is the highest supported. Firmwares higher than this version use Pure-FTPd, which has a bug that prevents FFmpeg from correctly rendering video files.

Important

Raspbian users: Don’t forget to install ffmpeg support on your platform, otherwise, you’ll not see video.

Note

The live stream writing by the camera is not a supported format when Home Assistant reads through FTP for Yi 720p and Xiaofang Cameras, so this platform retrieves the video which was saved 1 minute earlier.

Tip

If you enabled RTSP server, you can connect to your camera via other Home Assistant camera platforms. However, this RTSP server disables the ability to use the supremely-useful Mi Home app. In order to maintain both Home Assistant compatibility and the native app, this platform retrieves videos via FTP.

Configuration

To enable the camera, add the following lines to your configuration.yamlThe configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI. [Learn more] file:

camera:
  - platform: xiaomi
    name: Camera
    host: "192.168.1.100"
    model: "yi"
    password: YOUR_PASSWORD

Configuration Variables

name string Required

A human-friendly name for the camera.

host template Required

The IP address or hostname of the camera.

model string Required

The model of Xiaomi Camera, currently supporting yi and xiaofang.

password string Required

The password to the FTP server on the camera (from above), can be any string as the current firmware doesn’t allow setting ftp passwords.

path string (Optional)

The path to the raw MP4 files.

Default:

/media/mmcblk0p1/record

username string (Optional, default: root)

The user that can access the FTP server.

ffmpeg_arguments string (Optional)

Extra options to pass to ffmpeg.

Important

The default for path: will not work with all cameras. It may be needed that you add that key with the exact path for your device.

Image quality

Any option supported by ffmpeg camera can be utilized via the ffmpeg_arguments configuration parameter.

One particularly useful adjustment deals with video size. Since Yi videos are fairly large (especially on the 1080p cameras), the following configuration will bring them down to a manageable size:

camera:
  - platform: xiaomi
    name: My Camera
    host: "192.168.1.100"
    model: "xiaofang"
    password: YOUR_PASSWORD
    path: /home/camera/feed
    ffmpeg_arguments: "-vf scale=800:450"

Hostname template

The hostname/IP address can be provided either a value or from the existing entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] attributes.

camera:
  - platform: xiaomi
    name: Front Camera
    host: ""
    model: "yi"
    password: 1234
    path: /tmp/sd/record

Router

The Xiaomi router integration offers presence detection by looking at connected devices to a Xiaomi router.

Configuration

To use an Xiaomi router in your installation, add the following to your configuration.yamlThe configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI. [Learn more] file:

# Example configuration.yaml entry
device_tracker:
  - platform: xiaomi
    host: YOUR_ROUTER_IP
    password: YOUR_ADMIN_PASSWORD

Configuration Variables

host string Required

The IP address of your router, e.g., 192.168.0.1.

username string (Optional, default: admin)

The admin username.

password string Required

The password for the admin account.

See the device tracker integration page for instructions how to configure the people to be tracked.

Compatibility test

To ensure that your router is compatible, navigate to http://YOUR_ROUTER_IP/api/misystem/devicelist. You should see a listing of the device currently connected to your router.

However, some users report that even when the previous URL does not work, they have been able to integrate their Mi Router 3 in Home Assistant. E.g., some users with the Mi Router 3 and firmware version 2.10.46 Stable have integrated their routers successfully and an alternative URL to test integration with is http://YOUR_ROUTER_IP/cgi-bin/luci/api/misystem/devicelist. Navigating to this page should show the {"code":401,"msg":"Invalid token"} message.