From 9d97fe4ed0f045f3bfeb9c8ef326548daa3eb3a3 Mon Sep 17 00:00:00 2001 From: lsiepel Date: Fri, 11 Oct 2024 13:12:43 +0200 Subject: [PATCH] Configurable refreshinterval (#17523) Signed-off-by: Leo Siepel --- bundles/org.openhab.binding.omnikinverter/README.md | 11 ++++++----- .../internal/OmnikInverterConfiguration.java | 1 + .../internal/handler/OmnikInverterHandler.java | 2 +- .../resources/OH-INF/i18n/omnikinverter.properties | 2 ++ .../src/main/resources/OH-INF/thing/thing-types.xml | 6 ++++++ 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bundles/org.openhab.binding.omnikinverter/README.md b/bundles/org.openhab.binding.omnikinverter/README.md index 54b649b0897..0d06b761570 100644 --- a/bundles/org.openhab.binding.omnikinverter/README.md +++ b/bundles/org.openhab.binding.omnikinverter/README.md @@ -13,11 +13,12 @@ No autodiscovery available ## Thing Configuration -| Config | Description | type | Default | -| :------- | :------------ | :----- | :-------- | -| hostname | The hostname or ip through which the inverter can be accessed | string | n/a | -| port | TCP port through which the inverter listens on for incoming connections | integer | 8899 | -| serial | The serial of the wifi module. The Wifi module's SSID contains the number. This is the numerical part only, i.e. without _AP__ | integer | n/a | +| Config | Description | type | Default | +|:----------------|:-------------------------------------------------------------------------------------------------------------------------------|:--------|:--------| +| hostname | The hostname or ip through which the inverter can be accessed | string | n/a | +| port | TCP port through which the inverter listens on for incoming connections | integer | 8899 | +| serial | The serial of the wifi module. The Wifi module's SSID contains the number. This is the numerical part only, i.e. without _AP__ | integer | n/a | +| refreshInterval | Interval the device is polled in seconds. | integer | 10 | ## Channels diff --git a/bundles/org.openhab.binding.omnikinverter/src/main/java/org/openhab/binding/omnikinverter/internal/OmnikInverterConfiguration.java b/bundles/org.openhab.binding.omnikinverter/src/main/java/org/openhab/binding/omnikinverter/internal/OmnikInverterConfiguration.java index adbf9cbfa81..fd087c59e53 100644 --- a/bundles/org.openhab.binding.omnikinverter/src/main/java/org/openhab/binding/omnikinverter/internal/OmnikInverterConfiguration.java +++ b/bundles/org.openhab.binding.omnikinverter/src/main/java/org/openhab/binding/omnikinverter/internal/OmnikInverterConfiguration.java @@ -24,4 +24,5 @@ public class OmnikInverterConfiguration { public String hostname = ""; public int port; public int serial; + public int refreshInterval = 10; } diff --git a/bundles/org.openhab.binding.omnikinverter/src/main/java/org/openhab/binding/omnikinverter/internal/handler/OmnikInverterHandler.java b/bundles/org.openhab.binding.omnikinverter/src/main/java/org/openhab/binding/omnikinverter/internal/handler/OmnikInverterHandler.java index fdf95cf952e..da2b01c9d9c 100644 --- a/bundles/org.openhab.binding.omnikinverter/src/main/java/org/openhab/binding/omnikinverter/internal/handler/OmnikInverterHandler.java +++ b/bundles/org.openhab.binding.omnikinverter/src/main/java/org/openhab/binding/omnikinverter/internal/handler/OmnikInverterHandler.java @@ -74,7 +74,7 @@ public class OmnikInverterHandler extends BaseThingHandler { inverter = new OmnikInverter(config.hostname, config.port, config.serial); updateStatus(ThingStatus.UNKNOWN); - pollJob = scheduler.scheduleWithFixedDelay(this::updateData, 0, 10, TimeUnit.SECONDS); + pollJob = scheduler.scheduleWithFixedDelay(this::updateData, 0, config.refreshInterval, TimeUnit.SECONDS); } @Override diff --git a/bundles/org.openhab.binding.omnikinverter/src/main/resources/OH-INF/i18n/omnikinverter.properties b/bundles/org.openhab.binding.omnikinverter/src/main/resources/OH-INF/i18n/omnikinverter.properties index 0ab0fc4b5c5..fb639c1281e 100644 --- a/bundles/org.openhab.binding.omnikinverter/src/main/resources/OH-INF/i18n/omnikinverter.properties +++ b/bundles/org.openhab.binding.omnikinverter/src/main/resources/OH-INF/i18n/omnikinverter.properties @@ -50,6 +50,8 @@ thing-type.config.omnikinverter.omnik.hostname.label = Hostname thing-type.config.omnikinverter.omnik.hostname.description = The hostname or IP of the Omnik Inverter thing-type.config.omnikinverter.omnik.port.label = Port thing-type.config.omnikinverter.omnik.port.description = The TCP port of the Omnik inverter, usually 8899 +thing-type.config.omnikinverter.omnik.refreshInterval.label = Refresh Interval +thing-type.config.omnikinverter.omnik.refreshInterval.description = Interval the device is polled in seconds. thing-type.config.omnikinverter.omnik.serial.label = Serial thing-type.config.omnikinverter.omnik.serial.description = The serial of the Omnik inverter's Wifi module. This the number part only. diff --git a/bundles/org.openhab.binding.omnikinverter/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.omnikinverter/src/main/resources/OH-INF/thing/thing-types.xml index e8010521fd1..76341eba8b2 100644 --- a/bundles/org.openhab.binding.omnikinverter/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.omnikinverter/src/main/resources/OH-INF/thing/thing-types.xml @@ -103,6 +103,12 @@ The serial of the Omnik inverter's Wifi module. This the number part only. + + + Interval the device is polled in seconds. + 10 + true +