Possible for Z2M to accept restart command via MQTT after adapter disconnects? #22587
Replies: 1 comment
-
Update: Docker could restart if only I could make it waitIt occurred to me that, perhaps, docker itself could be used to automatically restart Z2M in a scenario where it stops after the adapter (USB dongle) gets disconnected. I discovered that, yes, the docker container for Z2M does indeed stop, and the Docker daemon does attempt to restart it (because there is a However, the issue is that Docker attempts to restart the container almost instantly, before the USB device has been put back. Because the container is configured to pass through the file representing this device, Docker's attempt to restart the container fails. It is not attempted again because it was not a problem with the container, it was a problem with the actual start sequence. I am guessing that Docker does not automatically try again when the container could not be launched due to a missing device. Next stepsI'm looking to see if it is possible to get Docker to wait a bit before attempting to restart the container (to give the person that unplugged the USB time to put it back), and/or if I can get Docker to keep retrying until the device becomes available. Will keep you posted... |
Beta Was this translation helpful? Give feedback.
-
Sorry if this is a n00b question; I did a brief search on Duck Duck Go and in this GitHub discussion area but could not find relevant results.
Question
Is it possible to configure Z2M to keep running even after its adapter is disconnected? I would like to be able to issue a restart command via MQTT (rather than restarting the docker container itself, for instance) to recover from this condition.
My desired use case
Currently, if someone unplugs the Zigbee radio adapter from the Raspberry Pi I use to host Z2M, it stops working until manually restarted. I'd like to automate the restart.
Z2M issues the following MQTT message as soon as the USB dongle is disconnected from my hardware:
I'd love to have Home Automation listen for that message, and use it to trigger sending a restart command to Z2M via MQTT, as described on the relevant page of the guide website.
However, that restart command will never be received because Z2M stops completely when the adapter disconnects. Is there a way to change that behavior so that I can trigger a restart via MQTT?
Reason I want to set it up this way
I accidentally unplugged the USB Zigbee radio dongle from my Raspberry Pi the other day and had to manually restart the docker container running Zigbee2MQTT. The adapter is an area of the house where someone might unplug it out of curiosity to look at it, and getting things running again after this happens is currently pretty cumbersome.
I've written up a how-to guide in the documentation I keep for people that also live in the house, but it's asking a lot for other members of the household to SSH into a Raspberry Pi, look up credentials, issue docker commands, etc.
I would love to find a way to automate this restart process, with appropriate delays, etc., to automatically recover from the possibility of someone unplugging the adapter, looking at it, then plugging it right back in.
Thanks!
I really appreciate any guidance you guys have. Perhaps there's an existing feature / config flag I'm missing, or a better approach entirely that would better accomplish my goal of an automated recovery from the unplug/plug-back-in scenario. Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions