Skip to content

Using a USB Z Wave or Zigbee controller

Troy Prelog edited this page Nov 22, 2022 · 13 revisions

USB Z-Wave and Zigbee Controllers

ℹ️ The TrueNAS CORE Community Plugin includes the devfs_ruleset in plugin manifest.

  • USB device are passed through automagically, when using the community plugin 🧙

USB pass-through using a custom devfs_ruleset

⚠️ To directly access devices like the Aeotec Gen-5 USB Stick, Nortek HUSZB-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 ruleset, it must first be created on the FreeNAS host.

  • This will use a script to create the custom devfs_ruleset on your FreeNAS
  • The name of this script is trivial. In this example I use zwave-ruleset.sh

☢️ There is a know issue that iocage deletes the devfs_ruleset when the jail is stopped ( and restarted ) - Typically, there is no need for frequently stopping or restarting the jail so this is usually not an issue, however, if your Z-Wave or Zigbee devices have suddenly stopped working after a plugin update or jail restart, this is the most likely cause. You'll need to stop the jail, re-run the zwave-ruleset.sh script on your FreeNAS to re-create this devfs_ruleset, and finally start jail.


Create a script zwave-ruleset.sh on your FreeNAS

  • The script will create devfs_ruleset 99 on your FreeNAS
  • I use 99 because it seems unlikely this would otherwise be used
  • To use a different ruleset number, change RULE_NUM=99

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

ee zwave-ruleset.sh

Add the following contents

#!/bin/sh

## Create custom devfs_ruleset RULE_NUM
RULE_NUM=99

/sbin/devfs rule -s ${RULE_NUM} add include 1
/sbin/devfs rule -s ${RULE_NUM} add include 2
/sbin/devfs rule -s ${RULE_NUM} add include 3
/sbin/devfs rule -s ${RULE_NUM} add path zfs unhide
/sbin/devfs rule -s ${RULE_NUM} add path 'bpf*' unhide
/sbin/devfs rule -s ${RULE_NUM} add path 'cua*' unhide
  • To Save and Exit, press ESC then press ENTER twice

Make the script executable

chmod +x zwave-ruleset.sh

Run the script from the FreeNAS console

  • Keep this script handy for the issue mentioned above
sh zwave-ruleset.sh

Check that your custom ruleset has been successfully created

devfs rule -s 99
  • You should see similar output
$ sudo devfs rule -s 99 show

100 include 1
200 include 2
300 include 3
400 path zfs unhide
500 path bpf* unhide
600 path cua* unhide

Setting your jail to use the custom ruleset

  • You can do this from the FreeNAS console or use the webui
  • I find using the FreeNAS console quickest

For example, if your jail is named homeassistant

iocage set devfs_ruleset=99 homeassistant
iocage restart homeassistant

Automatically creating the custom ruleset

  • Set zwave-ruleset.sh to run at startup using the FreeNAS webui

This is required for FreeNAS to automatically (re)create the custom ruleset during (re)boot.

full size image