diff --git a/bundles/org.openhab.binding.intesis/README.md b/bundles/org.openhab.binding.intesis/README.md index b591e6ddffca3..648987bc71e56 100644 --- a/bundles/org.openhab.binding.intesis/README.md +++ b/bundles/org.openhab.binding.intesis/README.md @@ -19,11 +19,12 @@ Intesis devices do not support auto discovery. The binding uses the following configuration parameters. -| Parameter | Valid for ThingType | Description | -|-----------|---------------------|----------------------------------------------------------------| -| ipAddress | Both | IP-Address of the device | -| password | IntesisHome | Password to login to the local webserver of IntesisHome device | -| port | IntesisBox | TCP port to connect to IntesisBox device, defaults to 3310 | +| Parameter | Valid for ThingType | Description | +|------------------|---------------------|----------------------------------------------------------------| +| ipAddress | Both | IP-Address of the device | +| password | IntesisHome | Password to login to the local webserver of IntesisHome device | +| port | IntesisBox | TCP port to connect to IntesisBox device, defaults to 3310 | +| pollingInterval | Both | Interval to retrieve updates from the connected devices | ## Channels diff --git a/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/IntesisBindingConstants.java b/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/IntesisBindingConstants.java index b63017ea30ee5..1ee3b1f15dde3 100644 --- a/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/IntesisBindingConstants.java +++ b/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/IntesisBindingConstants.java @@ -27,7 +27,6 @@ public class IntesisBindingConstants { public static final String BINDING_ID = "intesis"; public static final int INTESIS_HTTP_API_TIMEOUT_MS = 5000; - public static final int INTESIS_REFRESH_INTERVAL_SEC = 30; // List of all Thing Type UIDs public static final ThingTypeUID THING_TYPE_INTESISHOME = new ThingTypeUID(BINDING_ID, "intesisHome"); diff --git a/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/api/IntesisHomeHttpApi.java b/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/api/IntesisHomeHttpApi.java index 6f28d7d4bad81..19bf1561b6722 100644 --- a/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/api/IntesisHomeHttpApi.java +++ b/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/api/IntesisHomeHttpApi.java @@ -63,7 +63,7 @@ public String postRequest(String ipAddress, String contentString) { String response = contentResponse.getContentAsString().replace("\t", "").replace("\r\n", "").trim(); - if (response != null && !response.isEmpty()) { + if (!response.isEmpty()) { return response; } else { return null; diff --git a/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/config/IntesisBoxConfiguration.java b/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/config/IntesisBoxConfiguration.java index d7ae5040553a6..20fd281eaf031 100644 --- a/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/config/IntesisBoxConfiguration.java +++ b/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/config/IntesisBoxConfiguration.java @@ -23,4 +23,5 @@ public class IntesisBoxConfiguration { public String ipAddress = ""; public int port; + public int pollingInterval = 45; } diff --git a/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/config/IntesisHomeConfiguration.java b/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/config/IntesisHomeConfiguration.java index ed5c7f9424511..933efcaa4b065 100644 --- a/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/config/IntesisHomeConfiguration.java +++ b/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/config/IntesisHomeConfiguration.java @@ -23,4 +23,5 @@ public class IntesisHomeConfiguration { public String ipAddress = ""; public String password = ""; + public int pollingInterval = 30; } diff --git a/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/handler/IntesisBoxHandler.java b/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/handler/IntesisBoxHandler.java index 8257d47e3bef7..8de6e1af2d800 100644 --- a/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/handler/IntesisBoxHandler.java +++ b/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/handler/IntesisBoxHandler.java @@ -93,7 +93,6 @@ public void initialize() { config = getConfigAs(IntesisBoxConfiguration.class); if (!config.ipAddress.isEmpty()) { - updateStatus(ThingStatus.UNKNOWN); scheduler.submit(() -> { @@ -107,14 +106,13 @@ public void initialize() { intesisLocalApi.sendId(); intesisLocalApi.sendLimitsQuery(); intesisLocalApi.sendAlive(); - } catch (IOException e) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); return; } updateStatus(ThingStatus.ONLINE); }); - pollingTask = scheduler.scheduleWithFixedDelay(this::polling, 3, 45, TimeUnit.SECONDS); + pollingTask = scheduler.scheduleWithFixedDelay(this::polling, 3, config.pollingInterval, TimeUnit.SECONDS); } else { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "No IP address specified)"); } @@ -237,7 +235,7 @@ private void receivedUpdate(String function, String receivedValue) { break; case "SETPTEMP": - if (value.equals("32768")) { + if ("32768".equals(value)) { value = "0"; } updateState(CHANNEL_TYPE_TARGETTEMP, @@ -277,7 +275,7 @@ private void receivedUpdate(String function, String receivedValue) { private void handleMessage(String data) { logger.debug("handleMessage(): Message received - {}", data); - if (data.equals("ACK") || data.equals("")) { + if ("ACK".equals(data) || "".equals(data)) { return; } if (data.startsWith(ID + ':')) { @@ -295,7 +293,7 @@ private void handleMessage(String data) { case LIMITS: logger.debug("handleMessage(): Limits received - {}", data); String function = message.getFunction(); - if (function.equals("SETPTEMP")) { + if ("SETPTEMP".equals(function)) { List limits = message.getLimitsValue().stream().map(l -> Double.valueOf(l) / 10.0d) .collect(Collectors.toList()); if (limits.size() == 2) { diff --git a/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/handler/IntesisHomeHandler.java b/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/handler/IntesisHomeHandler.java index 2e9e80dd9658f..f352fc2a6edbc 100644 --- a/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/handler/IntesisHomeHandler.java +++ b/bundles/org.openhab.binding.intesis/src/main/java/org/openhab/binding/intesis/internal/handler/IntesisHomeHandler.java @@ -137,7 +137,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { int value = 0; String channelId = channelUID.getId(); if (command instanceof RefreshType) { - // Refresh command is not supported as the binding polls all values every 30 seconds + getAllUidValues(); } else { switch (channelId) { case CHANNEL_TYPE_POWER: @@ -466,7 +466,7 @@ private void handleDataPointsResponse(Response response) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); } logger.trace("Start Refresh Job"); - refreshJob = scheduler.scheduleWithFixedDelay(this::getAllUidValues, 0, INTESIS_REFRESH_INTERVAL_SEC, + refreshJob = scheduler.scheduleWithFixedDelay(this::getAllUidValues, 0, config.pollingInterval, TimeUnit.SECONDS); } diff --git a/bundles/org.openhab.binding.intesis/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.intesis/src/main/resources/OH-INF/thing/thing-types.xml index 32d2cef57fb1b..703981bab9c63 100644 --- a/bundles/org.openhab.binding.intesis/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.intesis/src/main/resources/OH-INF/thing/thing-types.xml @@ -22,6 +22,15 @@ @text/thing-type.config.intesisHome.password.description password + + + + Defines the time in seconds to pull the + state of the connected devices. The minimum is 30 + seconds. + + 30 + @@ -46,6 +55,15 @@ The TCP port to the IntesisBox. 3310 + + + + Defines the time in seconds to pull the + state of the connected devices. The minimum is 45 + seconds. + + 45 +