My (outdated) Quick Start for Home Assistant Core on FreeNAS 11.2

Thanks! The new version worked perfectly!

1 Like

Hey!

Im getting this efter fresh install (scripted install):

Unable to prepare setup for platform media_player.songpal: Could not install all requirements.
17:27 setup.py (ERROR)
Not initializing media_player.songpal because could not install requirement python-songpal==0.0.9.1
17:27 requirements.py (ERROR)
Unable to install package python-songpal==0.0.9.1: The directory '/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Command "/srv/homeassistant/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-7tz9wkm5/lxml/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-afiqdbvr/install-record.txt --single-version-externally-managed --compile --install-headers /srv/homeassistant/include/site/python3.6/lxml" failed with error code 1 in /tmp/pip-install-7tz9wkm5/lxml/
17:27 util/package.py (ERROR)
Setup failed for logbook: Could not set up all dependencies.
17:26 setup.py (ERROR)
Unable to set up dependencies of logbook. Setup failed for dependencies: recorder
17:26 setup.py (ERROR)
Setup failed for history: Could not set up all dependencies.
17:26 setup.py (ERROR)
Unable to set up dependencies of history. Setup failed for dependencies: recorder
17:26 setup.py (ERROR)
Setup failed for recorder: Component failed to initialize.
17:26 setup.py (ERROR)
Error during connection setup: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
17:26 components/recorder/__init__.py (ERROR)
Error during connection setup: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
17:26 components/recorder/__init__.py (ERROR)
Error during connection setup: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
17:26 components/recorder/__init__.py (ERROR)
Error during connection setup: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
17:26 components/recorder/__init__.py (ERROR)
Error during connection setup: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
17:26 components/recorder/__init__.py (ERROR)
Error during connection setup: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
17:26 components/recorder/__init__.py (ERROR)
Setup of recorder is taking over 10 seconds.
17:26 util/async_.py (WARNING)
Error during connection setup: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
17:26 components/recorder/__init__.py (ERROR)
Error during connection setup: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
17:26 components/recorder/__init__.py (ERROR)
Error during connection setup: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
17:26 components/recorder/__init__.py (ERROR)
Error during connection setup: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
17:26 components/recorder/__init__.py (ERROR)

Not sure what to check, but every user have no problem creating any files or read any files inside configfolder
No files are touched, im getting these errors right after first launch :frowning:

I have tested creating a fresh scripted install and can not reproduce your issue.

These first errors lead me to think that file and/or directory permissions are not properly set.

 Unable to prepare setup for platform media_player.songpal: Could not install all requirements. 17:27 setup.py (ERROR)
 Not initializing media_player.songpal because could not install requirement python-songpal==0.0.9.1 17:27 requirements.py (ERROR)

Few questions to help narrow a starting point for trouble shooting

  • Are you trying to mount a separate dataset for the config file?
  • Did you create the dataset following the getting started section of this guide or is it pre-existing dataset?
  • Are you using the example config files offered by the install script?
  • Finally, can you paste the output of the following command
    sudo iocage exec homeassistant ls -la /home/hass

Weirdā€¦

What I did was:

First create a new dataset called ā€œHASSā€, for mounting/smb-share /home/hass basically
Ive doublechecked and ive even set permissions now to 777 for debugging.
ACL Type is set to Unix, it was Windows when i created the dataset (default was unix before 11.2 im pretty sure), this is the only thing i can think about might be the problemā€¦ but on the other hand, ive suā€™d into hass user inside the jail and it has no problem touching files or reading/editing configs.

Yes, ive used the example files just to try get things going, my old jail is handling my live setup.

root@freenas:~ # iocage exec homeassistant ls -la /home/hass
total 30
drwxrwxrwx+ 5 root  wheel    6 Jan 22 17:56 .
drwxr-xr-x  3 root  wheel    3 Jan 22 16:59 ..
-rwxrwxr-x+ 1 hass  wheel  187 Jan 22 19:23 .bash_history
drwxrwxrwx+ 3 root  wheel    3 Jan 22 16:20 .cache
drwxrwxrwx+ 2 root  wheel    3 Jan 22 17:00 configurator
drwxrwxrwx+ 6 root  wheel   23 Jan 22 19:24 homeassistant

Just a test, here is how hass user creates files:
-rwxrwxr-x+ 1 hass wheel 0 Jan 22 17:55 test123

Ok ā€“ I see a few things here.
Iā€™m pretty sure this is a permission problem.

The install script will create a user/group hass inside the jail to run Home-Assistant, Hass-Configurator, etcā€¦
All files and folders inside /home/hass should have a user/group set to hass. After following the entire getting started section, I would expect the output of iocage exec homeassistant ls -la /home/hass to be the following.

troy@freenas~ $ sudo iocage exec homeassistant ls -la /home/hass

drwxrwxr-x   7 hass  hass      9 Dec 24 15:59 .
drwxr-xr-x   3 root  wheel     3 Dec 10 20:27 ..
-rw-------   1 hass  hass   1547 Dec 24 17:58 .bash_history
drwx------   3 hass  hass      3 Dec 10 20:27 .cache
drwxrwxr-x   5 hass  hass      5 Dec 10 20:27 appdaemon
drwxrwxr-x   2 hass  hass      3 Dec 10 20:27 configurator
drwxrwxr-x  11 hass  hass     36 Jan 22 15:32 homeassistant

Here is one thing to try.

sudo iocage exec homeassistant chown -R hass /home/hass
sudo iocage exec homeassistant service homeassistant restart

If that does not work it would be quicker for me to suggest deleting the entire jail and hass dataset and starting over from scratch. The goal here is to ensure the permissions for the hass dataset are set correctly from the beginning. I can help you configure and test permissions are set correctly before installing Home-Assistant.

Ideally if the /home/hass dataset is empty and has the correct permissions set, Home-Assistant can install correctly with proper permissions.

Permissions between Window and a UNIX type system (like Linux or FreeNAS) are not a direct one-to-one match. Beyond the simple R(ead)-W(rite)-X(ecute) there are thing like aclā€™s used only by Windows. These are translated in Linux or on FreeNAS to xattr or extended attributes. There are also things like umask, sticky bits, and file or directory create masks to help complicate things on UNIX side of things. I only have a basic understanding of permissions and advanced features can quickly complicate things even more. I can write an entire post just explaining the little bit I do know.

My setup and the getting started only deals simply with R-W-X permissions which are set for the user/group.
It relies on the dataset being setup as shown in the getting started section in order for permission to work. Because the dataset type is set to UNIX permissions should not be manged from Windows.

I see two things wrong here. First is the + (plus sign) Second the wheel group

  • The + plus means there extended attributes. This is because the data was set to Windows when it was created. Thereā€™s ways to fix this but the easiest is to re-create the dataset with ACL type set to UNIX

  • The wheel group. Did you skip setting the group name to hass on the /home/hass when you created your dataset. Iā€™m relying on the group permission for everything to work.


The owner or group must be set to hass in order for homeassistant or the configurator to interact with them

  • Files need rw- or rwx permissions to be set
  • Directories require r-x or rwx permissions to be set

I thought all the time root had to be the owner, but ofcs you never run anything under rootā€¦

And i thought changing acl to unix changed everything, but i guess its not that easy

Ill try later today.

Edit: Ofcs it works nowā€¦

Hello,

Troy, thank you very much for your guide Iā€™m up and running. Thatā€™s quite an extensive guide, it helps a lot!

Trying to understand how this home assistant docker interact with command line and was trying a command_line feature.

Here is what I wanted to achieve

  • platform: command_line

name: SSL cert expiry

unit_of_measurement: days

scan_interval: 10800

command: ā€œ./ssl-cert-check -b -c /home/hass/homeassistant/ssl/mycert.crt | awk ā€˜{ print $NF }ā€™ā€

From jail shell

I installed ssl-cert-check script (ref. https://github.com/Matty9191/ssl-cert-check) :

root@homeassistant:~ # su - hass

[hass@homeassistant ~]$ wget https://raw.githubusercontent.com/Matty9191/ssl-cert-check/master/ssl-cert-check

I gave permission to the script :

[hass@homeassistant ~]$ chmod 755 /home/hass/ssl-cert-check

I execute the script :

[hass@homeassistant ~]$ ./ssl-cert-check -b -c /home/hass/homeassistant/ssl/mycert.crt | awk ā€˜{ print $NF }ā€™

It prints correctly :

77

But within home assistant I donā€™t see the value and it seems it execute script without error :

2019-01-25 23:53:34 INFO (SyncWorker_37) [homeassistant.components.sensor.command_line] Running command: ./ssl-cert-check -b -c /home/hass/homeassistant/ssl/mycert.crt | awk '{ print $NF }

I also install ssl-cert-check script on root user, I got same result can execute within jail shell but home assistant canā€™t pull value.

I know I can use built in cert_expiry platform but doing it this way mainly to understand.

Iā€™m pretty new to docker/linux/freebsd in general so I might miss something.

Anyone has a clue?

Thanks,

Cool77

Sorry Iā€™m not really sure. The good news is the script works from the jail console so you maybe (Iā€™m guessing)
you need a command line or command line binary sensor that HA can use to see result? I have never tried to return a value to HA from a command line script.

To further clarify ā€œdocker/linux/freebsd in generalā€

@DrKK wrote in the FreeNAS forum

Disclaimer: Iā€™m going to oversimplify some complicated things, and Iā€™m going to use small lies in order to make this more understandable. For the people that really understand this stuff, try very hard to resist your compulsion to correct the purposeful imprecision and white lies. This is intended for people that have never heard of jails before

The concept of a ā€œFreeBSD jailā€ has been around since about 2000. It was one of the first types of quasivitualizations done at the operating system level. It is not correct, however, to think of it as a virtual machine. It is not too incorrect to think of it as more hard core than a ā€œchrootā€ (assuming you know what is), and less hard core than a proper virtual machine.

On FreeBSD itself (not FreeNAS, now), the concept of a ā€œjailā€ is primarily useful because it offers a mechanism by which the system can be compartmentalized with satisfactory granularity; i.e., it keeps rootā€™s business strictly outside of anything that can be accessed from within a ā€œjailā€. Accordingly, it offers that degree of ā€œsecurityā€ where an untrusted user can still have something that looks and acts mostly like a complete operating system, but is actually separated from the root operating system. So the usefulness, really, to Joe Blow FreeBSD user, is that it offers this isolation of various tasks in strongly walled gardens.

On FreeNAS, the main advantage of jails (these are the same FreeBSD jails, of course) is quite different than this. FreeNAS is an appliance , meaning that its operating system is not intended to be modified, tweaked, expanded, jacked, bummed, experimented with, or anything else. If you want to install some bit of software into FreeNAS, you really ā€œcanā€™tā€, because thatā€™s just not how ā€œappliancesā€ work. But what you CAN do is create a ā€œjailā€, and you can install software INTO THAT JAIL.

The nice thing about jails is you can experiment with them with no threat to your system. When you are done with your jail? Just delete it. By the nature of the jail, you canā€™t screw up your FreeNAS appliance (unless you try really, really, really hard), so it safe to experiment.

We have two types of jail on FreeNAS: The plugin jails, ā€¦ are primarily conveniences to users who donā€™t want to get their hands dirty, and, ā€œregularā€ jails, that come more or less in a virginal state, ready for you to ā€œdo somethingā€ with themā€¦

FreeBSD and Linux are not the same however for an average user (myself included) they seem to be very similar. This means 95% of this guide uses the same commands you would use if running Home Assistant on Linux using a Virtualenv.

For your original problem, maybe try to create a separate topic in the Configuration section. Since your script works from the console, there should not be anything different because your using FreeNAS. I think you just need to configure something in HA to properly interact with the results.

Thanks for your reply. Iā€™ll try to understand whatā€™s under the hood of HA command_line. Cheers

Hi Troy

I followed your guide again about a month ago, but this time I did the script install. Worked perfectly. I even got ffmpeg working for my cameras.

Today I thought to give configurator a try instead of using ssh into hass to make changes. But every time I opened the configurator ipanel hass would notify me of a bad login. So I did a bad thing and entered the bad login IP into trusted network from inside the configurator. Now when I open it I get ā€œPolicy not fulfilledā€

Where is the trusted networks file in hass to edit it or how can I fix it?

@Dayve67
I use long live access tokens, not trusted networks so Iā€™m not 100% sure.

Does the Configurator work if you go to itā€™s IP:Port address directly?

I got it back working again. But a different problem is that if I restart my FreeNAS Configurator does not start. I have to SSH in and start it that way.

How did you install the Configurator? Seems from your comment that you may have installed this after the fact?

Iā€™m guessing you either need the start-script or need to enable it. This start-up script is FreeNAS specific and something that I provided. Itā€™s not included with the Configurator.

I used the iocage standard-jail ā€“ Scripted Install. I do notice the appdeamon never starts either. Not that Iā€™m using it right now tho.

How can I go about getting it to start now?

So on the scripted install - How did you answer these questions?

Install Home-Assistant?  [Y/n]:
Install Hass-Configurator?  [Y/n]:
App-Daemon & HA-Dashboard?  [Y/n]:
Use the pre-configured examples?  [Y/n]:

Sorry for so many questions. I need to get handle on whatā€™s going on before Iā€™m able to provide any useful tips. Thereā€™s a few things that need to line up for everything to work

I said yes to everything but the pre-configured examples.

Here is a snip if I check status:

image

Perfect! Hopefully we can start getting somewhere now.

So appdaemon and the configurator both require config files before they will start. (which is the purpose of my example files, so they can work ā€œout of the boxā€) Also the start-up scripts I provide are looking for these config files in a specific place.

Most likely you just need to fix a path-to-config. Basically you have 2 options.

  • Move your files and use the step to match the startup script
  • Change some variables used by the startup script to match your choosing

All the following is done inside the jail:

Iā€™m not sure your level FreeNAS but if you wonder and want to look:

  • The startup scripts are located in /usr/local/etc/rc.d. These are really the only thing I made that are unique to my guides or scripts. They include some RC_VARS to make it easy to change certain things like the expected location of a config file.

Configurator:

  • Default Path to config: /home/hass/configurator/configurator.conf

Most likely you have a different path to this file. Try setting this to match your path-to-config.
For example you can change the location to: /home/hass/configurator.conf

sysrc configurator_config="/home/hass/configurator.conf"
service configurator restart

See if that works and check if the configurator will auto-start after restarting the jail.

If that did not work, please tell me the path your configurator.conf and the command that you are using to start the configurator from ssh. Also do have a file /var/log/configurator_daemon.log. If so please provide that as well

Okay it seems I have something else going on. If I do a restart of FreeNAS none of my jails are auto starting. That includes Plex, Transmission and a few others.

The only thing different I have done is installed a second NIC on the weekend and assigned the home automation jails to the new NIC. Not sure if that is causing it. I would not think so.

I have checked in FreeNAS that the auto start jail is checked on all jails.

Wonder what changed.

Good thing is that following your instructions Configurator is now starting when I start Home assistant just getting the bad login again when I open it.

This is getting beyond my knowledge and probably best asked in the FreeNAS forums.

Is this error just when you try to use the configurator iframe in HA? Can you try removing all permissions to get it working. As I mentioned Iā€™m not very sure about ā€œtrusted networksā€ but I do not think there is anything ā€œFreeNAS specificā€ to setting this up.

For the interest of trouble shooting. Below is the ā€œexample configā€ file I provide with the script. Can you temporally try replacing your config with the one below.

{
    "LISTENIP": "0.0.0.0",
    "LISTENPORT": 3218,
    "BASEPATH": "/home/hass/homeassistant",
    "SSL_CERTIFICATE": null,
    "SSL_KEY": null,
    "HASS_API": "http://127.0.0.1:8123/api/",
    "HASS_API_PASSWORD": "use-long-live-token-here",
    "CREDENTIALS": null,
    "ALLOWED_NETWORKS": [],
    "BANNED_IPS": [],
    "BANLIMIT": 0,
    "IGNORE_PATTERN": [".*", "*.xml", "*.db", "*.sqlite", "tts", "deps"],
    "DIRSFIRST": true,
    "SESAME": null,
    "VERIFY_HOSTNAME": null
}