diff --git a/server/services/zigbee2mqtt/lib/disconnect.js b/server/services/zigbee2mqtt/lib/disconnect.js index 8d35fab225..44159731dd 100644 --- a/server/services/zigbee2mqtt/lib/disconnect.js +++ b/server/services/zigbee2mqtt/lib/disconnect.js @@ -28,7 +28,7 @@ async function disconnect() { this.gladysConnected = false; this.emitStatusEvent(); - // Stop MQTT container + // Stop & remove MQTT container let dockerContainer = await this.gladys.system.getContainers({ all: true, filters: { name: [mqttContainerDescriptor.name] }, @@ -36,11 +36,12 @@ async function disconnect() { if (dockerContainer.length > 0) { [container] = dockerContainer; await this.gladys.system.stopContainer(container.id); + await this.gladys.system.removeContainer(container.id); } this.mqttRunning = false; this.emitStatusEvent(); - // Stop zigbee2mqtt container + // Stop & remove zigbee2mqtt container dockerContainer = await this.gladys.system.getContainers({ all: true, filters: { name: [zigbee2mqttContainerDescriptor.name] }, @@ -48,6 +49,7 @@ async function disconnect() { if (dockerContainer.length > 0) { [container] = dockerContainer; await this.gladys.system.stopContainer(container.id); + await this.gladys.system.removeContainer(container.id); } this.zigbee2mqttRunning = false; this.zigbee2mqttConnected = false; diff --git a/server/test/services/zigbee2mqtt/lib/disconnect.test.js b/server/test/services/zigbee2mqtt/lib/disconnect.test.js index 8fcf97793e..fddb7778cd 100644 --- a/server/test/services/zigbee2mqtt/lib/disconnect.test.js +++ b/server/test/services/zigbee2mqtt/lib/disconnect.test.js @@ -38,6 +38,7 @@ describe('zigbee2mqtt disconnect', () => { system: { getContainers: fake.resolves([container]), stopContainer: fake.resolves(true), + removeContainer: fake.resolves(true), }, }; @@ -71,6 +72,7 @@ describe('zigbee2mqtt disconnect', () => { }, }); assert.calledTwice(gladys.system.stopContainer); + assert.calledTwice(gladys.system.removeContainer); }); it('mqtt connected', async () => { @@ -96,6 +98,7 @@ describe('zigbee2mqtt disconnect', () => { }, }); assert.calledTwice(gladys.system.stopContainer); + assert.calledTwice(gladys.system.removeContainer); assert.calledOnce(mqtt.end); assert.calledOnce(mqtt.removeAllListeners);