Home Assistant安装与插件配置笔记

1. 智能家居系统(homeassistant)

1.1 拉取镜像并创建配置目录

docker pull ghcr.io/home-assistant/home-assistant:2025.1.0
mkdir /root/haconfig

1.2 编写运行脚本

编写运行脚本run-homeassistant.sh

#!/bin/bash

docker run -d \
	--name homeassistant \
	--network=host \
	--privileged \
	--restart=unless-stopped \
	-e TZ=Asia/Shanghai \
	-e HTTP_PROXY="http://192.168.0.100:7890" \
	-e HTTPS_PROXY="http://192.168.0.100:7890" \
	-e NO_PROXY="localhost,127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16" \
	-v /root/haconfig:/config \
	-v /run/dbus:/run/dbus:ro \
	ghcr.io/home-assistant/home-assistant:2025.1.0

启动homeassistant

chmod +x run-homeassistant.sh
./run-homeassistant.sh

说明

  • --privileged 赋予容器高级权限,部分硬件交互需要。
  • -v /run/dbus:/run/dbus:ro 挂载主机的 D-Bus 套接字,用于与蓝牙等系统服务通信。
  • --network=host 使用主机网络,方便发现局域网设备。

2. 小爱音箱本地曲库(xiaomusic)

2.1 拉取镜像并创建配置目录

docker pull docker.hanxi.cc/hanxi/xiaomusic:v0.3.100
mkdir /root/xiaomusic_music /root/xiaomusic_conf

2.2 编写运行脚本

编写运行脚本run-xiaomusic.sh

#!/bin/bash

docker run -d \
	--name xiaomusic \
	--network=host \
	--restart=unless-stopped \
	-e XIAOMUSIC_PUBLIC_PORT=8090 \
	-e HTTP_PROXY="http://192.168.0.100:7890" \
	-e HTTPS_PROXY="http://192.168.0.100:7890" \
	-e NO_PROXY="localhost,127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16" \
	-v /root/xiaomusic_music:/app/music \
	-v /root/xiaomusic_conf:/app/conf \
	docker.hanxi.cc/hanxi/xiaomusic:v0.3.100

启动xiaomusic

chmod +x run-xiaomusic.sh
./run-xiaomusic.sh

说明

  • 音乐文件放入 /xiaomusic_music 目录,容器内映射为 /app/music
  • 配置文件保存在 /xiaomusic_conf
  • 默认 Web 端口为 8090,可通过环境变量 XIAOMUSIC_PUBLIC_PORT 修改。

3. 常用插件汇总

插件类型 插件名称 仓库地址 用途
插件商店 HACS(官方) https://github.com/hacs/integration 官方插件管理
插件商店 HACS(国内版) https://github.com/hacs-china/integration 适配国内网络的 HACS
设备集成 小米官方插件 https://github.com/XiaoMi/ha_xiaomi_home 集成小米智能家居设备
设备集成 美的空调插件 https://github.com/wuwentao/midea_ac_lan 本地控制美的空调
物联网 巴法云插件 https://github.com/larry-wong/bemfa 巴法云物联网平台
posted @ 2025-02-26 16:40  wanghongwei-dev  阅读(62)  评论(0)    收藏  举报