mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-16 18:39:09 -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) => {
|
||||||
data.forEach(function(devinfo) {
|
logger.debug(`Processing scan for: '${parent}'`);
|
||||||
const childDev = shepherd._findDevByAddr(devinfo.ieeeAddr);
|
if (data) {
|
||||||
devinfo.parent = parent;
|
data.forEach(function(devinfo) {
|
||||||
devinfo.status = childDev ? childDev.status : 'offline';
|
const childDev = shepherd._findDevByAddr(devinfo.ieeeAddr);
|
||||||
linkSet.push(devinfo);
|
devinfo.parent = parent;
|
||||||
});
|
devinfo.status = childDev ? childDev.status : 'offline';
|
||||||
|
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