• 一键部署Home Assistant ubuntu 20.4.3 树莓派3b+脚本


     
    树莓派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

    ------ 往事如烟,伴着远去的步伐而愈加朦胧。未来似雾,和着前进的风儿而逐渐清晰!
  • 相关阅读:
    Atitit.js图表控件总结
    atitit.attilax的软件 架构 理念.docx
    Atitit.异常处理 嵌套  冗长的解决方案
    Atitit.异常处理 嵌套  冗长的解决方案
    Atitit.atiagent  agent分销系统 代理系统 设计文档
    Atitit.atiagent  agent分销系统 代理系统 设计文档
    Atitit ati licenseService    设计原理
    Atitit ati licenseService    设计原理
    Atitit.项目修改补丁打包工具 使用说明
    Atitit.项目修改补丁打包工具 使用说明
  • 原文地址:https://www.cnblogs.com/cutesnow/p/15576701.html
Copyright © 2020-2023  润新知