From 74cdde23b912578b1f50a6762e268b81e402277e Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Tue, 1 Jan 2019 22:15:05 +0100 Subject: [PATCH] Prevent battery devices to be checked for availability. https://github.com/Koenkk/zigbee2mqtt/issues/775 --- lib/extension/deviceAvailability.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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); } }