Installation of Home Assistant on your FreeNAS

Here’s my TL;DR take on it

The Supervisor comes with Home Assistant OS, it not something you can just add. It also requires Docker, which is not available on FreeBSD at this time. Home Assistant OS is designed to be an appliance and provides addons, which are simply other Docker containers, that have been pre-configured to work with Home Assistant, mostly “out-of-the-box”. It’s my understanding, the Supervisor is responsible for managing all the addons (Docker containers) and provides a means to configure them from within the Home Assistant UI.

Addons are similar to plugins on FreeNAS / TrueNAS Core. Basically, the purpose is to provide some additional piece of software. Unlike addons, plugins are typically a standalone service, meaning they not pre-configured to work with other plugins. – So do you need these addons? I don’t know… Do you need plugins? :man_shrugging: In either case, 99% percent of the time, the software can be installed manually and configured to work as needed.

If you’d like to consider running Home Assistant OS on TrueNAS CORE, see this guide. ( On the other hand, TrueNAS SCALE is based on Debian and will include Docker. )

I am newbie. I am trying to install the Home Assistant on my TrueNAS server. I manage to create the jail but not able to run the “python3.8 -m venv . source ./bin/activate”. Please help? I am stuck her and not sure how to create virtualenv or the syntax is wrong??

I am not able to start the service on Shell (not jail shell). failed precmd routine for homeassistant.
image

Why not just install the plugin and save yourself a lot of grief?
The plugin works out of the box, does everything you need, and is hassle free, thanks to the work of @troy.

1 Like

Hi @MrTeaIOT – Sorry your having trouble.

Installing the community plugin is the easiest solution. If you would like to continue with a manual installation…

The answer to your question about the failed pre-cmd routine. It looks like you have not created the homeassistant user group inside the jail. Are you trying to run Home Assistant as a different user or have you created the homeassistant user with a different group? There a solutions for all of these cases but I need to know what your trying to accomplish…

Again, if you just want to get Home Assistant installed, use the plugin… The most important thing with any installation method will be moving your configuration to a separate dataset. This will move your configuration safely outside the jail, allowing you to easily switch from the plugin to a manual jail at any time.

I did follow the instructions and created user and group under same 8123. I am not able to run using the plug-in because I tried it 2 times and my TrueNAS server GUI screen froze up and kill my internet network down. After I reboot the TrueNAS from console, the internet back online. I like to do plugin if it works. Any video instruction to do manually in the jail will be okay too?

A couple things here…

First you are not using the suggested name. That’s OK though, you can use any user name you want, however you will need to configure the Home Assistant service accordingly.

Before we get to that… From your screen shot, it looks as though you’ve created this user on TrueNAS. I realize this may be confusing, let me briefly try to explain.

For the Home Assistant service to run, you need to create the user inside the jail. This is not the same user you created on TrueNAS. Think of the jail as a separate computer and you have the same account on two computers.

  • The user is required to exist inside the jail.
  • The user on TrueNAS is optional. We only create this user for convenience

I’m not sure what would cause that. The plugin only provides the installation script. The delivery system for files and what you click on in the UI, is all handled by TrueNAS itself. I don’t control any part of the delivery system or how the jail is created from the manifest.


To solve the pre-cmd error using the hassio user name you have already created on TrueNAS,

Please try the following to also create the hassio user inside your Home Assistant jail.

iocage console $JAIL

## Create empty home directory and add user
install -d -g 8123 -o 8123 -m 775 -- /home/hassio
pw adduser -u 8123 -n hassio -d /home/hassio -w no -s /usr/local/bin/bash -G dialer

## Configure the Home Assistant service to use a different user or group
sysrc homeassistant_user=hassio
sysrc homeassistant_group=hassio

## Set a path to the configuration directory
sysrc homeassistant_config_dir=/home/hassio/homeassistant

I also have a guide in plugin wiki page for using the rc.d/homeassistant script to install Home Assistant in a manual jail. It is the middle ground between this guide and using the plugin

A post was split to a new topic: Connecting Node Red to Home Assistant

Now that HA has dropped support for python 3.7 is anyone else having issues upgrading? I just tried upgrading to 2021.3.2 but even after updating my Python env to 3.9, I can’t install cryptography. Looking on freshports, it looks like there isn’t a version for FreeBSD that supports python 3.8 or 3.9… Anyone find a work around?

What I did in the TrueNAS community plugin, was to add a pip.conf file (this stops pip from nagging about the available update, which should not be updated) and I started using requirements and constraints during pip install.

Basically download both files inside you HA jail, then you need to edit the first line of requirements.txt so it points to the constraints.txt file you also downloaded.

Then to install Home Assistant, activate a new virtualenv and use the following

pip install wheel
pip install homeassistant -r /path/to/requirements.txt

I can’t install cryptography . Looking on freshports, it looks like there isn’t a version for FreeBSD that supports python 3.8 or 3.9

FYI, I don’t install cryptography from fresh ports in the TN plugin, it gets compiled and installed automatically by Home Assistant, inside the virtualenv

Worth upgrading the instructions to Python v 3.9? I’m a little hesitant of just changing 38 to 39 without knowing its been tested … thanks

Python version

Support for the running Python version 3.8.8 is deprecated and will be removed in Home Assistant 2022.1. Please upgrade Python to 3.9.0 or higher.

You have no choice

Python 3.8 has been deprecated because Python 3.10 has been released. Support will be dropped in Home Assistant 2022.1.

I have the choice of waiting up to two months and making sure the instructions are up-to-date and tested before updating my core system. I also would like to help other users by asking the question publicly. I also have the choice of not being facetious.

The answer wasn’t facetious … but if you want to take it that way, have at it.

If your using the community plugin you can do this

iocage console $JAIL_NAME
# press 0 to exit menu
pkg install -y python39 py39-sqlite3
sysrc homeassistant_python=/usr/local/bin/python3.9
service homeassistant reinstall homeassistant

If you installed HA manually in a jail you can follow this post

I also updated the OP for Python 3.9

1 Like

Thanks Troy, very useful for confirmation. Have run this and it all works great.

1 Like

Me too. All works a treat.

Hi all - trying this on a fresh install of Freebsd 13.2-RELEASE in a jail, and it’s failing on installing PyYAML-6.0. Has anyone run this successfully recently?

Collecting pyyaml==6.0 (from homeassistant)
  Downloading PyYAML-6.0.tar.gz (124 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 125.0/125.0 kB 9.1 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [48 lines of output]
      running egg_info
      writing lib/PyYAML.egg-info/PKG-INFO
      writing dependency_links to lib/PyYAML.egg-info/dependency_links.txt
      writing top-level names to lib/PyYAML.egg-info/top_level.txt
      Traceback (most recent call last):
        File "/srv/homeassistant/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/srv/homeassistant/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/srv/homeassistant/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 288, in <module>
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 314, in run
          self.find_sources()
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 322, in find_sources
          mm.run()
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 551, in run
          self.add_defaults()
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 589, in add_defaults
          sdist.add_defaults(self)
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/command/sdist.py", line 104, in add_defaults
          super().add_defaults()
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/sdist.py", line 251, in add_defaults
          self._add_defaults_ext()
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/sdist.py", line 336, in _add_defaults_ext
          self.filelist.extend(build_ext.get_source_files())
        File "<string>", line 204, in get_source_files
        File "/tmp/pip-build-env-n5r9wj56/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__
          raise AttributeError(attr)
      AttributeError: cython_sources
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

I can’t really help with this error in particular but it looks like you’re using Python 3.9 which has not been supported for some time now. As of Home Assistant 2023.8, you will need Python 3.11.

This was documented in 2023.6 Breaking Changes

Python

All Home Assistant versions, of which the Home Assistant project manages the Python version for you, have been upgraded to Python 3.11. This affects the following installation types:

  • Home Assistant Operating System
  • Home Assistant Container
  • Home Assistant Supervised

This might affect you when using custom integrations, as those must be compatible with Python 3.11.

Furthermore, as of this release, Python 3.10 is deprecated, and support will be removed in Home Assistant 2023.8. This only affects you if you are running Home Assistant Core installation type in your own Python virtual environment. Please update your Python version to Python 3.11.

If you run Home Assistant OS, Home Assistant Container, or Home Assistant Supervised, we have taken care of this for you; you will be using Python 3.11 automatically on upgrade.

Maybe upgrading to a supported version of Python will help. Keep in mind, with this installation method you’ll need to upgrade Python and rebuild your virtual environment every year.

If you really want to run Home Assistant on TrueNAS, you can use this script I created a while back. It is still using python3.10 because 3.11 is having issue with one of the packages (PyTurboJPEG) or something.

1 Like