]> git.basschouten.com Git - openhab-addons.git/blob
03975048c3cafa005c537a55b785783e9c66d0d4
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.loxone.internal;
14
15 import java.io.IOException;
16 import java.util.Map;
17
18 import org.openhab.binding.loxone.internal.controls.LxControl;
19 import org.openhab.binding.loxone.internal.security.LxWsSecurity;
20 import org.openhab.binding.loxone.internal.types.LxUuid;
21 import org.openhab.core.thing.ChannelUID;
22 import org.openhab.core.thing.Thing;
23 import org.openhab.core.thing.ThingUID;
24 import org.openhab.core.types.State;
25 import org.openhab.core.types.StateDescription;
26
27 import com.google.gson.Gson;
28
29 /**
30  * Representation of a Loxone Miniserver. It is an openHAB {@link Thing}, which is used to communicate with
31  * objects (controls) configured in the Miniserver over channels.
32  *
33  * @author Pawel Pieczul - Initial contribution
34  */
35 public interface LxServerHandlerApi {
36
37     /**
38      * Sends an action to a Loxone Miniserver's control.
39      *
40      * @param id identifier of the control
41      * @param operation identifier of the operation
42      * @throws IOException when communication error with Miniserver occurs
43      */
44     void sendAction(LxUuid id, String operation) throws IOException;
45
46     /**
47      * Add a control - creates internal data structures and channels in the framework.
48      * This method should be used for all dynamically created controls, usually as a result of Miniserver's state update
49      * messages, after the static configuration is setup.
50      *
51      * @param control control to be added
52      */
53     void addControl(LxControl control);
54
55     /**
56      * Remove a control - removes internal data structures and channels from the framework
57      * This method should be used for all dynamically created controls, usually as a result of Miniserver's state update
58      * messages, after the static configuration is setup.
59      *
60      * @param control control to remove
61      */
62     void removeControl(LxControl control);
63
64     /**
65      * Sets channel's state to a new value
66      *
67      * @param channelId channel ID
68      * @param state new state value
69      */
70     void setChannelState(ChannelUID channelId, State state);
71
72     /**
73      * Sets a new channel state description. This method is called to dynamically change the way the channel state is
74      * interpreted and displayed. It is called when a dynamic state update is received from the Miniserver with a new
75      * way of displaying control's state.
76      *
77      * @param channelId channel ID
78      * @param description a new state description
79      */
80     void setChannelStateDescription(ChannelUID channelId, StateDescription description);
81
82     /**
83      * Get configuration parameter from the thing configuration. This method is called by the {@link LxWsSecurity} class
84      * to dynamically retrieve previously stored login token and its parameters.
85      *
86      * @param name parameter name
87      * @return parameter value
88      */
89     String getSetting(String name);
90
91     /**
92      * Set configuration parameters in the thing configuration. This method is called by the {@link LxWsSecurity} class
93      * to dynamically stored login token and its parameters received from the Miniserver.
94      *
95      * @param properties pairs of parameter names and values
96      */
97     void setSettings(Map<String, String> properties);
98
99     /**
100      * Get GSON object for reuse
101      *
102      * @return GSON object
103      */
104     Gson getGson();
105
106     /**
107      * Get ID of the Miniserver's Thing
108      *
109      * @return ID of the Thing
110      */
111     ThingUID getThingId();
112 }