Node-RED integration: Give Docker container access to USB ports

Hello @pierre-gilles
does that correspond to this instruction?
:sudo chown -R 1000:1000 /var/lib/gladysassistant/node-red

If that’s it
I modified the Docker run like this and it works:

sudo docker run -d \
-u node-red:dialout \
  --name gladys-node-red \
  --restart always \
  -p 1881:1880 \
  -v /var/lib/gladysassistant/node-red:/data \
  --log-opt max-size=10m \
--device=/dev/ttyUSB0 \
  nodered/node-red:3.1

But you have to run, afterwards, this command:

sudo chown -R 1000:1000 /var/lib/gladysassistant/node-red

But if you confirm that it’s in the Node-RED integration code it should work.

With this command --device=/dev/ttyUSB0, do we force the RFLink to be connected to USB0? Does that cause a problem?

That’s it :slight_smile:

Yes that causes a problem, it’s always the same issue, we don’t know which port will be used.

That’s why my original PR proposed an approach based on volume sharing:

-v /dev:/dev \\
-v /run/udev:/run/udev:ro \\

With the additional --privileged option to give extra privileges to the container.

But based on your feedback, it doesn’t work.

I managed to do what you asked me, a long time ago :roll_eyes:
Gladys is indeed running as root, but node-red is run by the user node-red.

pi@rasp3b:~ $ docker exec -it gladys-node-red bash
eeb32d757218:~$ whoami
node-red
eeb32d757218:~$ groups
node-red
eeb32d757218:~$ exit


pi@rasp3b:~ $ docker exec -it gladys bash
root@rasp3b:/src/server# whoami
root
root@rasp3b:/src/server# groups
root

So there’s a problem then? If I understood correctly .

I wanted to add node-red to the dialout group in the docker run of the Gladys image, but since the node-red container hasn’t been created yet, it gives me an error

I don’t think that’s related, you’re comparing the users inside the container, that’s not the same thing.

If you look at the Dockerfile of the Node-RED project (Source), you can see that they create a Node-RED user.

Good evening @pierre-gilles
I’m at the limit of my knowledge and if I don’t get some help to point me in the right direction, I won’t be able to do anything more, sorry :thinking:

1 Like

Ah darn, well it’s true that it’s a very technical subject :smiley:

In this thread, who « needed » this development?

Just you @elfedagger?

I see you mention Somfy roller shutters above, I don’t know if you followed, but I’m

1 Like

Good evening, I think that those who use Arduinos, RFLink, RXcom — launching a poll would be interesting!

It’s a shame not to continue looking, because the internal Node-RED in Gladys is still more convenient to install, and if we could also trigger a backup that could be restored like Zigbee, that would be great. For my part I’m still on an external Node-RED, which once launched works very well, and to back up I export the file to Windows’ Downloads folder which I put aside just in case.

1 Like

Hello,

I would really like to be able to manage my Somfy shutters directly in Gladys. I’m afraid that with the assemblies and settings I might lose everything or mess everything up, so I stick with basic control using the remote. It’s problematic when I’m away.

@Jluc what Somfy equipment do you have?
shutter, blind, curtain, Velux?
IO, RTS?
box (which one), remote?
If needed we can start a new topic to talk about this part and avoid polluting this feed.

I also switched back to an external Node-RED, but when there’s a power outage and Gladys stops, on restart the USB ports get swapped and nothing works anymore. No more Zigbee and no more RFLink — it’s a pain to restart everything. As for Matter, I’m waiting to see. With RFLink there is no control of my blinds. My blinds are solar-powered, so there’s no question of adding hardware to them or investing

Hello everyone,
it’s true I had forgotten this problem as well, which is why this tutorial is useful

Thanks for your feedback @elfedagger :slight_smile:

In that case we can look at it together, it’s not very complicated to change, and nothing is tied to that request if that’s all that’s bothering you!

Is there a dedicated thread where we could discuss this?

1 Like

Hello @pierre-gilles,

I’ve resumed my tests to open the USB ports so that the RFLink can connect to Node-RED.
Here is a docker run that works. When you have a bit of time, could you check if this suits you and build me a Gladys-Node-RED image with this Docker integrated? Thanks in advance and happy holidays.

docker run -d \
  --name gladys-node-red \
  --restart always \
  --network host \
  --privileged \
  -e "PORT=1881" \
  --group-add dialout \
  -v /dev:/dev \
  -v /var/lib/gladysassistant/node-red:/data \
  --log-opt max-size=10m \
  nodered/node-red:3.1
1 Like

I hadn’t seen this question.

I mainly need the Node-RED integrated into Gladys to recognize the USB ports so I can use it with my RFlink and it seems to be on the right track. As for the USB ports that swap on external Node-RED, I set up a restart procedure

1 Like

Good evening @elfedagger

Can you explain what you did? Because for me it always gets reversed

Good evening, when my mini PC shuts down due to a power cut, before restarting I unplug what’s connected to my USB ports, leaving only my Zigbee dongle plugged in. When Gladys starts, the usb0 port is assigned to zigbee2mqtt and then I can reconnect my RFlink and usb1 is assigned to it. I restart external Node-RED and everything works again at my place. It’s very inconvenient but it’s the only way I have until the internal Node-RED recognizes the USB ports of my mini PC. My RFlink is only used to automate my Somfy shutters; I’m wondering if I should get a Tahoma Mini and automate my shutters outside of Gladys, maybe with Alexa to eliminate this problem.

Good evening @elfedagger
We use the same method, I thought you had named your ports!
Thanks for your reply
Have a good evening

Thanks @Psoy for the tests !

Can you explain to me each parameter you modified ?

In particular --network host \\ + -e \"PORT=1881\" \\ ?

Currently, we were using port mapping — did you change that so you can do network scanning, for example ?

Hello @pierre-gilles,
Just before tackling the USB ports issue, I was trying to reconnect my Xiaomi gateway and since I had two Node-RED instances running, the AI recommended \"--network host \\\" + -e "PORT=1881" \\". I just tested reverting to -p 1881:1880 \\, it works but you need these lines: --privileged \\ --group-add dialout \\ -v /dev:/dev /

Here is the docker run:

docker run -d \
  --name gladys-node-red \
  --restart always \
  -p 1881:
1 Like

Ok thanks for the feedback!

So actually in my initial PR, it was only missing --group-add dialout :slight_smile:

I’ve updated the PR accordingly:

I just retriggered a build which will be available on gladysassistant/gladys:node-red-usb-ports in about twenty minutes, I’d appreciate your feedback :wink:

1 Like