Button to reset the Zigbee2Mqtt integration

The Zigbee2mqtt integration has an “Enable/Disable” button that stops the containers, but does not clean up either database variables or files on disk. There is no way to start from scratch without manual intervention. The idea is to add a “Reset” button on the setup page, with confirmation (like on matterbridge/node-red), that performs a full reset: disconnection, deletion of variables, deletion of files and containers.

Reset procedure:

  1. Call this.disconnect() (stop containers + MQTT disconnection)
  2. Delete all config variables in the database via this.gladys.variable.destroy(key, this.serviceId) for each CONFIGURATION key in constants.js:
  • ZIGBEE2MQTT_DRIVER_PATH, Z2M_BACKUP, ZIGBEE_DONGLE_NAME, Z2M_MQTT_MODE, Z2M_TCP_POR, Z2M_MQTT_URL
  • Z2M_MQTT_USERNAME_KEY, Z2M_MQTT_PASSWORD_KEY
  • GLADYS_MQTT_USERNAME_KEY, GLADYS_MQTT_PASSWORD_KEY
  • DOCKER_MQTT_VERSION, DOCKER_Z2M_VERSION
  1. Delete the zigbee2mqtt/ folder on disk
  2. Reset state (discoveredDevices, usbConfigured, status flags, etc.)
  3. Emit a status event via this.emitStatusEvent()

:warning: Only available in “Install from Gladys” mode

Design proposal + messages

With confirmation

For Gladys devices linked to this integration, I think they should be kept (otherwise, we might break scenes?).

For what it’s worth, it looks perfect to me. It’s very clear!

Regarding Gladys + backup, if we restore a version with an old dongle, is there any risk? Or conversely, is it an additional safety net because we could restore in case of a mistake?

That’s something to test, I don’t know how it behaves. In the cases we’ve seen on the forum, it was a different situation: dongle change with files already on the disk.

In the case of a Gladys Plus restore, we don’t restore the Zigbee2mqtt files

1 Like

For me, we back up the entire contents of the zigbee2mqtt folder (so configuration.yaml, database.db and coordinator_backup.json).

But the restore checks whether a new configuration is present. If you restore a backup made with an old dongle (while a new dongle is plugged in and z2m is not initialized), you will also need to use that button.