Fixes source filter not working for `GenericEventTrigger` (#3837)

While reviewing https://github.com/openhab/openhab-js/pull/300,
I noticed that filtering by source `org.openhab.core.expire` was not possible.

This was because the specified source was checked against the event topic, which makes no sense at all given that different schemes.
Source filtering is done inside the `apply` method.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
pull/3838/head
Florian Hotze 2023-10-08 19:43:08 +02:00 committed by GitHub
parent e5518b9322
commit 176e23f296
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 7 deletions

View File

@ -74,9 +74,9 @@ public class GenericEventTriggerHandler extends BaseTriggerModuleHandler impleme
topicFilter = null;
}
if (module.getConfiguration().get(CFG_TYPES) != null) {
this.types = Set.of(((String) module.getConfiguration().get(CFG_TYPES)).split(","));
types = Set.of(((String) module.getConfiguration().get(CFG_TYPES)).split(","));
} else {
this.types = Set.of();
types = Set.of();
}
String payload = (String) module.getConfiguration().get(CFG_PAYLOAD);
if (!payload.isBlank()) {
@ -104,11 +104,8 @@ public class GenericEventTriggerHandler extends BaseTriggerModuleHandler impleme
public void receive(Event event) {
ModuleHandlerCallback callback = this.callback;
if (callback != null) {
logger.trace("Received Event: Source: {} Topic: {} Type: {} Payload: {}", event.getSource(),
event.getTopic(), event.getType(), event.getPayload());
if (!event.getTopic().contains(source)) {
return;
}
logger.trace("Received Event: Topic: {} Type: {} Source: {} Payload: {}", event.getTopic(), event.getType(),
event.getSource(), event.getPayload());
Map<String, Object> values = new HashMap<>();
values.put("event", event);