Skip to content

Commit

Permalink
Prevent battery devices to be checked for availability. #775
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Jan 1, 2019
1 parent 57aefe4 commit 74cdde2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/extension/deviceAvailability.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 74cdde2

Please sign in to comment.