Script that stops HASS, updates HASS and starts HASS again?

Thank you!

This is my version (changed source and added apt-get clean) with little changes that seems working on my Pi3

#!/bin/bash -x

    ##########################################
    ## This script upgrades the OS on my pi,##
    ## upgrades HA then reboots the device  ##
    ##########################################

    sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get clean && sudo apt-get autoremove
    source /srv/homeassistant/homeassistant_venv/bin/activate
    pip3 install --upgrade homeassistant
    sudo reboot

Sorry for the necro-bump, but I wanted to add my Hass updater script. Has the benefit of not requiring any external scripts, and it seems to work fine (just used it to update from 0.57.3 to 0.59.1).

shell_command:
    update_hass: >
        venv/bin/python3 -m pip install --upgrade --find-links=venv/.cache
            homeassistant uvloop appdaemon pip wheel
    make_update_wheel: >
        venv/bin/python3 -m pip wheel --wheel-dir=venv/.cache
            homeassistant uvloop appdaemon pip wheel

script:
    update_hass:
        alias: Update Hass
        sequence:
        - service: shell_command.make_update_wheel
        - service: shell_command.update_hass
        - delay:
            minutes: 5
        - service: homeassistant.restart

Finally, I use this to push me a notification when a new version is available (and go ahead and download the update wheels to make the update process much faster):

- id: update_notifications
  alias: Home Assistant Update Notifications
  trigger:
      - platform: state
        entity_id: updater.updater
  action:
      - service: notify.pushover
        data:.
          title: 'New Home Assistant Release'
          message: "Home Assistant  {{ states.updater.updater.state }}  is now available."
      - service: shell_command.make_update_wheel
4 Likes

Hi
for me updater.updater not show any info from 3 days about new versdion 0.65.6 ? Before i has 0.65.5
Now i update manualy…
Why updater.updater not show info ?

I’m trying to use your solution but I am faced with error

FileNotFoundError: [Errno 2] No such file or directory: 'venv/bin/python3': 'venv/bin/python3'

Any Ideas what I’m doing wrong?

Scripts must be modified to match the individual environment. That means making sure any statement with a path matches your installed path.

When I run this command sudo /bin/bash /home/homeassistant/.homeassistant/misc/scripts/update_ha.sh
directly on the Hassbian console (pi3) it returns this error, via putty.

I’m just testing the stop command in the .sh file and returns the error below.

pi@hassbian:~ $ sudo /bin/bash /home/homeassistant/.homeassistant/misc/scripts/update_ha.sh
/home/homeassistant/.homeassistant/misc/scripts/update_ha.sh: line 2: $'\r': command not found
Failed to stop [email protected]\x0d.service: Unit [email protected]\x0d.service not loaded.
/home/homeassistant/.homeassistant/misc/scripts/update_ha.sh: line 5: $'\r': command not found
Failed to restart home-assistant@hass\x0d.service: Unit home-assistant@hass\x0d.service not found.
1 Like

What’s uvloop, and do we need to enable appdaemon before using your script?

Optional.

appdaemon is also optional.