Вернуться назад

Установка HomeAssistant на PC Ubuntu 22.04

Install Home Assistant Core on Ubuntu 22.04

  1. apt update && apt upgrade
    optionally to make sure all packages are installed correctly:

    • dpkg --configure -a
    • apt install -f
    • apt-get --fix-broken install
    • apt-get update --fix-missing
    • apt update && apt upgrade
  2. add-apt-repository ppa:deadsnakes/ppa

  3. apt update

  4. apt install wget build-essential libncursesw5-dev libssl-dev
    libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev

  5. apt install python3.11 python3.11-dev python3.11-venv python3-pip

  6. Change the first line in files “/usr/bin/pip” & “/usr/bin/pip3” to “#!/usr/bin/python3.11”

  7. apt install bluez libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5 libturbojpeg0-dev tzdata ffmpeg liblapack3 liblapack-dev libatlas-base-dev

  8. useradd -rm homeassistant -G dialout

  9. mkdir /srv/homeassistant

  10. chown homeassistant:homeassistant /srv/homeassistant

  11. sudo -u homeassistant -H -s

  12. cd /srv/homeassistant

  13. python3.11 -m venv .

  14. source bin/activate

  15. python3.11 -m pip install wheel

  16. pip3 install homeassistant==2023.8.3

  17. hass

  18. Create file (init.d script) “/etc/init.d/homeassistant”


 

#!/bin/sh
# For Ubuntu:
# description: Home Assistant
# processname: hass

### BEGIN INIT INFO
# Provides:          hass
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Home Assistant service
# Description:       Home Assistant
### END INIT INFO

name="HomeAssistant"
pid_file="/var/run/$name.pid"

case "$1" in
    start)
        su - homeassistant -c '/srv/homeassistant/bin/python3.11 /srv/homeassistant/bin/hass' &>/dev/null &
        echo $(pgrep python3.11) > "$pid_file"
        echo "Running with PID: $(pgrep python3.11)"
    ;;
    stop)
        echo -n "Stopping $name.."
        kill $(pgrep python3.11)
    rm "/var/run/$name.pid"

    ;;
    restart)
        stop
        start
    ;;
    status)
        if $(pgrep hass); then
            echo "Running with PID: $(pgrep python3.11)"
        else
            echo "$name is not running"
            exit 1
        fi

    ;;
    *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac
exit 0

 

  1. chmod 0755 /etc/init.d/homeassistant

  2. update-rc.d homeassistant defaults

  3. reboot

  4. Check if Home Assistant is running:
    service homeassistant status

  5. Done

  6. Go to “http:// « ip address » :8123”

  7. Close the session to end root access

 

Взято тут


igel
Дата: 30 января 2024 г. в 13:12:12

Автор: igel