This commit is contained in:
Koen Kanters 2022-06-15 17:05:04 +02:00
parent a8233e0521
commit dd129830d3
4 changed files with 7 additions and 0 deletions

View File

@ -238,6 +238,7 @@ export default class Bridge extends Extension {
}
@bind async backup(message: string | KeyValue): Promise<MQTTResponse> {
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'));

View File

@ -183,6 +183,10 @@ export default class Zigbee {
return this.herdsman.isStopping();
}
async backup(): Promise<void> {
return this.herdsman.backup();
}
async getNetworkParameters(): Promise<zh.NetworkParameters> {
return this.herdsman.getNetworkParameters();
}

View File

@ -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));

View File

@ -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}}),