Configuration du dongle usb interrompue au redémarrage du conteneur docker

Hi

(Toutes mes excuses pour le mauvais français, j’utilise google translate.)

J’utilise docker-compose pour exécuter Gladys. J’ai configuré Zigbee2MQTT et cela fonctionne parfois. Mais chaque fois que le conteneur redémarre, le dongle USB n’est plus connecté. Le message indique « Aucun dongle USB Zigbee2mqtt n’est attaché à Gladys ».

Deux périphériques sont toujours répertoriés : /dev/ttyUSB0 et /dev/AMA0. Ce qui résout généralement le problème est de choisir un périphérique qui n’est pas sélectionné et de cliquer sur « Sauvegarder ». Peu importe lequel des deux est choisi.

Je dois pouvoir redémarrer les conteneurs sans surveillance, sans utiliser l’interface utilisateur pour modifier la configuration à chaque fois. Quelqu’un peut-il m’aider à comprendre ce qui ne va pas? Merci.

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

Ceci est mon fichier compose:

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

Le zigbee2mqtt container est en cours d’exécution et continue de fonctionner correctement. Je peux accéder à http://gladys-ip:8080/#/dashboard et voir les appareils. Mais gladys ne voit pas qu’il est en cours d’exécution. Ça montre « Aucun dongle USB Zigbee2mqtt configuré, veuillez vous rendre sur… » Puis je clique sur « Sauvegarder » et ça refonctionne.

Ce sont les containers qui tournent :

$ 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

Je n’ai pas réussi à déboguer ce problème. @pierre-gilles, avez-vous des suggestions ?

Watchtower a redémarré mon conteneur « myhub_gladys_1 » aujourd’hui, puis tous les appareils ont disparu.

Pour que cela fonctionne, je devais aller sur /dashboard/integration/device/zigbee2mqtt/setup et éteindre et rallumer « Activer Zigbee2MQTT ». Cela a redémarré les « gladys-z2m-mqtt » et « gladys-z2m-zigbee2mqtt » et tout a fonctionné à nouveau.

Lorsque Gladys échoue comme ça, je peux toujours accéder à http://:8080/#/dashboard et voir tous les appareils fonctionner correctement, donc ce n’est pas un problème avec le dongle ou le moustique/zigbee2mqtt. Que puis-je faire pour rendre Gladys plus stable ?

J’ai compris que pour que cela fonctionne, je dois faire une requête POST à ​​https://host/api/v1/service/zigbee2mqtt/connect après le redémarrage du container.

Existe-t-il un moyen d’amener Gladys à faire cet appel au démarrage ?

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.

J’ai supprimé docker-compose de l’équation.

Ce problème se produit toujours lors de l’utilisation des commandes « docker run » comme indiqué dans la documentation.

Si le container gladys est redémarré, la connexion USB est perdue : « 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 « J'aime »

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 « J'aime »