Domoticz in LXD on Ubuntu server

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

Post Reply
LXDBlast
Posts: 2
Joined: Thursday 27 December 2018 20:52
Target OS: Linux
Domoticz version:
Contact:

Domoticz in LXD on Ubuntu server

Post by LXDBlast »

Hello, I installed Domoticz in a LXC container (DOM1) following the howto for Linux.
The website is up and running but my USB RFXcom (RFXtrx433XL) in the host does not show up in the Domoticz hardware configurator.
To be more precise, the "serial port" list is empty. No devices are displayed.

I added the usb device to my container to make it accessible for Domoticz. Commands from within container DOM1:

Code: Select all

root@DOM1:~# lsusb | grep 0403
Bus 001 Device 003: ID 0403:6015 Future Technology Devices International, Ltd Bridge(I2C/SPI/UART/FIFO)

root@DOM1:~# lsmod | grep usbserial
usbserial              53248  1 ftdi_sio

root@DOM1:~# ls -l /dev | grep tty
crw--w---- 1 root tty     136,   7 Dec 27 14:44 console
crw-rw-rw- 1 root root      5,   0 Dec 27 15:16 tty
crw-rw-rw- 1 root dialout 188,   0 Dec 27 15:52 ttyUSB0
What can be the reason why Domoticz does not see my devices? The list remains empty.
Domoticz is start as normal user (not root) I added the user in DOM1 to the dialout group.

What can I check to see what is wrong with this setup? Adding udev rules inside a container is not possible in LXD.

Any help is greatly appreciated.

Domoticz_no_serial_ports.PNG
Domoticz_no_serial_ports.PNG (59.98 KiB) Viewed 1337 times
domotica
Posts: 2
Joined: Sunday 30 December 2018 13:48
Target OS: Linux
Domoticz version:
Contact:

Re: Domoticz in LXD on Ubuntu server

Post by domotica »

Hello,

Exact same error here ! Empty list in serial port dropdownlist for all new hardware created :

- LXC container with Proxmox
- Domoticz ultimate beta version (v 4.10303)
- I see in command line /dev/ttyUSB0 and seem to have the good users/right
- Domoticz start as root user

I try verbose mode in Domoticz log without success.
i think the problem is in https://github.com/domoticz/domoticz/tr ... are/serial

Any help is greatly appreciated.
domotica
Posts: 2
Joined: Sunday 30 December 2018 13:48
Target OS: Linux
Domoticz version:
Contact:

Re: Domoticz in LXD on Ubuntu server

Post by domotica »

Hello,

Finally the problem is not here : https://github.com/domoticz/domoticz/tr ... are/serial

but is here : https://github.com/contactless/domoticz ... Helper.cpp in function "GetSerialPorts"
and I think LXC is not detected as normal system, may be is posible to created a fake /boot/config.txt. i'll try ...

My workaround :

Edit app/HardwareController.js and change :
$.ajax({
url: "json.htm?type=command&param=serial_devices",
async: false,
dataType: 'json',
success: function (data) {
if (typeof data.result != 'undefined') {
$.each(data.result, function (i, item) {
var option = $('<option />');
option.attr('value', item.value).text(item.name);
$("#hardwareparamsserial #comboserialport").append(option);
});
}
}
});
for this :
$.ajax({
url: "json.htm?type=command&param=serial_devices",
async: false,
dataType: 'json',
success: function (data) {
var option = $('<option />');
option.attr('value', '/dev/ttyUSB0').text('/dev/ttyUSB0');
$("#hardwareparamsserial #comboserialport").append(option);

}
});
this change is very ugly but work for me ...
LXDBlast
Posts: 2
Joined: Thursday 27 December 2018 20:52
Target OS: Linux
Domoticz version:
Contact:

Re: Domoticz in LXD on Ubuntu server

Post by LXDBlast »

Hi domotica,

Thanks for your "hack" suggestion. I am not 100% sure that my LXD container on ubuntu server act the same as your LXC container but your "mod" came across my mind too. I did not know where the setting was. Thanks for pointing out. I agree it will work, but did not try it.

To prevent making the change every update of Domoticz I came up with an even more ugly solution... I went to another domotica platform. OpenHAB2 does detect my hardware like it should.

If anyone comes across this thread, here is what I did to make ttyUSB0 available in an LXD container (on ubuntu 16.04 and LXD 3.0.3)
It might work for future Domiticz updates. But be careful, not every LXC platform is the same and you may need to "tweak" it for your own setup.

Create a new container and add following to the container config:

Code: Select all

lxc config device add <your container name> ttyUSB0 unix-char source=/dev/serial/by-id/usb-RFXCOM_RFXtrx433XL_DO2XOT6T-if00-port0 path=/dev/ttyUSB0 required=false gid=20 mode=660
If you have LXD 3.0.3 and can't connect to the domotica web page, check if the ip_tables kernel module is loaded inside the container. I had to add it to my container config for unknown reason. With LXD 2.0.11 you should not need to do this.

That is all
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest