diff --git a/lib/extension/deviceAvailability.js b/lib/extension/deviceAvailability.js index 3679f33aa..9cbe9a4ae 100644 --- a/lib/extension/deviceAvailability.js +++ b/lib/extension/deviceAvailability.js @@ -25,9 +25,12 @@ class DeviceAvailabilityHandler { this.queue.autostart = true; } + isPingable(device) { + return device.type === 'Router' && (device.powerSource && device.powerSource !== 'Battery'); + } + getAllPingableDevices() { - return this.zigbee.getAllClients() - .filter((d) => d.type === 'Router' && (d.powerSource && d.powerSource !== 'Battery')); + return this.zigbee.getAllClients().filter((d) => this.isPingable(d)); } onMQTTConnected() { @@ -102,7 +105,7 @@ class DeviceAvailabilityHandler { onZigbeeMessage(message, device, mappedDevice) { // When a zigbee message from a device is received we know the device is still alive. // => reset the timer. - if (device) { + if (device && this.isPingable(this.zigbee.getDevice(device.ieeeAddr))) { this.setTimer(device.ieeeAddr); } }