Help needed: Access to USB Z-wave stick and openhab on system startup

All,
I am using a raspberry pi with the latest Raspian (2015-05-05-raspbian-wheezy.img) and openhab 1.7.1.
Both, the installation of raspian and openhab were easy.
Then I installed the latest habmin (0.1.3)
When starting openhab by running sudo /opt/openhab/start.sh (as user pi) I can access the demo house web interface and the habmin web interface.
After plugging in my Z-Wave ZME_UZB1 Me USB Stick it’s recognized without issues (/dev/ttyACM0) and I can see it in the Binding configuration under “devices”.

For starting up openhab on system boot I use the following script placed as openhab in /etc/init.d/
http://www.homeautomationforgeeks.com/code/openhab.txt

Of course I did
sudo chmod 777 /etc/init.d/openhab
and
sudo update-rc.d openhab defaults

BUT:
After boot sequence I can connect to the web interfaces (openhab and habmin) but I do not see the z-wave stick any more.
Even after stopping the boot up script by
sudo /etc/init.d/openhab stop
and starting the “usual” way by
sudo /opt/openhab/start.sh I did not see the stick in habmin’s devices.

Just after disabling the bootup script by:
sudo update-rc.d -f openhab remove
I was able to start as usual (after reboot) with
sudo /opt/openhab/start.sh
and saw the usb stick in devices again.

Additional info:
In the “usual” way mentioned above I use pi and sudo to start the ./start.sh
The boot script contains
DAEMON_USER=root
Which I guess will result in root opening and blocking the USB stick during startup (no access by pi afterwards)!?
So I guess it’s somthing about access rights!? (root vs. pi?)

Any hint would be greatly appreciated.

The normal apt-get installation instructions in the wiki give you the init script, so introducing one that is not part of the installation can lead to issues. Normal convention in that case is to have an openhab user that runs the server (not root or pi), and add the openhab user to the dialout group so it has normal access to serial ports.

sudo usermod openhab -a -G dialout

Hi watou,
thank you very much for your quick response.
Of course I would prefer an official solution, but unfortunately I did not find an init script.
Which one (and where) are you referring to?

Secondly I heard that the default user name is openhab and it’s created automatically, but my system does not have this user.
So I need to create one!?

Best regards,
Enzio

I think the preferred way to install openHAB on Linux is through the apt-get instructions found here that is what @watou referred to. When installed in this manner an openhab user is automatically created and a start script is already placed in /etc/init.d and activated to start on boot. It will also keep your openHAB up to date as new versions are released when you run apt-get upgrade to update the rest of your system. The only additional config required is to make sure the openhab user has permission to read and write on your /dev/tty/ACM0 which the apt-get install doesn’t do.

The manual install instructions like those at the link you provide will require you to create your own start script, openhab user and other miscellaneous configurations yourself. This is why the apt-get method is preferred.

All that being said:

Have you looked in the log for any errors from the z-wave binding? Unfortunately it will report “cannot find device” (i.e. /dev/ttyACM0 in your case) even if it is actually there but openHAB just doesn’t have permission to read it.

That makes me think that the dongle moved to another device port. Did you happen to unplug and replug the device in at some point? I’ve found doing that moves the device to the next number (i.e. for me it moves from /dev/ttyUSB0 to /dev/USB1).

Quite possibly this is correct. Make sure that pi is a member of the dialout group for one. If you go back and install via apt-get, also add the openhab user to the dialout group so they those users can read and write the device. I don’t know if a program gets exclusive access to the device file (i.e. once root has it through openHAB no one else can read or write to it). This is also what @watou was referring to in his posting.

1 Like

Hi Rich,

thank you for your detailed response.
I will delete all openhab files and will start from scratch using apt-get (I previously used wget and unzipped the files in the according folders).

When I did not find the dongle on habmin, it was systemwise still present on the same location (ttyACM0).
And I did not change it physically to another port.

However, I will proceed as you and @watou suggested.
I will update you later.

Best regards,
NCO

@rlkoshak @watou

I did it!
After following your recommendation, it works as expected!
Thanks you very much for your support!

The only thing which is not working yet is the access from habmin to the sitemap and item files.
When trying to save a change in the sitemap for instance I get a message:
“Error saving sitemap”

Best regards,
NCO

Hi
I am getting mad with the same issue.
I installed initially manually via wget etc.
Then I installed a single binfing via repository and it instaled the dependency (runtime) too and, I guess, setup also all the “context”.

Now: if I start via sudo ./start.sh It works but then when I turn off the pc the session dies after a while.
If i go through sudo service openhab start or sudo /etc/init.d/openhab start: no way of connecting to the stick.

I tried to apt-get install and purge to no avail.
the problem is still there.

I would not like to go to a full reinstall since I have now quite a few things configured (zwace devices, opensprinkler, heatmiser to name a few).

It would be enough even to send it to the background using screen or & but the process dies after a while.

before posting the full setup (users, scripts etc…) do you have any suggestions to fix the problem?

Thanks in advance

Most of all : no way I am going to repair 10 zwave devices opening switches in the home :frowning:

I suggest following that preferred link EXACTLY and also, if you are on a RPi, go to here.
This works perfectly well and should also solve your problems.

To paraphrase an old quote. now you have two problems. You have two instances of openHAB installed and you have to be very careful you are configuring, starting, and using the correct one. Installation of openHAB is an all or nothing thing. Either you do all apt-get or you do all wget. You can’t mix the two because they install in completely different ways and in completely different folders.

As I, watou, @sihui, and others have recommended, the best and most recommended approach is to install via apt-get on Linux.

So presumably when you installed via wget you put it in /opt/openhab and EVERYTHING ends up in that folder. With apt-get, stuff gets spread out. All your configs go in /etc/openhab, your logs go to /var/log/openhab, and your addons go to /usr/share/openhab/addons.

When you install via openhab, there is no start.sh script. The only way to start it is through /etc/init.d. Similarly, when you install via wget, unless you write your own or download them from somewhere, there is no script in /etc/init.d to run openHAB and therefore service doesn’t know anything about it.

I have no idea what you may or may not have done to the setup with an atp-get purge so I’m going to suggest starting over.

Before you panic, you will lose no configuration by starting over. You 10 z-wave devices and the z-wave network is all stored on the stick, not within openHAB so you don’t have to repair, readd, or rejoin the network.

  1. Make a backup of your configurations folder. Presumably this is located in /opt/openhab. Make sure you get your items, rules, persistence, transformations, and scripts folders. Also make sure to grab your openhab.cfg and logback.xml files. Do this and you will lose nothing you have already done.

  2. Remove the wget installed folders. Get rid of them completely.

  3. Install using apt-get per the apt-get instructions. Install openHAB and addons using apt-get.

  4. Restore your backed up configurations to /etc/openhab.

  5. Since you know what the device is since it works when you run via start.sh your problem is not the same as the one described above. Your problem is that when openHAB is installed via apt-get and started via the initialization daemon (i.e. service) it runs as the openhab user. So to fix your original problem you just need to add the openhab user to the dailout group so it has read/write permission on the /dev/tty device your dongle resides on.

1 Like

Thanks for the quick reply, but…
I know that probably installing everything per the user guide willl solve the problem.
What I am asking is a way to avoid it since maybe I can get away copying the config directory altogether but I do not know if I manage to restore my zwave config just copying the /etc/zwave directory.
If this is not the case and I will have to open a few switches in the walls at my house I would rather try another solution and restart as a last resort.

TY

I guess chris jackson answered my question in another post:
"
Yes, the nodeIds will change but it will almost certainly sort itself out. One of the checks that the binding does when it loads the XML files is to check node numbers and the homeId. When you reset your controller, the homeId will change, so it will perform a full initialisation in the same way as if you’d deleted the XML files…"

If I reinstall copying the xml files describing the nodes just wont help

I found what was wrong.
stupid , really stupid, mismatch between my setup and the one of the script I was copying from the web.
I am a little bit ashamed to mention it but … well the serial port specified was differnt from the one I used.

I know: this is basic “check the cable” stuff but I think it is a learning both for me and other community members:

  • do not copy dumbly
  • check the very basics first (I was looking at user rights, dialout groups…)

One other lesson: do not mix manual and apt-get installation and, if you still can (not much configured), go for the supported one (apt-get)

KR

I just want to reiterate that your zwave network (i.e. which devices are included) is stored on the zwave dongle, not openHab. Even if you took the dongle to another computer (assuming nothing is wrong with the dongle) and use some other HA solution (e.g HomeGeini) you would not need to open your walls and readd the devices. The zwave binding may assign different node numbers to them which would require editing your bound items, but that is all.

Yes that ws my understanding too. But I did not know if the only place to edit was in /etc/zwave.

Thanks

I had the same issue, and if it helps anyone, I ran this

sudo usermod openhab -a -G dialout

as watou recommended, after reboot it worked ok…