Instructions for openHAB on FreeNAS?

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

I checked the permissions and ownership an everythink looks fine.

I have tried a second way, by making a backup of the PI-configuration with

> sudo openhab-cli backup
after that I copied the backup-file to the jail /var/db/openhab2/backup and changed the ownership top openhab:openhab. Than I start the jail. Finaly I tried to restore the backup with
> openhab-cli restore /var/db/openhab2/backup/<backup-file>.zip
but I got an error-message that told me that the command

openhab-cli

is unknown. Are there so many differences between openhabian and openhab for FreeBSD?

Another behavier I regconized is that the openHAB 2 Log Viewer will not be accessible. The workaround for this is to open the correspondig log-file from the shared directories. There I couldn’t see any message that shows that the LCN service will start.

Anyone any idears?
Thanks an best regards
Stef

I had an openhabian installation on a Pi so i did the migration as you. And my steps are these on my post #17.
There are many differences if you compare the openhabian and FreeBSD installation, mainly the directories used by the application.
That’s why i posted them.

I just copied the configuration folder to the new installation and installed all necessary bindings etc from scratch.

The log viewer is frontail. Yes this is not ‘supported’. We do it as a workaround manually but even i have to start it … manually :slight_smile:

I don’t know the LCN binding to help you for that. I hope your jail is ok with networking.

Oh, try this command on your jail.

# sysrc -f /etc/rc.conf openhab2_java_opts="-Djava.net.preferIPv4Stack=true"

It will help if your FreeNAS installation has IPv6 enabled…

Hello Nick,

the sysrc-line you posted is the same as I have inside my /etc/rc.conf-file.

It seems that I have the lcn-stuff runing, but it won’t run aout of the box by copying the lcn.cfg file. I had manualy initialize the binding by adding it as thing. After that I could the that openhab connects to the interface an the state changed to online … :wink:

Now I start thinking about the performance of the jails and the NAS-Hardware. Why? Well the messages in log appears much slower than on the rasperbery PI (3B). So my current NAS-hardware is an old AMD E350 processor (with 16GByte) witch should deliver more power than the PI … should. I think about upgrading the system, but I’m not shure whoe “huge” a TrueNAS-Hardware/processor should be, when the main functions of the NAS are only file-server and openHAB? Has anyone expirences in this direction? An other point is that the NAS should consume as little power as possible. Are there any idears?

Thanks and best regards
Stef

I tested a 12.1 iocage jail for manual OH3 installation.

I installed OpenJDK11

# pkg install openjdk11

I unzipped the OH3.1-snapshot to a newly created directory (ie. /usr/local/libexec/openhab3)

# chmod -R 755 /usr/local/libexec/openhab3
# cd /usr/local/libexec/openhab3
# ./start.sh

And that’s all, i can see it running.
What needs to be done is either a proper port or maybe a TrueNAS plugin scripted installation for user creation and service script.

Great news. There is a new port for FreeBSD for OH3.

This will be a different package name!
https://www.freshports.org/misc/openhab

1 Like