In my own experience, this will almost always take more than 60 seconds because even after the update is complete, other components are updated on first run.
Have you thought about just detecting the change and calling an external script to handle the update itself and maybe just read the output or result you want from a log somewhere?
Hi and thanks for all the replies. Very much appreciated.
how would I achieve this?
Some background. I need to maintain several “sub” instances of HA that I don´t have direct access to (at least not to the “backend”). So the the idea was:
Test the HA version on my main HA instance
Post the HA version to upgrade to (not the most recent one) on a webserver
Create a sensor on the the sub HA instances that fetches the HA version to.
create an automation on the sub HA instance that will check on latest version and current version and if latest version > current version run a script to do the upgrade.
Upgrade is applied on next scheduled restart
Of course i could create a cron job on my RPI to do the job but I would like to avoid this when there is a solution “inside” HA.
Hope that explains something.
Thanks and regards
I tried to do exactly this by using nohup in the shell command:
ssh -i /pathtokey/keyfile [email protected] "nohup sh /pathtoscript/update_ha.sh &"
The script below DOES work when run from the command line, but for some reason that has escaped me it doesn’t work when called from within HA (HA stops and then restarts without updating). This is on a Mac running in a VENV so some of the commands would change for a Pi.
Well @bbrendon I’m not sure what part of your advice worked, but my button in HA now successfully shuts it down, updates to the latest version, and restarts (at least it did once). It doesn’t make any sense, but it seemed like adding a custom output file is what made the difference.
The shell command:
For those who are interested in the solution that I implemented in the end. All intentions to upgrade HA within HA failed (or at least I couldn´t find a way to do so). So I modified the script a little bit and run it as cron job (once a month).
!/bin/bash
# stop HA
sudo systemctl stop home-assistant@homeassistant
# Become user 'homeassistant'
sudo su -s /bin/bash homeassistant <<'EOF'
# Activate the virtualenv
source /srv/homeassistant/bin/activate
# Install Home Assistant
pip3.8 install -r /home/homeassistant/.homeassistant/homeassistant_requirement.txt --log /home/homeassistant/.homeassistant/homeassistant_update_log.txt
exit
EOF
# start HA
sudo systemctl start home-assistant@homeassistant