Hi all,
Short question. How do I manually update Home Assistant to the newest version?
Kind Regards,
Wodian
Hi all,
Short question. How do I manually update Home Assistant to the newest version?
Kind Regards,
Wodian
For anyone else who wants to upgrade:
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
pip3 install --upgrade homeassistant
Very useful, thanks. One question, why do you need the ‘sudo su -s’ if you are logged in as root?
Unfortunately this does not work as ‘activate’ does not exist in that directory.
Any suggestions on how to activate the virtualenv?
So I have managed it but not really sure what all these commands actually do to achieve that!
First login as the ‘homeassistant’ user
sudo su -s /bin/bash homeassistant
Next navigate to the homeassistant folder
cd /srv/homeassistant/
Execute this command - found in the homeassistant-start.sh file used by systemctl. Not too sure what this does!
export PATH="/home/homeassistant/.pyenv/bin:$PATH"; eval "$(pyenv init -)"; eval "$(pyenv virtualenv-init -)"
You should see a prompt like this indicating you are in the virtual environment.
(homeassistant-3.6.3) homeassistant@
Execute the pip3 command to update homeassistant.
pip3 install --upgrade homeassistant
Exit out of the su session
Exit
Restart the homeassistant service
systemctl restart home-assistant
I think this homeassistant-start.sh might be specific to DietPi and if so perhaps I could suggest a specific upgrade script?
HTH
Here you go, there will be a homeassistant-update.sh in that directoy at some point, have not had time to get to it. Put this in a updatehs.sh file and run it.
#!/bin/bash
HA_USER="homeassistant"
HA_USERROOT="/home/$HA_USER"
HA_SRVROOT="/srv/homeassistant"
HA_PYENV_ACTIVATION="export PATH=\"$HA_USERROOT/.pyenv/bin:\$PATH\"; export PYENV_VIRTUALENV_DISABLE_PROMPT=1; eval \"\$(pyenv init -)\"; eval \"\$(pyenv virtualenv-init -)\""
HA_PYTHON_VERSION="3.6.3"
echo "Stopping HA..."
systemctl stop home-assistant.service
echo "Updating HA"
su --shell /bin/bash --command "cd $HA_SRVROOT; $HA_PYENV_ACTIVATION; pyenv activate homeassistant-$HA_PYTHON_VERSION; pip3 install --upgrade homeassistant" $HA_USER
echo "Starting HA..."
systemctl start home-assistant.service
echo "Checking to see if up (Localhost must be in http trusted_networks)"
start=$(date '+%s')
until curl --silent --show-error --connect-timeout 1 -X GET -H "Content-Type: application/json" -k https://127.0.0.1:8123/api/ | grep -q 'API running'; do
date '+[%Y-%m-%d %H:%M:%S] --- Home Assistant is starting, please wait...'
systemctl status home-assistant.service
sleep 10
done
dur=$(($(date '+%s') - start))
echo -e "\e[00;32mHome Assistant is ready! ($dur second delay)\e[00m"
Looks good, thanks. I’ll give it a go next time I need to update
Just tried this and it stalled at the first hurdle, stopping the service (I get the message “stopping HA…” then nothing). Tried the command from the command line and it worked OK.
So I just followed my other instructions and updated successfully.
Using systemctl with HomeAssistant that was installed with the DietPi menu system requires referencing the service as:
home-assistant
So:
systemctl stop home-assistant.service
will not work. This works:
systemctl stop home-assistant
Same story for systemctl start, restart & status.
I modified your code below with fixes, I can’t currently test it since I’m running hass.io. When mosquitto, samba and home assistant installs are fixed for rpi0w, I will go back to dietpi.
Ok, thanks. v160 is due soon and I’ll test it then.
I’m also running an instance of Hass.io but in a docker installed in DietPi on a VM!
I just updated to 160 and installing docker, going to play with Hass.IO on it and see if it is work adding this as a install option.
I did this on a V158 image and it worked great.
Thanks Sparky, the script works like a charm. I’m on an rpi0w/dietpi running mosquitto, samba and home assistant. Since 6.2 all of those work flawless. Before i had problems with mosquitto, but that has since been resolved due to a new binary for arm6l.