diff --git a/lib/extension/bridge.ts b/lib/extension/bridge.ts index c9be0354..10f5fea0 100644 --- a/lib/extension/bridge.ts +++ b/lib/extension/bridge.ts @@ -238,6 +238,7 @@ export default class Bridge extends Extension { } @bind async backup(message: string | KeyValue): Promise { + await this.zigbee.backup(); const dataPath = data.getPath(); const files = utils.getAllFiles(dataPath).map((f) => [f, f.substring(dataPath.length + 1)]) .filter((f) => !f[1].startsWith('log')); diff --git a/lib/zigbee.ts b/lib/zigbee.ts index 4d543b77..b7d3ccc9 100644 --- a/lib/zigbee.ts +++ b/lib/zigbee.ts @@ -183,6 +183,10 @@ export default class Zigbee { return this.herdsman.isStopping(); } + async backup(): Promise { + return this.herdsman.backup(); + } + async getNetworkParameters(): Promise { return this.herdsman.getNetworkParameters(); } diff --git a/test/bridge.test.js b/test/bridge.test.js index c2399a5e..a19f54ae 100644 --- a/test/bridge.test.js +++ b/test/bridge.test.js @@ -1019,6 +1019,7 @@ describe('Bridge', () => { MQTT.publish.mockClear(); MQTT.events.message('zigbee2mqtt/bridge/request/backup', ''); await flushPromises(); + expect(zigbeeHerdsman.backup).toHaveBeenCalledTimes(1); expect(mockJSZipFile).toHaveBeenCalledTimes(4); expect(mockJSZipFile).toHaveBeenNthCalledWith(1, 'configuration.yaml', expect.any(Object)); expect(mockJSZipFile).toHaveBeenNthCalledWith(2, 'ext_converters/123/myfile.js', expect.any(Object)); diff --git a/test/stub/zigbeeHerdsman.js b/test/stub/zigbeeHerdsman.js index 03584cd7..34698dc6 100644 --- a/test/stub/zigbeeHerdsman.js +++ b/test/stub/zigbeeHerdsman.js @@ -207,6 +207,7 @@ const mock = { touchlinkScan: jest.fn(), touchlinkIdentify: jest.fn(), start: jest.fn(), + backup: jest.fn(), isStopping: jest.fn(), permitJoin: jest.fn(), getCoordinatorVersion: jest.fn().mockReturnValue({type: 'z-Stack', meta: {version: 1, revision: 20190425}}),