Restart of HA

also:

sudo service home-assistant@homeassistant restart

@Landrash it is possible to create a script for to do this automaticly?

It is. It’s already submitted to the hassbian scripts repo and I’m going to rework it to work with the next version of hassbian.

1 Like

I created a quick and dirty control script for anyone having issues figuring out or remembering what the service names are for hass.

$ export HA=/usr/bin/hassctl;touch $HA;chmod +x $HA
$ nano $HA

#!/bin/bash
set -e
case "$1" in
        start)
            sudo systemctl start [email protected]
            exit 0
        ;;
        stop)
            sudo systemctl stop [email protected]
            exit 0
        ;;
        status)
            sudo systemctl status [email protected]
            exit 0
        ;;
        restart)
            sudo systemctl restart [email protected]
            exit 0
        ;;
        upgrade)
            sudo systemctl stop [email protected]
            sudo su - homeassistant -c "source /srv/homeassistant/bin/activate"
            sudo su - homeassistant -c "pip3 install --upgrade homeassistant"
            sudo systemctl start [email protected]
            exit 0
        ;;
        chkconfig)
            sudo su - homeassistant -c "source /srv/homeassistant/bin/activate"
            sudo su - homeassistant -c "hass --script check_config"
            exit 0
        ;;
        *)
            echo;echo $"Usage: $0 {start|stop|restart|status|upgrade|chkconfig}.";echo
            echo $"start: Start HASS. | stop: Stop HASS. | restart: Restart HASS."
            echo $"status: Check the status of HASS. | upgrade: Upgrade HASS."
            echo $"chkconfig: Check the validity of the HASS configuration.";echo
            exit 1
esac

Then just type “hassctl” from anywhere for a list of commands.

This part is not working. sudo hass command not found

try this:

sudo su - homeassistant -c “source /srv/homeassistant/bin/activate && hass --script check_config”

I made a script that autorestart homeassistant when certain files are changed