Home Assistant Core -- TrueNAS CORE Community Plugin

@mhm69 @shandogs

2020-06-21 21:06:44 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Z-Wave (import from configuration.yaml) for zwave
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/config_entries.py", line 217, in async_setup
    hass, self
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/zwave/__init__.py", line 341, in async_setup_entry
    from openzwave.option import ZWaveOption
  File "/srv/homeassistant/lib/python3.7/site-packages/openzwave/option.py", line 29, in <module>
    import libopenzwave
ImportError: /srv/homeassistant/lib/python3.7/site-packages/libopenzwave.so: Undefined symbol "libiconv"

Thereā€™s certainly something going on here ā€“ I think I have almost narrowed down the cause now. Iā€™ll be sending you both a PM soon

Is there anyway to edit the IP address of the File editor in the side bar? I changed the IP address for the home assistant jail and now the file editor side bar link doesnā€™t work.

Absolutely. In fact File Editor and AppDaemon that you see in the side panel are simply iframes that have been enabled in homeassistant/packages/freenas_plugin.yaml

You can still reach the File Editor directly at http://new.ip.add.ress:3218 to make changes.

Troy, Thanks for your continued work on this plugin for FreeNAS/TrueNAS. I looked at your temp page on your wiki and I think you have a lot of good ideas in the works. I am looking forward to the final result! Here are a few things that I thought of that would help me and possibly a few others:

  • Maintain a Manual Install Guide along side of the plugin. This will allow those of us that need to adjust some things to our specific situation. For example: I donā€™t use DHCP for server jails and I have multiple VLANs in my jail. This guide could also provide a good starting point for someone that needed to install on raw FreeBSD or in a jail not managed by iocage.
  • Provide instructions for use with the plugin and the Manual Guide to keeping the Home Assistant configuration and data in datasets outside of the jail.
  • Consider creating a FreeBSD port with your scripts. This would mean that the Plugin only had to create the correct jail environment and install the package created from your port and it would make Home Assistant available to a lot of FreeBSD users that are not using FreeNAS.

Thanks again for all your work on this,
Kelly

1 Like

amazing!! thankyou

@jkhii Thank you for your feedback :confetti_ball:

Iā€™m already working on this :wink:

3 years ago, my first guide was a manual guide and shortly there after I made the first version of this plugin but having the usual concerns about ā€œpluginsā€ on FreeNAS, I quickly backed away from that in favor of a ā€œscripted installā€ for a standard-jail for FreeNAS 11.2. When FN 11.3 was released with the community plugins page, and I realized I could still have full control of the artifact repo, I figured I would re-release this as a ā€œpluginā€

This was already in my 11.2 guide but I never updated anything as far as a manual guide for the 11.3 release. ( the previous guide is really only outed in terminology and screenshots more than anything else ) We can talk about my excuses for that delay another timeā€¦ Anyways for TrueNAS Core, my goal is finally bring everything back together once and for all. Hopefully the new service script mentioned on the temp wiki page is going to be the start. ā€“

This already, is not the typical ā€œpluginā€ you may expect or be used to. I think in general, itā€™s easy for FreeNAS userā€™s to have bad taste for ā€œpluginsā€ dating back to the old warden days. With iocage, at least in the case of this plugin, things are different. For instance, this plugin always installs the current version HA Core available at the time and you can mange maintain a version or update as you see fit. Also there is no need to wait for any kind of ā€œplugin updateā€ in order to update HA.

I think this is very much a hybrid-plugin - meaning you still have almost full control ( currently itā€™s just very fragmented if you want to change some things ) Typically a plugin would manage everything for you. Iā€™m only using the ā€œpluginā€ as a way to provide an install button from the FN UI and provide easy updates for a few files, like the console menu script and the rc service scripts. There are a few considerations I really do need to document but basically you can about 98% percent treat this ā€œpluginā€ like a ā€œmanual installā€ ā€“ This is also why, in this plugin you will sometimes see ā€œmanual intervention requiredā€ ā€“ It is not something extra because your using this ā€œpluginā€ ā€“ It is a step that would still be required in a manual installation anyways.

Which brings me to the updated service script on the temp wiki page and finally bringing everything back together. My hope is that by the time TrueNAS Core is released, Iā€™ll have mostly refactored this plugin ( in this case I mean the virtualenv services ) to be configurable using sysrc. The idea is to use the RC Service Guide ( temporary wiki page ) as the configuration guide for the plugin ā€“ Then in the RC Service Guide Iā€™ll break down each service command into the manual steps that are being preformed.

I really like this idea. I think the new service script will really go along way to make this happen. In fact, if you installed the requirements and created the user first, I see no reason to prevent the new service script from working on a vanilla FreeBSD system, outside of iocage right now! I think ( after I get things cleaned up ) the only thing missing is creating a port.

The HomeKit /openssl saga continues in the 11.3-RELEASEā€¦

I think Iā€™m gonna have to revert the ā€œout-of-the-boxā€ update to openssl This solution ( in itā€™s current state ) breaks the ā€œout-of-the-boxā€ working Z-Wave ( 1.4 ) integration.

2020-06-21 21:06:44 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Z-Wave (import from configuration.yaml) for zwave
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/config_entries.py", line 217, in async_setup
    hass, self
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/zwave/__init__.py", line 341, in async_setup_entry
    from openzwave.option import ZWaveOption
  File "/srv/homeassistant/lib/python3.7/site-packages/openzwave/option.py", line 29, in <module>
    import libopenzwave
ImportError: /srv/homeassistant/lib/python3.7/site-packages/libopenzwave.so: Undefined symbol "libiconv"

There is another workaround to get Z-Wave working again but this workaround will need to applied aafter every update to homeassistant-pyozw . So now there are 2 workarounds and the seconds needs constant attention for all Z-Wave usersā€¦ I think This is steamy pile :poop:

iocage console $JAIL
# Press `0` to exit the menu

su - hass

export CFLAGS=
export LDFLAGS=
export CPATH=
export LIBRARY_PATH=

source /srv/homeassistant/bin/activate
pip install --force-reinstall --no-cache homeassistant-pyozw==0.1.10
deactivate && exit

service homeassistant restart

After consideration, I think it best that I remove the updated openssl from this plugin. The bottom line is thatā€™s itā€™s unacceptable to by default, apply a workaround or update something in this plugin, that will break something else, that would otherwise work if you followed a manual installation.

Iā€™m going to submit another pull request to have openssl removed from the plugin manifestā€¦ If you have already installed openssl, it will not be removed unless done so manually. If your HomeKit is working today it should not be affected.

One way or another, someone needs to apply a work around, the best I can do here trying to minimize the effect. Moving forward on the 11.3-RELEASE community plugin, if you need to use the HomeKit integration, you will still be able to follow the steps needed to update openssl in a manual installation.

  • If you update openssl for HomeKit and you are not using the Z-Wave integration, this will be a one time manual intervention.
  • If you update openssl for HomeKit and you are using the Z-Wave integration, you will need to manually apply both workarounds and will continue to require manual intervention every time homeassistant-pyozw is updated

The 12.x -RELEASES includes openssl 1.1.1. The HomeKit integration already works ā€œout-of -the-boxā€ in TrueNAS Core 12, without any additional steps or workarounds

Thanks, this is awesome. Still donā€™t have everything working yet, but this has gotten me much further along so far than any other post!

Hi @mikeyricci ā€“ Sorry your having troublesā€¦ I really jumped the gun pushing that update for openssl. Hopefully I have somewhat contained this for now.


Update on the issues with HomeKit/openssl and Z-Wave

I just pushed an update to remove openssl from any clean installs. So from this point, Z-Wave should working again. HomeKit users that require openssl-1.1.1 can still follow this manual guide. These are the same steps that would be required to use HomeKit if you manually installed Home Assistant Core in a standard-jail.

Iā€™m still waiting for this pull-request to be merged, which will remove openssl from the manifest.

Any effects of all this should be limited to anyone who installed or updated the plugin between 05-26-2020 and 06-28-2020 and further limited ( I hope ) to only Z-Wave and HomeKit users ā€“ Iā€™m really sorry for the inconvenience this is causing everyone :disappointed: Iā€™m learning as we goā€¦ hopefully you all donā€™t give-up on using this plugin.

Fortunately, the jails in TrueNAS Core 12 are using the 12.1-RELEASE which ships with openssl-1.1.1 in the base. In other words, both HomeKit and Z-Wave are working on TrueNAS Core 12 without any extra steps or workarounds.


TrueNAS Core 12 Beta 1 is around the corner

The Home Assistant Core plugin will not work in the TrueNAS Core nightly until this pull-request is merged. ā€“ Iā€™ve already pushed an updated manifest to my own plugin repo, which can be used to test this plugin in the mean time.

I suggest this for testing only
</s> <s># Install</s> <s>iocage fetch -P homeassistant -g https://github.com/tprelog/freenas-plugin-index.git --branch 12.1-RELEASE --name JAIL_NAME</s> <s># update</s> <s>iocage update -P homeassistant</s> <s>

Updates already in TrueNAS Core 12 Community Plugin

  • Custom devfs_ruleset is now included for Z-Wave and Zigbee devices !
  • Home Assistant is using Python 3.8
  • HomeKit works again ( no extra steps required )
  • Slightly improved ( auto-start ) rc service script ( more options )
  • The venv directory has been moved to /usr/local/share/homeassistant

ā€“ Lots of general clean-up still to come

Changing some defaults

At this time, the TrueNAS 12 Community plugin is still using the hass username from FreeNAS 11.3

Iā€™ve become aware that numerous people do not care to use the hass username, as this translates to hate in German. For this reason Iā€™m changing the default user to the typical homeassistant which will of course effect the configuration directory, now getting located at /home/homeassistant/homeassistant. ( removing the leading . that would normally make this directory hidden )

Also the venv directory. Iā€™m thinking will be moved to /usr/local/share/homeassistant to better make standard FreeBSD convention

I am planning to update the Manual Installation Guide as well and I would like this plugin to have defaults matching those used in that guide. Obviously any defaults can still be adjusted on a per user basis to meet specific needs but I would still like to includes defaults that a majority of people are happy with.

Maybe something like /home/homeassistant/ha-config or similar. Makes it more clear what is in the directory and avoids duplicating the word homeassistant.

@jkhii Thank you again for your suggestion ā€“ Are you joined on the Home Assistant Discord channel? If you donā€™t mind, I would like to invite you to a ( very ) small PM group.

Upgraded to the TrueNAS 12 beta and tried a fresh install the Homeassistant plugin as a test - unfortunately having a number of package failures:

Error: Homeassistant had a failure Exception: RuntimeError Message: pkg error: - ffmpeg :,gcc :,gmake :,libxml2 :,libxslt :,pkgconf :,python38 :,py38-sqlite3 :,sudo :,wget :,zip : Refusing to fetch artifact and run post_install.sh! Partial plugin destroyed

Not sure if anyone else is having issues?

Steve

Hi @SteveR

Iā€™m having the same problem this morning. Looks like ffmpeg is no longer available in http://pkg.FreeBSD.org/${ABI}/latest

Not sure why this would have been removed but it was there and installed correctly last week

root@ha12-beta1:~ # pkg show ffmpeg
ffmpeg-4.3,1
Name           : ffmpeg
Version        : 4.3,1
Installed on   : Tue Jun 30 10:41:57 2020 EDT
Origin         : multimedia/ffmpeg
Architecture   : FreeBSD:12:amd64
Prefix         : /usr/local
Categories     : net audio multimedia
Licenses       : GPLv3+, LGPL3+
Maintainer     : [email protected]
WWW            : http://ffmpeg.org/
Comment        : Realtime audio/video encoder/converter and streaming server

EDIT

I changed, in the plugin manifest "packagesite": to "http://pkg.FreeBSD.org/${ABI}/quarterly", which still contains ffmpeg and the plugin installs again.

EDIT 2 ā€“ I tested some other plugins on TrueNAS Core 12 and it seems that all the plugins using "http://pkg.FreeBSD.org/${ABI}/latest" and listing ffmpeg in the manifest are now failing to install.

Iā€™ve submitted a pull request to have this plugin switched to "http://pkg.FreeBSD.org/${ABI}/quarterly"


In the mean time, you can edit the manifest file manually.

It is located in the iocage dataset, for example on my server /mnt/nvme/iocage.

ee /mnt/nvme/iocage/.plugins/github_com_ix-plugin-hub_iocage-plugin-index_git/homeassistant.json

On line 39 you will find

  "packagesite": "http://pkg.FreeBSD.org/${ABI}/latest",

Change line 39 to

  "packagesite": "http://pkg.FreeBSD.org/${ABI}/quarterly",

Press esc then enter twice to save and exit.

After that the plugin should install ā€“ Note this is temporary until the pull request is merged.

@troy,
I looked this morning and the ffmpeg package is back in the latest repo. It looks like it was missing for a few days due to a fetch error on the build server. The quarterly repo should be more stable.

You can look at the current status of a port/package at FreshPorts. For example the ffmpeg page:
https://www.freshports.org/multimedia/ffmpeg/

If you scroll down on that page there is a grey table that lists what packages are available.

Kelly

Thatā€™s a relief to see itā€™s only missing by accident :sweat_smile: ā€“ I did manage to find the fresh ports link pretty quickly, however I could not figure out how the search for the reason ā€“

It looks like it was missing for a few days due to a fetch error on the build server."

Thanks for clearing that up!


Using HomeKit/openssl and Z-wave: Round 3 - FIGHT :fist_right: :boom: :fist_left:

There is a side-effect to the current approach for using openssl-1.1.1 in the 11.3-RELEASE when ffmpeg is also installed. ā€“ If you have the following error trying to setup the Z-Wave integration

2020-06-21 21:06:44 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Z-Wave (import from configuration.yaml) for zwave
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/config_entries.py", line 217, in async_setup
    hass, self
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/zwave/__init__.py", line 341, in async_setup_entry
    from openzwave.option import ZWaveOption
  File "/srv/homeassistant/lib/python3.7/site-packages/openzwave/option.py", line 29, in <module>
    import libopenzwave
ImportError: /srv/homeassistant/lib/python3.7/site-packages/libopenzwave.so: Undefined symbol "libiconv"

For now, there is a manual fix that can be preformed.

iocage console $JAIL
# Press `0` to exit the menu

su - hass
export LDFLAGS=
source /srv/homeassistant/bin/activate
pip install --force-reinstall --no-cache homeassistant-pyozw==0.1.10
deactivate && exit

service homeassistant restart

I am currently testing an easier solution that will ( if successful ) be available in a near future update.

Hi.

Thank you making it so easy to install Home Assistant.

I have it working almost perfectly.

Thereā€™s two things I canā€™t get to work, and I think it may have to do with the jail configuration or maybe vnet

I have some TPlink Kasaa device and SenseMe (installed via HACS) unit, I canā€™t get them to find any devices.
Even playing with the command line binary (like aiosenseme --discover), no devices are found. I see errors about UDP broadcast when run

When I run the same set-up on a Linux box, it works well.

Both SenseMe and TPLink use UDP broadcast to find devices.

Is there anything special to do with the network configuration ? I used the defaults, using DHCP with ipv4, I have ipv6 on this network but it didnā€™t pick any config there.

Thank you.
JY

Hi!

I have installed configurator and appdeamon on TrueNAS Core 12. I have got error message, when test it on shell.
Testing virtualenvā€¦
NO DIRECTORY: /srv/configurator
and
NO DIRECTORY: /srv/appdeamon

Can you help me, what do i wrong?

Thanks. Maxim

@jyavenard Iā€™m sorry missed your post yesterday ā€“

I am not aware of any special network setting, Iā€™ve used TPLink in the past and the only requirement was to locate the device on the same network sub-net. I could not get it to work over VLAN but Iā€™m not anything close to a network admin. I also use the default setting myself because they usually just work.

Sometime itā€™s just something random ā€“ for example, using emulated hue from a jailā€¦ Iā€™ve seen people try to all sorts setting, both on HOST and in the JAIL, to get this working ā€“ At the end of the day, the easy solution ( required no system configuration ) was to just use a different port.

emulated_hue:
  listen_port: 8300
  upnp_bind_multicast: true

Iā€™m sorry I canā€™t any offer any direct help, Iā€™ve havenā€™t spent much time trying to configure jails with non-default settings. Iā€™ll tell you this, donā€™t be scared because your using the ā€œpluginā€ ā€“ If your trying to get something to work, you can do / try anything you would normally do in a manually created jail.


You are doing nothing wrong ā€“ Iā€™ve been messing with the setting in the plugin ā€“ This is entire thing is getting completely refactored so using the TrueNAS beta plugin may be a little rough until I can this finished. ā€“ Iā€™ve only been focused on Home Assistant Core ( appdaemon and configurator are not going away, these are not my primary concern ATM, since TN 12 is still beta )

The short story - right now the services are pulling $rcvars directly from the rc service scripts. These are the defaults I keep talking about changing ā€“ I have made some temporary changes already in TN 12 but in the process of all this I had a light bulb moment ā€“ I decided to trash this entire thing and started from scratch.

To get this fixed up, hereā€™s what you can do right now.

# press `0` to EXIT the console menu
rm -rf /usr/local/srv/appdaemon
rm -rf /usr/local/srv/configurator

sysrc appdaemon_venv=/usr/local/srv/appdaemon
sysrc configurator_venv=/usr/local/srv/configurator

# restart the console menu
menu

Install appdaemon and configurator ā€“ Ignore message about existing configuration

1 Like

I assure you this is for the best ā€“ This plugin is really just an install script that follows the same steps you would perform during a manual installation. At the end of the day, this is always a pip install homeassistant ā€“ The pluginā€™s post_install.sh simply does all step required leading up to any finally installing homeassistant ā€“ In fact, the only basic difference between this plugin and Installation of Home Assistant on your FreeNAS is was my choice of username and location for the virtualenv ā€“

The provided configuration is nothing special, truth be told, itā€™s only there because I wanted to have some minimum defaults to test a clean installation.

All it does

  1. Enable packages. Using a package, I can easily add the iframes ( HA side panel links to AppDaemon and File Editor ) without touching any other configuration files.

  2. Provide a way to add your access token for appdaemon, before its installed. This not actually required either ā€“ but you will be spammed with endless ā€œlogin attempted failā€ if appdaemon is running and this is not correctly set.

  3. The configurator ( File Editor ) technically does not need any configuration file at all! - but when itā€™s there, it will provide persistent settings. The access token is optional for the basic file editing, but itā€™s needed if you want to communicate with the HA api. I use this file to again provide some sane defaults. Most useful is setting that starts in $homeassistant_config_dir when you looking for a file to edit.


In the past, I came at this from the Home Assistant side. This approach seemed OK and was perfectly natural to me because I am a Linux user ā€“ Thatā€™s why the virtualenv was in /srv/homeassistant and Iā€™m pretty sure I remember, waaay long ago ( I think around days of the AIO install ), hass was even the official username. ( It is still the core program name )

After much debate :roll_eyes: ( Special thanks to @atxbyea @Tinkerer @jkhii for not blocking me on Discord ) Iā€™m finally looking at this from the FreeBSD side.

Clean installs of the plugin will now use sane defaults that a BSD user would expect. The updated service script also includes some fragmented bits that were spread around this plugin and allows more settings via $rcvars. The new service should work for anyone already using some variation of the existing service script.

Iā€™m hoping a guide for the new service script will bridge the gap between this plugin and the manual installationā€¦ also providing manual break down of what should be happening, and by reference how preform the same steps manually


Quick Example ā€“ This is still pip venv, but using the service, we do not have to always remember about who the user is or location of the virtualenv.

service homeassistant install [CMD]

That is equal to

su - $homeassistant_user
source $homeassistant_venv/bin/activate
pip install [CMD]
deactivate

Typical use cases

  • Upgrade Home Assistant
service homeassistant install --upgrade homeassistant
2 Likes

The thing is, even using iocage console homeassistant (the name of it)

and manually running the senseme python code; it canā€™t detect any devices.
I then tried the same thing outside the jail ; same deal.

For whatever reason, I canā€™t get it to work on this freenas box.

Iā€™ve moved the code into a docker container and ran it with a linux host: all working fine.

I then found a spare Pine A64 board ; and ran it there. works fine too.

I would have preferred to have it all running on my freenas, itā€™s much more convenient. Canā€™t figure out whatā€™s wrong.

The homeassistant jail was created with the default; I didnā€™t change a thing.

1 Like