Hi all,
Short question. How do I manually update Home Assistant to the newest version?
Kind Regards,
Wodian
Update Home Assistant
Re: Update Home Assistant
For anyone else who wants to upgrade:
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
pip3 install --upgrade homeassistant
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
pip3 install --upgrade homeassistant
Re: Update Home Assistant
Very useful, thanks. One question, why do you need the 'sudo su -s' if you are logged in as root?wodian wrote:For anyone else who wants to upgrade:
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
pip3 install --upgrade homeassistant
Re: Update Home Assistant
Unfortunately this does not work as 'activate' does not exist in that directory.wodian wrote: source /srv/homeassistant/bin/activate
Any suggestions on how to activate the virtualenv?
Re: Update Home Assistant
So I have managed it but not really sure what all these commands actually do to achieve that!
First login as the 'homeassistant' user
Next navigate to the homeassistant folder
Execute this command - found in the homeassistant-start.sh file used by systemctl. Not too sure what this does!
You should see a prompt like this indicating you are in the virtual environment.
Execute the pip3 command to update homeassistant.
Exit out of the su session
Restart the homeassistant service
I think this homeassistant-start.sh might be specific to DietPi and if so perhaps I could suggest a specific upgrade script?
HTH
First login as the 'homeassistant' user
Code: Select all
sudo su -s /bin/bash homeassistant
Code: Select all
cd /srv/homeassistant/
Code: Select all
export PATH="/home/homeassistant/.pyenv/bin:$PATH"; eval "$(pyenv init -)"; eval "$(pyenv virtualenv-init -)"
Code: Select all
(homeassistant-3.6.3) homeassistant@
Code: Select all
pip3 install --upgrade homeassistant
Code: Select all
Exit
Code: Select all
systemctl restart home-assistant
HTH
Re: Update Home Assistant
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.
Code: Select all
#!/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"
Re: Update Home Assistant
Looks good, thanks. I'll give it a go next time I need to update 

Re: Update Home Assistant
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.sytone wrote:Here you go, there will be a homeassistant-update.sh in that directoy at some point, ....
So I just followed my other instructions and updated successfully.
Re: Update Home Assistant
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.
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.
sytone wrote: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.
Code: Select all
#!/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 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 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 sleep 10 done dur=$(($(date '+%s') - start)) echo -e "\e[00;32mHome Assistant is ready! ($dur second delay)\e[00m"
Sparky
Re: Update Home Assistant
Ok, thanks. v160 is due soon and I'll test it then.Sparky wrote: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.
I'm also running an instance of Hass.io but in a docker installed in DietPi on a VM!