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.
55 public String getVersion();
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 public 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 public 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 public 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 public 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
140 public @Nullable 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 @Nullable 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 @Nullable 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 @Nullable 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 @Nullable Application getWeather();
178 * Get any of the built-in applications.
181 * the app to retrieve
182 * @return the requested app
184 public @Nullable 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 @Nullable Application getApplication(@Nullable 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(@Nullable 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) {
392 return new LaMetricTimeImpl(config);
396 * Create an instance of this API. For greater control over the
398 * {@link #create(LocalConfiguration, CloudConfiguration, ClientBuilder)}.
401 * the configuration parameters that the new instance will use
402 * @param clientBuilder
403 * the builder that will be used to create clients for
404 * communicating with the device and cloud services
405 * @return the API instance
407 public static LaMetricTime create(Configuration config, ClientBuilder clientBuilder) {
408 return new LaMetricTimeImpl(config, clientBuilder);
412 * Create an instance of this API specifying detailed configuration for both
413 * the local and cloud APIs. See also
414 * {@link #create(LocalConfiguration, CloudConfiguration, ClientBuilder)}.
417 * the local API configuration for the new instance
419 * the cloud API configuration for the new instance
420 * @return the API instance
422 public static LaMetricTime create(LocalConfiguration localConfig, CloudConfiguration cloudConfig) {
423 return new LaMetricTimeImpl(localConfig, cloudConfig);
427 * Create an instance of this API specifying detailed configuration for both
428 * the local and cloud APIs as well as the generic client.
431 * the local API configuration for the new instance
433 * the cloud API configuration for the new instance
434 * @param clientBuilder
435 * the builder that will be used to create clients for
436 * communicating with the device and cloud services
437 * @return the API instance
439 public static LaMetricTime create(LocalConfiguration localConfig, CloudConfiguration cloudConfig,
440 ClientBuilder clientBuilder) {
441 return new LaMetricTimeImpl(localConfig, cloudConfig, clientBuilder);