Only setup reporting for non battery powered routers. #1064

This commit is contained in:
Koen Kanters
2019-04-16 17:56:28 +02:00
parent a1b43d12f6
commit d0e66ed1da
+16 -8
View File
@@ -1,6 +1,7 @@
const zigbeeShepherdConverters = require('zigbee-shepherd-converters');
const logger = require('../util/logger');
const CC2530Router = zigbeeShepherdConverters.devices.find((d) => d.model === 'CC2530.ROUTER');
const utils = require('../util/utils');
const candidates = {
'genOnOff': {
@@ -82,14 +83,20 @@ class DeviceReport {
});
}
onZigbeeStarted() {
this.zigbee.getAllClients().forEach((device) => {
const mappedDevice = zigbeeShepherdConverters.findByZigbeeModel(device.modelId);
shouldSetupReporting(device) {
return utils.isRouter(device) && !utils.isBatteryPowered(device);
}
if (mappedDevice) {
this.setupReporting(mappedDevice, device);
}
});
onZigbeeStarted() {
this.zigbee.getAllClients()
.filter((d) => this.shouldSetupReporting(d))
.forEach((device) => {
const mappedDevice = zigbeeShepherdConverters.findByZigbeeModel(device.modelId);
if (mappedDevice) {
this.setupReporting(mappedDevice, device);
}
});
}
onZigbeeMessage(message, device, mappedDevice) {
@@ -98,7 +105,8 @@ class DeviceReport {
// Ikea TRADFRI tend to forget their reporting after powered off.
// Re-setup reporting.
// https://github.com/Koenkk/zigbee2mqtt/issues/966
if (device && mappedDevice && ['endDeviceAnnce', 'devIncoming'].includes(message.type)) {
if (device && mappedDevice && ['endDeviceAnnce', 'devIncoming'].includes(message.type) &&
this.shouldSetupReporting(device)) {
this.setupReporting(mappedDevice, device);
}
}