mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-28 05:24:29 +00:00
Merge remote-tracking branch 'origin/master' into dev
This commit is contained in:
+31
-3
@@ -275,6 +275,10 @@ class Zigbee {
|
||||
return this.shepherd.find(device.ieeeAddr, 1);
|
||||
}
|
||||
|
||||
getScanable() {
|
||||
return this.getDevices().filter((d) => d.type != 'EndDevice');
|
||||
}
|
||||
|
||||
getGroup(ID) {
|
||||
return this.shepherd.getGroup(ID);
|
||||
}
|
||||
@@ -287,10 +291,34 @@ class Zigbee {
|
||||
|
||||
networkScan(callback) {
|
||||
logger.info('Starting network scan...');
|
||||
this.shepherd.lqiScan().then((result) => {
|
||||
|
||||
const processResponse = function(parent, shepherd) {
|
||||
return function(data) {
|
||||
const linkSet = [];
|
||||
return new Promise((resolve) => {
|
||||
data.forEach(function(devinfo) {
|
||||
const childDev = shepherd._findDevByAddr(devinfo.ieeeAddr);
|
||||
devinfo.parent = parent;
|
||||
devinfo.status = childDev ? childDev.status : 'offline';
|
||||
linkSet.push(devinfo);
|
||||
});
|
||||
resolve(linkSet);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
const allScans = this.getScanable().map((dev) => {
|
||||
return this.shepherd.lqi(dev.ieeeAddr).then(processResponse(dev.ieeeAddr, this.shepherd));
|
||||
}, this);
|
||||
Promise.all(allScans).then((linkSets) => {
|
||||
const linkMap = [].concat(...linkSets);
|
||||
logger.info('Network scan completed');
|
||||
callback(result);
|
||||
});
|
||||
callback(linkMap);
|
||||
})
|
||||
.catch(function() {
|
||||
logger.info('Network scan failed');
|
||||
callback([]);
|
||||
});
|
||||
}
|
||||
|
||||
getEndpoint(ieeeAddr, ep) {
|
||||
|
||||
Reference in New Issue
Block a user