]> git.basschouten.com Git - openhab-addons.git/blob
f8e37775978f03d743b7e7c1dce3abc50a13a7dc
[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.velux.internal.bridge.json;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.velux.internal.bridge.VeluxBridgeInstance;
18 import org.openhab.binding.velux.internal.bridge.common.BridgeAPI;
19 import org.openhab.binding.velux.internal.bridge.common.GetDeviceStatus;
20 import org.openhab.binding.velux.internal.bridge.common.GetFirmware;
21 import org.openhab.binding.velux.internal.bridge.common.GetHouseStatus;
22 import org.openhab.binding.velux.internal.bridge.common.GetLANConfig;
23 import org.openhab.binding.velux.internal.bridge.common.GetProduct;
24 import org.openhab.binding.velux.internal.bridge.common.GetProductLimitation;
25 import org.openhab.binding.velux.internal.bridge.common.GetProducts;
26 import org.openhab.binding.velux.internal.bridge.common.GetScenes;
27 import org.openhab.binding.velux.internal.bridge.common.GetWLANConfig;
28 import org.openhab.binding.velux.internal.bridge.common.Login;
29 import org.openhab.binding.velux.internal.bridge.common.Logout;
30 import org.openhab.binding.velux.internal.bridge.common.RunProductCommand;
31 import org.openhab.binding.velux.internal.bridge.common.RunProductDiscovery;
32 import org.openhab.binding.velux.internal.bridge.common.RunProductIdentification;
33 import org.openhab.binding.velux.internal.bridge.common.RunProductSearch;
34 import org.openhab.binding.velux.internal.bridge.common.RunScene;
35 import org.openhab.binding.velux.internal.bridge.common.SetHouseStatusMonitor;
36 import org.openhab.binding.velux.internal.bridge.common.SetProductLimitation;
37 import org.openhab.binding.velux.internal.bridge.common.SetSceneVelocity;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40
41 /**
42  * JSON-based 3rd Level I/O interface towards the <B>Velux</B> bridge.
43  * <P>
44  * It provides the one-and-only protocol specific 1st-level communication class.
45  * Additionally it provides all methods for different gateway interactions.
46  * <P>
47  * The following class access methods exist:
48  * <UL>
49  * <LI>{@link JsonBridgeAPI#getDeviceStatus} for retrieving the bridge state (i.e. IDLE, BUSY, a.s.o),</LI>
50  * <LI>{@link JsonBridgeAPI#getFirmware} for retrieving the firmware version of the bridge,</LI>
51  * <LI>{@link JsonBridgeAPI#getHouseStatus} for retrieving the information about device state changes recognized by the
52  * bridge,</LI>
53  * <LI>{@link JsonBridgeAPI#getLANConfig} for retrieving the complete LAN information of the bridge,</LI>
54  * <LI>{@link JsonBridgeAPI#getProduct} for retrieving the any information about a device behind the bridge,</LI>
55  * <LI>{@link JsonBridgeAPI#getProductLimitation} for retrieving the limitation information about a device behind the
56  * bridge,</LI>
57  * <LI>{@link JsonBridgeAPI#getProducts} for retrieving the any information for all devices behind the bridge,</LI>
58  * <LI>{@link JsonBridgeAPI#getScenes} for retrieving the any information for all scenes defined on the bridge,</LI>
59  * <LI>{@link JsonBridgeAPI#getWLANConfig} for retrieving the complete WLAN information of the bridge,</LI>
60  * <LI>{@link JsonBridgeAPI#login} for establishing a trusted connectivity by authentication,</LI>
61  * <LI>{@link JsonBridgeAPI#logout} for tearing down the trusted connectivity by deauthentication,</LI>
62  * <LI>{@link JsonBridgeAPI#runProductCommand} for manipulation of a device behind the bridge (i.e. instructing to
63  * modify a position),</LI>
64  * <LI>{@link JsonBridgeAPI#runProductDiscovery} for activation of learning mode of the bridge to discovery new
65  * products,</LI>
66  * <LI>{@link JsonBridgeAPI#runProductIdentification} for human-oriented identification a device behind the bridge (i.e.
67  * by winking or switching on-and-off),</LI>
68  * <LI>{@link JsonBridgeAPI#runProductSearch} for searching for lost products on the bridge,</LI>
69  * <LI>{@link JsonBridgeAPI#runScene} for manipulation of a set of devices behind the bridge which are tied together as
70  * scene,</LI>
71  * <LI>{@link JsonBridgeAPI#setHouseStatusMonitor} for activation or deactivation of the house monitoring mode to be
72  * informed about device state changes recognized by the bridge,</LI>
73  * <LI>{@link JsonBridgeAPI#setSceneVelocity} for changes the velocity of a scene defined on the bridge (i.e. silent or
74  * fast mode).</LI>
75  * </UL>
76  * <P>
77  * As most derived class of the several inheritance levels it defines an
78  * interfacing method which returns the JSON-protocol-specific communication for gateway interaction.
79  *
80  * @author Guenther Schreiner - Initial contribution.
81  */
82 @NonNullByDefault
83 class JsonBridgeAPI implements BridgeAPI {
84     private final Logger logger = LoggerFactory.getLogger(JsonBridgeAPI.class);
85
86     private static final GetDeviceStatus GETDEVICESTATUS = new JCgetDeviceStatus();
87     private static final GetFirmware GETFIRMWARE = new JCgetFirmware();
88     private static final GetLANConfig GETLANCONFIG = new JCgetLANConfig();
89     private static final GetProducts GETPRODUCTS = new JCgetProducts();
90     private static final GetScenes GETSCENES = new JCgetScenes();
91     private static final GetWLANConfig GETWLANCONFIG = new JCgetWLANConfig();
92     private static final Login LOGIN = new JClogin();
93     private static final Logout LOGOUT = new JClogout();
94     private static final RunProductDiscovery RUNPRODUCTDISCOVERY = new JCrunProductDiscovery();
95     private static final RunProductIdentification RUNPRODUCTIDENTIFICATION = new JCrunProductIdentification();
96     private static final RunProductSearch RUNPRODUCTSEARCH = new JCrunProductSearch();
97     private static final RunScene RUNSCENE = new JCrunScene();
98     private static final SetSceneVelocity SETSCENEVELOCITY = new JCsetSceneVelocity();
99
100     /**
101      * Constructor.
102      * <P>
103      * Inherits the initialization of the binding-wide instance for dealing for common information and
104      * initializes the handler {@link org.openhab.binding.velux.internal.bridge.json.JsonVeluxBridge#bridgeAPI
105      * JsonVeluxBridge.bridgeAPI}
106      * to pass the interface methods.
107      *
108      * @param bridgeInstance refers to the binding-wide instance for dealing for common informations.
109      */
110     JsonBridgeAPI(VeluxBridgeInstance bridgeInstance) {
111         logger.trace("JsonBridgeAPI(constructor) called.");
112     }
113
114     @Override
115     public GetDeviceStatus getDeviceStatus() {
116         return GETDEVICESTATUS;
117     }
118
119     @Override
120     public GetFirmware getFirmware() {
121         return GETFIRMWARE;
122     }
123
124     @Override
125     public @Nullable GetHouseStatus getHouseStatus() {
126         return null;
127     }
128
129     @Override
130     public GetLANConfig getLANConfig() {
131         return GETLANCONFIG;
132     }
133
134     @Override
135     public @Nullable GetProduct getProduct() {
136         return null;
137     }
138
139     @Override
140     public @Nullable GetProductLimitation getProductLimitation() {
141         return null;
142     }
143
144     @Override
145     public @Nullable SetProductLimitation setProductLimitation() {
146         return null;
147     }
148
149     @Override
150     public GetProducts getProducts() {
151         return GETPRODUCTS;
152     }
153
154     @Override
155     public GetScenes getScenes() {
156         return GETSCENES;
157     }
158
159     @Override
160     public GetWLANConfig getWLANConfig() {
161         return GETWLANCONFIG;
162     }
163
164     @Override
165     public Login login() {
166         return LOGIN;
167     }
168
169     @Override
170     public Logout logout() {
171         return LOGOUT;
172     }
173
174     @Override
175     public @Nullable RunProductCommand runProductCommand() {
176         return null;
177     }
178
179     @Override
180     public RunProductDiscovery runProductDiscovery() {
181         return RUNPRODUCTDISCOVERY;
182     }
183
184     @Override
185     public RunProductIdentification runProductIdentification() {
186         return RUNPRODUCTIDENTIFICATION;
187     }
188
189     @Override
190     public RunProductSearch runProductSearch() {
191         return RUNPRODUCTSEARCH;
192     }
193
194     @Override
195     public RunScene runScene() {
196         return RUNSCENE;
197     }
198
199     @Override
200     public @Nullable SetHouseStatusMonitor setHouseStatusMonitor() {
201         return null;
202     }
203
204     @Override
205     public SetSceneVelocity setSceneVelocity() {
206         return SETSCENEVELOCITY;
207     }
208 }