]> git.basschouten.com Git - openhab-addons.git/commitdiff
[automower] Support for GPS coordinates provided by API (#11323)
authorBernhard Bauer <bern77@gmail.com>
Sat, 30 Oct 2021 11:14:24 +0000 (13:14 +0200)
committerGitHub <noreply@github.com>
Sat, 30 Oct 2021 11:14:24 +0000 (13:14 +0200)
* Added support for the 50 GPS waypoints provided by the Automower API

Signed-off-by: Bernhard Bauer <bern77@gmail.com>
* Added Channel for last position

Signed-off-by: Bernhard Bauer <bern77@gmail.com>
* Fixed channel of position 40

Signed-off-by: Bernhard Bauer <bern77@gmail.com>
* Updated Doku + mvn:spotless apply

Signed-off-by: Bernhard Bauer <bern77@gmail.com>
* Inputs from static code analysis

Signed-off-by: Bernhard Bauer <bern77@gmail.com>
* Removed channel groups

Signed-off-by: Bernhard Bauer <bern77@gmail.com>
* mvn spotless:apply

Signed-off-by: Bernhard Bauer <bern77@gmail.com>
bundles/org.openhab.binding.automower/README.md
bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/AutomowerBindingConstants.java
bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/api/automowerconnect/dto/MowerData.java
bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/api/automowerconnect/dto/Position.java [new file with mode: 0644]
bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/things/AutomowerCommand.java
bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/things/AutomowerHandler.java
bundles/org.openhab.binding.automower/src/main/resources/OH-INF/thing/thing-types.xml

index 70a3b0f59371a05c75cf0d2c4e59c8e1ed36a25c..076bfeafb017df6a322cbb84d489ecdeddff4fbe 100644 (file)
@@ -40,25 +40,91 @@ With the default value of 10min this would mean ~4300 requests per month per sin
 
 ## Channels
 
+### Status Channels
 
 | channel                 | type     | access mode | description                                                                                                                                                                 |
 |-------------------------|----------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| mower-status#mode                     | String   | R | The current mode (MAIN_AREA, SECONDARY_AREA, HOME, DEMO, UNKNOWN)                                                                                                |
-| mower-status#activity                 | String   | R | The current activity (UNKNOWN, NOT_APPLICABLE, MOWING, GOING_HOME, CHARGING, LEAVING, PARKED_IN_CS, STOPPED_IN_GARDEN)                                           |
-| mower-status#state                   | String   | R | The current state (UNKNOWN, NOT_APPLICABLE, PAUSED, IN_OPERATION, WAIT_UPDATING, WAIT_POWER_UP, RESTRICTED_NONE, RESTRICTED_WEEK_SCHEDULE, RESTRICTED_PARK_OVERRIDE, RESTRICTED_SENSOR, RESTRICTED_DAILY_LIMIT, OFF, STOPPED, ERROR, FATAL_ERROR, ERROR_AT_POWER_UP)  |
-| mower-status#last-update              | DateTime | R | The time when the automower updated its states                                                                                                                   |
-| mower-status#battery                  | Number   | R | The battery state of charge in percent                                                                                                                           |
-| mower-status#error-code               | Number   | R | The current error code                                                                                                                                           |
-| mower-status#error-timestamp         | DateTime | R | The timestamp when the current error occurred                                                                                                                    |
-| mower-status#planner-next-start      | DateTime | R | The time for the next auto start. If the mower is charging then the value is the estimated time when it will be leaving the charging station. If the mower is about to start now, the value is NULL.                                                                  |
-| mower-status#planner-override-action | String   | R | The action that overrides current planner operation.                                                                                                                                                                                                                  |
-| mower-status#calendar-tasks          | String   | R | The JSON with the information about Automower planner.                                                                                                    |
-| mower#start                       | Number   | W | Starts the automower for a duration                     |
-| mower#resume_schedule             | Switch   | W | Resumes the Automower schedule                          |
-| mower#pause                       | Switch   | W | Pause the Automower                                     |
-| mower#park                        | Number   | W | Park the Automower for a duration                       |
-| mower#park_until_next_schedule    | Switch   | W | Park the Automower until next schedule                  |
-| mower#park_until_further_notice   | Switch   | W | Park the Automower until further notice.                |
+| mode                    | String   | R | The current mode (MAIN_AREA, SECONDARY_AREA, HOME, DEMO, UNKNOWN)                                                                                                |
+| activity                | String   | R | The current activity (UNKNOWN, NOT_APPLICABLE, MOWING, GOING_HOME, CHARGING, LEAVING, PARKED_IN_CS, STOPPED_IN_GARDEN)                                           |
+| state                   | String   | R | The current state (UNKNOWN, NOT_APPLICABLE, PAUSED, IN_OPERATION, WAIT_UPDATING, WAIT_POWER_UP, RESTRICTED_NONE, RESTRICTED_WEEK_SCHEDULE, RESTRICTED_PARK_OVERRIDE, RESTRICTED_SENSOR, RESTRICTED_DAILY_LIMIT, OFF, STOPPED, ERROR, FATAL_ERROR, ERROR_AT_POWER_UP)  |
+| last-update             | DateTime | R | The time when the automower updated its states                                                                                                                   |
+| battery                 | Number   | R | The battery state of charge in percent                                                                                                                           |
+| error-code              | Number   | R | The current error code                                                                                                                                           |
+| error-timestamp         | DateTime | R | The timestamp when the current error occurred                                                                                                                    |
+| planner-next-start      | DateTime | R | The time for the next auto start. If the mower is charging then the value is the estimated time when it will be leaving the charging station. If the mower is about to start now, the value is NULL.                                                                  |
+| planner-override-action | String   | R | The action that overrides current planner operation.                                                                                                                                                                                                                  |
+| calendar-tasks          | String   | R | The JSON with the information about Automower planner.                                                                                                    |
+
+### Command Channels
+
+| channel                     | type     | access mode | description                                                                                                                                                                 |
+|-----------------------------|----------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| start                       | Number   | W | Starts the automower for a duration                     |
+| resume_schedule             | Switch   | W | Resumes the Automower schedule                          |
+| pause                       | Switch   | W | Pause the Automower                                     |
+| park                        | Number   | W | Park the Automower for a duration                       |
+| park_until_next_schedule    | Switch   | W | Park the Automower until next schedule                  |
+| park_until_further_notice   | Switch   | W | Park the Automower until further notice.                |
+
+### Position Channels
+
+These channels hold the last 50 GPS positions recorded by the Automower, thus describing the path it followed.
+Position 01 is the latest recorded position, the other positions are pushed back, thus removing the previous position 50 from the list because it is replaced by the previous position 49.
+Channel `last-position` is always identical with channel `position01` and thus provides more convenient access if only the latest GPS information is required by the user.
+
+| channel    | type     | access mode | description                                                                                                                                                                 |
+|------------|----------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| position01 | Location | R | GPS Position 01 |
+| position02 | Location | R | GPS Position 02 |
+| position03 | Location | R | GPS Position 03 |
+| position04 | Location | R | GPS Position 04 |
+| position05 | Location | R | GPS Position 05 |
+| position06 | Location | R | GPS Position 06 |
+| position07 | Location | R | GPS Position 07 |
+| position08 | Location | R | GPS Position 08 |
+| position09 | Location | R | GPS Position 09 |
+| position10 | Location | R | GPS Position 10 |
+| position11 | Location | R | GPS Position 11 |
+| position12 | Location | R | GPS Position 12 |
+| position13 | Location | R | GPS Position 13 |
+| position14 | Location | R | GPS Position 14 |
+| position15 | Location | R | GPS Position 15 |
+| position16 | Location | R | GPS Position 16 |
+| position17 | Location | R | GPS Position 17 |
+| position18 | Location | R | GPS Position 18 |
+| position19 | Location | R | GPS Position 19 |
+| position20 | Location | R | GPS Position 20 |
+| position21 | Location | R | GPS Position 21 |
+| position22 | Location | R | GPS Position 22 |
+| position23 | Location | R | GPS Position 23 |
+| position24 | Location | R | GPS Position 24 |
+| position25 | Location | R | GPS Position 25 |
+| position26 | Location | R | GPS Position 26 |
+| position27 | Location | R | GPS Position 27 |
+| position28 | Location | R | GPS Position 28 |
+| position29 | Location | R | GPS Position 29 |
+| position30 | Location | R | GPS Position 30 |
+| position31 | Location | R | GPS Position 31 |
+| position32 | Location | R | GPS Position 32 |
+| position33 | Location | R | GPS Position 33 |
+| position34 | Location | R | GPS Position 34 |
+| position35 | Location | R | GPS Position 35 |
+| position36 | Location | R | GPS Position 36 |
+| position37 | Location | R | GPS Position 37 |
+| position38 | Location | R | GPS Position 38 |
+| position39 | Location | R | GPS Position 39 |
+| position40 | Location | R | GPS Position 40 |
+| position41 | Location | R | GPS Position 41 |
+| position42 | Location | R | GPS Position 42 |
+| position43 | Location | R | GPS Position 43 |
+| position44 | Location | R | GPS Position 44 |
+| position45 | Location | R | GPS Position 45 |
+| position46 | Location | R | GPS Position 46 |
+| position47 | Location | R | GPS Position 47 |
+| position48 | Location | R | GPS Position 48 |
+| position49 | Location | R | GPS Position 49 |
+| position50 | Location | R | GPS Position 50 |
+| last-position | Location | R | Last GPS Position (identical with positions#position01) |
 
 
 ## Actions
@@ -87,23 +153,26 @@ The following actions are available for `automower`things:
 
 ### automower.items
 
-       String Automower_Mode               "Mode [%s]"                   { channel="automower:automower:mybridge:myAutomower:mower-status#mode" }
-       String Automower_Activity           "Activity [%s]"                  { channel="automower:automower:mybridge:myAutomower:mower-status#activity" }
-       String Automower_State              "State [%s]"                     { channel="automower:automower:mybridge:myAutomower:mower-status#state" }
-       DateTime Automower_Last_Update      "Last Update"            { channel="automower:automower:mybridge:myAutomower:mower-status#last-update" }
-       Number Automower_Battery            "Battery [%d %%]"                { channel="automower:automower:mybridge:myAutomower:mower-status#battery" }
-       Number Automower_Error_Code         "Error Code [%d]"             { channel="automower:automower:mybridge:myAutomower:mower-status#error-code" }
-       DateTime Automower_Error_Time       "Error Time"             { channel="automower:automower:mybridge:myAutomower:mower-status#error-timestamp" }
-       String Automower_Override_Action    "Override Action [%s]"        { channel="automower:automower:mybridge:myAutomower:mower-status#planner-override-action" }
-       DateTime Automower_Next_Start_Time  "Next Start Time"        { channel="automower:automower:mybridge:myAutomower:mower-status#planner-next-start" }
-       String Automower_Calendar_Tasks     "Planned Tasks [%s]"          { channel="automower:automower:mybridge:myAutomower:mower-status#calendar-tasks" }
-
-       Number Automower_Command_Start               "Start mowing for duration [%d min]"    { channel="automower:automower:mybridge:myAutomower:mower#start" }
-       Switch Automower_Command_Resume              "Resume the schedule"          { channel="automower:automower:mybridge:myAutomower:mower#resume_schedule" }
-       Switch Automower_Command_Pause               "Pause the automower"          { channel="automower:automower:mybridge:myAutomower:mower#pause" }
-       Number Automower_Command_Park                "Park for duration [%d min]"            { channel="automower:automower:mybridge:myAutomower:mower#park" }
-       Switch Automower_Command_Park_Next_Schedule  "Park until next schedule"     { channel="automower:automower:mybridge:myAutomower:mower#park_until_next_schedule" }
-       Switch Automower_Command_Park_Notice         "Park until further notice"    { channel="automower:automower:mybridge:myAutomower:mower#park_until_further_notice" }
+       String Automower_Mode               "Mode [%s]"                   { channel="automower:automower:mybridge:myAutomower:mode" }
+       String Automower_Activity           "Activity [%s]"                  { channel="automower:automower:mybridge:myAutomower:activity" }
+       String Automower_State              "State [%s]"                     { channel="automower:automower:mybridge:myAutomower:state" }
+       DateTime Automower_Last_Update      "Last Update"            { channel="automower:automower:mybridge:myAutomower:last-update" }
+       Number Automower_Battery            "Battery [%d %%]"                { channel="automower:automower:mybridge:myAutomower:battery" }
+       Number Automower_Error_Code         "Error Code [%d]"             { channel="automower:automower:mybridge:myAutomower:error-code" }
+       DateTime Automower_Error_Time       "Error Time"             { channel="automower:automower:mybridge:myAutomower:error-timestamp" }
+       String Automower_Override_Action    "Override Action [%s]"        { channel="automower:automower:mybridge:myAutomower:planner-override-action" }
+       DateTime Automower_Next_Start_Time  "Next Start Time"        { channel="automower:automower:mybridge:myAutomower:planner-next-start" }
+       String Automower_Calendar_Tasks     "Planned Tasks [%s]"          { channel="automower:automower:mybridge:myAutomower:calendar-tasks" }
+
+       Number Automower_Command_Start               "Start mowing for duration [%d min]"    { channel="automower:automower:mybridge:myAutomower:start" }
+       Switch Automower_Command_Resume              "Resume the schedule"          { channel="automower:automower:mybridge:myAutomower:resume_schedule" }
+       Switch Automower_Command_Pause               "Pause the automower"          { channel="automower:automower:mybridge:myAutomower:pause" }
+       Number Automower_Command_Park                "Park for duration [%d min]"            { channel="automower:automower:mybridge:myAutomower:park" }
+       Switch Automower_Command_Park_Next_Schedule  "Park until next schedule"     { channel="automower:automower:mybridge:myAutomower:park_until_next_schedule" }
+       Switch Automower_Command_Park_Notice         "Park until further notice"    { channel="automower:automower:mybridge:myAutomower:park_until_further_notice" }
+
+    Location Automower_Last_Position    "Last Position" { channel="automower:automower:mybridge:myAutomower:last-position" }
+   
 
 ### automower.sitemap
 
index 14bebefa09d2e72be7ab79721852c90578ae6ffe..e43bc53525605e73fa452c7a18d3bdce5b46373d 100644 (file)
@@ -12,6 +12,9 @@
  */
 package org.openhab.binding.automower.internal;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.thing.ThingTypeUID;
 
@@ -31,26 +34,54 @@ public class AutomowerBindingConstants {
     // generic thing types
     public static final ThingTypeUID THING_TYPE_AUTOMOWER = new ThingTypeUID(BINDING_ID, "automower");
 
-    // List of all Channel ids
-    public static final String CHANNEL_STATUS_NAME = "name";
-    public static final String CHANNEL_STATUS_MODE = "mode";
-    public static final String CHANNEL_STATUS_ACTIVITY = "activity";
-    public static final String CHANNEL_STATUS_STATE = "state";
-    public static final String CHANNEL_STATUS_LAST_UPDATE = "last-update";
-    public static final String CHANNEL_STATUS_BATTERY = "battery";
-    public static final String CHANNEL_STATUS_ERROR_CODE = "error-code";
-    public static final String CHANNEL_STATUS_ERROR_TIMESTAMP = "error-timestamp";
-    public static final String CHANNEL_PLANNER_NEXT_START = "planner-next-start";
-    public static final String CHANNEL_PLANNER_OVERRIDE_ACTION = "planner-override-action";
-    public static final String CHANNEL_CALENDAR_TASKS = "calendar-tasks";
-
-    // Command channels
-    public static final String CHANNEL_COMMAND_START = "start";
-    public static final String CHANNEL_COMMAND_RESUME_SCHEDULE = "resume_schedule";
-    public static final String CHANNEL_COMMAND_PAUSE = "pause";
-    public static final String CHANNEL_COMMAND_PARK = "park";
-    public static final String CHANNEL_COMMAND_PARK_UNTIL_NEXT_SCHEDULE = "park_until_next_schedule";
-    public static final String CHANNEL_COMMAND_PARK_UNTIL_NOTICE = "park_until_further_notice";
+    // List of all status Channel ids
+    public static final String GROUP_STATUS = ""; // no channel group in use at the moment, we'll possibly introduce
+                                                  // this in a future release
+    public static final String CHANNEL_STATUS_NAME = GROUP_STATUS + "name";
+    public static final String CHANNEL_STATUS_MODE = GROUP_STATUS + "mode";
+    public static final String CHANNEL_STATUS_ACTIVITY = GROUP_STATUS + "activity";
+    public static final String CHANNEL_STATUS_STATE = GROUP_STATUS + "state";
+    public static final String CHANNEL_STATUS_LAST_UPDATE = GROUP_STATUS + "last-update";
+    public static final String CHANNEL_STATUS_BATTERY = GROUP_STATUS + "battery";
+    public static final String CHANNEL_STATUS_ERROR_CODE = GROUP_STATUS + "error-code";
+    public static final String CHANNEL_STATUS_ERROR_TIMESTAMP = GROUP_STATUS + "error-timestamp";
+    public static final String CHANNEL_PLANNER_NEXT_START = GROUP_STATUS + "planner-next-start";
+    public static final String CHANNEL_PLANNER_OVERRIDE_ACTION = GROUP_STATUS + "planner-override-action";
+    public static final String CHANNEL_CALENDAR_TASKS = GROUP_STATUS + "calendar-tasks";
+
+    // Position Channels ids
+    public static final String GROUP_POSITIONS = ""; // no channel group in use at the moment, we'll possibly
+                                                     // introduce
+    // this in a future release
+    public static final String LAST_POSITION = GROUP_POSITIONS + "last-position";
+    public static final ArrayList<String> CHANNEL_POSITIONS = new ArrayList<String>(
+            List.of(GROUP_POSITIONS + "position01", GROUP_POSITIONS + "position02", GROUP_POSITIONS + "position03",
+                    GROUP_POSITIONS + "position04", GROUP_POSITIONS + "position05", GROUP_POSITIONS + "position06",
+                    GROUP_POSITIONS + "position07", GROUP_POSITIONS + "position08", GROUP_POSITIONS + "position09",
+                    GROUP_POSITIONS + "position10", GROUP_POSITIONS + "position11", GROUP_POSITIONS + "position12",
+                    GROUP_POSITIONS + "position13", GROUP_POSITIONS + "position14", GROUP_POSITIONS + "position15",
+                    GROUP_POSITIONS + "position16", GROUP_POSITIONS + "position17", GROUP_POSITIONS + "position18",
+                    GROUP_POSITIONS + "position19", GROUP_POSITIONS + "position20", GROUP_POSITIONS + "position21",
+                    GROUP_POSITIONS + "position22", GROUP_POSITIONS + "position23", GROUP_POSITIONS + "position24",
+                    GROUP_POSITIONS + "position25", GROUP_POSITIONS + "position26", GROUP_POSITIONS + "position27",
+                    GROUP_POSITIONS + "position28", GROUP_POSITIONS + "position29", GROUP_POSITIONS + "position30",
+                    GROUP_POSITIONS + "position31", GROUP_POSITIONS + "position32", GROUP_POSITIONS + "position33",
+                    GROUP_POSITIONS + "position34", GROUP_POSITIONS + "position35", GROUP_POSITIONS + "position36",
+                    GROUP_POSITIONS + "position37", GROUP_POSITIONS + "position38", GROUP_POSITIONS + "position39",
+                    GROUP_POSITIONS + "position40", GROUP_POSITIONS + "position41", GROUP_POSITIONS + "position42",
+                    GROUP_POSITIONS + "position43", GROUP_POSITIONS + "position44", GROUP_POSITIONS + "position45",
+                    GROUP_POSITIONS + "position46", GROUP_POSITIONS + "position47", GROUP_POSITIONS + "position48",
+                    GROUP_POSITIONS + "position49", GROUP_POSITIONS + "position50"));
+
+    // Command Channel ids
+    public static final String GROUP_COMMANDS = ""; // no channel group in use at the moment, we'll possibly introduce
+                                                    // this in a future release
+    public static final String CHANNEL_COMMAND_START = GROUP_COMMANDS + "start";
+    public static final String CHANNEL_COMMAND_RESUME_SCHEDULE = GROUP_COMMANDS + "resume_schedule";
+    public static final String CHANNEL_COMMAND_PAUSE = GROUP_COMMANDS + "pause";
+    public static final String CHANNEL_COMMAND_PARK = GROUP_COMMANDS + "park";
+    public static final String CHANNEL_COMMAND_PARK_UNTIL_NEXT_SCHEDULE = GROUP_COMMANDS + "park_until_next_schedule";
+    public static final String CHANNEL_COMMAND_PARK_UNTIL_NOTICE = GROUP_COMMANDS + "park_until_further_notice";
 
     // Automower properties
     public static final String AUTOMOWER_ID = "mowerId";
index 7dc8e7740ceac6a12d6417f9afbe28d44fe79758..fa7410225c6935525291c0f7b833e4de05f70c69 100644 (file)
@@ -12,6 +12,8 @@
  */
 package org.openhab.binding.automower.internal.rest.api.automowerconnect.dto;
 
+import java.util.ArrayList;
+
 /**
  * @author Markus Pfleger - Initial contribution
  */
@@ -22,6 +24,7 @@ public class MowerData {
     private Calendar calendar;
     private Planner planner;
     private Metadata metadata;
+    private ArrayList<Position> positions = new ArrayList<Position>();
 
     public System getSystem() {
         return system;
@@ -70,4 +73,16 @@ public class MowerData {
     public void setMetadata(Metadata metadata) {
         this.metadata = metadata;
     }
+
+    public void addPosition(Position position) {
+        this.positions.add(position);
+    }
+
+    public ArrayList<Position> getPositions() {
+        return this.positions;
+    }
+
+    public Position getLastPosition() {
+        return !this.positions.isEmpty() ? this.positions.get(0) : null;
+    }
 }
diff --git a/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/api/automowerconnect/dto/Position.java b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/api/automowerconnect/dto/Position.java
new file mode 100644 (file)
index 0000000..beaa270
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2010-2021 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.automower.internal.rest.api.automowerconnect.dto;
+
+/**
+ * @author Bernhard Bauer - Initial contribution
+ */
+public class Position {
+    private double latitude;
+    private double longitude;
+
+    public double getLatitude() {
+        return latitude;
+    }
+
+    public void setLatitude(double latitude) {
+        this.latitude = latitude;
+    }
+
+    public double getLongitude() {
+        return longitude;
+    }
+
+    public void setLongitude(double longitude) {
+        this.longitude = longitude;
+    }
+}
index 54dcfd6fa9b682a4c823709112fde0687d86c3f2..2a9960ce0cf7a626be942fffbcfd7b11d2b1cde8 100644 (file)
@@ -17,11 +17,13 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.thing.ChannelUID;
 
 /**
  * @author Markus Pfleger - Initial contribution
  */
+@NonNullByDefault
 public enum AutomowerCommand {
     START("Start", "mower#start"),
     RESUME_SCHEDULE("ResumeSchedule", "mower#resume_schedule"),
index ebca1fee96608cf52b7195715093fbe84aafb986..e41d55fe164e27e291374418b64c0a592585ddf0 100644 (file)
@@ -16,6 +16,7 @@ import static org.openhab.binding.automower.internal.AutomowerBindingConstants.*
 
 import java.time.Instant;
 import java.time.ZonedDateTime;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
@@ -34,12 +35,14 @@ import org.openhab.binding.automower.internal.actions.AutomowerActions;
 import org.openhab.binding.automower.internal.bridge.AutomowerBridge;
 import org.openhab.binding.automower.internal.bridge.AutomowerBridgeHandler;
 import org.openhab.binding.automower.internal.rest.api.automowerconnect.dto.Mower;
+import org.openhab.binding.automower.internal.rest.api.automowerconnect.dto.Position;
 import org.openhab.binding.automower.internal.rest.api.automowerconnect.dto.RestrictedReason;
 import org.openhab.binding.automower.internal.rest.api.automowerconnect.dto.State;
 import org.openhab.binding.automower.internal.rest.exceptions.AutomowerCommunicationException;
 import org.openhab.core.i18n.TimeZoneProvider;
 import org.openhab.core.library.types.DateTimeType;
 import org.openhab.core.library.types.DecimalType;
+import org.openhab.core.library.types.PointType;
 import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.types.StringType;
 import org.openhab.core.library.unit.Units;
@@ -313,6 +316,16 @@ public class AutomowerHandler extends BaseThingHandler {
 
             updateState(CHANNEL_CALENDAR_TASKS,
                     new StringType(gson.toJson(mower.getAttributes().getCalendar().getTasks())));
+
+            updateState(LAST_POSITION,
+                    new PointType(new DecimalType(mower.getAttributes().getLastPosition().getLatitude()),
+                            new DecimalType(mower.getAttributes().getLastPosition().getLongitude())));
+            ArrayList<Position> positions = mower.getAttributes().getPositions();
+            for (int i = 0; i < positions.size(); i++) {
+                updateState(CHANNEL_POSITIONS.get(i), new PointType(new DecimalType(positions.get(i).getLatitude()),
+                        new DecimalType(positions.get(i).getLongitude())));
+
+            }
         }
     }
 
index 5172a21455bdc4c2a8465eba84be318c5875e33b..087e7691c8f8d3750cbfe099380dd1c4d39c074a 100644 (file)
@@ -45,6 +45,7 @@
                <description>An automatic lawn mower</description>
 
                <channels>
+                       <!-- Status -->
                        <channel id="name" typeId="nameType"/>
                        <channel id="mode" typeId="modeType"/>
                        <channel id="activity" typeId="activityType"/>
                        <channel id="planner-next-start" typeId="plannerNextStartTimestampType"/>
                        <channel id="planner-override-action" typeId="plannerOverrideActionType"/>
                        <channel id="calendar-tasks" typeId="calendarTasksType"/>
+                       <!-- Commands -->
                        <channel id="start" typeId="start"/>
                        <channel id="resume_schedule" typeId="resumeSchedule"/>
                        <channel id="pause" typeId="pause"/>
                        <channel id="park" typeId="park"/>
                        <channel id="park_until_next_schedule" typeId="parkUntilNextSchedule"/>
                        <channel id="park_until_further_notice" typeId="parkUntilFurtherNotice"/>
+
+                       <!-- Positions -->
+                       <channel id="last-position" typeId="positionType">
+                               <description>Last Position</description>
+                       </channel>
+                       <channel id="position01" typeId="positionType"/>
+                       <channel id="position02" typeId="positionType"/>
+                       <channel id="position03" typeId="positionType"/>
+                       <channel id="position04" typeId="positionType"/>
+                       <channel id="position05" typeId="positionType"/>
+                       <channel id="position06" typeId="positionType"/>
+                       <channel id="position07" typeId="positionType"/>
+                       <channel id="position08" typeId="positionType"/>
+                       <channel id="position09" typeId="positionType"/>
+                       <channel id="position10" typeId="positionType"/>
+                       <channel id="position11" typeId="positionType"/>
+                       <channel id="position12" typeId="positionType"/>
+                       <channel id="position13" typeId="positionType"/>
+                       <channel id="position14" typeId="positionType"/>
+                       <channel id="position15" typeId="positionType"/>
+                       <channel id="position16" typeId="positionType"/>
+                       <channel id="position17" typeId="positionType"/>
+                       <channel id="position18" typeId="positionType"/>
+                       <channel id="position19" typeId="positionType"/>
+                       <channel id="position20" typeId="positionType"/>
+                       <channel id="position21" typeId="positionType"/>
+                       <channel id="position22" typeId="positionType"/>
+                       <channel id="position23" typeId="positionType"/>
+                       <channel id="position24" typeId="positionType"/>
+                       <channel id="position25" typeId="positionType"/>
+                       <channel id="position26" typeId="positionType"/>
+                       <channel id="position27" typeId="positionType"/>
+                       <channel id="position28" typeId="positionType"/>
+                       <channel id="position29" typeId="positionType"/>
+                       <channel id="position30" typeId="positionType"/>
+                       <channel id="position31" typeId="positionType"/>
+                       <channel id="position32" typeId="positionType"/>
+                       <channel id="position33" typeId="positionType"/>
+                       <channel id="position34" typeId="positionType"/>
+                       <channel id="position35" typeId="positionType"/>
+                       <channel id="position36" typeId="positionType"/>
+                       <channel id="position37" typeId="positionType"/>
+                       <channel id="position38" typeId="positionType"/>
+                       <channel id="position39" typeId="positionType"/>
+                       <channel id="position40" typeId="positionType"/>
+                       <channel id="position41" typeId="positionType"/>
+                       <channel id="position42" typeId="positionType"/>
+                       <channel id="position43" typeId="positionType"/>
+                       <channel id="position44" typeId="positionType"/>
+                       <channel id="position45" typeId="positionType"/>
+                       <channel id="position46" typeId="positionType"/>
+                       <channel id="position47" typeId="positionType"/>
+                       <channel id="position48" typeId="positionType"/>
+                       <channel id="position49" typeId="positionType"/>
+                       <channel id="position50" typeId="positionType"/>
                </channels>
 
                <properties>
 
        </thing-type>
 
+
        <channel-type id="nameType">
                <item-type>String</item-type>
                <label>Automower Name</label>
                <state readOnly="true"/>
        </channel-type>
 
+       <channel-type id="positionType">
+               <item-type>Point</item-type>
+               <label>GPS Position</label>
+               <description>The channel providing a waypoint of the mower's activity.</description>
+               <state readOnly="true"/>
+       </channel-type>
+
        <channel-type id="start">
                <item-type>Number</item-type>
                <label>Start with Duration</label>