From a7ec511dca2249a7dc1a2c67594aa8c751bd0d22 Mon Sep 17 00:00:00 2001 From: Bernhard Bauer Date: Sat, 30 Oct 2021 13:14:24 +0200 Subject: [PATCH] [automower] Support for GPS coordinates provided by API (#11323) * Added support for the 50 GPS waypoints provided by the Automower API Signed-off-by: Bernhard Bauer * Added Channel for last position Signed-off-by: Bernhard Bauer * Fixed channel of position 40 Signed-off-by: Bernhard Bauer * Updated Doku + mvn:spotless apply Signed-off-by: Bernhard Bauer * Inputs from static code analysis Signed-off-by: Bernhard Bauer * Removed channel groups Signed-off-by: Bernhard Bauer * mvn spotless:apply Signed-off-by: Bernhard Bauer --- .../org.openhab.binding.automower/README.md | 135 +++++++++++++----- .../internal/AutomowerBindingConstants.java | 71 ++++++--- .../api/automowerconnect/dto/MowerData.java | 15 ++ .../api/automowerconnect/dto/Position.java | 37 +++++ .../internal/things/AutomowerCommand.java | 2 + .../internal/things/AutomowerHandler.java | 13 ++ .../resources/OH-INF/thing/thing-types.xml | 65 +++++++++ 7 files changed, 285 insertions(+), 53 deletions(-) create mode 100644 bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/api/automowerconnect/dto/Position.java diff --git a/bundles/org.openhab.binding.automower/README.md b/bundles/org.openhab.binding.automower/README.md index 70a3b0f59371a..076bfeafb017d 100644 --- a/bundles/org.openhab.binding.automower/README.md +++ b/bundles/org.openhab.binding.automower/README.md @@ -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 diff --git a/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/AutomowerBindingConstants.java b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/AutomowerBindingConstants.java index 14bebefa09d2e..e43bc53525605 100644 --- a/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/AutomowerBindingConstants.java +++ b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/AutomowerBindingConstants.java @@ -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 CHANNEL_POSITIONS = new ArrayList( + 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"; diff --git a/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/api/automowerconnect/dto/MowerData.java b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/api/automowerconnect/dto/MowerData.java index 7dc8e7740ceac..fa7410225c693 100644 --- a/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/api/automowerconnect/dto/MowerData.java +++ b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/api/automowerconnect/dto/MowerData.java @@ -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 positions = new ArrayList(); public System getSystem() { return system; @@ -70,4 +73,16 @@ public Metadata getMetadata() { public void setMetadata(Metadata metadata) { this.metadata = metadata; } + + public void addPosition(Position position) { + this.positions.add(position); + } + + public ArrayList 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 index 0000000000000..beaa270286909 --- /dev/null +++ b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/api/automowerconnect/dto/Position.java @@ -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; + } +} diff --git a/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/things/AutomowerCommand.java b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/things/AutomowerCommand.java index 54dcfd6fa9b68..2a9960ce0cf7a 100644 --- a/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/things/AutomowerCommand.java +++ b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/things/AutomowerCommand.java @@ -17,11 +17,13 @@ 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"), diff --git a/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/things/AutomowerHandler.java b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/things/AutomowerHandler.java index ebca1fee96608..e41d55fe164e2 100644 --- a/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/things/AutomowerHandler.java +++ b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/things/AutomowerHandler.java @@ -16,6 +16,7 @@ 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.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 @@ private void updateChannelState(@Nullable Mower mower) { 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 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()))); + + } } } diff --git a/bundles/org.openhab.binding.automower/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.automower/src/main/resources/OH-INF/thing/thing-types.xml index 5172a21455bdc..087e7691c8f8d 100644 --- a/bundles/org.openhab.binding.automower/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.automower/src/main/resources/OH-INF/thing/thing-types.xml @@ -45,6 +45,7 @@ An automatic lawn mower + @@ -56,12 +57,68 @@ + + + + + Last Position + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -85,6 +142,7 @@ + String @@ -201,6 +259,13 @@ + + Point + + The channel providing a waypoint of the mower's activity. + + + Number