USB dongle configuration interrupted on Docker container restart

Hi

(My apologies for the poor French, I’m using Google Translate.)

I use docker-compose to run Gladys. I’ve configured Zigbee2MQTT and it works sometimes. But every time the container restarts, the USB dongle is no longer connected. The message says « No Zigbee2mqtt USB dongle is attached to Gladys ».

Two devices are always listed: /dev/ttyUSB0 and /dev/AMA0. What usually resolves the problem is to pick a device that is not selected and click « Save ». It doesn’t matter which of the two is chosen.

I need to be able to restart the containers unattended, without using the UI to change the configuration each time. Can anyone help me understand what’s wrong? Thanks.

Hi @orval

Google translate does a pretty good job don’t worry.

Can you post your compose file ?

When you have this error, is zigbee2mqtt service is started ? ( You can check that in sytem view )

Hi @VonOx

This is my compose file:

version: '3'

services:
  gladys:
    image: gladysassistant/gladys:v4
    restart: always
    privileged: true
    network_mode: host
    environment:
      NODE_ENV: production
      SQLITE_FILE_PATH: /var/lib/gladysassistant/gladys-production.db
    volumes:
      - /data/myhub/gladysassistant:/var/lib/gladysassistant
      - /var/run/docker.sock:/var/run/docker.sock
      - /dev:/dev
    ports:
      - '80:1443'
      - '443:1443'
      - '8080:8080'
  watchtower:
    image: containrrr/watchtower
    restart: always
    command: --cleanup --include-restarting
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

The zigbee2mqtt container is running and continues to work properly. I can access http://gladys-ip:8080/#/dashboard and see the devices. But Gladys doesn’t detect that it is running. It shows « No Zigbee2mqtt USB dongle configured, please go to… » Then I click « Save » and it works again.

These are the running containers:

$ docker ps --all
CONTAINER ID   IMAGE                       COMMAND                  CREATED         STATUS         PORTS      NAMES
eb14c756a72c   gladysassistant/gladys:v4   \"docker-entrypoint.s…\"   6 minutes ago   Up 6 minutes              myhub_gladys_1
abcc0834603d   containrrr/watchtower       \"/watchtower --clean…\"   6 minutes ago   Up 6 minutes   8080/tcp   myhub_watchtower_1
322d22c2fa6a   koenkk/zigbee2mqtt:latest   \"docker-entrypoint.s…\"   3 days ago      Up 3 days                 gladys-z2m-zigbee2mqtt
eb10f041a2a2   eclipse-mosquitto:2         \"/docker-entrypoint.…\"   8 days ago      Up 8 days                 gladys-z2m-mqtt

I wasn’t able to debug this issue. @pierre-gilles, do you have any suggestions?

Watchtower restarted my container « myhub_gladys_1 » today, and then all devices disappeared.

To make it work, I had to go to /dashboard/integration/device/zigbee2mqtt/setup and turn off and on « Enable Zigbee2MQTT ». That restarted the « gladys-z2m-mqtt » and « gladys-z2m-zigbee2mqtt » and everything worked again.

When Gladys fails like that, I can still access http://:8080/#/dashboard and see all devices working correctly, so it’s not a problem with the dongle or mosquitto/zigbee2mqtt. What can I do to make Gladys more stable?

I understand that for this to work I need to make a POST request to https://host/api/v1/service/zigbee2mqtt/connect after restarting the container.

Is there a way to make Gladys perform this call at startup?

Gladys already do that at startup.

I can suggest you not using compose and follow documentation, mqtt and zigbee2mqtt are created outside the stack ( don’t know if this is the root cause). Compose have no value here.

You are the only one with this kind of problem.

well, clearly not in a way that actually works.

It’s literally just the docker-compose equivalent to the run commands in the documentation: Installation with Docker | Gladys Assistant

It has value to me, since that is how I all my containers are deployed, via community.docker.docker_compose in Ansible.

So what? Are you saying that bugs are only investigated if more that one person finds it?

No, I’m not saying that.

I have no idea why you are experiencing that. The major difference with your configuration is your deployment method ( ansible / compose)

I’m trying to identify the cause.

I’ve removed docker-compose from the equation.

This problem still occurs when using the « docker run » commands as shown in the documentation.

If the gladys container is restarted, the USB connection is lost: « Gladys is not attached to any Zigbee2mqtt USB Dongle. »

What is the host OS?

For some reason Gladys can’t access dongle.

The zigbee2mqtt service is not starting when the container restarts as it’s marked as « manually stopped ».

$ journalctl CONTAINER_NAME=gladys | grep -i zigbee2m
Oct 12 21:40:06 dpi02 b2c767401a3d[724]: 2022-10-12T21:40:06+0100 <info> service.startAll.js:30 () Service zigbee2mqtt was manually stopped, so it is ignored at startup
Oct 12 21:42:40 dpi02 b2c767401a3d[724]: 2022-10-12T21:42:40+0100 <info> init.js:47 () Zigbee2mqtt USB dongle attached to /dev/ttyUSB0
Oct 12 21:42:40 dpi02 b2c767401a3d[724]: 2022-10-12T21:42:40+0100 <info> installMqttContainer.js:105 (Zigbee2mqttManager.installMqttContainer) MQTT broker container successfully started
Oct 12 21:42:40 dpi02 b2c767401a3d[724]: 2022-10-12T21:42:40+0100 <info> installZ2mContainer.js:73 (Zigbee2mqttManager.installZ2mContainer) Zigbee2mqtt container successfully started
Oct 12 21:42:40 dpi02 b2c767401a3d[724]: 2022-10-12T21:42:40+0100 <info> subscribe.js:12 (Zigbee2mqttManager.subscribe) Subscribing to MQTT topic zigbee2mqtt/#

The log from init.js:47 does happen until I click Save settings in the UI, which as two minutes after the container started.

[edit] platform is Raspberry Pi OS on a v4 Pi

[edit2] looks like the service table in the database has not been updated for a long time:

$ echo "select enabled, updated_at, status from t_service where name = 'zigbee2mqtt';"|sqlite3 gladys-production.db
1|2022-09-18 23:17:48.594 +00:00|STOPPED

It is running now and working at the moment.

so I found the /dashboard/settings/service page and all services were set to Stopped. I don’t get why anything worked at all with it like that but whatever. I changed Zigbee2mqtt to Running and now the service starts as expected when the container restarts.

3 Likes

Cool !

Yes that’s why in my previous post I was asking.

my bad. I didn’t realise the service was a separate thing to « Enable Zigbe2mqtt » being set on the Zigbe2mqtt configuration page. I have been using a bunch of Zigbee devices in Gladys for a few weeks without the service running!

1 Like