Disable legacy options on new network start.

This commit is contained in:
Koen Kanters
2021-06-07 09:46:10 +02:00
parent 95d39a3ff6
commit 0401a13d5d
2 changed files with 16 additions and 2 deletions
+9 -2
View File
@@ -60,10 +60,11 @@ class Zigbee extends events.EventEmitter {
herdsmanSettings.network.panID = newPanID;
}
let startResult;
try {
herdsmanSettings.acceptJoiningDeviceHandler = this.acceptJoiningDeviceHandler;
this.herdsman = new ZigbeeHerdsman.Controller(herdsmanSettings, logger);
await this.herdsman.start();
startResult = await this.herdsman.start();
} catch (error) {
logger.error(`Error while starting zigbee-herdsman`);
throw error;
@@ -79,10 +80,16 @@ class Zigbee extends events.EventEmitter {
this.herdsman.on('message', (data) => this.emit('event', 'message', data));
this.herdsman.on('permitJoinChanged', (data) => this.emit('permitJoinChanged', data));
logger.info('zigbee-herdsman started');
logger.info(`zigbee-herdsman started (${startResult})`);
logger.info(`Coordinator firmware version: '${stringify(await this.getCoordinatorVersion())}'`);
logger.debug(`Zigbee network parameters: ${stringify(await this.herdsman.getNetworkParameters())}`);
// Disable some legacy options on new network creation
if (startResult === 'reset') {
settings.set(['advanced', 'legacy_api'], false);
settings.set(['device_options', 'legacy'], false);
}
for (const device of this.getClients()) {
// If a passlist is used, all other device will be removed from the network.
const passlist = settings.get().passlist.concat(settings.get().whitelist);
+7
View File
@@ -623,4 +623,11 @@ describe('Controller', () => {
expect(MQTT.publish).toHaveBeenCalledTimes(1);
expect(MQTT.publish).toHaveBeenCalledWith('zigbee2mqtt/fo', 'bar', { retain: false, qos: 0 }, expect.any(Function));
});
it('Should disable legacy options on new network start', async () => {
expect(settings.get().advanced.legacy_api).toBeTruthy();
zigbeeHerdsman.start.mockReturnValueOnce('reset');
await controller.start();
expect(settings.get().advanced.legacy_api).toBeFalsy();
});
});