Home Assistant Core -- TrueNAS CORE Community Plugin

@troy
Thank you for your reply.
Also need to install iocage-mosquitto plugin or is it already included ?
Maybe ZHA is easier ? No more other jail to install ?

For zigbee to MQTT, yes you should install the mosquito plugin as wellā€¦ If you use ZHA there will not be a need for mosquito however if you plan to use any tasmoda devices in the future you will still need MQTT anyways

Hi everyone! I have been using home assistant hosted on a Raspberry Pi 3 for a few years until it started to behave erratically recently. I did a fresh install and not long after it started to go weird again. Thanks to the community on Discord pointing out to me - never did I realise it might be the hardware (SD card or the Pi) failing on me. So the logical thought is to move to what has the most reliable hardware in my home - FreeNAS / TrueNAS! So thank you ahead @troy for creating this plugin!

Just a question on network security, I liked the idea of RPi as it can stay in my subnet with all the IoT hosted on that network. My FreeNAS server however is hosted on my main LAN.

Do you place your NAS server on a different subnet to your IoT devices?

1 Like

When I was running FreeNAS / TrueNAS CORE, I had my plugins / jails on the same VLAN as TrueNAS host - but the IOT devices themselves were on a separate VLAN.

Now that I have switched to using Docker containers on TrueNAS SCALE - I am running all my containers on a separate VLAN from the host. But I think my method to accomplish this is more of a hack and not a proper solution. ā€“ Basically, my server has two on board network ports. I have both ports connected to a Unifi switch. On my switch, I have configured one of these ports to be on a separate VLAN. Then on TrueNAS SCALE, I created a macvlan bridge assigned to that network port, that I use for the containers in my docker-compose file.

Oh why did I not think of it!! Indeed my server also have two on board physical ethernet ports. I have not experimented with it, but the setup of the host to have networking etc. does my head in.

How was the transition to SCALE? Were you able to preserve all your pools, and for HA preserve all your configuration?
I havenā€™t seen much documentation yet on a migration process from CORE to SCALE.

CFC

Hi @CFC

It was fairly smooth. Both of my zpools were successfully imported and so far seem to be working without a glitch. I will say though, I do not use any ACL permissions. Itā€™s my understanding mileage may vary if you have configured ACLā€™s on CORE ā€“ Keep in mind, SCALE is still in an ALPHA state. The first BETA is scheduled for release by the end of this month. Still, this is not recommended for production systems. I took a few extra steps that will hopefully allow me to revert back to CORE with relative ease.

On TrueNAS CORE -----

  1. Make notes of all system settings, users, services, network shares, ectā€¦
  2. Stop, then disable the auto-start for all plugins and jails
  3. Optional - Export plugins that are currently installed
  4. Export all zpools
  5. Make final backup of system configuration

Moving to SCALE -----

I would still consider this transition a reinstall not a migration. In other words, only my zpools were saved. There is not a CORE ā†’ SCALE way of transfering your TrueNAS configuration. My setup is rather simple so this was not a big deal.

  1. Install SCALE
  2. Configure basic system settings like timezone and hostname
  3. Import zpools (do not upgrade to any new features or versions)
  4. Add myself as user to SCALE
  5. Configure / Enable SSH and SAMBA

Generally speaking, youā€™ll be able to preserve and copy the configuration from any of your plugin / jails.

Rather than use existing any datasets, I created a new apps dataset from the SCALE UI, then inside apps, I created other datasets and directories for each of the apps (containers) and copied the configuration from the previous locations.

Some modification may still be required. For example if youā€™re reinstalling Home Assistant and Mosquitto on SCALE, either using the Launch Docker Image or from TrueCharts, the ip address will likely be different from when these were running in a jail on CORE ā€“ You may still need to reconfigure some things accordingly, like the MQTT broker IP for the integration and on all connecting devices.

Instead of installing apps using the SCALE UI (which is using kubernetes) - I am using docker-compose with macvlan. Currently, using docker / docker-compose is allowed but not supported by ix-systems (meaning they are not going to intentionally prevent this but it is not tested, not guaranteed to work, and may break at time). Using macvlan (instead of host network), I was able assign the same IPs, previously used by the corresponding jails. I had to make some minor adjustment for the paths in my mosquitto.conf but after that Home Assistant, Mosquitto, ESPHome and Z-Wave- JS to MQTT (using Z-Wave JS Server) all came back up with working configurations.

1 Like

Hi @troy
I ordered a CC2652RB usb stick to use with ZHA.
Could you tel me where are instructions to expose the Serial Device Path into Home Assistant jail?
Thanks

If you are using the plugin-jail, these devices should be passed through automagically. Usually they show up as /dev/CUA* devices from inside the jail.

If your using a standard jail, youā€™ll need to create a custom devfs ruleset. ā€“ It sounds more complicated than it is :sweat_smile: ā€“ I havenā€™t test this on TrueNAS but I believe the instructions from FreeNAS 11.x will still work.

2 Likes

Thanks so much for the insight @troy Iā€™m still learning a good bit on jail creating, and TrueNAS in general so this may be a dumb question.
How did you manage to get the devfs_ruleset to stick on restarts for the HA plugin-jail vs. having to create the script and adding it as a Init script for a conventional jail?
Is there a way to create a jail from onset to have the custom devfs_ruleset permanent?
I didnā€™t realize you also maintained the ESPHome plugin. I was about to install it soon, and was wondering about USB pass-through. I assume youā€™ve also set it up with a devs rule to pass USB.

Thanks again,
CFC

The only option I know in the conventional jail properties will allow you to change the devfs_rulset but there is nothing to actually create one. You could just use ruleset 3 and it will pass everything on your host into the jail. The script is what creates a ruleset to pass through only the serial USB devices instead of everything. Because this is on the TrueNAS host, it will not survive a reboot, so we add it as init script for convenience.

The plugin works because the devfs_ruleset is included in the plugin manifest. Iā€™m not really sure whatā€™s going on under the hood but this seems to be applied to the jail in a way that works with default ruleset.

Only Home Assistant and Z-Wave JS to MQTT plugins have passthrough ā€“ Iā€™ve never tried with ESPHome. If it does work, I can certainly add it the manifest. I think the easiest way to try, is inside the jail properties, set it to ruleset 3. I think everything should be pass through. If the ESP device shows up in ESPHome, we can figure out what device needs to be passed through and create a ruleset for it, in the manifest.

Well I donā€™t actively maintain that oneā€¦ I made that with someoneā€™s help. Whenever it broke they would fix it and I would just add the changes to plugin. Unfortunately that person is no longer using ESPHome on FreeBSD ā€“ Honestly, Iā€™m not sure how much longer the ESPHome plugin will survive. The main problem is that ESPHome relies on platformio to compile firmware for the devices. For this to work in our jails, platformio must download certain libraries made for FreeBSD however updated version are no longer provided.

I hate to say, but in a roundabout way, ESPHome was kinda the deciding factor for me to change my server over to SCALE. Basically I came to accept the only long term solution for somethings, is to start using containers ā€“ My server did fine running multiple plugins and jails on CORE - But to use containers, we need Linux. I thought about just adding a Linux VM, but my server donā€™t have enough overhead for multiple jails and a VM to run efficiently. I figured, if I have to give up my jails so I can run the VM, I might as well just switch to SCALE, skip the VM, and run the containers directly.

So I had a go at adding a devfs_ruleset for ESPHome plugin on CORE. It will pass the ESP device to the jail but itā€™s still not recognized by ESPHome. I thought maybe it didnā€™t work because of the device permissions, but even running ESPHome as root, it does not see the serial connection :disappointed:

ls -al /dev/ | grep ttyU

crw-------   1 root  wheel     0x7e Jun 16 18:08 ttyU0
crw-------   1 root  wheel     0x7f Jun 16 18:08 ttyU0.init
crw-------   1 root  wheel     0x80 Jun 16 18:08 ttyU0.lock

Using the ESPHome container on SCALE, the device shows up in ESPHome, as expected.

Thanks for checking @troy
SCALE is obviously the future of TrueNAS. Iā€™ll probably make that switch at the first RC.
It looks like with the ESP Web Tools news today from the HA team though, we wonā€™t need a jail at all: Power-up your ESP8266 and ESP32 projects: browser-based installation and configure Wi-Fi via Bluetooth LE - Home Assistant
Pretty exciting. Iā€™m about to order my first devices.

CFC

Hi @troy
Both ZHA integration in this HA plugin and in Zigbee2MQTT jail couldnā€™t connect to my usb coordinator.
Within both jail I get this information:
ls -l /dev/

crw-------  1 root  wheel      0x17 Jun 20 19:43 bpf
lrwxr-xr-x  1 root  wheel         3 Jun 20 19:53 bpf0 -> bpf
crw-rw-rw-  1 root  wheel      0x43 May  8 09:56 crypto
crw-rw----  1 uucp  dialer    0x103 Jun 20 20:58 cuaU0
crw-rw----  1 uucp  dialer    0x104 Jun 20 12:29 cuaU0.init
crw-rw----  1 uucp  dialer    0x105 Jun 20 12:29 cuaU0.lock
dr-xr-xr-x  2 root  wheel       512 May  8 09:56 fd
crw-rw-rw-  1 root  wheel      0x2d Jun 20 21:00 null
crw-rw-rw-  1 root  wheel       0xf May  8 09:56 ptmx
dr-xr-xr-x  2 root  wheel       512 Jun 20 19:53 pts
crw-r--r--  1 root  wheel       0x5 May  8 09:57 random
lrwxr-xr-x  1 root  wheel         4 Jun 20 19:53 stderr -> fd/2
lrwxr-xr-x  1 root  wheel         4 Jun 20 19:53 stdin -> fd/0
lrwxr-xr-x  1 root  wheel         4 Jun 20 19:53 stdout -> fd/1
crw-------  1 root  wheel     0x100 Jun 20 12:29 ttyU0
crw-------  1 root  wheel     0x101 Jun 20 12:29 ttyU0.init
crw-------  1 root  wheel     0x102 Jun 20 12:29 ttyU0.lock
lrwxr-xr-x  1 root  wheel         6 Jun 20 19:53 urandom -> random
crw-rw-rw-  1 root  wheel      0x2e May  8 09:56 zero
crw-rw-rw-  1 root  operator   0x41 May  8 09:56 zfs

and usbconfig command: ā†’ No device match or lack of permissions.

On my linux laptop ls -l /dev/serial/by-id command: ā†’ lrwxrwxrwx 1 root root 13 20 jun 21:35 usb-Silicon_Labs_slae.sh_cc2652rb_stick_-_slaesh_s_iot_stuff_00_12_4B_00_23_93_30_43-if00-port0 -> ../../ttyUSB0

@tebra

I thinkā€¦ try using /dev/cuaU0

It works now.
For information, I forgot to change the MQTT server (localhost ā†’ IP of mosquito jail) in configuration file of zigbee2mqtt

So @troy, I assume this is the limitation you meant on the FreeBSD version?

Tool Manager: Installing platformio/toolchain-xtensa32 @ ~2.50200.0
Error: Could not find the package with 'platformio/toolchain-xtensa32 @ ~2.50200.0' requirements for your system 'freebsd_amd64'

Iā€™m guessing at this point thereā€™s not much else I can do beyond running ESPHome on something different right?

CFC

@CFC

Ah that sucks - It is unfortunately the error I was referring to

Youā€™ll most likely find itā€™s easiest to run ESPHome on something else. At least youā€™ll be able to save/transfer any existing devices you have configured. Sorry, I donā€™t have time give details right now but let me know if you have questions and Iā€™ll try to help, if I can

I guess this means itā€™s time to remove ESPHome from the plugin list :disappointed:

Ha! No worries.
I went old school and just used the CLI on my Windows desktop.
No pretty dashboard, but it got the job done.

CFC

If anyone is actually familiar with FreeBSD (beyond these jails on TrueNAS CORE) or maybe just building software from source in general, it should be possible to compile these missing toolchains yourself.

FreeBSD users should be able to build esp32 projects by following instructions in the following repositories below.

1 Like