Error could not find the directory for home assistant

Home Assistant release with the issue: 0.65.6 Last working Home Assistant release (if known): Operating environment (Hass.io/Docker/Windows/etc.): Running Hass.io in Docker on Ubuntu 16.04.4 Compon...

however…

I’ve checked permissions for the above mentioned directory and they’re fine.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

I’ve tried with » and also ‘ around the above path.

systemmonitor: Error on device update!
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 188, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 327, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/systemmonitor.py", line 119, in update
    self._state = psutil.disk_usage(self.argument).percent
  File "/usr/lib/python3.6/site-packages/psutil/__init__.py", line 1967, in disk_usage
    return _psplatform.disk_usage(path)
  File "/usr/lib/python3.6/site-packages/psutil/_psposix.py", line 127, in disk_usage
    st = os.statvfs(path)
FileNotFoundError: [Errno 2] No such file or directory: '/hdd/winbackup'

Spoiler

2022-01-15 22:39:38 ERROR (SyncWorker_3) [homeassistant.util.package] Unable to install package PyNaCl==1.4.0: ERROR: Command errored out with exit status 1:
     command: /opt/bin/python3 /opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /opt/tmp/tmpp_7worrw
         cwd: /opt/tmp/pip-install-7h74s0vn/pynacl_a83329435b6d497e830d928c0652b7c9
    Complete output (36 lines):
    Traceback (most recent call last):
      File «/opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py», line 349, in <module>
        main()
      File «/opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py», line 331, in main
        json_out[‘return_val’] = hook(**hook_input[‘kwargs’])
      File «/opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py», line 151, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File «/opt/tmp/pip-build-env-0sk9yr6u/overlay/lib/python3.10/site-packages/setuptools/build_meta.py», line 174, in prepare_metadata_for_build_wheel
        self.run_setup()
      File «/opt/tmp/pip-build-env-0sk9yr6u/overlay/lib/python3.10/site-packages/setuptools/build_meta.py», line 158, in run_setup
        exec(compile(code, __file__, ‘exec’), locals())
      File «setup.py», line 216, in <module>
        setup(
      File «/opt/tmp/pip-build-env-0sk9yr6u/overlay/lib/python3.10/site-packages/setuptools/__init__.py», line 155, in setup
        return distutils.core.setup(**attrs)
      File «/opt/tmp/pip-build-env-0sk9yr6u/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py», line 109, in setup
        _setup_distribution = dist = klass(attrs)
      File «/opt/tmp/pip-build-env-0sk9yr6u/overlay/lib/python3.10/site-packages/setuptools/dist.py», line 459, in __init__
        _Distribution.__init__(
      File «/opt/tmp/pip-build-env-0sk9yr6u/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py», line 293, in __init__
        self.finalize_options()
      File «/opt/tmp/pip-build-env-0sk9yr6u/overlay/lib/python3.10/site-packages/setuptools/dist.py», line 837, in finalize_options
        ep(self)
      File «/opt/tmp/pip-build-env-0sk9yr6u/overlay/lib/python3.10/site-packages/setuptools/dist.py», line 858, in _finalize_setup_keywords
        ep.load()(self, ep.name, value)
      File «/opt/tmp/pip-build-env-0sk9yr6u/overlay/lib/python3.10/site-packages/cffi/setuptools_ext.py», line 219, in cffi_modules
        add_cffi_module(dist, cffi_module)
      File «/opt/tmp/pip-build-env-0sk9yr6u/overlay/lib/python3.10/site-packages/cffi/setuptools_ext.py», line 49, in add_cffi_module
        execfile(build_file_name, mod_vars)
      File «/opt/tmp/pip-build-env-0sk9yr6u/overlay/lib/python3.10/site-packages/cffi/setuptools_ext.py», line 25, in execfile
        exec(code, glob, glob)
      File «src/bindings/build.py», line 36, in <module>
        ffi = FFI()
      File «/opt/tmp/pip-build-env-0sk9yr6u/overlay/lib/python3.10/site-packages/cffi/api.py», line 48, in __init__
        import _cffi_backend as backend
    ModuleNotFoundError: No module named ‘_cffi_backend’
    —————————————-
WARNING: Discarding https://files.pythonhosted.org/packages/cf/5a/25aeb636baeceab15c8e57e66b8aa930c011ec1c035f284170cacb05025e/PyNaCl-1.4.0.tar.gz#sha256=54e9a2c849c742006516ad56a88f5c74bf2ce92c9f67435187c3c5953b346505 (from https://pypi.org/simple/pynacl/) (requires-python:>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*). Command errored out with exit status 1: /opt/bin/python3 /opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /opt/tmp/tmpp_7worrw Check the logs for full command output.
ERROR: Cannot install PyNaCl==1.4.0 because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
WARNING: You are using pip version 21.2.3; however, version 21.3.1 is available.
You should consider upgrading via the ‘/opt/bin/python3 -m pip install —upgrade pip’ command.
2022-01-15 22:40:31 ERROR (SyncWorker_1) [homeassistant.util.package] Unable to install package PyNaCl==1.4.0: ERROR: Command errored out with exit status 1:
     command: /opt/bin/python3 /opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /opt/tmp/tmpei11f4s8
         cwd: /opt/tmp/pip-install-aln5rjbj/pynacl_a82a26df1bce40acb38907933c7d495d
    Complete output (36 lines):
    Traceback (most recent call last):
      File «/opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py», line 349, in <module>
        main()
      File «/opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py», line 331, in main
        json_out[‘return_val’] = hook(**hook_input[‘kwargs’])
      File «/opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py», line 151, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File «/opt/tmp/pip-build-env-7xbys8jc/overlay/lib/python3.10/site-packages/setuptools/build_meta.py», line 174, in prepare_metadata_for_build_wheel
        self.run_setup()
      File «/opt/tmp/pip-build-env-7xbys8jc/overlay/lib/python3.10/site-packages/setuptools/build_meta.py», line 158, in run_setup
        exec(compile(code, __file__, ‘exec’), locals())
      File «setup.py», line 216, in <module>
        setup(
      File «/opt/tmp/pip-build-env-7xbys8jc/overlay/lib/python3.10/site-packages/setuptools/__init__.py», line 155, in setup
        return distutils.core.setup(**attrs)
      File «/opt/tmp/pip-build-env-7xbys8jc/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py», line 109, in setup
        _setup_distribution = dist = klass(attrs)
      File «/opt/tmp/pip-build-env-7xbys8jc/overlay/lib/python3.10/site-packages/setuptools/dist.py», line 459, in __init__
        _Distribution.__init__(
      File «/opt/tmp/pip-build-env-7xbys8jc/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py», line 293, in __init__
        self.finalize_options()
      File «/opt/tmp/pip-build-env-7xbys8jc/overlay/lib/python3.10/site-packages/setuptools/dist.py», line 837, in finalize_options
        ep(self)
      File «/opt/tmp/pip-build-env-7xbys8jc/overlay/lib/python3.10/site-packages/setuptools/dist.py», line 858, in _finalize_setup_keywords
        ep.load()(self, ep.name, value)
      File «/opt/tmp/pip-build-env-7xbys8jc/overlay/lib/python3.10/site-packages/cffi/setuptools_ext.py», line 219, in cffi_modules
        add_cffi_module(dist, cffi_module)
      File «/opt/tmp/pip-build-env-7xbys8jc/overlay/lib/python3.10/site-packages/cffi/setuptools_ext.py», line 49, in add_cffi_module
        execfile(build_file_name, mod_vars)
      File «/opt/tmp/pip-build-env-7xbys8jc/overlay/lib/python3.10/site-packages/cffi/setuptools_ext.py», line 25, in execfile
        exec(code, glob, glob)
      File «src/bindings/build.py», line 36, in <module>
        ffi = FFI()
      File «/opt/tmp/pip-build-env-7xbys8jc/overlay/lib/python3.10/site-packages/cffi/api.py», line 48, in __init__
        import _cffi_backend as backend
    ModuleNotFoundError: No module named ‘_cffi_backend’
    —————————————-
WARNING: Discarding https://files.pythonhosted.org/packages/cf/5a/25aeb636baeceab15c8e57e66b8aa930c011ec1c035f284170cacb05025e/PyNaCl-1.4.0.tar.gz#sha256=54e9a2c849c742006516ad56a88f5c74bf2ce92c9f67435187c3c5953b346505 (from https://pypi.org/simple/pynacl/) (requires-python:>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*). Command errored out with exit status 1: /opt/bin/python3 /opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /opt/tmp/tmpei11f4s8 Check the logs for full command output.
ERROR: Cannot install PyNaCl==1.4.0 because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
WARNING: You are using pip version 21.2.3; however, version 21.3.1 is available.
You should consider upgrading via the ‘/opt/bin/python3 -m pip install —upgrade pip’ command.
2022-01-15 22:41:11 ERROR (SyncWorker_0) [homeassistant.util.package] Unable to install package PyNaCl==1.4.0: ERROR: Command errored out with exit status 1:
     command: /opt/bin/python3 /opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /opt/tmp/tmpfasc06rz
         cwd: /opt/tmp/pip-install-qp0et389/pynacl_038c88f4f39940e1bbec7f3afe8a21d3
    Complete output (36 lines):
    Traceback (most recent call last):
      File «/opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py», line 349, in <module>
        main()
      File «/opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py», line 331, in main
        json_out[‘return_val’] = hook(**hook_input[‘kwargs’])
      File «/opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py», line 151, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File «/opt/tmp/pip-build-env-cmbj3u37/overlay/lib/python3.10/site-packages/setuptools/build_meta.py», line 174, in prepare_metadata_for_build_wheel
        self.run_setup()
      File «/opt/tmp/pip-build-env-cmbj3u37/overlay/lib/python3.10/site-packages/setuptools/build_meta.py», line 158, in run_setup
        exec(compile(code, __file__, ‘exec’), locals())
      File «setup.py», line 216, in <module>
        setup(
      File «/opt/tmp/pip-build-env-cmbj3u37/overlay/lib/python3.10/site-packages/setuptools/__init__.py», line 155, in setup
        return distutils.core.setup(**attrs)
      File «/opt/tmp/pip-build-env-cmbj3u37/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py», line 109, in setup
        _setup_distribution = dist = klass(attrs)
      File «/opt/tmp/pip-build-env-cmbj3u37/overlay/lib/python3.10/site-packages/setuptools/dist.py», line 459, in __init__
        _Distribution.__init__(
      File «/opt/tmp/pip-build-env-cmbj3u37/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py», line 293, in __init__
        self.finalize_options()
      File «/opt/tmp/pip-build-env-cmbj3u37/overlay/lib/python3.10/site-packages/setuptools/dist.py», line 837, in finalize_options
        ep(self)
      File «/opt/tmp/pip-build-env-cmbj3u37/overlay/lib/python3.10/site-packages/setuptools/dist.py», line 858, in _finalize_setup_keywords
        ep.load()(self, ep.name, value)
      File «/opt/tmp/pip-build-env-cmbj3u37/overlay/lib/python3.10/site-packages/cffi/setuptools_ext.py», line 219, in cffi_modules
        add_cffi_module(dist, cffi_module)
      File «/opt/tmp/pip-build-env-cmbj3u37/overlay/lib/python3.10/site-packages/cffi/setuptools_ext.py», line 49, in add_cffi_module
        execfile(build_file_name, mod_vars)
      File «/opt/tmp/pip-build-env-cmbj3u37/overlay/lib/python3.10/site-packages/cffi/setuptools_ext.py», line 25, in execfile
        exec(code, glob, glob)
      File «src/bindings/build.py», line 36, in <module>
        ffi = FFI()
      File «/opt/tmp/pip-build-env-cmbj3u37/overlay/lib/python3.10/site-packages/cffi/api.py», line 48, in __init__
        import _cffi_backend as backend
    ModuleNotFoundError: No module named ‘_cffi_backend’
    —————————————-
WARNING: Discarding https://files.pythonhosted.org/packages/cf/5a/25aeb636baeceab15c8e57e66b8aa930c011ec1c035f284170cacb05025e/PyNaCl-1.4.0.tar.gz#sha256=54e9a2c849c742006516ad56a88f5c74bf2ce92c9f67435187c3c5953b346505 (from https://pypi.org/simple/pynacl/) (requires-python:>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*). Command errored out with exit status 1: /opt/bin/python3 /opt/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /opt/tmp/tmpfasc06rz Check the logs for full command output.
ERROR: Cannot install PyNaCl==1.4.0 because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
WARNING: You are using pip version 21.2.3; however, version 21.3.1 is available.
You should consider upgrading via the ‘/opt/bin/python3 -m pip install —upgrade pip’ command.
2022-01-15 22:41:11 ERROR (MainThread) [homeassistant.setup] Setup failed for mobile_app: Requirements for mobile_app not found: [‘PyNaCl==1.4.0’].

i have changed to Armbian_22.08_Jammy_Kernel_5.15.y_296Mb_Sep.24,2022 but the problem is same. 

To update pip, run:          

pip install --upgrade pip 
Successfully installed pip-22.2.2

To install Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Quote

(homeassistant) hass@orangepizero:/root$ curl https://sh.rustup.rs -sSf | sh                 -sSf | sh
info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /home/hass/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  /home/hass/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /home/hass/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /home/hass/.profile
  /home/hass/.bashrc
  /home/hass/.zshenv

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: armv7-unknown-linux-gnueabihf
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation

>1

info: profile set to 'default'
info: setting default host triple to armv7-unknown-linux-gnueabihf
warning: Updating existing toolchain, profile choice will be ignored
info: syncing channel updates for 'stable-armv7-unknown-linux-gnueabihf'
info: default toolchain set to 'stable-armv7-unknown-linux-gnueabihf'

  stable-armv7-unknown-linux-gnueabihf unchanged - rustc 1.64.0 (a55dd71d5 2022-09-19)


Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. This has not been done automatically.

To configure your current shell, run:
source "$HOME/.cargo/env"
(homeassistant) hass@orangepizero:/root$ rustc –version
bash: rustc: command not found
(homeassistant) hass@orangepizero:/root$ cargo –version
bash: cargo: command not found


          Python: 3.10.6
          platform: Linux-5.15.69-sunxi-armv7l-with-glibc2.35
          pip: n/a
          setuptools: 65.4.1
          setuptools_rust: 1.5.2
          rustc: n/a
          =============================DEBUG ASSISTANCE=============================

      error: can’t find Rust compiler

      If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.

      To update pip, run:

          pip install —upgrade pip

      and then retry package installation.

      If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.

      This package requires Rust >=1.48.0.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cryptography
Failed to build cryptography
ERROR: Could not build wheels for cryptography, which is required to install pyproject.toml-based projects


Edited October 10, 2022 by Richard_Balogh

Welcome to the always up to date Home Assistant (Supervised) installation guide

This guide will go over how to install Home Assistant (Supervised) on Debian based Linux Distributions. Remember only the latest version of Debian is supported, no derivatives

Important Please Read

Before continuing make sure you read and understand the following documents:

0014. Installation method: Home Assistant Supervised

0012. Define supported installation method

Pre-installation Steps

Step 1: Becoming Root

Before we start, you must make sure you are logged in as root, Debian may not come with sudo installed, so in order to become root type:

su -

Then enter the root password you configured during installation, Be sure not to forget the dash as it allows the system to run the login scripts for the root user.

However, if you are on a system with sudo installed you can use the command:

sudo su -

Before preceding, confirm you are root by typing:

whoami

You must be root in order to continue

Step 2: Updating your System

Before starting it is a good idea to update your system, to do so enter the three following commands:

apt-get update
apt-get upgrade -y
apt-get dist-upgrade -y

Step 3: Install Dependency’s

Install all the required dependency’s with the following command:

apt-get install 
apparmor 
jq 
wget 
curl 
udisks2 
libglib2.0-bin 
network-manager 
dbus 
lsb-release 
systemd-journal-remote -y

Step 1: Install The Docker Engine

1. Run the Docker CE installation script

Simply run the Docker CE for Linux installation script:

curl -fsSL get.docker.com | sh

2. Test your Docker Install (Optional)

To test your docker install run the hello-world script:

docker run hello-world

If Docker is working correctly the following message will be displayed:

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Installing Home Assistant is easy simply follow these steps

1. Install the OS Agent

The OS Agent allows the Home Assistant Supervisor to communicate with D-Bus and will soon be required

To Install it simply use the follow commands:

wget https://github.com/home-assistant/os-agent/releases/latest/download/os-agent_1.4.0_linux_x86_64.deb
dpkg -i os-agent_1.4.0_linux_x86_64.deb

Of course being sure you replace `os-agent_1.4.0_linux_x86_64.deb` with the latest version which matches your CPU architecture. Available at the GitHub Releases page

2. Run the Home Assistant Install Script

Now that you are root simply run these commands to download and install Home Assistant Supervised:

wget https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
dpkg -i homeassistant-supervised.deb

After it has finished running you should be able to access Home Assistant from:

http://your.ip.address.here:8123

Step 3: Post Install Steps

1. Install The SSH Add On

The SSH add on in Home Assistant allows you to access the Home Assistant command line interface which can be vary helpful for diagnosing issues with you Home Assistant install

  • To install SSH head to the Supervisor tab
  • Then click Add on Store
  • Now find Terminal & SSH and Click install

Before starting you must set a password and change the port as port 22 is already used by the Host’s SSH server

So before you start the Addon head to the configuration tab and change the Port setting under Network and add a password. Be sure to save both these settings then you can start the add on

You should now be able to now SSH into your hassio instance using the command

ssh [email protected] -p 29

2. Install SAMBA

SAMBA will allow you to access your configuration files from any PC on your local network

To install it simply

Find SAMBA share in the add on store

Edit the Configuration to to include your own username and password

Then save the config and start the add on

Now you should be able to access your files from any file manager on the network by typing

\your.ip.address.here

into your file browser

Your Home Assistant config files will be found in the config folder

Congratulations you have now setup Home Assistant!!!

Thanks for reading, if you have any questions feel free to contact me on Twitter or the DrZzs Discord Server

Notes:

Ubuntu Server is no longer officially supported by Home Assistant

Home Assistant (Supervised) now only officially supports the latest version of Debian, That means that if anything breaks you cannot complain about it. However they are not preventing you from still installing it If you are installing Home Assistant Supervised on anything other than Debian Bullseye you will get this notice in your supervisor (as shown in the image below):

To learn more please read the Home Architecture Decision Record Documents:

0014. Installation method: Home Assistant Supervised

0012. Define supported installation method

Also be sure to update me in the comments below or reach out to me on Twitter or Discord if you run into any issues you believe to be caused by this change


There are several reasons why it makes sense to run Home Assistant in a virtual environment. A virtualenv encapsulates all aspect of a Python environment within a single directory tree. That means the Python packages you install for Home Assistant won’t interact with the rest of your system and vice-versa. It means a random upgrade for some other program on your computer won’t break Home Assistant, and it means you don’t need to install Python packages as root.

Virtualenvs are pretty easy to setup. This example will walk through one method of setting one up (there are certainly others). We’ll be using Debian in this example (as many Home Assistant users are running Raspbian on a Raspberry Pi), but all of the Python related steps should be the same on just about any platform.

Step 0: Install some dependencies

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install python3-pip python3-dev
$ sudo pip3 install --upgrade virtualenv

Step 1: Create a Home Assistant user & group

This step is optional, but it’s a good idea to give services like Home Assistant their own user. It gives you more granular control over permissions, and reduces the exposure to the rest of your system in the event there is a security related bug in Home Assistant. This is a reasonably Linux oriented step, and will look different on other operating systems (or even other Linux distributions).

$ sudo adduser --system homeassistant
$ sudo addgroup homeassistant

Home Assistant stores its configuration in $HOME/.homeassistant by default, so in this case, it would be in /home/homeassistant/.homeassistant

If you plan to use a Z-Wave controller, you will need to add this user to the dialout group

$ sudo usermod -G dialout -a homeassistant

Step 2: Create a directory for Home Assistant

This can be anywhere you want. As example we put it in /srv. You also need to change the ownership of the directory to the user you created above (if you created one).

$ sudo mkdir /srv/homeassistant
$ sudo chown homeassistant:homeassistant /srv/homeassistant

Step 3: Become the new user

This is obviously only necessary if you created a homeassistant user, but if you did, be sure to switch to that user whenever you install things in your virtualenv, otherwise you’ll end up with mucked up permissions.

$ sudo su -s /bin/bash homeassistant

The su command means ‘switch’ user. We use the ‘-s’ flag because the homeassistant user is a system user and doesn’t have a default shell by default (to prevent attackers from being able to log in as that user).

Step 4: Set up the virtualenv

All this step does is stick a Python environment in the directory we’re using. That’s it. It’s just a directory. There’s nothing special about it, and it is entirely self-contained.

It will include a bin directory, which will contain all the executables used in the virtualenv (including Home Assistant itself). It also includes a script called activate which we will use to activate the virtualenv.

$ virtualenv -p python3 /srv/homeassistant

Step 5: Activate the virtualenv

$ source /srv/homeassistant/bin/activate

After that, your prompt should include (homeassistant).

Step 6: Install Home Assistant

Once your virtualenv has been activated, you don’t need to sudo any of your pip commands. pip will be installing things in the virtualenv, which the homeassistant user has permission to modify.

(homeassistant)$ pip3 install --upgrade homeassistant

And that’s it… you now have Home Assistant installed, and you can be sure that every bit of it is contained in /srv/homeassistant.

Finally… Run Home Assistant

There are two ways to launch Home Assistant. If you are in the virtualenv, you can just run hass and it will work as normal. If the virtualenv is not activated, you just use the hass executable in the bin directory mentioned earlier. There is one caveat… Because Home Assistant stores its configuration in the user’s home directory, we need to be the user homeassistant user or specify the configuration with -c.

$ sudo -u homeassistant -H /srv/homeassistant/bin/hass

The -H flag is important. It sets the $HOME environment variable to /home/homeassistant so hass can find its configuration.

Upgrading Home Assistant

Upgrading Home Assistant is simple, just repeat steps 3, 5 and 6.

Starting Home Assistant on boot

The autostart instructions will work just fine, just be sure to replace /usr/bin/hass with /srv/homeassistant/bin/hass and specify the homeassistant user where appropriate.

Понравилась статья? Поделить с друзьями:
  • Error could not find or load main class как исправить
  • Error could not find or load main class worker org gradle process internal worker gradleworkermain
  • Error could not find or load main class version
  • Error could not find or load main class test class
  • Error could not find or load main class sun applet appletviewer