Skip to content
Snippets Groups Projects
Commit 4f3fa657 authored by Gregor Maier's avatar Gregor Maier
Browse files

Add hook to DeviceManager to allow discarding entities before learning.

parent 50f6aa6e
No related branches found
No related tags found
No related merge requests found
......@@ -1071,7 +1071,11 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
} else {
// If the secondary index does not contain the entity,
// create a new Device object containing the entity, and
// generate a new device ID
// generate a new device ID. However, we first check if
// the entity is allowed (e.g., for spoofing protection)
if (!isEntityAllowed(entity, entityClass)) {
return null;
}
synchronized (deviceKeyLock) {
deviceKey = Long.valueOf(deviceKeyCounter++);
}
......@@ -1102,6 +1106,9 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
break;
}
if (!isEntityAllowed(entity, device.getEntityClass())) {
return null;
}
int entityindex = -1;
if ((entityindex = device.entityIndex(entity)) >= 0) {
// update timestamp on the found entity
......@@ -1205,6 +1212,10 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
return device;
}
protected boolean isEntityAllowed(Entity entity, IEntityClass entityClass) {
return true;
}
protected EnumSet<DeviceField> findChangedFields(Device device,
Entity newEntity) {
EnumSet<DeviceField> changedFields =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment