From eb9a50e953bdee9f1960ad2328c7fae034e72ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96rjan=20Backsell?= Date: Tue, 26 Nov 2024 12:10:59 +0100 Subject: [PATCH] [ferroamp] Binding for ferroamp 20241126 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes done in FerroampHandler.java Signed-off-by: Örjan Backsell --- .../binding/ferroamp/internal/FerroampHandler.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bundles/org.openhab.binding.ferroamp/src/main/java/org/openhab/binding/ferroamp/internal/FerroampHandler.java b/bundles/org.openhab.binding.ferroamp/src/main/java/org/openhab/binding/ferroamp/internal/FerroampHandler.java index c47b20b4b6c..82534487bec 100644 --- a/bundles/org.openhab.binding.ferroamp/src/main/java/org/openhab/binding/ferroamp/internal/FerroampHandler.java +++ b/bundles/org.openhab.binding.ferroamp/src/main/java/org/openhab/binding/ferroamp/internal/FerroampHandler.java @@ -84,6 +84,7 @@ public class FerroampHandler extends BaseThingHandler implements MqttMessageSubs public void initialize() { // Set configuration parameters ferroampConfig = getConfigAs(FerroampConfiguration.class); + // Set channel configuration parameters channelConfigEhub = FerroampChannelConfiguration.getChannelConfigurationEhub(); channelConfigSsoS1 = FerroampChannelConfiguration.getChannelConfigurationSsoS1(); @@ -93,13 +94,11 @@ public class FerroampHandler extends BaseThingHandler implements MqttMessageSubs channelConfigEso = FerroampChannelConfiguration.getChannelConfigurationEso(); channelConfigEsm = FerroampChannelConfiguration.getChannelConfigurationEsm(); - if (ferroampConfig != null && channelConfigEhub != null && channelConfigSsoS1 != null - && channelConfigSsoS2 != null && channelConfigSsoS3 != null && channelConfigSsoS4 != null - && channelConfigEso != null && channelConfigEsm != null) { + if (ferroampConfig != null) { + FerroampConfiguration ferroampConfig = getConfigAs(FerroampConfiguration.class); final MqttBrokerConnection ferroampConnection = new MqttBrokerConnection(ferroampConfig.hostName, FerroampBindingConstants.BROKER_PORT, false, false, ferroampConfig.userName); - scheduler.scheduleWithFixedDelay(this::pollTask, 60, refreshInterval, TimeUnit.SECONDS); this.setFerroampConnection(ferroampConnection); updateStatus(ThingStatus.UNKNOWN); @@ -111,7 +110,7 @@ public class FerroampHandler extends BaseThingHandler implements MqttMessageSubs private void pollTask() { try { - startMqttConnection(); + startMqttConnection(getConfigAs(FerroampConfiguration.class)); } catch (InterruptedException e) { logger.debug("Not connected to the MqttBroker"); return; @@ -134,7 +133,7 @@ public class FerroampHandler extends BaseThingHandler implements MqttMessageSubs } } - private void startMqttConnection() throws InterruptedException { + private void startMqttConnection(FerroampConfiguration ferroampConfig) throws InterruptedException { MqttBrokerConnection localSubscribeConnection = FerroampHandler.getFerroampConnection();