也许,时间见过我们
posts - 97,comments - 14,views - 24万
 
树莓派3b+安装好 Ubuntu Server 20.04.3 LTS 32bit 后即可适用此脚本,其他版本树莓派/系统可能需要微调脚本
*为方便一些未知/已知错误排查 脚本存在
冗余部分,足够了解linux的可自行精简,Y/N在需要时手动键入
下面HA驱动处根据需要修改
复制代码
# 树莓派3b+安装好 Ubuntu Server 20.04.3 LTS 32bit 后即可适用此脚本,其他版本树莓派/系统可能需要微调脚本
# 下面HA驱动处根据需要修改
# author: bright

# docker安装 # 更新源
cat>/etc/apt/sources.list<<EOF deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib deb [arch=armhf] https://download.docker.com/linux/ubuntu focal stable # deb-src [arch=armhf] https://download.docker.com/linux/ubuntu focal stable

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

EOF

# 服务密钥重置
gpg --keyserver  keyserver.ubuntu.com --recv-keys 9165938D90FDDD2E
gpg --export --armor  9165938D90FDDD2E | sudo apt-key add -
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository    "deb [arch=armhf] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update && sudo apt-get upgrade 
# 安装步骤
sudo apt-get install docker-ce
apt-get install docker.io
apt-get install runc >= 1.0.0
apt install docker

# docker拉取&&安装homeassistant
docker pull homeassistant/raspberrypi3-homeassistant


# 启动homeassistant
docker run -d --name homeassistant -p 8123:8123 homeassistant/raspberrypi3-homeassistant

# 配置HA自启动
# 获取容器id
cid=$(docker ps -a|grep "homeassistant" | awk '{print $1}')
echo $cid
# 添加homeassistant自启动配置文件
touch /etc/init.d/homeassistant.sh
cat>/etc/init.d/homeassistant.sh<<EOF
#!/bin/bash
docker restart $cid
exit 0
EOF
touch /etc/rc.local
cat>/etc/rc.local<<EOF
#!/bin/bash
docker restart $cid
exit 0
EOF
# 权限+自启
chmod 755 /etc/rc.local
chmod 755 /etc/init.d/homeassistant.sh
update-rc.d homeassistant.sh defaults 90

# homeassistant配置Xiaomi_gateway3 和 air_condition驱动
# 进入容器


# 如需直接跑跳到终端不运行可将下面命令新建一个setup.sh 脚本
# docker exec -it $cid /bin/bash
#
docker ps -a 可以拿到cid
# touch setup.sh # 复制下面这些命令到脚本中在ha container中跑 # vi setup.sh # bash setup.sh


# 驱动相关
# 进行驱动拉取 docker restart $cid docker exec -i $cid mkdir custom_components docker exec -i $cid cd custom_components docker exec -i $cid mkdir bak docker exec -i $cid cd bak # XiaomiGateway3 docker exec -i $cid git clone https://github.com/AlexxIT/XiaomiGateway3 docker exec -i $cid cp -r XiaomiGateway3/custom_components/xiaomi_gateway3 ../../custom_components/ # 01 02 11LM 空调伴侣驱动 docker exec -i $cid git clone https://github.com/syssi/xiaomi_airconditioningcompanion.git docker exec -i $cid cp -r xiaomi_airconditioningcompanion/custom_components/xiaomi_miio_airconditioningcompanion ../../custom_components/ # 如需其他驱动仿照此中方式添加进来 # 修改yaml主配置文件 docker exec -i $cid cd /config && mv configuration.yaml configuration.bak docker exec -i $cid touch configuration.yaml docker exec -i $cid cat>configuration.yaml<<EOF # Configure a default setup of Home Assistant (frontend, api, etc) default_config: # Text to speech tts: - platform: google_translate group: !include groups.yaml automation: !include automations.yaml script: !include scripts.yaml scene: !include scenes.yaml climate: - platform: xiaomi_miio_airconditioningcompanion name: Aqara Air Conditioning Companion host: 192.168.1.xx # 需要修改空调伴侣的ip token: xx # 修改空调伴侣对应的token target_sensor: sensor.temperature_158d0001f53706 scan_interval: 60 EOF docker exec -i $cid exit

apt install ntpdate
ntpdate us.pool.ntp.org

reboot
复制代码

 

其他home assistant iot参考:

https://www.cnblogs.com/cutesnow/p/15511959.html

posted on   画入新雪  阅读(990)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5

Copyright ©2017 画入新雪
点击右上角即可分享
微信分享提示