Home Assistant Core -- FreeNAS / TrueNAS Core Community Plugin

Tags: #<Tag:0x00007f73a65b67f8>

Home Assistant Core is available as a Community Plugin on FreeNAS 11.3 / TrueNAS Core 12.x

FreeNAS and TrueNAS Core are free and open-source network-attached storage (NAS) software based on FreeBSD and the OpenZFS file system. They are licensed under the terms of the BSD License, run on virtually any x86_64 system and provides a broad set of features for many users. Community Plugins like Home Assistant Core allow the functionality of a system to be expanded.

Plugin Update: 07/20/2020 – New defaults beginning with ver_0.4.0

:information_source: The default virtualenv location, user and config directories have changed. The new defaults will apply to clean installations only. An existing plugin will retain the previous settings. There is also an updated service script that aims to simplify standard tasks for all users while also allowing advanced users to easily reconfigure the service after the initial installation.

  • This plugin will create an iocage jail for Home Assistant Core
  • The included rc service will install and run Home Assistant Core using a python virtualenv
  • Also includes options to create and install separate python virtualenvs for the following
  • A separate directory for each ( service ) virtualenv will be created under /usr/local/share
  • The plugin’s provided services run as non-root user homeassistant with a uid of 8123
  • Separate configuration directories for each service are located in /home/homeassistant

This Community Plugin provides these basic configuration files to help get started


Quick Start for Home Assistant Core on FreeNAS 11.3 and TrueNAS Core 12

Installation - Community Plugin

Install Home Assistant Core from the Community Plugins page

At a minimum you only need to enter a name for this jail to enable the save button. I manage all of my device IP address from my router, so I leave DHCP checked and click save to begin the install.

Installation - Standard jail

You can use the service script to install Home Assistant Core in a standard jail

Use the standard jail if you need to compile packages from the ports tree or if you need more advanced control over the FreeBSD system itself. With regards to Home Assistant Core and the other services running in virtualenvs, there should be no advantage to using a standard jail.

Click Here


Initial Startup

Initial startup may take an additional 5-10 minutes before the Home Assistant UI reachable. It takes my FreeNAS about 10 min from the time I press install until I am able to login for the first time. This amount of time will vary depending on your setup and hardware. After the initial startup is complete, you will able to reach Home Assistant Core from the Plugins page by pressing MANAGE.

The first time you connect to Home Assistant, you will need to complete the onboarding process. At the end of onboarding you will be given an opportunity to add any auto discovered integrations. If you plan to add the optional services for the Configurator and AppDaemon, or install HACS (Home Assistant Community Store), just skip this step for now. At this point, we are just interested in getting everything installed. Any of these extras are of course optional.

Installing optional services

Click Here

You can install the optional services and HACS using the jails console or shell, its the same thing. Don’t worry, there are no commands to copy paste at this point. You can connect with ssh if you want but I tried to make this all work easily from the browser. Back in FreeNAS, your Home Assistant Core plugin will show up under both, Plugins and Jails, it is still a jail after all. Enter the console from the Jails page by pressing SHELL.

The FreeNAS plugin includes a simple console menu to help with some common functions inside the jail. From the main console menu, number 2 will be the Configurator. Use option 8 to install.

After the install has finished, use the given link to open the Configurator in a new browser tab. We’re gonna use it in the next steps to add the long lived access token(s) to the configuration file(s). Leave the Configurator open and head back over to the Home Assistant tab in your browser.

We’re gonna create two tokens at this point. One for the Configurator and one AppDaemon. Hopefully, this is where the included configuration starts to make things easy. You can create your your long lived access token from your profile page. Start by creating an access token for the Configurator and copy it to your clipboard.

Using the Configurator, add the token you just created to configurator/config.json. Paste your access token to the second line where indicated. Be sure to save the file!

Next, if you plan to install AppDaemon, you should set that up now as well. The example configuration included with AppDaemon is set up to share the Home Assistant secrets file to store its access token and location information. Go back to your Home Assistant profile page and create another long live access token for AppDaemon. Use the Configurator to add the token to homeassistant/secrets.yaml. While you there, you should also configure your correct location information as well. Make sure you save your changes!

We are done with the Configurator for now. You can close it’s browser tab and head back over to FreeNAS. From the Configurator service menu, select 3 to restart the configurator.

After the Configurator restarts, press 1 to return to the main menu, then press 3 to enter the AppDaemon service menu. Use option 8 to install


Saving the best for last! There’s one more step before you restart Home Assistant. Installing HACS. There’s no service menu since HACS is a custom integration. This is just a little shortcut to download the latest HACS release and extract it to homeassistant/custom_components/hacs.

At the main console menu of the jail, type install hacs and press enter.


Now head into the Home Assistant Core service menu and select 3 to restart Home Assistant. Notice here that option 8 is check_config. The service will also check_config automatically before restarting Home Assistant. The first time check_config used, you may see an additional package or two get installed. This is normal and only happens the first time.

After you restart Home Assistant you should have links for File Editor and AppDaemon added to the side panel. These are simply iframes that have been enabled in homeassistant/packages/freenas_plugin.yaml

Finally, head to the integrations and finish adding HACS.


At this point, it’s all yours!

Continue to add any auto discovered integrations and begin your Home Assistant journey!

Have Fun! :slightly_smiling_face:


Attention HomeKit Users

:warning: FreeNAS 11.3 - HomeKit requires openssl 1.1.0 or later as the HomeKit Accessory Protocol (HAP) uses the ChaCha20 stream cipher and the Poly1305 authenticator. Please beware that the 11.3-RELEASE base only contains openssl 1.0.2. A Home Assistant jail ( including this plugin ) can be manually updated to use openssl 1.1.1 in order to allow HomeKit to work again.

:information_source: TrueNAS Core 12.x - This does not apply to FreeBSD 12 / TrueNAS Core. The 12.1-RELEASE base already contains openssl-1.1.1. HomeKit should work without intervention.


Using a USB Z-Wave or Zigbee Controller

:warning: To directly access USB devices like the Aeotec Gen-5 Z-Stick, Nortek HUSBZB-1 or similar USB controllers inside an iocage jail, you will need to use a custom devfs_ruleset. Before a jail can use the custom devfs_ruleset, it must first be created on the FreeNAS host.

:information_source: The TrueNAS Core 12.x Community Plugin now creates the custom ruleset from the plugin manifest. No additional steps are required to access Z-Wave or Zigbee USB controllers!


Using the OpenZWave (beta) Integration

The OpenZWave (beta) integration for Home Assistant requires that ozwdaemon is running somewhere on your network.


Additional information might be found in the plugin project wiki


My FreeNAS Community plugins
Click Here

Most of these are available on the community plugin page in FreeNAS

  • ESPHome
  • Gogs
  • Home Assistant Core
  • Node-RED
  • Mosquitto (MQTT Broker)
  • TasmoAdmin

The current artifact files for this plugin can be found HERE
All of my FreeNAS plugin manifests can be found HERE


This plugin and example configuration is only a quick start to get things up and running

If you want to run Hass.io on your FreeNAS check out this post by @Petrica

Thanks for stopping by!

4 Likes

Troy, your work is amazing for the Freenas-User-Community. I’ve been following your installation guides since version 11 (your initial post from 2017) and you’ve been a great (!) help! Keep on this fabulous work, please! Thank you!

1 Like

Thanks for posting this. I had no trouble installing this on FreeNAS 11.2-U7. I have these jails installed per your 11.2 manual. I decided to follow this guide and fstab the hass folder to install data from 11.2. I was on Home Assistant 0.95 or 0.96. Everything upgraded and I had to fix some of my configuration due to Home Assistant changes.

Does anyone have an issue with the GUI in 0.105.4 refreshing every 30 seconds? This causes problems when I’m trying to use the Configurator or and GUI in HA. This bug causes you to lose any unsaved changes because it’s like you press refresh in your browser.

Looks like other system installs have similar issues: https://github.com/home-assistant/home-assistant-polymer/issues/4894

The strikeout issue was due to my http settings and HAProxy. I was able to fix this.

1 Like

Hi, I’m struggiling to get the appdaemon installed, after installation it cannot start. Where can I find any logs for what’s wrong? During installation I am receiving a message: ERROR: requests 2.22.0 has requirement idna<2.9,>=2.5, but you'll have idna 2.9which is incompatible. But even installing previous version of idna component (2.8) does not resolve this problem. Still getting the same error message during appdaemon installation and still the appdaemon service won’t start. Any hints?

I’ve installed it with pip3 install appdaemon in the /srv/appdaemon virtual environment and works ok, no problem with this dependency occured anymore. There was another one, i had to downgrade the astral component as per advise here
All good now but seems that the plugin requires some fixing

@adorobis

Thanks for reporting this.

I did know about the need to downgrade astral ( that already happens in the plugin script )

:thinking: This is weird… I mean, the plugin creates a new virtualenv for appdaemon. I just did a clean install of the plugin and installed appdaemon. Everything worked as expected and appdaemon started as soon as the install was finished. I’ll need to do some further investigating on this one…

1 Like

Hey thank you for years of great guidance! i have a homeassistant jail created with the old guide, how would i go about uprgrading/ migrating? what is the best way?

@lop3r Hello

It really depends on what you want to do and if you’re using a separate dataset for /home/hass

Having that separate dataset changes everything – I’ll assume as most people, you do not…

If you want to upgrade your existing jail, it is possible to do that and then copy some updated files into place. ( nothing by itself is difficult but this would likely be the most “advanced” )

If you want to migrate from your existing jail to the plugin, basically you just need to install the plugin and then copy your existing configuration into place. There are numerous ways to go about this depending on how comfortable you are on the command line.

The very first thing to consider is the name you want to use for the new plugin-jail. If you want to use the exact name of your existing jail, then you will need to destroy it before you can use the name again.

IMO, the easiest approach is to use a different name for the plugin. This way you can be sure the plugin is setup and working before you destroy the existing HA jail. Taking this approach I would basically do these steps.

  1. Install new plugin-jail, let Home Assistant finish installing and do initial onboarding
  2. Stop plugin-jail – Stop existing jail
  3. Use the FreeNAS console to rename (or remove) /home/hass in the new plugin-jail
  4. Use rsync from FreeNAS console to copy /home/hass from the existing jail to the new plugin
  5. Start plugin – Install Configurator – Install Appdaemon

If you want to use the exact name that’s already in use then you would basically

  1. Backup the existing /home/hass ( use a zip or tar ) and copy the backup to somewhere safe
  2. Export the the existing HA jail ( this makes a backup you can restore later if necessary )
  3. Destroy the existing HA jail
  4. Install new plugin-jail, let Home Assistant finish installing and do initial onboarding
  5. Stop Home Assistant service – restore config
  6. Start Home Assistant – Install Configurator – Install Appdaemon

Let me know, I can help with more detailed steps depending on what you want to do or if you are using a separate dataset for /home/hass

1 Like

Omg man youre amazing! Ill try when i get home!

Thank you for this! One question though (apologies in adv. if this is stupid) but when creating the USB controller to use the stick you mention
I used the FreeNAS console to create the script in my user’s home directory.

Where would I be installing this, in root or the homeassistant jail or where else?

Hi @slickbeerd

I used the FreeNAS console to create the script in my user’s home directory

On my FreeNAS, I have created myself a normal user and I also have created dataset that I use as a “home directory”. I store my zwave-ruleset in my “home directory” dataset

Really this can stored almost anywhere on your FreeNAS. I have found only these consideration.

  • It should be stored inside a dataset of your main zpool.
  • It should not be stored anywhere inside the iocage dataset. ( This means you can not use the Home Assistant directory )

So turns out i had created a separate dataset for it as per youre instructions. i had just forgotten about it caus it was so long ago. Made the upgrade a breeze.
Thanx man!

1 Like

Hi Troy, been using your guides for the last couple of years now, thanks for all your hard work and time spent making this simple!

If I were to use the new plugin method do I still have the ability to manually upgrade home assistant and the other tools as I would in a custom jail?

Absolutely! There is even a new menu when you login to the jail console to make it even easier. Basically everything from the manual jails still applies to the plugin. They both use the same script to install

Additionally the plugin itself can be updated using the FreeNAS webui. To be clear, when you update the plugin, it will only update the system files I have provided ( like the console menu or the rc.d/startup scripts ). The plugin update will not update Home Assistant or the other services that can be individually updated from the jails console menu.

This is great! The only thing not working is installing HACS.


Archive:  /var/tmp/hacs.zip
unzip: open('homeassistant/custom_components/hacs/const.py'): No such file or directory

Press ENTER to continue...

Worked here. Used winSCP to updload the files.
Followed the instructions here.

To update to latest version of HA do i have to wait for the plugin manager to update it? or is there anyway to update it manualy?

Yes – I added a console menu to make it easier to use from the FreeNAS webui
When you log into the HA plugin console – there should see main menu

Use number 1 for Home Assistant

Use number 4 to upgrade HA

OR – You can use the command line

service homeassistant upgrade

No – The plugin manager will never update HA or any other virtualenv

  • I will always leave this in your control

The plugin manager will only update the FreeBSD system packages. It will also update the system files I provided with the plugin. For example, when I add ( or need to fix ) something in the console menu – or when there is an update to the service script

1 Like

Uau :smiley: damn you’re the MAN! :smiley: thanks

1 Like

Troy - really appreciate the massive effort you’ve put into making a Freenas plugin for HA. Can’t thank you enough.

Does anyone have any experience of installing Zigbee2mqtt on Freenass? I’m trying to hook up some Xiaomi sensors. The official instructions over at www.zigbee2mqtt.io give guidance on running on a bare-metal Linux and virtualized environments, but as we know Freenas is basically Freebsd and I am out of my depth with that, the syntax and commands are not the same and although I can handle using the command line I tend to struggle a bit at the best of times.

Is it necessary to install Zigbee2mqtt in a separate jail from the main HA jail?
Is it possible to install Hass.io on freenas? Zigbee2mqtt is available as an official addon for that.

Any help much appreciated

@shanghaiultra

  • What kind of zigbee hub do you have? Is it a USB device?

With a few extra steps – USB devices like the HUSBZB-1 can be used by HA directly.

  • Is there a reason you do not connect directly to HA?
  • Is there a reason you want ( or need ) to use Zigbee2mqtt?

I’m asking so I can understand if you have a different use case that would require Zigbee2mqtt.


If you want to install Zigbee2mqtt I would strongly recommend a separate jail


In any case – To connect a USB zigbee or zwave hub, to any jail on FreeNAS



This is something separate – I can only say where to look.

Yes – but there is no way to access your usb zigbee device

1 Like