-
-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add openhab user to dialout group #18
Comments
Hey, that's a topic we also discussed in the forum thread a few times. What's a bit troubling for me: dialout is always only halve the solution. Not saying that I'll not do it but there are a few extra steps needed to make your ZWave dongle etc. work in openHAB (activate the serial port, change java parameters, ...) Do you have an idea for a more complete approach? |
Hi again Thomas! Yeah, you are right, adding the openhab user to the dialout group doesn't solve the problem completely and in all cases, but, for example, the default file where the distribution mounts the USB devices ("/dev/ttyAMC0") can be read by openHAB and therefore it can be used immediately without further modifications. If you want to link the file to another file ("/dev/zwave" -> "/dev/ttyAMC0" using an udev rule), then what you say is correct, you need to pass the "/dev/zwave" file as a -Dgnu.io.rxtx.SerialPorts java parameter, and I'm not sure what would be the best solution to handle the problem, sorry 😢 |
Just a few notes on the topic. devices:
openHAB runtime parameters -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0
# or
-Dgnu.io.rxtx.SerialPorts=/dev/ttyS0:/dev/ttyUSB0 Serial port
System Judging from what was said in the threads, only the following is needed: sudo adduser openhab dialout
sudo adduser openhab tty # ? Judging by what I saw in the forum, the real problem is to select the right serial device and to decide wether it needs to be added to gnu.io.rxtx.SerialPorts. |
Hi Thomas! Sorry for the late response :( Yes, you are right, it's not an easy task to configure the Razberry board to be used with openHAB (well, it's not difficult, but require a few steps), but for examples, the default mounting points of the USB sticks like /dev/ttyUSB0 or /dev/ttyACM0 can be accessed by openHAB just adding the openhab user to the dialout group. You don't need to add any line to the /etc/default/openhab2 file (-Dgnu.io.rxtx.SerialPorts parameter) nor to the /boot/config.txt file, just execute "sudo usermod openhab -a -G dialout" and you are ready to go! That's why my suggestion was to add the openhab user to the dialout group, at least the USB stick user's life (Z-Wave, RFXcom, Enocean,...) will be simpler ;) |
@bodiroga I've done the needed changes (finally!) When installing openHAB:
After selecting the menu entry "Serial Port": if grep -q "enable_uart" /boot/config.txt; then
sed -i 's/^.*enable_uart=.*$/enable_uart=1/g' /boot/config.txt
else
echo "enable_uart=1" >> /boot/config.txt
fi
sed -i 's/console=tty.*console=tty1/console=tty1/g' /boot/cmdline.txt
sed -i 's/^T0/\#T0/g' /etc/inittab This should also respect the differences between RPi1+2 and 3. I will test this now in my RPi3. The last piece needed by some users is the addition of "gnu.io.rxtx.SerialPorts" but as details are missing, I'll leave that to the user for now. |
Awesome work Thomas, many thanks for your patient! I will try to test it next week and report back if I find any problem, although I'm sure that everything will work flawlessly ;) Keep up with the good job and thanks for your contribution to the openHAB community! |
Thanks for your help. Any further additions from your side are always welcome ;) Let me know if everything went smooth! |
@bodiroga, earlier you said:
Do you by any chance know the reason behind that? Maybe a better solution could evolve out of a short investigation. Also feel free to take part in the referenced issue #33! |
Hi Thomas! As far as I know (I'm not an expert by all means), openHAB can read the /dev/ttyUSB0 or /dev/ttyACM0 ports being part of the dialout group because in Linux, serial ports mounted in /dev folder are owned by root under the dialout group. Here you have a link that talks about it: http://askubuntu.com/questions/774541/what-is-dialout-group-in-ubuntu/774545 The problem with the "-Dgnu.io.rxtx.SerialPorts" parameter is that Java is not able to "see" serial ports with non-standard port names (/dev/ttyAMA0 or custom names such as /dev/zwave and /dev/rfxcomm) and in order to solve that you need specify the ports that you need to use manually in the -Dgnu parameter. (More information: http://angryelectron.com/rxtx-on-raspbian/). And I don't know what can be done to solve it... 😢 Perhaps, the best solution is to add an udev rule (there is an entry for that in the openHAB wiki: https://github.com/openhab/openhab/wiki/symlinks), create a list of most used devices (in the link you have the idVendor and idProduct of two ZWAVE usb dongles and the RFXcom transceiver, we could add the information about the Razberry), define a name for each device (/dev/zwave or /dev/USBzwave for all the ZWave devices, as it is very unlikely that someone will plug two ZWave controllers in the same device) and add those personal names to the -Dgnu.rxtx.SerialPorts parameter, instead of adding all possible ports combination (/dev/ttyS1, /dev/ttyS2, /dev/ttyAMA0, /dev/ttyAMA1,...). How does it sound? At least, at the binding configuration time, /dev/USBzwave is a much more meaningful name than /dev/ttyAMA0... Thanks for your work as always and best regards, Aitor |
Signed-off-by: Markus Storm <markus.storm@gmx.net>
Signed-off-by: Markus Storm <markus.storm@gmx.net>
Signed-off-by: Markus Storm <markus.storm@gmx.net>
Signed-off-by: Markus Storm <markus.storm@gmx.net>
Signed-off-by: Markus Storm <markus.storm@gmx.net>
Signed-off-by: Markus Storm <markus.storm@gmx.net>
Good morning Thomas!
Would it be possible to add the openhab user to the dialout group after openHAB is successfully installed?
Bindings that depend on USB controllers (ZWave, Enocean, RXFcom,...) need access to the USB devices (/dev/ttyUSB0, /dev/ttyACM0,...), so automatically adding the openhab user to the dialout group will avoid users to ssh the device just to type "sudo usermod openhab -a -G dialout".
Small detail that will make openhab users life easier ;)
Thank you for your patience!
The text was updated successfully, but these errors were encountered: