* It therefore provides a method *
* {"action":"discover","params":{}} *+ * + * NOTE: the gateway software is extremely sensible to this exact JSON structure. + * Any modifications (like omitting empty params) will lead to an gateway error. */ public static class Request { diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetDeviceStatus.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetDeviceStatus.java index b7337706fe5d0..32acc825c24fa 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetDeviceStatus.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetDeviceStatus.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -43,6 +43,9 @@ public BCgetDeviceStatus() { *
* {"action":"getDeviceStatus","params":{}} *+ * + * NOTE: the gateway software is extremely sensible to this exact JSON structure. + * Any modifications (like omitting empty params) will lead to an gateway error. */ public static class Request { diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetFirmware.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetFirmware.java index e46cdc03a9655..20d31cac55bdc 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetFirmware.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetFirmware.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetLANConfig.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetLANConfig.java index d26f016530d7c..88d0f41f93443 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetLANConfig.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetLANConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetProducts.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetProducts.java index 3e8efa2d5674d..db254d783490c 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetProducts.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetProducts.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetScenes.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetScenes.java index 6e3800f710f54..a8ff7f82d4b58 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetScenes.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetScenes.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetWLANConfig.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetWLANConfig.java index 12f1f81ce6db7..7f6c2f55a2157 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetWLANConfig.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetWLANConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCidentifyProduct.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCidentifyProduct.java index 204bd3584dc0d..2c22c6fc4f44b 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCidentifyProduct.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCidentifyProduct.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogin.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogin.java index 2b1ea23d9c714..2d6ed4feacb5f 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogin.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogin.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogout.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogout.java index bf0fbd3ee8eac..d2505c03bfc44 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogout.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogout.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCproduct.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCproduct.java index a4c7396386b96..731e39e63be27 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCproduct.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCproduct.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCrunScene.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCrunScene.java index 07dd1e823ddcc..f94b992085309 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCrunScene.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCrunScene.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCsetSilentMode.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCsetSilentMode.java index 99c9a9f008302..534c40a8be0cb 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCsetSilentMode.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCsetSilentMode.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BridgeCommunicationProtocol.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BridgeCommunicationProtocol.java index e107de9b4152b..72d56563f8b7d 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BridgeCommunicationProtocol.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BridgeCommunicationProtocol.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -53,40 +53,32 @@ public interface BridgeCommunicationProtocol
* Besides the usual {@link BaseBridgeHandler} methods, it provides three methods
* for interaction,
@@ -66,6 +66,9 @@ public class VeluxBridgeHandler extends BaseBridgeHandler {
/** Configuration options for {@link VeluxBridgeHandler}. */
private VeluxBridgeConfiguration configuration = null;
+ /** Bridge {@link VeluxBridge}. */
+ private VeluxBridge veluxBridge = null;
+
/** BridgeCommunicationProtocol authentication token for Velux Bridge. */
private String authenticationToken = "";
@@ -100,12 +103,10 @@ public VeluxBridgeHandler(Bridge bridge) {
logger.trace("Creating a VeluxBridgeHandler for thing '{}'.", getThing().getUID());
}
- /**
- * {@inheritDoc}
- */
+ @SuppressWarnings({ "null", "unused" })
@Override
public void initialize() {
- logger.info("Initializing Velux bridge handler for '{}'.", getThing().getUID());
+ logger.info("Initializing Velux veluxBridge handler for '{}'.", getThing().getUID());
configuration = getConfigAs(VeluxBridgeConfiguration.class);
@@ -114,14 +115,20 @@ public void initialize() {
configuration = new VeluxBridgeConfiguration();
}
- if (configuration.bridgeURL.length() < 6) { // six means minimum of "http:/"
- logger.warn("Velux bridge configuration error (missing bridgeURL).");
+ if (configuration.bridgeIPAddress.length() < 7) { // seven means minimum of "1.1.1.1"
+ logger.warn("Velux veluxBridge configuration error (bad bridgeIPAddress).");
+ updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Unable to connect Velux Bridge.");
+ return;
+ }
+ if ((configuration.bridgeTCPPort < 1) || (configuration.bridgeTCPPort > 65535)) {
+ logger.warn("Velux veluxBridge configuration error (bad bridgeTCPPort).");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Unable to connect Velux Bridge.");
return;
}
logger.trace("Adjusting communication parameters.");
- VeluxBridge.ioSetup(configuration.retries, configuration.timeoutMsecs);
+ veluxBridge = new VeluxBridge();
+ veluxBridge.ioSetup(configuration.retries, configuration.timeoutMsecs);
logger.trace("Initializing empty storage for existing products.");
existingsProducts = new VeluxExistingProducts();
@@ -132,28 +139,23 @@ public void initialize() {
* Try a sequence of Login followed by Logout.
*/
if (bridgeLogin() && bridgeLogout()) {
-
- logger.debug("Velux bridge is online, now.");
+ logger.debug("Velux veluxBridge is online, now.");
updateStatus(ThingStatus.ONLINE);
/*
* Fetch all scenes for further invocations
*/
logger.trace("Fetch existing scenes.");
- VeluxBridgeGetScenes.getScenes(this);
-
+ new VeluxBridgeGetScenes().getScenes(this);
} else {
- logger.info("Velux bridge login/logout sequence failed; expecting bridge is OFFLINE.");
+ logger.info("Velux veluxBridge login/logout sequence failed; expecting veluxBridge is OFFLINE.");
updateStatus(ThingStatus.OFFLINE);
}
}
- /**
- * {@inheritDoc}
- */
@Override
public synchronized void dispose() {
- logger.trace("Shutting down Velux bridge '{}'.", getThing().getUID());
+ logger.trace("Shutting down Velux veluxBridge '{}'.", getThing().getUID());
logger.trace("dispose() releasing the authentication session by logging out.");
bridgeLogout();
@@ -177,9 +179,6 @@ public void channelLinked(ChannelUID channelUID) {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
logger.trace("handleCommand({},{}) called.", channelUID.getAsString(), command);
@@ -188,7 +187,6 @@ public void handleCommand(ChannelUID channelUID, Command command) {
if (command instanceof RefreshType) {
switch (channelId) {
-
case CHANNEL_BRIDGE_STATUS:
String deviceStatus = new VeluxBridgeDeviceStatus().retrieve(this);
logger.trace("handleCommand() updating {} to {}.", channelUID, deviceStatus);
@@ -287,7 +285,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
case CHANNEL_BRIDGE_PRODUCTS:
if (this.existingsProducts.getNoMembers() == 0) {
logger.trace("handleCommand() is about to fetch existing products.");
- VeluxBridgeGetProducts.getProducts(this);
+ new VeluxBridgeGetProducts().getProducts(this);
}
String productInfo = this.existingsProducts.toString();
logger.info("handleCommand() found products {}.", productInfo);
@@ -299,15 +297,14 @@ public void handleCommand(ChannelUID channelUID, Command command) {
default:
logger.trace("handleCommand() cannot handle REFRESH on channel {}.", channelId);
}
-
} else if (command instanceof OnOffType)
{
switch (channelId) {
- case CHANNEL_BRIDGE_DETECTION:
+ case CHANNEL_BRIDGE_DO_DETECTION:
if (command.equals(OnOffType.ON)) {
- logger.trace("handleCommand() about to activate bridge detection mode.");
- VeluxBridgeDetectProducts.detectProducts(this);
+ logger.trace("handleCommand() about to activate veluxBridge detection mode.");
+ new VeluxBridgeDetectProducts().detectProducts(this);
} else {
logger.trace("handleCommand() ignoring OFF command.");
}
@@ -320,18 +317,12 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public void childHandlerInitialized(ThingHandler childHandler, Thing childThing) {
logger.trace("childHandlerInitialized({},{}) called.", childHandler, childThing);
super.childHandlerInitialized(childHandler, childThing);
}
- /**
- * {@inheritDoc}
- */
@Override
public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) {
logger.trace("childHandlerDisposed({},{}) called.", childHandler, childThing);
@@ -339,7 +330,7 @@ public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) {
}
/**
- * Prepares an authorization request and communicate it with the Velux bridge.
+ * Prepares an authorization request and communicate it with the Velux veluxBridge.
* In the positive case, the return authorization token will be stored within this class
* for any further communication via {@link#bridgeCommunicate} up
* to a deauthorization with method {@link VeluxBridgeHandler#bridgeLogout}
@@ -363,7 +354,7 @@ public synchronized boolean bridgeLogin() {
}
/**
- * Prepares an (authenticated!) deauthorization request and communicate it with the Velux bridge.
+ * Prepares an (authenticated!) deauthorization request and communicate it with the Velux veluxBridge.
* In any case, the authorization token stored in this class will be destroyed, so that the
* next communication has to start with {@link VeluxBridgeHandler#bridgeLogin}.
*
@@ -389,22 +380,17 @@ public synchronized boolean bridgeLogout() {
}
/**
- * Initializes a client/server communication towards Velux bridge
+ * Initializes a client/server communication towards Velux veluxBridge
* based on the Basic I/O interface {@link VeluxBridge} and parameters
* passed as arguments (see below) and provided by {@link VeluxBridgeConfiguration}.
*
- * @param communication
- * Structure of interface type {@link BridgeCommunicationProtocol} describing the intended communication,
+ * @param communication Structure of interface type {@link BridgeCommunicationProtocol} describing the intended
+ * communication,
* that is request and response interactions as well as appropriate URL definition.
- *
- * @param