[gpstracker] Fix handling ambigious region names (#17805)

* Fix regionname
* Fix SAT
* Improve log line

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
lsiepel 2024-12-03 19:22:29 +01:00 committed by Ciprian Pascu
parent 867786cb8c
commit 75e6bb781f

View File

@ -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);
}
}
}