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

* Fix regionname
* Fix SAT
* Improve log line

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
lsiepel 2024-12-03 19:22:29 +01:00 committed by GitHub
parent 5a27b0e752
commit d0ea14f441
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -68,10 +68,16 @@ public class GPSTrackerTriggerSwitchProfile implements TriggerProfile {
@Override @Override
public void onTriggerFromHandler(String payload) { public void onTriggerFromHandler(String payload) {
if (payload.startsWith(regionName)) { if (!payload.contains("/")) {
OnOffType state = OnOffType.from(payload.endsWith("enter")); 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); 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);
} }
} }
} }