Implement availability blacklist. #775

This commit is contained in:
Koen Kanters 2019-02-02 18:10:25 +01:00
parent 054892641b
commit 5828ee9989
3 changed files with 13 additions and 0 deletions

View File

@ -64,4 +64,7 @@ advanced:
# Availability timeout in seconds, disabled by default (0).
# When enabled, devices will be checked if they are still online.
availability_timeout: 0,
# Blacklist devices from being checked for availability
availability_blacklist:
- DEVICE_FRIENDLY_NAME
```

View File

@ -22,9 +22,18 @@ class Availability {
this.timers = {};
this.pending = [];
this.state = {};
// Initialize blacklist
this.blacklist = settings.get().advanced.availability_blacklist.map((e) => {
return settings.getIeeeAddrByFriendlyName(e) || e;
});
}
isPingable(device) {
if (this.blacklist.includes(device.ieeeAddr)) {
return false;
}
if (pingableDevices.find((d) => d.zigbeeModel.includes(device.modelId))) {
return true;
}

View File

@ -23,6 +23,7 @@ const defaults = {
// Availability timeout in seconds, disabled by default.
availability_timeout: 0,
availability_blacklist: [],
/**
* Home Assistant requires ALL attributes to be present in ALL MQTT messages send by the device.