My (almost) complete quick start to installing Home Assistant on FreeNAS 11.2 (Including AppDaemon/HA-Dashboard, Hass-Configurator, Mosquitto and TasmoAdmin)


#21

Thanks! The new version worked perfectly!


#22

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:


#23

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

#24

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.

[email protected]:~ # 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


#25

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.

[email protected]~ $ 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.


#26

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

#27

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…


#28

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) :

[email protected]:~ # su - hass

[[email protected] ~]$ wget https://raw.githubusercontent.com/Matty9191/ssl-cert-check/master/ssl-cert-check

I gave permission to the script :

[[email protected] ~]$ chmod 755 /home/hass/ssl-cert-check

I execute the script :

[[email protected] ~]$ ./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


#29

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.


#30

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


#31

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?


#32

@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?


#33

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.


#34

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.


#35

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?


#36

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


#37

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

Here is a snip if I check status:

image


#38

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


#39

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.


#40

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
}