diff --git a/bundles/org.openhab.binding.knx/README.md b/bundles/org.openhab.binding.knx/README.md index d2a8632e86..ed575a4f51 100644 --- a/bundles/org.openhab.binding.knx/README.md +++ b/bundles/org.openhab.binding.knx/README.md @@ -97,12 +97,12 @@ When _fetch_ is set to true, the binding will read out the memory of the KNX act This is just for information and has no effect on the functionality of the binding. It can safely be turned off to save bandwidth on the bus or avoid problems with older devices. -| Name | Required | Description | Default value | -|--------------|----------|--------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------| -| address | N | The individual device address (in 0.0.0 notation) | - | -| fetch | N | Read out the device parameters and address/communication object tables (requires the address) | false | -| pingInterval | N | Interval (in seconds) to contact the device and set the Thing status based on the result (requires the address) | 600 | -| readInterval | N | Interval (in seconds) to actively request reading of values from the bus (0 if they should only be read once at startup) | 0 | +| Name | Required | Description | Default value | +|----------------|------------|--------------------------------------------------------------------------------------------------------------------------------------------------|-----------------| +| address | N | The individual device address (in 0.0.0 notation) | - | +| fetch | N | Read out the device parameters and address/communication object tables (requires the address) | false | +| pingInterval | N | Interval (in seconds) to contact the device and set the Thing status based on the result (requires the address, 0 disables polling) | 600 | +| readInterval | N | Interval (in seconds) to actively request reading of values from the bus (0 if they should only be read once at startup) | 0 | Different kinds of channels are defined and can be used to group together Group Addresses. All channels of a device share one configuration parameter defined at the device level: _readInterval_, an optional parameter that indicates if the 'readable' group addresses of that Channel should be read periodically at the given interval, in seconds. diff --git a/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/handler/DeviceThingHandler.java b/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/handler/DeviceThingHandler.java index ff44c1d208..b6ca5243e0 100644 --- a/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/handler/DeviceThingHandler.java +++ b/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/handler/DeviceThingHandler.java @@ -12,7 +12,7 @@ */ package org.openhab.binding.knx.internal.handler; -import static org.openhab.binding.knx.internal.KNXBindingConstants.*; +import static org.openhab.binding.knx.internal.KNXBindingConstants.CHANNEL_RESET; import java.math.BigDecimal; import java.time.Duration; @@ -509,8 +509,8 @@ public class DeviceThingHandler extends BaseThingHandler implements GroupAddress updateStatus(ThingStatus.ONLINE); DeviceConfig config = getConfigAs(DeviceConfig.class); if (!filledDescription && config.getFetch()) { - Future descriptionJob = this.descriptionJob; - if (descriptionJob == null || descriptionJob.isCancelled()) { + Future currentDescriptionJob = this.descriptionJob; + if (currentDescriptionJob == null || currentDescriptionJob.isCancelled()) { long initialDelay = Math.round(config.getPingInterval() * random.nextFloat()); this.descriptionJob = getBackgroundScheduler().schedule(() -> { filledDescription = describeDevice(address); @@ -537,17 +537,22 @@ public class DeviceThingHandler extends BaseThingHandler implements GroupAddress DeviceConfig config = getConfigAs(DeviceConfig.class); try { if (!config.getAddress().isEmpty()) { - updateStatus(ThingStatus.UNKNOWN); address = new IndividualAddress(config.getAddress()); long pingInterval = config.getPingInterval(); - long initialPingDelay = Math.round(INITIAL_PING_DELAY * random.nextFloat()); + if (pingInterval <= 0) { + logger.debug("Polling disabled for '{}' (pingInterval={})", getThing().getUID(), pingInterval); + updateStatus(ThingStatus.ONLINE); + } else { + updateStatus(ThingStatus.UNKNOWN); + long initialPingDelay = Math.round(INITIAL_PING_DELAY * random.nextFloat()); - ScheduledFuture pollingJob = this.pollingJob; - if ((pollingJob == null || pollingJob.isCancelled())) { - logger.debug("'{}' will be polled every {}s", getThing().getUID(), pingInterval); - this.pollingJob = getBackgroundScheduler().scheduleWithFixedDelay(this::pollDeviceStatus, - initialPingDelay, pingInterval, TimeUnit.SECONDS); + ScheduledFuture currentPollingJob = this.pollingJob; + if ((currentPollingJob == null || currentPollingJob.isCancelled())) { + logger.debug("'{}' will be polled every {}s", getThing().getUID(), pingInterval); + this.pollingJob = getBackgroundScheduler().scheduleWithFixedDelay(this::pollDeviceStatus, + initialPingDelay, pingInterval, TimeUnit.SECONDS); + } } } else { updateStatus(ThingStatus.ONLINE); diff --git a/bundles/org.openhab.binding.knx/src/main/resources/OH-INF/i18n/knx.properties b/bundles/org.openhab.binding.knx/src/main/resources/OH-INF/i18n/knx.properties index e72ee49805..1b951aeecc 100644 --- a/bundles/org.openhab.binding.knx/src/main/resources/OH-INF/i18n/knx.properties +++ b/bundles/org.openhab.binding.knx/src/main/resources/OH-INF/i18n/knx.properties @@ -24,7 +24,7 @@ thing-type.config.knx.device.address.description = The individual address in x.y thing-type.config.knx.device.fetch.label = Fetch thing-type.config.knx.device.fetch.description = Read out the device parameters and address/communication object tables thing-type.config.knx.device.pingInterval.label = Ping Interval -thing-type.config.knx.device.pingInterval.description = Interval (in seconds) between attempts to poll the device status +thing-type.config.knx.device.pingInterval.description = Interval (in seconds) between attempts to poll the device status (0 disables polling) thing-type.config.knx.device.readInterval.label = Read Interval thing-type.config.knx.device.readInterval.description = Interval (in seconds) between attempts to read the status group addresses on the bus thing-type.config.knx.ip.autoReconnectPeriod.label = Auto Reconnect Period diff --git a/bundles/org.openhab.binding.knx/src/main/resources/OH-INF/thing/device.xml b/bundles/org.openhab.binding.knx/src/main/resources/OH-INF/thing/device.xml index 65c0565a71..02e2cd7858 100644 --- a/bundles/org.openhab.binding.knx/src/main/resources/OH-INF/thing/device.xml +++ b/bundles/org.openhab.binding.knx/src/main/resources/OH-INF/thing/device.xml @@ -25,7 +25,7 @@ - Interval (in seconds) between attempts to poll the device status + Interval (in seconds) between attempts to poll the device status (0 disables polling) 600