Home Assistant最佳实践
# 1 简介
# 2 安装
参考:Generic x86-64 - Home Assistant (opens new window)
services:
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
volumes:
- /PATH_TO_YOUR_CONFIG:/config
- /etc/localtime:/etc/localtime:ro
- /run/dbus:/run/dbus:ro
restart: unless-stopped
privileged: true
network_mode: host
environment:
TZ: Asia/Shanghai
访问 http://<host>:8123
# 3 Nginx 反代
默认情况下,使用 nginx 反代 hs 的地址会提示 400: Bad Request ,需要配置。
# 3.1 网页设置
从 Home Assistant 2026.8 开始,反向代理设置移到了网页界面。HTTP - Home Assistant (opens new window)
- 打开 Home Assistant (opens new window),用管理员账号登录。首次访问时先完成初始化。
- 进入 设置 → 系统 → 网络 → HTTP 服务器。
- 开启 信任 X-Forwarded-For,在 受信任的代理 中添加
10.10.20.131。 - 保存后 Home Assistant 会重启。重新打开页面,在 5 分钟内确认新设置,否则会自动回退。 HTTP 服务器设置 (opens new window)
# 3.2 修改 configuration.yaml(Deprecated)
适用 2026.8 之前的版本
config/configuration.yaml 添加:
http:
use_x_forwarded_for: true
trusted_proxies:
- XXX.XXX.XXX.XXX # Add the IP address of the proxy server
# 4 开始
按提示下一步即可
# 5 安装 HACS(Deprecated)
Tip
- HACS does not work on Home Assistant 2026.11 and newer (found 2026.11.1), as it has been replaced by the native Marketplace integration. See https://www.home-assistant.io/integrations/marketplace
- 新的入口:设置 - 市场
全称:Home Assistant Community Store(Home Assistant 社区商店) 参考:HACS (opens new window)
# 5.1 容器安装
# 进入Home Assistant容器
docker exec -it <name of the container running homeassistant> bash
# 安装
wget -O - https://get.hacs.xyz | bash -
exit
# 重启容器
docker compose restart
# 5.2 集成
- 设置 - 设备与服务
- 右下角 -
添加集成 - 搜索
HACS添加(需登录 Github)
# 5.3 社区插件
在侧边栏 HACS 搜索
# 6 接入
# 6.1 海尔
参考:banto6/haier: 海尔智能家居设备接入 HomeAssistant (opens new window)
- 安装:参考 Github
- 抓包:最新海尔小程序抓包教程 - 『HomeAssistant』综合讨论区 - 『瀚思彼岸』» 智能家居技术论坛 - Powered by Discuz! (opens new window)
- 配置:设置 - 设备与服务 - 集成 - 添加集成 - 搜索
haier
# 6.2 美的
# 6.3 Apple HomeKit(家庭)
参考:HomeKit Bridge - 家庭助手 --- HomeKit Bridge - Home Assistant (opens new window)
- iOS 设备需安装
家庭 - 集成安装:略
# 6.4 米家
插件名称: Xiaomi Home
上次更新: 2026/11/17, 18:43:43