在orange pi上安装homeassistant
我使用的是orange pi zero 512M的版本,其他版本的orange pi 类似。
首先前往armbian网站下载最新版的Debian_stretch镜像并写入TF卡,将机器接入网线然后通电开机。
登录路由器或手机下载Fing软件,找到orange pi的IP地址,然后用Putty登录root账户,默认密码是1234。
首次登录系统会要求修改root密码以及创建一个新用户(下面以pi用户名为例进行演示),我们根据提示进行操作就可以了。
接下来我们输入armbian-config命令来进行连接WIFI,修改时区,修改网络名称,禁用IPV6等操作,根据菜单提示一步一步进行即可。设置完之后我们reboot一次机器。
等机器重启完之后我们用root登录,然后进行以下操作:
apt update
apt upgrade -y
apt install sudo net-tools -y
将我们创建的用户加入到sudo组
nano /etc/sudoers
将pi ALL=NOPASSWD: ALL插入到相应位置。
然后我们切换到之前创建的pi用户来进行下面的操作
su pi
sudo apt install wget screen git curl -y
sudo wget https://github.com/home-assistant/hassbian-scripts/releases/download/v0.6/hassbian-scripts_0.6.deb
sudo apt install bluetooth avahi-daemon python3-venv python3-pip python3-dev libbluetooth-dev build-essential libssl-dev libffi-dev python-dev libudev-dev -y
sudo dpkg -i hassbian-scripts_0.6.deb;
sudo hassbian-config show;
sudo mv /opt/hassbian/suites/install_homeassistant.sh /opt/hassbian/suites/install_homeassistant.sh.bak
sudo nano /opt/hassbian/suites/install_homeassistant.sh
然后复制以下内容并保存退出:
#!/bin/bash
function homeassistant-show-short-info {
echo "Home Assistant install script for Hassbian"
}
function homeassistant-show-long-info {
echo "Installs the base homeassistant package onto this system."
}
function homeassistant-show-copyright-info {
echo "Copyright(c) 2017 Fredrik Lindqvist <https://github.com/Landrash>";
}
function homeassistant-install-package {
homeassistant-show-short-info
homeassistant-show-copyright-info
echo "Changing to the homeassistant user"
sudo adduser --system homeassistant
sudo addgroup homeassistant
sudo chown -R homeassistant:homeassistant /srv/homeassistant
sudo su -s /bin/bash homeassistant
echo "Creating Home Assistant venv"
python3 -m venv /srv/homeassistant
echo "Changing to Home Assistant venv"
source /srv/homeassistant/bin/activate
echo "Installing latest version of Home Assistant"
pip3 install pip==18.1 netdisco setuptools wheel
pip3 install homeassistant
echo "Deactivating virtualenv"
deactivate
EOF
echo "Enabling Home Assistant service"
systemctl enable home-assistant@homeassistant.service
sync
echo "Disabling the Home Assistant install script"
systemctl disable install_homeassistant
systemctl daemon-reload
echo "Starting Home Assistant"
systemctl start home-assistant@homeassistant.service
cd
ip_address=$(ifconfig ' awk -F':' '/inet addr/&&!/127.0.0.1/{split($2,_," ");print _[1]}')
echo
echo "Installation done."
echo
echo "Your Home Assistant installation is running at $ip_address:8123 or if prefered http://hassbian.local:8123";
echo
echo "To continue have a look at https://home-assistant.io/getting-started/configuration/";
echo
echo "If this script failed then this Raspberry Pi most likely did not have a fully functioning internet connection."
echo "If you have issues with this script, please say something in the #Hassbian channel on Discord."
echo
return 0
}
# Make this script function as it always has if run standalone, rather than issue a warning and do nothing.
[[ $0 == "$BASH_SOURCE" ]] && homeassistant-install-package
接下来运行
sudo hassbian-config install homeassistant
等停止之后输入
exit
安装会继续进行。
等到安装结束之后运行下面命令:
sudo chown -R homeassistant:homeassistant /srv/homeassistant;
sudo systemctl stop home-assistant@homeassistant.service;
sudo su -s /bin/bash homeassistant;
source /srv/homeassistant/bin/activate;
hass
直到我们能正常打开orange pi ip:8123看到网页,整个安装过程结束。
之后我们可以使用sudo hassbian-config show来安装samba、mqtt等服务。