Instructions for openHAB on FreeNAS?

Right. I’ve got the same lock problem - running openHAB in an iocell/jail on freebsd.

I’m happy to put some effort into resolving this. What’s the current state of play? Have any of you got a working config, or are you all getting the lock issue every time?

It depends. If you plan on locally plugging-in a USB ZWave stick, then all of us get abort traps and it is unusable. For that reason, and also because I prefer to have my ZWave away from the server running FreeBSD/FreeNAS, I have pushed for an RFC2217 connection. After a lot of effort on the side of several community members, that seems to work, but I need to do more testing (tomorrow) because I am unsure how stable it is.

If you are thinking of a remote USB device and using socat to create a local port, you will get abort traps just as if you plugged it in to the server. Realistically, rfc2217 is the only option if you need ZWave. For RFXCOM USB (which I also use) it works well just over TCP. No experience of other types of USB in my setup.

I had the same error and I tried this solution but the erros is still there… what should I do?

Have you cleared the OpenHAB caches? On FreeBSD/FreeNAS delete the files in /var/db/openhab2/userdata/cache/ and for a good measure also in /var/db/openhab2/userdata/tmp/

After restarting OpenHAB it will throw a Java error about unresolved dependency (in the log), then a few minutes later it restarts again, populates the cache, and starts working—at least for me.

You can confirm if you are using the newer version of the ZWave binding in Karaf with list -s | grep zwave

I’ve managed to get it working in a cage ok - I fixed devfs to make the device node available, and I was able to plug the zwave controller into the machine and poll devices inside of OpenHAB. I did then get the lock file failure - removing the lock file by hand fixed it until I got the issue again.

So, my problem appears only to be that the usb device lock file isn’t being managed properly. Are there other issues too?

(This was using the most recent openhab2 from the freebsd ports).

Joe

The locking issue is the problem—see the long thread (bottom of it) for more on that, as well as a good few reports on Github. There is an underlying issue in either nrjavaserial or in OH itself that affects lock handling with USB devices. The only way I have managed to bypass that is by using rfc2217 connection to a remote Pi running nothing other than the ZWave stick (and RFXCOM USB in my case).

Any other issues? I am not sure if Homekit integration works and I do not know if that is a FreeBSD or an OH issue. I have just failed on it, and I am awaiting info on a newer jar of the add-on to test. Having hit a good few walls with OH on FreeBSD so far, I am experimenting with HA+FreeBSD which seems to run smoother, no locking issues etc. :slight_smile:

What’s HA?

Are there any ports available to support the remote zstick? Can that be run on the same host and networked via the loop back?

I’ve seen a lot of file locking code over the years. Why are they rolling their own? There are standard plock/flock semantics available on most posix operating systems.

That is an interesting idea. I suspect all you need to do is install ser2net (from pkg/ports), add a line in its config pointing to the USB stick and expose on a port of your choice. Then connect to it using rfc2217://localhost:port as the ZWave port specifier. I suppose you could run it in the same or a different jail.

If you want to try this, make sure to use the newest version of the ZWave binding from this post: [SOLVED] [Zwave, Zigbee, ...] RFC2217 remote serial port HowTo? - #28 by wborn

I don’t know if I should answer this question on account of my future chances of getting any support from others on this forum. :sweat_smile: HA=Home Assistant, the frenemy of OpenHAB. In my (very limited) experience of it, it has a lot of stuff that works that does not work on OpenHAB, esp. under FreeBSD. Unfortunately, there is also a lot that does not work in HA (in general and also specifically under FreeBSD) that works awfully well in OpenHAB. I wish those two could get a room together.

Hello freebsd users,
Anybody knows where the configuration files are safed in freebsd?
I had configured some things under openhabian. There I found the configs under:
/etc/openhab2 (probably same in freebsd installation)
/var/lib/openhab2

Thanks a lot!

Hello @sawirth. As long as you have a “standard” install (eg. using pkg/ports) you will find all the standard configs (items, rules etc) in /usr/local/etc/openhab2. There is more in /var/db/openhab2/userdata and the add-ons go into /usr/local/libexec/openhab2. Enjoy!

I ran into the exact same locking issue (with the code dumps) on my FreeBSD jail.

The trick to use serial over telnet worked.

Here’s what I did:

Install, configure and start ser2net:

# pkg install ser2net
# echo "2000:telnet:0:/dev/ttyU0:115200 8DATABITS NONE 1STOPBIT remctl" > /usr/local/etc/ser2net.conf
# sysrc ser2net="YES"
# service ser2net start

Check that ser2net is listening to the TCP port:

# sockstat -4l | grep ser2net
root     ser2net    92939 6  tcp4   10.42.0.2:2000        *:*

Then, I configured my Z-Wave thing to use “serial” port rfc2217://10.42.0.2:2000

The binding is now working correctly.

Hi,

Is there any way (except Docker) for openhab3 on Freenas?

Frontail as a deamon. Who has a service startup script file working for iocage?

I haven’t started testing OH3 on my TrueNAS Core (aka FreeNAS) yet, but anyone who does succeed, please post here, it would be much appreciated.

I will just wait for the ports version, hope netchild sees that.

Hello ngalfas,

I try to get openHAB running on TrueNas too, but I’m struggling with the user rights or IDs … because I’m a newbe too. What I have discovered ist that the user- and group-ids inside of the jail are differend from the IDs of the NAS. So the NAS-IDs starts with 1000 and the openhab IDs in the jail are 235. So I tried to change them to become equal … well … but … I didn’t managed it.
In your post you said that this is a “tricky thing” … could you please explain, what I have to to, so solve this problem? If possible in a way that could be understand by a 6 years old child … :wink:

Thanks, best regards and … a happy new year
Stef

Hi Stef. This is a classic question for FreeNAS jails.
There is no need to invent the wheel for me to explain.
This is the BEST post expaining in detail this procedure.

This post is mandatory reading for future readers having similar issues and need to understand what needs to be done and WHY we need to do it.

In our case the easiest step is this

**SOLUTION 1 - USER WRITEABLE**
* Add a user in the FreeNAS WebUI with a matching UID as the plugin's default user.
* Change ownership of the data dataset/folders to the newly added user.

Since your jail user is openhab:openhab 235:235 you just need to create the same username and SET 235 manually on user and group creation pages on FreeNAS. First create the group and then the user.
Don’t leave the deafault 1000 user ID that FreeNAS suggests. You can change it right there! And you must.

So, delete your current TrueNAS openhab user (not the jail user!!!) and the TrueNAS openhab group.
Then you can create the TrueNAS openhab 235 group.
Then create the TrueNAS 235 openhab user.

And make the next steps. I will also edit my post above to be more informative.

Hello Nick, thanks for help. I first tried to change the openhab uid and group with the pw groupmod and usermod commandsbut with less success. So after reading your hint, I just deleted the openhab user and group within TrueNas an recreate them an the problems with the permissions disapear …

Now I copied my configuration (openhab_conf) from the PI to the TrueNas directories. Something happens … but not all. It seams the my hue-devices are connected, but my LCN-Devices are not available.

Is the the world not as easy as copiing the configuration-data to migrate from the Raspberry PI to TrueNas?

If someone has an idear, what I have to do to keep the LCN running gain?

Thanks and best regards
Stef

after such a copy, you must do the last step to be sure of file permissions

Do these inside the jail.

# chown -R openhab:openhab /usr/local/etc/openhab2
# chown -R openhab:openhab /var/log/openhab2
# chown -R openhab:openhab /var/db/openhab2/userdata
# chown -R openhab:openhab /var/run/openhab2
# chmod -R 755 /usr/local/etc/openhab2
# chmod -R 755 /var/log/openhab2
# chmod -R 755 /var/db/openhab2/userdata