在OrangePI上搭建homeassitant过程记录

1.更换Python版本

由于在新版的homeassistant当中需要使用python3.5.3及以后的版本,但由于apt源中只包含3.5.2的版本,所以需要升级到python3.6。

具体更换方式:

sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6 python3.6-venv python3.6-dev

具体可参考:https://github.com/home-assistant/home-assistant/issues/13089

安装Python3.6的pip【2】:

curl https://bootstrap.pypa.io/get-pip.py | sudo -H python3.6

具体可参考:https://github.com/home-assistant/home-assistant/issues/13089

关于更换到国内镜像:

pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

具体可参考:https://mirror.tuna.tsinghua.edu.cn/help/pypi/

更换默认python版本:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
sudo update-alternatives --config python3

具体可参考:https://blog.csdn.net/s_lisheng/article/details/78296177

2.homeassistant的安装

具体的安装过程可参考:https://juejin.im/post/5a74a2515188257a814ce254

cd /home/pi/Desktop && python3 -m venv homeassistant
cd homeassistant
source bin/activate
python3 -m pip install wheel
python3 -m pip install homeassistant
hass --open-ui

3.设置自启动

1.创建 home-assistant.service ,并放入以下内容 sudo vim /etc/systemd/system/home-assistant.service

扫描二维码关注公众号,回复: 4697119 查看本文章
[Unit]
Description=Home Assistant
After=network.target

[Service]
Type=simple
User=pi
Environment=PATH="$VIRTUAL_ENV/bin:$PATH"
ExecStart=/home/pi/Desktop/homeassistant/bin/hass -c "/home/pi/.homeassistant"

[Install]
WantedBy=multi-user.target

2.更新系统设置 

sudo systemctl --system daemon-reload

3.设置HomeAssistant开机启动

sudo systemctl enable home-assistant.service

4.启动

sudo systemctl start home-assistant.service

常见错误资料:

Fix ‘E: Could not get lock /var/lib/dpkg/lock’ Error in Ubuntu [Quick Tip]

缺少ffi.h  sudo apt-get install libffi-dev

猜你喜欢

转载自www.cnblogs.com/shubin/p/10195398.html