Home Assistant Core -- TrueNAS CORE Community Plugin

FYI – looks they are going to move 12.2 plugins to the the 12.3-RELEASE after all

Keep in mind, you’ll still be using the 12.2-RELEASE (Host OS) kernel - Unfortunately can not say if this update is going to work for Home Assistant. If you are determined to run Home Assistant on TrueNAS CORE, you may need to wait for the 13.0-RELEASE.

1 Like

Strange, i don’t have the word configuratior with the trash icon here?

At me there is: “u heeft nog geen langdurige toegangstokens.”
Translated: There is no Long Lived Access Tokens
so how to make the token now? for configurator?

Hi @bonestaak - You just need to manually create your token

Just checking before I upgrade to 2022.7, whether the move to Python 3.10 will create an issue?

You can upgrade to 2022.7 without upgrading to python 3.10 The best would be to get the TrueNAS plugin to be updated with python 3.10 dependency and re-install the HA service which will recreate the venv with all required dependencies. Upgrading python is a bit painful otherwise (based on my experience)

1 Like

i tried and my installation is completely broken, posted here asking for any input; HA not starting after failed update from 2022.6.7

The plugin will never switch the python version automatically after it’s been installed – As @adorobis correctly points out, reinstalling the virtualenv can be a bit of a pain. The issue is usually (re)building the wheels for all the python packages used by the integrations you may have installed. Because jails use FreeBSD, very few prebuilt wheels are available for download so they must be compiled during installation. The time this takes will depend on the number of integrations and power of your NAS. I’ve had reports of people waiting almost an hour.

That said, I’ll add Python 3.10 to the plugin manifest and get a pull request submitted to ix-systems before the end of July. I expect it will take some time to make its way to the release branch. Most likely, the update will only apply to the TrueNAS Core 13 – You’ll still need to manually switch python versions and reinstall Home Assistant. Like before, I’ll give copy/paste commands to follow.


@deathstargunner – Sorry for the short answers, it’s a busy week. I’ll try to help you on your post.

1 Like

So here it goes, I’ve upgraded python to 3.10. It is not a smooth excersise, probably I’m doing something in sub-optimal way. For extra safety I have cloned the HA jail to a new one just to be able to revert to old one quickly. The process:

  1. shut down HA jail
  2. clone to a new one
    iocage clone ha_old --name ha_new
  3. iocage start ha_new
  4. iocage console ha_new
  5. service homeassistant stop
  6. pkg install python310 py310-sqlite3
  7. sysrc homeassistant_python=/usr/local/bin/python3.10
  8. service homeassistant reinstall homeassistant - this step took around 15 minutes
  9. service homeassistant start
    After that I’ve received error about missing pymysql python module as I’m using MariaDB for recorder component. Not sure why it does not get installed automatically so I’ve added it to the venv manually:
    source /usr/local/share/homeassistant/bin/activate.csh
    pip install pymysql
    deactivate
    service homeassistant restart
    After that the HA has started ok but it took a long time for the first start (something between 15 to 30 minutes before the web gui was showing up and even more time before all integrations loaded.
1 Like

Not really… Steps 5 through 9 are exactly correct! And I think it’s a great idea to clone the jail – This approach can really minimize downtime, especially if you’re using an external set for your configuration.

Pretty sure you’ll need to do this every time. I don’t see pymysql listed anywhere in the requirements file. I’m guessing that’s why it is never installed automagically.

Remember, you should be able to reinstall pymysql along with homeassistant

service homeassistant reinstall homeassistant pymysql

You can also install thing in the venv like this

service homeassistant install pymysql

It’s ok to go full-on manual mode as well. I just want to point out a few details for others that might be following along at home.

  1. It’s important, you must switch to user homeassistant before activating the virtualenv
  2. User homeassistant has default shell set to bash, you don’t need to activate.csh

So revised commands would look like this

su - homeassistant
source /usr/local/share/homeassistant/bin/activate
pip install pymysql
deactivate && exit
service homeassistant restart
1 Like

Great, many thanks for all those hints!
Btw, do you know if there is anything in the TrueNAS 13 that could break the HA plugin? As far as I know the base for a jail is not updated automatically on TrueNAS upgrade so in theory nothing should break. But this is the first time I an holding back with the upgrade…

I have just upgraded to TrueNAS 13. Was very smooth and no issues. All jails work fine. I have also learned that upgrading jails is not possible/not recommended so if someone wants to run latest freebsd release in a jail it has to be recreated.

1 Like

I’d like to only include one version of Python with the plugin but I can’t really ensure that configurator and appdaemon will always be compatible with Home Assistant python requirement.

It’s been over a year since I’ve used it last so I don’t have anything to test 3.10 functionality.

Any chance you’ve updated the virtualenv for appdaemon as well ?

Not yet, I’ll try to do it when I find some free time. Appdaemon is not maintained at fast pace so I had no pressure for that.
Btw, I’ve just checked the documentation and it says it works with python from 3.7 to 3.9 So it might not actually work with 3.10 (yet)

I might have something different in mind now anyways… I think I’m gonna just take python off the plugin manifest all together. Instead I’ll install it from the post_install.sh script. And I’ll just install a needed versions for Appdaemon and Configurator only if they’re getting installed. For those having luck with the Plugin Updates, I’ll check for enabled services and reinstall whatever version of python is set in the respective rcvar during the post_update.sh

1 Like

Small update. Cloning a jails is a nice idea but there is one caveat: the clone is dependent on the source jail (the file system is a writable snapshot) which means that if the source is destroyed the clone as well… I’ve just learned it the hard way… It can be worked around by demoting the source and promoting the clone to become the master after which the source can be safely deleted.
https://iocage.readthedocs.io/en/latest/advanced-use.html
Good I have the config directory in a separate dataset… And I’m now testing installation of the updated plugin :slight_smile:
So far installation went fine, waiting for the first start of ha:

Testing virtualenv...
  /usr/local/share/homeassistant
  Python 3.10.5
  Home Assistant 2022.7.7
1 Like

Speaking of updated plugins…

Nothing groundbreaking here really just FYI for those who follow along… I made my PRs straight to the release branch for each TrueNAS version so the changes went live immediately upon merge.

Oh and my plugins on TN 13 should now be using the 13.1-RELEASE

Yes, HA does. Installation went smothly and now my HA is back without loosing anything. What a relief :slight_smile:
@troy many thanks for your continued support for an unsupported plugin!

1 Like

Looks like we have first component coming with 2022.8 release not compatible with FreeBSD. Bluetooth is based on some libraries requiring Linux. Not sure if there is a way to have some FreeBSD port.

2022-08-03 16:13:52.220 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing component homeassistant.components.bluetooth
Traceback (most recent call last):
  File "/usr/local/share/homeassistant/lib/python3.10/site-packages/homeassistant/loader.py", line 638, in get_component
    cache[self.domain] = importlib.import_module(self.pkg_path)
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/local/share/homeassistant/lib/python3.10/site-packages/homeassistant/components/bluetooth/__init__.py", line 14, in <module>
    from bleak import BleakError
  File "/usr/local/share/homeassistant/lib/python3.10/site-packages/bleak/__init__.py", line 81, in <module>
    raise BleakError(f"Unsupported platform: {platform.system()}")
bleak.exc.BleakError: Unsupported platform: FreeBSD

Personally I’m not using it so I have replaced the default_config: entry from configuration.yaml with listing all needed integrations explicitly (without the bluetooth).

Well this is an unfortunate turn of events…

I never thought I’d be disappointed to see an integration added to Home Assistant. It’s unfortunate the devs decided to block a feature request that would have allowed us to just disable Bluetooth.

I’ll try to have a look after work and see if there is anything we can do on FreeBSD side of things. Maybe install a new dependency or something but honestly I’m not very optimistic. I’m pretty sure a few people have tried to get Bluetooth working with this plugin in the past but had no success.

I don’t know if there is going to be a feasible work around for this one… I don’t think I can realistically maintain an updated configuration to work around the default config :frowning_face:

EDIT: A quick search on the TrueNAS forums seems to indicate this is not going to be possible. Most post are fairly old, this being the most recent.

Blah… This is stupid but it’s the best I can do for now.

You’ll need to make these changes manually to your existing configuration.yaml

1 Like