]> git.basschouten.com Git - openhab-addons.git/blob
c337ffa116c79409666e964b1878edff5519490f
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.opensprinkler.internal.api;
14
15 import java.math.BigDecimal;
16
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;
21
22 /**
23  * The {@link OpenSprinklerApi} interface defines the functions which are
24  * controllable on the OpenSprinkler API interface.
25  *
26  * @author Chris Graham - Initial contribution
27  */
28 public interface OpenSprinklerApi {
29     /**
30      * Whether the device entered manual mode and accepts API requests to control the stations.
31      *
32      * @return True if this API interface is connected to the Open Sprinkler API. False otherwise.
33      */
34     public abstract boolean isManualModeEnabled();
35
36     /**
37      * Enters the "manual" mode of the device so that API requests are accepted.
38      *
39      * @throws Exception
40      */
41     public abstract void enterManualMode() throws CommunicationApiException;
42
43     /**
44      * Disables the manual mode, if it is enabled.
45      *
46      * @throws Exception
47      */
48     public abstract void leaveManualMode() throws CommunicationApiException;
49
50     /**
51      * Starts a station on the OpenSprinkler device for the specified duration.
52      *
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.
55      * @throws Exception
56      */
57     public abstract void openStation(int station, BigDecimal duration)
58             throws CommunicationApiException, GeneralApiException;
59
60     /**
61      * Closes a station on the OpenSprinkler device.
62      *
63      * @param station Index of the station to open starting at 0.
64      * @throws Exception
65      */
66     public abstract void closeStation(int station) throws CommunicationApiException, GeneralApiException;
67
68     /**
69      * Returns the state of a station on the OpenSprinkler device.
70      *
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.
73      * @throws Exception
74      */
75     public abstract boolean isStationOpen(int station) throws GeneralApiException, CommunicationApiException;
76
77     /**
78      * Returns the current program data of the requested station.
79      *
80      * @param station Index of the station to request data from
81      * @return StationProgram
82      * @throws Exception
83      */
84     public abstract StationProgram retrieveProgram(int station) throws CommunicationApiException;
85
86     /**
87      * Returns the state of rain detection on the OpenSprinkler device.
88      *
89      * @return True if rain is detected, false if not or cannot determine.
90      * @throws Exception
91      */
92     public abstract boolean isRainDetected() throws CommunicationApiException;
93
94     /**
95      * Returns the current draw of all connected zones of the OpenSprinkler device in milliamperes.
96      *
97      * @return current draw in milliamperes
98      * @throws CommunicationApiException
99      * @throws
100      */
101     public abstract int currentDraw() throws CommunicationApiException, NoCurrentDrawSensorException;
102
103     /**
104      * Returns the water level in %.
105      *
106      * @return waterLevel in %
107      * @throws CommunicationApiException
108      * @throws
109      */
110     public abstract int waterLevel() throws CommunicationApiException;
111
112     /**
113      * Returns the number of total stations that are controllable from the OpenSprinkler
114      * device.
115      *
116      * @return Number of stations as an int.
117      * @throws Exception
118      */
119     public abstract int getNumberOfStations() throws Exception;
120
121     /**
122      * Returns the firmware version number.
123      *
124      * @return The firmware version of the OpenSprinkler device as an int.
125      * @throws Exception
126      */
127     public abstract int getFirmwareVersion() throws CommunicationApiException;
128 }