2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.robonect.internal.model.cmd;
15 import org.openhab.binding.robonect.internal.RobonectClient;
19 * The mode commands sets the mower into the corresponding mode. In addition to the mowers standard modes
20 * (HOME, MAN, AUTO) the module supports following modes:
22 * EOD (End Of Day): The mower is set into HOME mode until midnight. After midnight the module sets the mower in AUTO
24 * JOB: The JOB mode triggers a JOB and supports following additional parameter:
25 * * remoteStart: where to start the job (STANDARD, REMOTE_1 or REMOTE_2)
26 * * after: The mode to be set after the JOB is done. Allowed are all except JOB.
27 * * start: the start time in the form HH:MM (H=Hour,M=Minute)
28 * * end: the end time in the form HH:MM (H=Hour,M=Minute)
29 * * duration: mowing time in minutes (in combination with start or end time)
31 * @author Marco Meyer - Initial contribution
33 public class ModeCommand implements Command {
36 * The available modes. See class documentation for the meanings.
48 Mode(int code, String cmd) {
55 * The available remoteStart values.
57 public enum RemoteStart {
60 * Start immediatly at the docking station.
65 * Start at the configured remote 1 location.
70 * Start at the conifugred remote 2 location.
76 RemoteStart(int code) {
83 private RemoteStart remoteStart;
91 private Integer duration;
93 public ModeCommand(Mode mode) {
98 * sets the desired remoteStart option.
100 * @param remoteStart - the remoteStart option.
101 * @return - the command instance.
103 public ModeCommand withRemoteStart(RemoteStart remoteStart) {
104 this.remoteStart = remoteStart;
109 * set the mode after the job is done.
111 * @param afterMode - the desired mode after job execution.
112 * @return - the command instance.
114 public ModeCommand withAfter(Mode afterMode) {
115 this.after = afterMode;
120 * The desired start time in the format HH:MM (H=Hour, M=Minute)
122 * @param startTime - the start time.
123 * @return - the command instance.
125 public ModeCommand withStart(String startTime) {
126 this.start = startTime;
131 * The desired end time in the format HH:MM (H=Hour, M=Minute)
133 * @param endTime - the end time.
134 * @return - the command instance.
136 public ModeCommand withEnd(String endTime) {
142 * Sets the duration in minutes.
144 * @param durationInMinutes - the duration in minutes.
145 * @return - the command instance.
147 public ModeCommand withDuration(Integer durationInMinutes) {
148 this.duration = durationInMinutes;
155 * @param baseURL - will be passed by the {@link RobonectClient} in the form
156 * http://xxx.xxx.xxx/json?
160 public String toCommandURL(String baseURL) {
161 StringBuilder sb = new StringBuilder(baseURL);
162 sb.append("?cmd=mode&mode=");
171 if (remoteStart != null) {
172 sb.append("&remotestart=");
173 sb.append(remoteStart.code);
176 sb.append("&after=");
177 sb.append(after.code);
180 sb.append("&start=");
187 if (duration != null) {
188 sb.append("&duration=");
193 return sb.toString();