From 75e6bb781f9a210698ccb91486684bcdaad8516e Mon Sep 17 00:00:00 2001 From: lsiepel Date: Tue, 3 Dec 2024 19:22:29 +0100 Subject: [PATCH] [gpstracker] Fix handling ambigious region names (#17805) * Fix regionname * Fix SAT * Improve log line Signed-off-by: Leo Siepel Signed-off-by: Ciprian Pascu --- .../profile/GPSTrackerTriggerSwitchProfile.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.gpstracker/src/main/java/org/openhab/binding/gpstracker/internal/profile/GPSTrackerTriggerSwitchProfile.java b/bundles/org.openhab.binding.gpstracker/src/main/java/org/openhab/binding/gpstracker/internal/profile/GPSTrackerTriggerSwitchProfile.java index 9da015dee3b..a3b1db14cc0 100644 --- a/bundles/org.openhab.binding.gpstracker/src/main/java/org/openhab/binding/gpstracker/internal/profile/GPSTrackerTriggerSwitchProfile.java +++ b/bundles/org.openhab.binding.gpstracker/src/main/java/org/openhab/binding/gpstracker/internal/profile/GPSTrackerTriggerSwitchProfile.java @@ -68,10 +68,16 @@ public class GPSTrackerTriggerSwitchProfile implements TriggerProfile { @Override public void onTriggerFromHandler(String payload) { - if (payload.startsWith(regionName)) { - OnOffType state = OnOffType.from(payload.endsWith("enter")); + if (!payload.contains("/")) { + logger.debug("Transition trigger with mallformed payload: '{}', missing '\''", payload); + return; + } + String[] splitted = payload.split("/"); + if (splitted[0].equals(regionName)) { + OnOffType state = OnOffType.from("enter".equals(splitted[1])); callback.sendCommand(state); - logger.debug("Transition trigger {} handled for region {} by profile: {}", payload, regionName, state); + logger.debug("Transition trigger with payload: '{}' handled for region {} by profile: {}", payload, + regionName, state); } } }