[knx] Allow disabling device polling (#20740)

Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Kai Kreuzer
2026-05-17 01:19:16 +02:00
committed by GitHub
parent 355ea5fdb2
commit 43f70c3b8e
4 changed files with 23 additions and 18 deletions
+6 -6
View File
@@ -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.
@@ -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);
@@ -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
@@ -25,7 +25,7 @@
</parameter>
<parameter name="pingInterval" type="integer">
<label>Ping Interval</label>
<description>Interval (in seconds) between attempts to poll the device status</description>
<description>Interval (in seconds) between attempts to poll the device status (0 disables polling)</description>
<default>600</default>
</parameter>
<parameter name="readInterval" type="integer">