1.更换Python版本
方法一:可采用PPA的方式安装
由于在新版的homeassistant当中需要使用python3.5.3及以后的版本,但由于apt源中只包含3.5.2的版本,所以需要升级到python3.6。
具体更换方式:
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get updatesudo apt-get install python3.6 python3.6-venv python3.6-dev
安装Python3.6的pip【2】:
curl https://bootstrap.pypa.io/get-pip.py | sudo -H python3.6
关于更换到国内镜像:
pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
更换默认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
方法二:采用编译安装的方法
首先,安装相关依赖
sudo apt install gcc make zlib* libffi-dev libsqlite3-dev libssl-dev openssl
wget--no-check-certificate https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
tar zxvf Python-3.7.3.tgz
cd Python-3.7.3./configure --prefix=/usr/local/python3.7
make && sudo make install
sudo ln -s /usr/local/python3.7/bin/python3.7 /usr/bin/python3.7
sudo ln -s /usr/local/python3.7/bin/pip3.7 /usr/bin/pip3
2.homeassistant的安装
cd /home/pi/Desktop && python3 -m venv homeassistant
cd homeassistant
source bin/activate
python3-m pip installwheel
python3-m pip install homeassistanthass--open-ui
3.设置自启动
1.创建 home-assistant.service ,并放入以下内容 sudo vim /etc/systemd/system/home-assistant.service
[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
常见错误资料:
缺少ffi.h sudo apt-get install libffi-dev