2 * Copyright (c) 2010-2020 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.opensprinkler.internal.api;
15 import java.math.BigDecimal;
17 import org.openhab.binding.opensprinkler.internal.api.exception.CommunicationApiException;
18 import org.openhab.binding.opensprinkler.internal.api.exception.GeneralApiException;
19 import org.openhab.binding.opensprinkler.internal.model.NoCurrentDrawSensorException;
20 import org.openhab.binding.opensprinkler.internal.model.StationProgram;
23 * The {@link OpenSprinklerApi} interface defines the functions which are
24 * controllable on the OpenSprinkler API interface.
26 * @author Chris Graham - Initial contribution
28 public interface OpenSprinklerApi {
30 * Whether the device entered manual mode and accepts API requests to control the stations.
32 * @return True if this API interface is connected to the Open Sprinkler API. False otherwise.
34 public abstract boolean isManualModeEnabled();
37 * Enters the "manual" mode of the device so that API requests are accepted.
41 public abstract void enterManualMode() throws CommunicationApiException;
44 * Disables the manual mode, if it is enabled.
48 public abstract void leaveManualMode() throws CommunicationApiException;
51 * Starts a station on the OpenSprinkler device for the specified duration.
53 * @param station Index of the station to open starting at 0.
54 * @param duration The duration in seconds for how long the station should be turned on.
57 public abstract void openStation(int station, BigDecimal duration)
58 throws CommunicationApiException, GeneralApiException;
61 * Closes a station on the OpenSprinkler device.
63 * @param station Index of the station to open starting at 0.
66 public abstract void closeStation(int station) throws CommunicationApiException, GeneralApiException;
69 * Returns the state of a station on the OpenSprinkler device.
71 * @param station Index of the station to open starting at 0.
72 * @return True if the station is open, false if it is closed or cannot determine.
75 public abstract boolean isStationOpen(int station) throws GeneralApiException, CommunicationApiException;
78 * Returns the current program data of the requested station.
80 * @param station Index of the station to request data from
81 * @return StationProgram
84 public abstract StationProgram retrieveProgram(int station) throws CommunicationApiException;
87 * Returns the state of rain detection on the OpenSprinkler device.
89 * @return True if rain is detected, false if not or cannot determine.
92 public abstract boolean isRainDetected() throws CommunicationApiException;
95 * Returns the current draw of all connected zones of the OpenSprinkler device in milliamperes.
97 * @return current draw in milliamperes
98 * @throws CommunicationApiException
101 public abstract int currentDraw() throws CommunicationApiException, NoCurrentDrawSensorException;
104 * Returns the water level in %.
106 * @return waterLevel in %
107 * @throws CommunicationApiException
110 public abstract int waterLevel() throws CommunicationApiException;
113 * Returns the number of total stations that are controllable from the OpenSprinkler
116 * @return Number of stations as an int.
119 public abstract int getNumberOfStations() throws Exception;
122 * Returns the firmware version number.
124 * @return The firmware version of the OpenSprinkler device as an int.
127 public abstract int getFirmwareVersion() throws CommunicationApiException;