diff --git a/bundles/org.openhab.binding.konnected/src/main/java/org/openhab/binding/konnected/internal/KonnectedBindingConstants.java b/bundles/org.openhab.binding.konnected/src/main/java/org/openhab/binding/konnected/internal/KonnectedBindingConstants.java index a328ae54e..cfc0ad9ea 100644 --- a/bundles/org.openhab.binding.konnected/src/main/java/org/openhab/binding/konnected/internal/KonnectedBindingConstants.java +++ b/bundles/org.openhab.binding.konnected/src/main/java/org/openhab/binding/konnected/internal/KonnectedBindingConstants.java @@ -36,11 +36,11 @@ public class KonnectedBindingConstants { public static final ThingTypeUID THING_TYPE_PROMODULE = new ThingTypeUID(BINDING_ID, PRO_MODULE); // Thing config properties - public static final String HOST = "ipAddress"; + public static final String BASE_URL = "baseUrl"; public static final String MAC_ADDR = "macAddress"; - public static final String REQUEST_TIMEOUT = "request_timeout"; - public static final String RETRY_COUNT = "retry_count"; - public static final String CALLBACK_URI = "callback_uri"; + public static final String REQUEST_TIMEOUT = "requestTimeout"; + public static final String RETRY_COUNT = "retryCount"; + public static final String CALLBACK_URL = "callbackUrl"; // ESP8266_ZONE_TO_PIN map, this maps a zone to a pin for ESP8266 based devices // Source: https://help.konnected.io/support/solutions/articles/32000026808-zone-to-gpio-pin-mapping diff --git a/bundles/org.openhab.binding.konnected/src/main/java/org/openhab/binding/konnected/internal/discovery/KonnectedUPnPServer.java b/bundles/org.openhab.binding.konnected/src/main/java/org/openhab/binding/konnected/internal/discovery/KonnectedUPnPServer.java index 360954aac..29a512ec6 100644 --- a/bundles/org.openhab.binding.konnected/src/main/java/org/openhab/binding/konnected/internal/discovery/KonnectedUPnPServer.java +++ b/bundles/org.openhab.binding.konnected/src/main/java/org/openhab/binding/konnected/internal/discovery/KonnectedUPnPServer.java @@ -60,7 +60,7 @@ public class KonnectedUPnPServer implements UpnpDiscoveryParticipant { ThingUID uid = getThingUID(device); if (uid != null) { Map properties = new HashMap<>(); - properties.put(HOST, device.getDetails().getBaseURL()); + properties.put(BASE_URL, device.getDetails().getBaseURL()); properties.put(MAC_ADDR, device.getDetails().getSerialNumber()); DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties) .withLabel(device.getDetails().getFriendlyName()).withRepresentationProperty(MAC_ADDR).build(); diff --git a/bundles/org.openhab.binding.konnected/src/main/java/org/openhab/binding/konnected/internal/handler/KonnectedHandler.java b/bundles/org.openhab.binding.konnected/src/main/java/org/openhab/binding/konnected/internal/handler/KonnectedHandler.java index 1e604f5c0..befa1e611 100644 --- a/bundles/org.openhab.binding.konnected/src/main/java/org/openhab/binding/konnected/internal/handler/KonnectedHandler.java +++ b/bundles/org.openhab.binding.konnected/src/main/java/org/openhab/binding/konnected/internal/handler/KonnectedHandler.java @@ -56,7 +56,7 @@ public class KonnectedHandler extends BaseThingHandler { private final String konnectedServletPath; private final KonnectedHTTPUtils http = new KonnectedHTTPUtils(30); private String callbackIpAddress = null; - private String moduleIpAddress; + private String baseUrl; private final Gson gson = new GsonBuilder().create(); private int retryCount; private final String thingID; @@ -177,8 +177,10 @@ public class KonnectedHandler extends BaseThingHandler { Configuration testConfig = this.getConfig(); String testRetryCount = testConfig.get(RETRY_COUNT).toString(); String testRequestTimeout = testConfig.get(REQUEST_TIMEOUT).toString(); + baseUrl = testConfig.get(BASE_URL).toString(); logger.debug("The RequestTimeout Parameter is Configured as: {}", testRequestTimeout); logger.debug("The Retry Count Parameter is Configured as: {}", testRetryCount); + logger.debug("Base URL is Configured as: {}", baseUrl); try { this.retryCount = Integer.parseInt(testRetryCount); } catch (NumberFormatException e) { @@ -224,7 +226,7 @@ public class KonnectedHandler extends BaseThingHandler { if (cfg[1].equals("softreset") && value instanceof Boolean && (Boolean) value) { scheduler.execute(() -> { try { - http.doGet(moduleIpAddress + "/settings?restart=true", null, retryCount); + http.doGet(baseUrl + "/settings?restart=true", null, retryCount); } catch (KonnectedHttpRetryExceeded e) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); } @@ -233,7 +235,7 @@ public class KonnectedHandler extends BaseThingHandler { } else if (cfg[1].equals("removewifi") && value instanceof Boolean && (Boolean) value) { scheduler.execute(() -> { try { - http.doGet(moduleIpAddress + "/settings?restore=true", null, retryCount); + http.doGet(baseUrl + "/settings?restore=true", null, retryCount); } catch (KonnectedHttpRetryExceeded e) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); } @@ -288,7 +290,6 @@ public class KonnectedHandler extends BaseThingHandler { } catch (ConfigValidationException e) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage()); } - this.moduleIpAddress = this.getThing().getProperties().get(HOST).toString(); scheduler.execute(() -> { try { String response = updateKonnectedModule(); @@ -320,7 +321,7 @@ public class KonnectedHandler extends BaseThingHandler { * @return a json settings payload which can be sent to the Konnected Module based on the Thing */ private String constructSettingsPayload() { - String apiUrl = (String) getThing().getConfiguration().get(CALLBACK_URI); + String apiUrl = (String) getThing().getConfiguration().get(CALLBACK_URL); if (apiUrl == null) { apiUrl = "http://" + callbackIpAddress + this.konnectedServletPath; } @@ -404,7 +405,7 @@ public class KonnectedHandler extends BaseThingHandler { */ private String updateKonnectedModule() throws KonnectedHttpRetryExceeded { String payload = constructSettingsPayload(); - String response = http.doPut(moduleIpAddress + "/settings", payload, retryCount); + String response = http.doPut(baseUrl + "/settings", payload, retryCount); logger.debug("The response of the put request was: {}", response); return response; } @@ -469,7 +470,7 @@ public class KonnectedHandler extends BaseThingHandler { path = "/device"; break; } - http.doPut(moduleIpAddress + path, payloadString, retryCount); + http.doPut(baseUrl + path, payloadString, retryCount); } else { logger.debug("The channel {} returned null for channelId.getID(): {}", channelId.toString(), channelId.getId()); @@ -515,7 +516,7 @@ public class KonnectedHandler extends BaseThingHandler { private void sendSetSwitchState(String thingId, String payloadString) throws KonnectedHttpRetryExceeded { String path = thingId.equals(WIFI_MODULE) ? "/device" : "/zone"; - String response = http.doGet(moduleIpAddress + path, payloadString, retryCount); + String response = http.doGet(baseUrl + path, payloadString, retryCount); KonnectedModuleGson[] events = gson.fromJson(response, KonnectedModuleGson[].class); for (KonnectedModuleGson event : events) { this.handleWebHookEvent(event); diff --git a/bundles/org.openhab.binding.konnected/src/main/resources/OH-INF/config/config.xml b/bundles/org.openhab.binding.konnected/src/main/resources/OH-INF/config/config.xml index c807b8798..ed3bacd31 100644 --- a/bundles/org.openhab.binding.konnected/src/main/resources/OH-INF/config/config.xml +++ b/bundles/org.openhab.binding.konnected/src/main/resources/OH-INF/config/config.xml @@ -9,6 +9,10 @@ + + + The base URL of the Konnected Alarm Panel. + When set to false the Led on the device won't blink during transmission. @@ -23,7 +27,7 @@ true true - + The number of times the binding attempts to send http requests to the Konnected Alarm Panel. Increase this setting if you are experiencing situations where the module is reporting as offline but you can access the @@ -32,7 +36,7 @@ 2 true - + The timeout period in seconds for HTTP requests to the Konnected Alarm Panel. The default is 30. Adjusting this setting can help in networks situations with high latency where the binding is erroneously reporting @@ -41,7 +45,7 @@ true - + The URI where the Konnected panel will make callbacks. The default is to auto detect the port and IP address of openHAB. This may not work in case you use a reverse proxy or openHAB diff --git a/bundles/org.openhab.binding.konnected/src/main/resources/OH-INF/i18n/konnected.properties b/bundles/org.openhab.binding.konnected/src/main/resources/OH-INF/i18n/konnected.properties index d6b00bb3d..ed42b7855 100644 --- a/bundles/org.openhab.binding.konnected/src/main/resources/OH-INF/i18n/konnected.properties +++ b/bundles/org.openhab.binding.konnected/src/main/resources/OH-INF/i18n/konnected.properties @@ -12,10 +12,12 @@ thing-type.konnected.wifi-module.description = The Konnected Wi-Fi Alarm Panel # thing types config +thing-type.config.konnected.module.baseUrl.label = Base URL +thing-type.config.konnected.module.baseUrl.description = The base URL of the Konnected Alarm Panel. thing-type.config.konnected.module.blink.label = Blink thing-type.config.konnected.module.blink.description = When set to false the Led on the device won't blink during transmission. -thing-type.config.konnected.module.callback_uri.label = Callback URI -thing-type.config.konnected.module.callback_uri.description = The URI where the Konnected panel will make callbacks. The default is to auto detect the port and IP address of openHAB. This may not work in case you use a reverse proxy or openHAB is running in Docker. Then the plugin is bound to the /konnected http context. +thing-type.config.konnected.module.callbackUrl.label = Callback URI +thing-type.config.konnected.module.callbackUrl.description = The URI where the Konnected panel will make callbacks. The default is to auto detect the port and IP address of openHAB. This may not work in case you use a reverse proxy or openHAB is running in Docker. Then the plugin is bound to the /konnected http context. thing-type.config.konnected.module.controller_removewifi.label = Factory Reset thing-type.config.konnected.module.controller_removewifi.description = Resets the module to Factory Conditions. thing-type.config.konnected.module.controller_sendConfig.label = Update Settings @@ -25,10 +27,10 @@ thing-type.config.konnected.module.controller_softreset.description = Send A Res thing-type.config.konnected.module.discovery.label = Discovery thing-type.config.konnected.module.discovery.description = If set to false the device will not respond to discovery requests via UPnP. Make sure you have statically assigned an IP address to the module before turning this setting off. See https://help.konnected.io/support/solutions/articles/32000023968-disabling-device-discovery thing-type.config.konnected.module.group.actions.label = Actions -thing-type.config.konnected.module.request_timeout.label = Request Timeout -thing-type.config.konnected.module.request_timeout.description = The timeout period in seconds for HTTP requests to the Konnected Alarm Panel. The default is 30. Adjusting this setting can help in networks situations with high latency where the binding is erroneously reporting the thing as offline. -thing-type.config.konnected.module.retry_count.label = Retry Count -thing-type.config.konnected.module.retry_count.description = The number of times the binding attempts to send http requests to the Konnected Alarm Panel. Increase this setting if you are experiencing situations where the module is reporting as offline but you can access the website of the Alarm Panel to confirm that the Alarm Panel is Konnected to the Network. This will allow the binding to attempt more retries before it considers the connection a failure and marks the thing as offline. +thing-type.config.konnected.module.requestTimeout.label = Request Timeout +thing-type.config.konnected.module.requestTimeout.description = The timeout period in seconds for HTTP requests to the Konnected Alarm Panel. The default is 30. Adjusting this setting can help in networks situations with high latency where the binding is erroneously reporting the thing as offline. +thing-type.config.konnected.module.retryCount.label = Retry Count +thing-type.config.konnected.module.retryCount.description = The number of times the binding attempts to send http requests to the Konnected Alarm Panel. Increase this setting if you are experiencing situations where the module is reporting as offline but you can access the website of the Alarm Panel to confirm that the Alarm Panel is Konnected to the Network. This will allow the binding to attempt more retries before it considers the connection a failure and marks the thing as offline. # channel types