mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-17 02:48:31 -07:00
Network map error handling (#1565)
* Catch errors from failing network scans * Tidier code for process result * Fix eslint format errors
This commit is contained in:
parent
c4e9ea208a
commit
4b14222bda
@ -309,12 +309,15 @@ class Zigbee {
|
|||||||
return function(data) {
|
return function(data) {
|
||||||
const linkSet = [];
|
const linkSet = [];
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
logger.debug(`Processing scan for: '${parent}'`);
|
||||||
|
if (data) {
|
||||||
data.forEach(function(devinfo) {
|
data.forEach(function(devinfo) {
|
||||||
const childDev = shepherd._findDevByAddr(devinfo.ieeeAddr);
|
const childDev = shepherd._findDevByAddr(devinfo.ieeeAddr);
|
||||||
devinfo.parent = parent;
|
devinfo.parent = parent;
|
||||||
devinfo.status = childDev ? childDev.status : 'offline';
|
devinfo.status = childDev ? childDev.status : 'offline';
|
||||||
linkSet.push(devinfo);
|
linkSet.push(devinfo);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
resolve(linkSet);
|
resolve(linkSet);
|
||||||
logger.debug(`Processed device: '${parent}', linkSet: %j`, linkSet);
|
logger.debug(`Processed device: '${parent}', linkSet: %j`, linkSet);
|
||||||
});
|
});
|
||||||
@ -323,11 +326,15 @@ class Zigbee {
|
|||||||
|
|
||||||
const allScans = this.getScanable().map((dev) => {
|
const allScans = this.getScanable().map((dev) => {
|
||||||
logger.debug(`Preparing asynch network scan for '${dev.ieeeAddr}'`);
|
logger.debug(`Preparing asynch network scan for '${dev.ieeeAddr}'`);
|
||||||
return this.shepherd.lqi(dev.ieeeAddr).then(processResponse(dev.ieeeAddr, this.shepherd));
|
return this.shepherd.lqi(dev.ieeeAddr)
|
||||||
|
.then(processResponse(dev.ieeeAddr, this.shepherd))
|
||||||
|
.catch(() => {
|
||||||
|
return new Promise((resolve) => []);
|
||||||
|
});
|
||||||
}, this);
|
}, this);
|
||||||
logger.debug('All network map promises created');
|
logger.debug('All network map promises created');
|
||||||
// Collect all lqi scans but timeout after 2 seconds if any fail
|
// Collect all lqi scan results but timeout after specified miliseconds if any haven't completed
|
||||||
Promise.raceAll(allScans, 2000, []).then((linkSets) => {
|
Promise.raceAll(allScans, 8000, []).then((linkSets) => {
|
||||||
const linkMap = [].concat(...linkSets);
|
const linkMap = [].concat(...linkSets);
|
||||||
logger.info('Network scan completed');
|
logger.info('Network scan completed');
|
||||||
logger.debug(`Link map: %j`, linkMap);
|
logger.debug(`Link map: %j`, linkMap);
|
||||||
|
Loading…
Reference in New Issue
Block a user