374 words
2 minutes
Installing Home Assistant in Docker and Integrating Xiaomi Mi Home
2024-12-30

Installing Home Assistant#

I installed it with docker-compose, using the following docker-compose.yml:

version: '3.8'
services:
homeassistant:
image: homeassistant/home-assistant
container_name: home-assistant
restart: unless-stopped
volumes:
- ./home-assistant:/config
ports:
- '8123:8123'
environment:
- TZ=Asia/Shanghai

Home Assistant is then available at http://localhost:8123 in your browser.

TIP

To reach Home Assistant from the public internet, put it behind a reverse proxy with Nginx Proxy Manager — see Nginx Proxy Manager: A Comprehensive User Guide (in Chinese). At this point you probably still can’t get in remotely; the home-assistant container logs will show something like:

Terminal window
2024-12-26 14:59:40.393 ERROR (MainThread) [homeassistant.components.http.forwarded] A request from a reverse proxy was received from 192.168.97.1, but your HTTP integration is not set-up for reverse proxies

Fix it by editing the home-assistant config: add the following to configuration.yaml:

http:
use_x_forwarded_for: true
trusted_proxies:
- 192.168.97.0/24

Starting Home Assistant#

Terminal window
docker-compose up -d

Open http://localhost:8123 in a browser and follow the onboarding prompts to finish setting up Home Assistant.

Mi Home Integration#

Thanks to Xiaomi opening up officially, Home Assistant integrates with Xiaomi smart home devices almost effortlessly.

XiaoMi
/
ha_xiaomi_home
Waiting for api.github.com...
00K
0K
0K
Waiting...
  1. Open a terminal inside the home-assistant container
  2. Clone the Mi Home integration repository
Terminal window
git clone https://github.com/XiaoMi/ha_xiaomi_home.git
  1. Change into the ha_xiaomi_home directory
Terminal window
cd ha_xiaomi_home
  1. Run the install script
Terminal window
./install.sh /config
  1. Open Home Assistant in a browser and restart it
  2. After the restart, add the Mi Home integration:
    1. In Home Assistant, go to Settings -> Devices & Services -> Add Integration
    2. Search for Xiaomi Home in the integration search box
    3. Click the Xiaomi Home integration and follow the prompts
    4. Once configured, your Mi Home devices show up in Home Assistant, ready to control
TIP
  • If you’re using Safari, adding the integration may fail — try a different browser.
  • If Xiaomi account verification errors out, replace homeassistant.local in http://homeassistant.local:8123/api/webhook/xxx with your LAN IP address.

Adding Devices to the Apple Home App#

  1. In Home Assistant, go to Settings -> Devices & Services -> Add Integration
  2. Search for Apple -> HomeKit Bridge
  3. Click the HomeKit Bridge integration and follow the prompts
  4. When configuration finishes, the pairing code and QR code appear under Notifications in the bottom-left corner
  5. Open the Apple Home app, tap +, and choose Add or Scan Accessory
  6. Once added, your devices appear in the Apple Home app and can be controlled from there

Final Thoughts#

Home Assistant is a remarkably capable smart-home platform, and it makes short work of integrating Xiaomi devices. It supports a huge range of other devices too — browse the official Home Assistant docs to learn more.

Installing Home Assistant in Docker and Integrating Xiaomi Mi Home
https://www.mihouo.com/en/posts/docker/installing-home-assistant-in-docker-and-integrating-xiaomi-mi-home/
Author
Jia
Published at
2024-12-30
License
CC BY-NC-SA 4.0