]> git.basschouten.com Git - openhab-addons.git/commitdiff
[gpstracker] Fix `NumberFormatException` (#15337)
authorlsiepel <leosiepel@gmail.com>
Sat, 5 Aug 2023 20:41:12 +0000 (22:41 +0200)
committerGitHub <noreply@github.com>
Sat, 5 Aug 2023 20:41:12 +0000 (22:41 +0200)
Signed-off-by: lsiepel <leosiepel@gmail.com>
bundles/org.openhab.binding.gpstracker/src/main/java/org/openhab/binding/gpstracker/internal/message/dto/LocationMessage.java

index 05ad029c4183d186e45616bb37f54b6df046baca..58b8b99c734460c51e307ac7de1bce9ef44b8f53 100644 (file)
@@ -50,10 +50,10 @@ public class LocationMessage {
     private String trackerId = "";
 
     /**
-     * Altitude (iOS, Android/integer/meters/optional)
+     * Altitude (iOS, Android/float/meters/optional)
      */
     @SerializedName("alt")
-    private Integer altitude = Integer.MIN_VALUE;
+    private BigDecimal altitude = BigDecimal.ZERO;
 
     /**
      * Latitude (iOS, Android/float/meters/required)
@@ -109,7 +109,8 @@ public class LocationMessage {
      * @return Conversion result
      */
     public State getTrackerLocation() {
-        if (!BigDecimal.ZERO.equals(latitude) && !BigDecimal.ZERO.equals(longitude) && Integer.MIN_VALUE != altitude) {
+        if (!BigDecimal.ZERO.equals(latitude) && !BigDecimal.ZERO.equals(longitude)
+                && !BigDecimal.ZERO.equals(altitude)) {
             return new PointType(new DecimalType(latitude), new DecimalType(longitude), new DecimalType(altitude));
         } else if (!BigDecimal.ZERO.equals(latitude) && !BigDecimal.ZERO.equals(longitude)) {
             return new PointType(new DecimalType(latitude), new DecimalType(longitude));