This commit is contained in:
Koen Kanters 2021-06-07 09:54:33 +02:00
parent 0401a13d5d
commit 7b13b2d213
2 changed files with 11 additions and 7 deletions

View File

@ -100,8 +100,9 @@ class Controller {
logger.info(`Starting Zigbee2MQTT version ${info.version} (commit #${info.commitHash})`);
// Start zigbee
let startResult;
try {
await this.zigbee.start();
startResult = await this.zigbee.start();
this.callExtensionMethod('onZigbeeStarted', []);
this.zigbee.on('event', this.onZigbeeEvent.bind(this));
this.zigbee.on('adapterDisconnected', this.onZigbeeAdapterDisconnected);
@ -114,6 +115,13 @@ class Controller {
this.exitCallback(1);
}
// Disable some legacy options on new network creation
if (startResult === 'reset') {
settings.set(['advanced', 'legacy_api'], false);
settings.set(['device_options', 'legacy'], false);
this.enableDisableExtension(false, 'BridgeLegacy');
}
// Log zigbee clients on startup
const devices = this.zigbee.getClients();
logger.info(`Currently ${devices.length} devices are joined:`);

View File

@ -84,12 +84,6 @@ class Zigbee extends events.EventEmitter {
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);
@ -116,6 +110,8 @@ class Zigbee extends events.EventEmitter {
await this.herdsman.setTransmitPower(transmitPower);
logger.info(`Set transmit power to '${transmitPower}'`);
}
return startResult;
}
async getCoordinatorVersion() {