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