树莓派/斐讯N1/ARMBIAN/安装HOME ASSISTANT

RS 技术•随笔评论10,3231字数 2741阅读9分8秒阅读模式

1.树莓派更换国内apt源(可选,中国大陆必须)

sudo su
echo 'deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi' > /etc/apt/sources.list
echo 'deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi' >> /etc/apt/sources.list
echo 'deb http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui' > /etc/apt/sources.list.d/raspi.list
echo 'deb-src http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui' >> /etc/apt/sources.list.d/raspi.list
apt-get update
exit

斐讯N1 ArmBian换apt源(可选,中国大陆必须)

sudo su
echo 'deb http://mirrors.ustc.edu.cn/debian stretch main contrib non-free' > /etc/apt/sources.list
echo 'deb http://mirrors.ustc.edu.cn/debian stretch-updates main contrib non-free' > /etc/apt/sources.list
echo 'deb http://mirrors.ustc.edu.cn/debian stretch-backports main contrib non-free' > /etc/apt/sources.list
echo 'deb http://mirrors.ustc.edu.cn/debian-security/ stretch/updates main contrib non-free' > /etc/apt/sources.list
apt-get update
exit

2.安装依Python3运行环境

sudo apt-get -y install python3-pip build-essential libssl-dev libffi-dev python-dev openssl libssl-dev python3-cffi python3-setuptools python3-cryptography python3-bcrypt python-cryptography python-bcrypt python3-dev

3.修改阿里云pip源(可选,中国大陆必须)

sudo su
mv /etc/pip.conf /etc/pip.conf.bak
echo '[global]' > /etc/pip.conf
echo 'timeout = 6000' >> /etc/pip.conf
echo 'index-url = https://mirrors.aliyun.com/pypi/simple/' >> /etc/pip.conf
echo 'trusted-host = mirrors.aliyun.com' >> /etc/pip.conf
exit

4.安装python依赖包

pip3 install requests
pip3 install sqlalchemy
pip3 install distro
pip3 install hass-nabucasa
pip3 install xmltodict
pip3 install mutagen
pip3 install netdisco
pip3 install pynacl
pip3 install pyotp
pip3 install pyqrcode
pip3 install aiohttp
pip3 install aiohttp_cors
pip3 install cryptography
pip3 install gtts-token
pip3 install hass-nabucasa
sudo pip3 install pycryptodome
sudo pip3 install --upgrade pip

5.安装Home Assistant

sudo pip3 install homeassistant

6.手动启动测试一下是否正常,启动过程中会自动安装一些依赖包,耐心等待。

hass

7.创建系统服务

sudo chown -R $USER /tmp
echo $USER > /tmp/user.txt
sudo su
USER1=`cat /tmp/user.txt`
echo '[Unit]' > /etc/systemd/system/hass.service
echo 'Description=Home Assistant Service' >> /etc/systemd/system/hass.service
echo 'After=network.target' >> /etc/systemd/system/hass.service
echo 'Wants=network.target' >> /etc/systemd/system/hass.service
echo '[Service]' >> /etc/systemd/system/hass.service
echo 'User='$USER1 >> /etc/systemd/system/hass.service
echo 'Type=simple' >> /etc/systemd/system/hass.service
echo 'ExecStartPre=/bin/sleep 3' >> /etc/systemd/system/hass.service
echo 'ExecStart=/usr/local/bin/hass' >> /etc/systemd/system/hass.service
echo 'Restart=always' >> /etc/systemd/system/hass.service
echo '[Install]' >> /etc/systemd/system/hass.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/hass.service
exit

8.添加开机启动并启动Home Assistant

sudo systemctl enable hass
sudo systemctl start hass

打开Home Assistant 界面

http://xxx.xxx.xxx.xxx:8123

继续阅读
 
RS
  • 本文由 RS 发表于 2020年4月16日 19:49:35
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定