2 * Copyright 2017-2018 Gregory Moyer and contributors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.openhab.binding.lametrictime.api;
18 import javax.ws.rs.client.ClientBuilder;
20 import org.openhab.binding.lametrictime.api.cloud.CloudConfiguration;
21 import org.openhab.binding.lametrictime.api.cloud.LaMetricTimeCloud;
22 import org.openhab.binding.lametrictime.api.impl.LaMetricTimeImpl;
23 import org.openhab.binding.lametrictime.api.local.ApplicationActionException;
24 import org.openhab.binding.lametrictime.api.local.ApplicationActivationException;
25 import org.openhab.binding.lametrictime.api.local.ApplicationNotFoundException;
26 import org.openhab.binding.lametrictime.api.local.LaMetricTimeLocal;
27 import org.openhab.binding.lametrictime.api.local.LocalConfiguration;
28 import org.openhab.binding.lametrictime.api.local.NotificationCreationException;
29 import org.openhab.binding.lametrictime.api.local.UpdateException;
30 import org.openhab.binding.lametrictime.api.local.model.Application;
31 import org.openhab.binding.lametrictime.api.local.model.Audio;
32 import org.openhab.binding.lametrictime.api.local.model.Bluetooth;
33 import org.openhab.binding.lametrictime.api.local.model.Display;
34 import org.openhab.binding.lametrictime.api.local.model.UpdateAction;
35 import org.openhab.binding.lametrictime.api.local.model.Widget;
36 import org.openhab.binding.lametrictime.api.model.CoreAction;
37 import org.openhab.binding.lametrictime.api.model.CoreApplication;
38 import org.openhab.binding.lametrictime.api.model.CoreApps;
39 import org.openhab.binding.lametrictime.api.model.Icon;
40 import org.openhab.binding.lametrictime.api.model.enums.BrightnessMode;
41 import org.openhab.binding.lametrictime.api.model.enums.Priority;
42 import org.openhab.binding.lametrictime.api.model.enums.Sound;
44 public interface LaMetricTime
47 * Get the version identifier reported by the device.
51 public String getVersion();
54 * Send a low priority message to the device.
58 * @return the identifier of the newly created notification
59 * @throws NotificationCreationException
60 * if there is a communication error or malformed data
62 public String notifyInfo(String message) throws NotificationCreationException;
65 * Send a medium priority message to the device.
69 * @return the identifier of the newly created notification
70 * @throws NotificationCreationException
71 * if there is a communication error or malformed data
73 public String notifyWarning(String message) throws NotificationCreationException;
76 * Send an urgent message to the device. The notification will not be
77 * automatically removed. The user will be required to dismiss this
78 * notification or it must be deleted through he API.
82 * @return the identifier of the newly created notification
83 * @throws NotificationCreationException
84 * if there is a communication error or malformed data
86 public String notifyCritical(String message) throws NotificationCreationException;
89 * Send a notification to the device.
91 * Priority is important. It defines the urgency of this notification as
92 * related to others in the queue and the current state of the device.
94 * <li>{@link Priority#INFO}: lowest priority; not shown when the
95 * screensaver is active; waits for its turn in the queue
96 * <li>{@link Priority#WARNING}: middle priority; not shown when the
97 * screensaver is active; preempts {@link Priority#INFO}
98 * <li>{@link Priority#CRITICAL}: highest priority; shown even when the
99 * screensaver is active; preempts all other notifications (to be used
104 * the text to display
106 * the urgency of this notification; defaults to
107 * {@link Priority#INFO}
109 * the icon to display next to the message; can be
112 * the sound to play when the notification is displayed; can be
114 * @param messageRepeat
115 * the number of times the message should be displayed before
116 * being removed (use <code>0</code> to leave the notification on
117 * the device until it is dismissed by the user or deleted
120 * the number of times to repeat the sound (use <code>0</code> to
121 * keep the sound looping until the notification is dismissed by
122 * the user or deleted through the API)
123 * @return the identifier of the newly created notification
124 * @throws NotificationCreationException
125 * if there is a communication error or malformed data
127 public String notify(String message,
132 int soundRepeat) throws NotificationCreationException;
135 * Get the built-in clock application. This applications displays the time
136 * and date. It also provides an alarm feature.
138 * @return the clock app
140 public Application getClock();
143 * Get the built-in countdown timer application. This application counts
144 * time down to zero when it sets off a beeper until it is reset. The
145 * countdown can also be paused.
147 * @return the countdown app
149 public Application getCountdown();
152 * Get the built-in radio application. The radio can play streams from the
153 * Internet. The streams are set up in a list and can be navigated using
154 * 'next' and 'previous' actions. The music can be started and stopped.
156 * @return the radio app
158 public Application getRadio();
161 * Get the built-in stopwatch application. The stopwatch counts time
162 * forwards and can be started, paused, and reset.
164 * @return the stopwatch app
166 public Application getStopwatch();
169 * Get the built-in weather application. This application displays the
170 * current weather conditions. It can also display the forecast for today
173 * @return the weather app
175 public Application getWeather();
178 * Get any of the built-in applications.
181 * the app to retrieve
182 * @return the requested app
184 public Application getApplication(CoreApplication coreApp);
187 * Get any application installed on the device.
190 * the name of the app to retrieve
191 * @return the requested app
192 * @throws ApplicationNotFoundException
193 * if the requested app is not found on the device
195 public Application getApplication(String name) throws ApplicationNotFoundException;
198 * Display the given built-in application on the device.
201 * the app to activate
203 public void activateApplication(CoreApplication coreApp);
206 * Display the first instance (widget) of the given application on the
210 * the app to activate
211 * @throws ApplicationActivationException
212 * if the app fails to activate
214 public void activateApplication(Application app) throws ApplicationActivationException;
217 * Display the given widget on the device. A widget is simply an instance of
218 * an application. Some applications can be installed more than once (e.g.
219 * the {@link CoreApps#weather() weather} app) and each instance is assigned
223 * the application instance (widget) to activate
224 * @throws ApplicationActivationException
225 * if the app fails to activate
227 public void activateWidget(Widget widget) throws ApplicationActivationException;
230 * Perform the given action on the first instance (widget) of the
231 * corresponding built-in application. The widget will activate
232 * automatically before carrying out the action.
235 * the action to perform
237 public void doAction(CoreAction coreAction);
240 * Perform the given action on the first instance (widget) of the given
241 * application. The widget will activate automatically before carrying out
245 * the app which understands the requested action
247 * the action to perform
248 * @throws ApplicationActionException
249 * if the action cannot be performed
251 public void doAction(Application app, UpdateAction action) throws ApplicationActionException;
254 * Perform the given core action on the given widget. A widget is simply an
255 * instance of an application. Some applications can be installed more than
256 * once (e.g. the {@link CoreApps#weather() weather} app) and each instance
257 * is assigned a widget. The widget will activate automatically before
258 * carrying out the action.
261 * the widget which understands the requested core action
263 * the action to perform
264 * @throws ApplicationActionException
265 * if the action cannot be performed
267 public void doAction(Widget widget, CoreAction action) throws ApplicationActionException;
270 * Perform the given action on the given widget. A widget is simply an
271 * instance of an application. Some applications can be installed more than
272 * once (e.g. the {@link CoreApps#weather() weather} app) and each instance
273 * is assigned a widget. The widget will activate automatically before
274 * carrying out the action.
277 * the widget which understands the requested action
279 * the action to perform
280 * @throws ApplicationActionException
281 * if the action cannot be performed
283 public void doAction(Widget widget, UpdateAction action) throws ApplicationActionException;
286 * Set the display brightness. The {@link #setBrightnessMode(BrightnessMode)
287 * brightness mode} will also be set to {@link BrightnessMode#MANUAL}.
290 * the brightness value to set (must be between 0 and 100,
292 * @return the updated state of the display
293 * @throws UpdateException
294 * if the update failed
296 public Display setBrightness(int brightness) throws UpdateException;
299 * Set the brightness mode on the display. {@link BrightnessMode#MANUAL}
300 * will immediately respect the current brightness value while
301 * {@link BrightnessMode#AUTO} will ignore the brightness value and set the
302 * brightness based on ambient light intensity.
306 * @return the updated state of the display
307 * @throws UpdateException
308 * if the update failed
310 public Display setBrightnessMode(BrightnessMode mode) throws UpdateException;
313 * Set the speaker volume on the device.
316 * the volume to set (must be between 0 and 100, inclusive)
317 * @return the update audio state
318 * @throws UpdateException
319 * if the update failed
321 public Audio setVolume(int volume) throws UpdateException;
324 * Mute the device's speakers. The current volume will be stored so that
325 * {@link #unmute()} will restored it. If the volume is currently at zero,
326 * no action will be taken.
328 * @return the update audio state
329 * @throws UpdateException
330 * if the update failed
332 public Audio mute() throws UpdateException;
335 * Restore the volume prior to {@link #mute()}. If the volume has not been
336 * muted previously and the volume is currently zero, it will be set to 50%.
338 * @return the update audio state
339 * @throws UpdateException
340 * if the update failed
342 public Audio unmute() throws UpdateException;
345 * Set the active state of the Bluetooth radio on the device.
348 * <code>true</code> to activate Bluetooth; <code>false</code> to
350 * @return the updated state of Bluetooth on the device
351 * @throws UpdateException
352 * if the update failed
354 public Bluetooth setBluetoothActive(boolean active) throws UpdateException;
357 * Set the device name as seen via Bluetooth connectivity.
360 * the name to display on other devices
361 * @return the updated state of Bluetooth on the device
362 * @throws UpdateException
363 * if the update failed
365 public Bluetooth setBluetoothName(String name) throws UpdateException;
368 * Get the local API for more advanced interactions as well device inquiry.
370 * @return the local API
372 public LaMetricTimeLocal getLocalApi();
375 * Get the cloud API for interacting with LaMetric's services.
377 * @return the cloud API
379 public LaMetricTimeCloud getCloudApi();
382 * Create an instance of this API. For greater control over the
383 * configuration, see {@link #create(Configuration, ClientBuilder)},
384 * {@link #create(LocalConfiguration, CloudConfiguration)}, and
385 * {@link #create(LocalConfiguration, CloudConfiguration, ClientBuilder)}.
388 * the configuration parameters that the new instance will use
389 * @return the API instance
391 public static LaMetricTime create(Configuration config)
393 return new LaMetricTimeImpl(config);
397 * Create an instance of this API. For greater control over the
399 * {@link #create(LocalConfiguration, CloudConfiguration, ClientBuilder)}.
402 * the configuration parameters that the new instance will use
403 * @param clientBuilder
404 * the builder that will be used to create clients for
405 * communicating with the device and cloud services
406 * @return the API instance
408 public static LaMetricTime create(Configuration config, ClientBuilder clientBuilder)
410 return new LaMetricTimeImpl(config, clientBuilder);
414 * Create an instance of this API specifying detailed configuration for both
415 * the local and cloud APIs. See also
416 * {@link #create(LocalConfiguration, CloudConfiguration, ClientBuilder)}.
419 * the local API configuration for the new instance
421 * the cloud API configuration for the new instance
422 * @return the API instance
424 public static LaMetricTime create(LocalConfiguration localConfig,
425 CloudConfiguration cloudConfig)
427 return new LaMetricTimeImpl(localConfig, cloudConfig);
431 * Create an instance of this API specifying detailed configuration for both
432 * the local and cloud APIs as well as the generic client.
435 * the local API configuration for the new instance
437 * the cloud API configuration for the new instance
438 * @param clientBuilder
439 * the builder that will be used to create clients for
440 * communicating with the device and cloud services
441 * @return the API instance
443 public static LaMetricTime create(LocalConfiguration localConfig,
444 CloudConfiguration cloudConfig,
445 ClientBuilder clientBuilder)
447 return new LaMetricTimeImpl(localConfig, cloudConfig, clientBuilder);