No serial connection with auto-boot login

I’m using Openhab with a Raspberry Pi2.
Everything works fine.
I’m reading values wit my USB-serial port from the electricity meter with the DSMR binding.

When I start up with opt/openhab/sudo ./ everything works fine.

When I use Autoboot with a startup script, described in
then Openhab works but there is no communication with the serial port.

I think the reason is that with autoboot there is another user who has no rights to use the port.
But I don’t understand how to solve it.

To solve the problem find out what the other user is (if you had done an apt-get installation which is highly recommended) that user would be openhab. Add that user to the dialout group and it will have permissions to read and write to the serial device. You fan find out what user openhab is running as with the command:

ps -elf | grep openhab

Look for a line that has /usr/bin/java -Dlogback.configuration in it. The user will be the word in the third column.

This is the command to add the openhab user to the dialout group

useradd -G dialout openhab

I highly recommend that everyone use the apt-get installation instructions any time they are using a Debian based Linux server (which the raspbian is). It places everything in known locations, creates necessary users, sets openHAB up to run as a service, and it will receive updates automatically as they become released.

I wish everyone who has written an openHAB tutorial out there would update to the apt-get approach.

1 Like

Hi Rich,

Besides the solution for the serial port, you’re right about the installation process.
I was confused about the way the different instructions talk about the maps.

For example: etc/openhab or .opt/openhab or opt/openhab/addons-repo
So I decided to do it in a way I thought I understood what was going on.
With using commands like:
a) sudo mkdir /opt/openhab
b) sudo wget
c) sudo unzip

But now I’m sometimes in trouble with users and rights.
I’m not an experienced Linux user.
I’ve done this because I wanted to use auto-boot (on a RPi) and I wanted to understand where the files are installed, on what locations.

I’m willing to install everything again. With apt-get, as you suggest.
But what do you recommend?
Where do I have to start?
There are a lot of different instructions, all a littlebit different.

When in doubt always follow the instructions on openHAB’s sites. Specifically the instructions for apt-get are located here on the wiki. The wiki should be your first place to look for all questions as the most authoritative source for openHAB information.

I hate these wget based instructions because it completely cuts the users off from the source of the software and any changes to instructions, updates, and other useful info the creators of the software may provide. So when the instructions become stale you never know.

When you install via apt-get here is where everything gets placed:

  • /etc/openhab : probably the most important folder. This is where logback.xml, openhab.cfg, and your configurations folder end up. Pretty much all your handwritten configuration and rules go here.

  • /usr/share/openhab : this is where the binary parts of openHAB get installed. This is also where the addons and webapps folders reside so if you have a binding that you want to install that isn’t available via apt-get, this is where you copy it to. If you want to use Habmin, you will unzip the webapp part (the jar files go in addons) to this webapps. However, until you get more experience with openHAB I highly recommend sticking to apt-get to install bindings.

  • /var/log/openhab : This is where all your logs end up (unless you manually change logback.xml to send them somewhere else). You will probably only care about openhab.log and events.log.

  • /var/lib/openhab : You probably never have to worry about this folder but if you do, this is where your persistence DBs are stored (if you are using one of the embedded solutions like rrd4j instead of a separate server like MySQL) and some bindings will put things here as well (e.g. the z-wave binding will put the XML device descriptors for all your nodes in this folder)

Since you are using a serial device, one step that isn’t covered in the instructions is to add the openhab user to the dialout group as described above.

Starting and stopping openHAB will now be done solely through the startup utility. If you are on raspbian wheezy you will use:

sudo service openhab start
sudo service openhab restart
sudo service openhab stop
service openhab status

If you are on jessie you will use

sudo systemctl start openhab
sudo systemctl restart openhab
sudo systemctl stop openhab
systemctl status openhab

You need to tail -f /var/log/openhab/openhab.cfg to watch the log statements that usually flow by your screen when you start openhab using

Tomorrow I start installing everything again.
Last time I started I choose Noobs from the site.
I’ve used NOOBS v1-5-0
You talk about Wheezy or Jessie. Do I have to choose?

I have a Rpi 2.

Btw the suggestion about ps -elf | grep openhab did not work.
(All mentioned users already existed)

Noobs is just a way to install the operating system. The actual operating system is whatever you choose to have Noobs install. The latest Noobs will come with the latest raspbian which is jessie. Wheezy was the codename for the previous raspbian. When they make major changes to the operating system they give it a new name.

I don’t know what you mean by “All mentioned users already existed”. The purpose of that command is to see what user openhab is running under when you start it up using service. This will tell you what user you need to add to the dialout group.

Hi Rich,

I didn’t want to go further on a bad fundament so I’ve installed everything from scratch.
In the way you advised: with apt-get.

It now works perfect!

  • Serial port worked immediately.
  • Samba works with the right maps.
  • Auto boot works!
  • Logging works

— btw:
Auto Boot In the wiki:
I only added the next lines to /etc/rc.local
start openhab
/etc/init.d/openhab start

tail -f /var/log/openhab/openhab.cfg to watch the log statements
I’ve got an error.
I think it’s tail -f /var/log/openhab/openhab.log
I’ve done that and everything works.

Thank you very much for your detailed help!



With the apt-get install, this step should be unnecessary.

I’m glad you got it to work!