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.lametrictime.internal.api;
15 import javax.ws.rs.client.ClientBuilder;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.lametrictime.internal.api.cloud.CloudConfiguration;
20 import org.openhab.binding.lametrictime.internal.api.cloud.LaMetricTimeCloud;
21 import org.openhab.binding.lametrictime.internal.api.dto.CoreAction;
22 import org.openhab.binding.lametrictime.internal.api.dto.CoreApplication;
23 import org.openhab.binding.lametrictime.internal.api.dto.CoreApps;
24 import org.openhab.binding.lametrictime.internal.api.dto.Icon;
25 import org.openhab.binding.lametrictime.internal.api.dto.enums.BrightnessMode;
26 import org.openhab.binding.lametrictime.internal.api.dto.enums.Priority;
27 import org.openhab.binding.lametrictime.internal.api.dto.enums.Sound;
28 import org.openhab.binding.lametrictime.internal.api.impl.LaMetricTimeImpl;
29 import org.openhab.binding.lametrictime.internal.api.local.ApplicationActionException;
30 import org.openhab.binding.lametrictime.internal.api.local.ApplicationActivationException;
31 import org.openhab.binding.lametrictime.internal.api.local.ApplicationNotFoundException;
32 import org.openhab.binding.lametrictime.internal.api.local.LaMetricTimeLocal;
33 import org.openhab.binding.lametrictime.internal.api.local.LocalConfiguration;
34 import org.openhab.binding.lametrictime.internal.api.local.NotificationCreationException;
35 import org.openhab.binding.lametrictime.internal.api.local.UpdateException;
36 import org.openhab.binding.lametrictime.internal.api.local.dto.Application;
37 import org.openhab.binding.lametrictime.internal.api.local.dto.Audio;
38 import org.openhab.binding.lametrictime.internal.api.local.dto.Bluetooth;
39 import org.openhab.binding.lametrictime.internal.api.local.dto.Display;
40 import org.openhab.binding.lametrictime.internal.api.local.dto.UpdateAction;
41 import org.openhab.binding.lametrictime.internal.api.local.dto.Widget;
44 * Interface for LaMetric Time devices.
46 * @author Gregory Moyer - Initial contribution
49 public interface LaMetricTime {
51 * Get the version identifier reported by the device.
58 * Send a low priority message to the device.
62 * @return the identifier of the newly created notification
63 * @throws NotificationCreationException
64 * if there is a communication error or malformed data
66 String notifyInfo(String message) throws NotificationCreationException;
69 * Send a medium priority message to the device.
73 * @return the identifier of the newly created notification
74 * @throws NotificationCreationException
75 * if there is a communication error or malformed data
77 String notifyWarning(String message) throws NotificationCreationException;
80 * Send an urgent message to the device. The notification will not be
81 * automatically removed. The user will be required to dismiss this
82 * notification or it must be deleted through he API.
86 * @return the identifier of the newly created notification
87 * @throws NotificationCreationException
88 * if there is a communication error or malformed data
90 String notifyCritical(String message) throws NotificationCreationException;
93 * Send a notification to the device.
95 * Priority is important. It defines the urgency of this notification as
96 * related to others in the queue and the current state of the device.
98 * <li>{@link Priority#INFO}: lowest priority; not shown when the
99 * screensaver is active; waits for its turn in the queue
100 * <li>{@link Priority#WARNING}: middle priority; not shown when the
101 * screensaver is active; preempts {@link Priority#INFO}
102 * <li>{@link Priority#CRITICAL}: highest priority; shown even when the
103 * screensaver is active; preempts all other notifications (to be used
108 * the text to display
110 * the urgency of this notification; defaults to
111 * {@link Priority#INFO}
113 * the icon to display next to the message; can be
116 * the sound to play when the notification is displayed; can be
118 * @param messageRepeat
119 * the number of times the message should be displayed before
120 * being removed (use <code>0</code> to leave the notification on
121 * the device until it is dismissed by the user or deleted
124 * the number of times to repeat the sound (use <code>0</code> to
125 * keep the sound looping until the notification is dismissed by
126 * the user or deleted through the API)
127 * @return the identifier of the newly created notification
128 * @throws NotificationCreationException
129 * if there is a communication error or malformed data
131 String notify(String message, Priority priority, Icon icon, Sound sound, int messageRepeat, int soundRepeat)
132 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
141 Application getClock();
144 * Get the built-in countdown timer application. This application counts
145 * time down to zero when it sets off a beeper until it is reset. The
146 * countdown can also be paused.
148 * @return the countdown app
151 Application getCountdown();
154 * Get the built-in radio application. The radio can play streams from the
155 * Internet. The streams are set up in a list and can be navigated using
156 * 'next' and 'previous' actions. The music can be started and stopped.
158 * @return the radio app
161 Application getRadio();
164 * Get the built-in stopwatch application. The stopwatch counts time
165 * forwards and can be started, paused, and reset.
167 * @return the stopwatch app
170 Application getStopwatch();
173 * Get the built-in weather application. This application displays the
174 * current weather conditions. It can also display the forecast for today
177 * @return the weather app
180 Application getWeather();
183 * Get any of the built-in applications.
186 * the app to retrieve
187 * @return the requested app
190 Application getApplication(CoreApplication coreApp);
193 * Get any application installed on the device.
196 * the name of the app to retrieve
197 * @return the requested app
198 * @throws ApplicationNotFoundException
199 * if the requested app is not found on the device
202 Application getApplication(@Nullable String name) throws ApplicationNotFoundException;
205 * Display the given built-in application on the device.
208 * the app to activate
210 void activateApplication(CoreApplication coreApp);
213 * Display the first instance (widget) of the given application on the
217 * the app to activate
218 * @throws ApplicationActivationException
219 * if the app fails to activate
221 void activateApplication(Application app) throws ApplicationActivationException;
224 * Display the given widget on the device. A widget is simply an instance of
225 * an application. Some applications can be installed more than once (e.g.
226 * the {@link CoreApps#weather() weather} app) and each instance is assigned
230 * the application instance (widget) to activate
231 * @throws ApplicationActivationException
232 * if the app fails to activate
234 void activateWidget(Widget widget) throws ApplicationActivationException;
237 * Perform the given action on the first instance (widget) of the
238 * corresponding built-in application. The widget will activate
239 * automatically before carrying out the action.
242 * the action to perform
244 void doAction(CoreAction coreAction);
247 * Perform the given action on the first instance (widget) of the given
248 * application. The widget will activate automatically before carrying out
252 * the app which understands the requested action
254 * the action to perform
255 * @throws ApplicationActionException
256 * if the action cannot be performed
258 void doAction(Application app, UpdateAction action) throws ApplicationActionException;
261 * Perform the given core action on the given widget. A widget is simply an
262 * instance of an application. Some applications can be installed more than
263 * once (e.g. the {@link CoreApps#weather() weather} app) and each instance
264 * is assigned a widget. The widget will activate automatically before
265 * carrying out the action.
268 * the widget which understands the requested core action
270 * the action to perform
271 * @throws ApplicationActionException
272 * if the action cannot be performed
274 void doAction(@Nullable Widget widget, CoreAction action) throws ApplicationActionException;
277 * Perform the given action on the given widget. A widget is simply an
278 * instance of an application. Some applications can be installed more than
279 * once (e.g. the {@link CoreApps#weather() weather} app) and each instance
280 * is assigned a widget. The widget will activate automatically before
281 * carrying out the action.
284 * the widget which understands the requested action
286 * the action to perform
287 * @throws ApplicationActionException
288 * if the action cannot be performed
290 void doAction(Widget widget, UpdateAction action) throws ApplicationActionException;
293 * Set the display brightness. The {@link #setBrightnessMode(BrightnessMode)
294 * brightness mode} will also be set to {@link BrightnessMode#MANUAL}.
297 * the brightness value to set (must be between 0 and 100,
299 * @return the updated state of the display
300 * @throws UpdateException
301 * if the update failed
303 Display setBrightness(int brightness) throws UpdateException;
306 * Set the brightness mode on the display. {@link BrightnessMode#MANUAL}
307 * will immediately respect the current brightness value while
308 * {@link BrightnessMode#AUTO} will ignore the brightness value and set the
309 * brightness based on ambient light intensity.
313 * @return the updated state of the display
314 * @throws UpdateException
315 * if the update failed
317 Display setBrightnessMode(BrightnessMode mode) throws UpdateException;
320 * Set the speaker volume on the device.
323 * the volume to set (must be between 0 and 100, inclusive)
324 * @return the update audio state
325 * @throws UpdateException
326 * if the update failed
328 Audio setVolume(int volume) throws UpdateException;
331 * Mute the device's speakers. The current volume will be stored so that
332 * {@link #unmute()} will restored it. If the volume is currently at zero,
333 * no action will be taken.
335 * @return the update audio state
336 * @throws UpdateException
337 * if the update failed
339 Audio mute() throws UpdateException;
342 * Restore the volume prior to {@link #mute()}. If the volume has not been
343 * muted previously and the volume is currently zero, it will be set to 50%.
345 * @return the update audio state
346 * @throws UpdateException
347 * if the update failed
349 Audio unmute() throws UpdateException;
352 * Set the active state of the Bluetooth radio on the device.
355 * <code>true</code> to activate Bluetooth; <code>false</code> to
357 * @return the updated state of Bluetooth on the device
358 * @throws UpdateException
359 * if the update failed
361 Bluetooth setBluetoothActive(boolean active) throws UpdateException;
364 * Set the device name as seen via Bluetooth connectivity.
367 * the name to display on other devices
368 * @return the updated state of Bluetooth on the device
369 * @throws UpdateException
370 * if the update failed
372 Bluetooth setBluetoothName(String name) throws UpdateException;
375 * Get the local API for more advanced interactions as well device inquiry.
377 * @return the local API
379 LaMetricTimeLocal getLocalApi();
382 * Get the cloud API for interacting with LaMetric's services.
384 * @return the cloud API
386 LaMetricTimeCloud getCloudApi();
389 * Create an instance of this API. For greater control over the
390 * configuration, see {@link #create(Configuration, ClientBuilder)},
391 * {@link #create(LocalConfiguration, CloudConfiguration)}, and
392 * {@link #create(LocalConfiguration, CloudConfiguration, ClientBuilder)}.
395 * the configuration parameters that the new instance will use
396 * @return the API instance
398 static LaMetricTime create(Configuration config) {
399 return new LaMetricTimeImpl(config);
403 * Create an instance of this API. For greater control over the
405 * {@link #create(LocalConfiguration, CloudConfiguration, ClientBuilder)}.
408 * the configuration parameters that the new instance will use
409 * @param clientBuilder
410 * the builder that will be used to create clients for
411 * communicating with the device and cloud services
412 * @return the API instance
414 static LaMetricTime create(Configuration config, ClientBuilder clientBuilder) {
415 return new LaMetricTimeImpl(config, clientBuilder);
419 * Create an instance of this API specifying detailed configuration for both
420 * the local and cloud APIs. See also
421 * {@link #create(LocalConfiguration, CloudConfiguration, ClientBuilder)}.
424 * the local API configuration for the new instance
426 * the cloud API configuration for the new instance
427 * @return the API instance
429 static LaMetricTime create(LocalConfiguration localConfig, CloudConfiguration cloudConfig) {
430 return new LaMetricTimeImpl(localConfig, cloudConfig);
434 * Create an instance of this API specifying detailed configuration for both
435 * the local and cloud APIs as well as the generic client.
438 * the local API configuration for the new instance
440 * the cloud API configuration for the new instance
441 * @param clientBuilder
442 * the builder that will be used to create clients for
443 * communicating with the device and cloud services
444 * @return the API instance
446 static LaMetricTime create(LocalConfiguration localConfig, CloudConfiguration cloudConfig,
447 ClientBuilder clientBuilder) {
448 return new LaMetricTimeImpl(localConfig, cloudConfig, clientBuilder);