一 、docker 部署 homeassistant
homeassistant_官网地址:https://www.home-assistant.io
homeassistant_后台地址:http://localhost:8123
1 、Debian 终端命令创建docker-compose.yml文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| mkdir -p /mnt/mydisk/home/homeassistant && \ cd /mnt/mydisk/home/homeassistant && \ touch docker-compose.yml && \ cat > docker-compose.yml <<'EOF' services: homeassistant: container_name: homeassistant image: ghcr.io/home-assistant/home-assistant:stable restart: unless-stopped volumes: - ./config:/config - ./localtime:/etc/localtime:ro - ./dbus:/run/dbus:ro environment: - TZ=Asia/Shanghai privileged: true network_mode: host EOF docker-compose up -d
|
2 、拉取并运行
1
| cd /mnt/mydisk/home/homeassistant && docker-compose up -d
|
3 、停并止删除
1
| cd /mnt/mydisk/home/homeassistant && docker-compose down
|
4 、拉取镜像
1
| docker pull ghcr.io/home-assistant/home-assistant:stable
|
5 、容器升级
1 2 3 4 5
| cd /mnt/mydisk/home/homeassistant && \ docker-compose down && \ docker-compose pull && \ docker-compose up -d && \ docker image prune -f
|
二 、容器维护命令
1 、查所看有运行器容的名称
1
| docker ps -a --format "{{.Names}}"
|
2 、停止 homeassistant 容器
1
| docker stop homeassistant
|
3 、启动 homeassistant 容器
1
| docker start homeassistant
|
4 、重启 homeassistant 容器
1
| docker restart homeassistant
|
5 、进入 homeassistant 容器
1 2 3
|
docker exec -it homeassistant bash
|
6 、查看 homeassistant 配置文件
1
| cat /mnt/mydisk/home/homeassistant/docker-compose.yml
|
三 、安装 HACS
- 进入容器
1
| docker exec -it homeassistant bash
|
- 安装 HACS
1
| wget -O - https://hacs.vip/get | bash -
|
- 重启 homeassistant 容器
- 主界面–>设置–>设备与服务–>添加集成–>搜索 hacs–>绑定Github
- 在hacs中搜索
Xiaomi Miot Auto
并安装
- 主界面–>设置–>设备与服务–>添加集成–>搜索
apple
–>安装 HomeKit Bridge
四 、反向代理
编辑/mnt/mydisk/home/homeassistant/config/configuration.yaml
文件
在文件后面添加以下内容:
1 2 3 4 5
| http: use_x_forwarded_for: true trusted_proxies: - 10.10.10.0/24 - 127.0.0.1
|
Nginx 配置
后台地址:https://homeassistant.example.com:666
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| mkdir -pm 755 /etc/nginx/conf.d && \ touch /etc/nginx/conf.d/homeassistant.conf && \ cat <<'EOF' | sed '1!{/^[[:space:]]*#/d;/^[[:space:]]*$/d}' > /etc/nginx/conf.d/homeassistant.conf
server { listen 666 ssl; listen [::]:666 ssl;
server_name homeassistant.example.com;
ssl_certificate /etc/nginx/keyfile/cert.pem; ssl_certificate_key /etc/nginx/keyfile/key.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers HIGH:!aNULL:!MD5;
location / { proxy_pass http://10.10.10.251:8123; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Range $http_range; proxy_set_header If-Range $http_if_range; proxy_redirect off; proxy_buffering on; proxy_http_version 1.1; } charset utf-8; error_page 404 500 502 503 504 /50x.html; location = /50x.html { root /var/www/html; } } EOF
sudo systemctl restart nginx
|