Skip to content

Commit

Permalink
[ferroamp] Binding for ferroamp 20241128
Browse files Browse the repository at this point in the history
Changes done in:
FerroampHandler.java
FerroampMqttCommunication.java

Signed-off-by: Örjan Backsell <[email protected]>
  • Loading branch information
basse04 committed Nov 28, 2024
1 parent eb9a50e commit 07947b6
Show file tree
Hide file tree
Showing 2 changed files with 598 additions and 471 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class FerroampHandler extends BaseThingHandler implements MqttMessageSubs
private final static Logger logger = LoggerFactory.getLogger(FerroampHandler.class);
private @Nullable static MqttBrokerConnection ferroampConnection;
FerroampMqttCommunication ferroampMqttCommunication = new FerroampMqttCommunication(thing);
private @Nullable FerroampConfiguration ferroampConfig;
FerroampConfiguration ferroampConfig = new FerroampConfiguration();

private static List<FerroampChannelConfiguration> channelConfigEhub = new ArrayList<>();
private static List<FerroampChannelConfiguration> channelConfigSsoS1 = new ArrayList<>();
Expand Down Expand Up @@ -94,18 +94,12 @@ public void initialize() {
channelConfigEso = FerroampChannelConfiguration.getChannelConfigurationEso();
channelConfigEsm = FerroampChannelConfiguration.getChannelConfigurationEsm();

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);
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR);
logger.debug("Configuration problems");
}
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);
}

private void pollTask() {
Expand Down Expand Up @@ -244,7 +238,6 @@ public void processMessage(String topic, byte[] payload) {

public @Nullable static MqttBrokerConnection getFerroampConnection() {
try {

return ferroampConnection;
} catch (Exception e) {
logger.debug("Connection to MqttBroker disturbed during startup of MqttConnection");
Expand Down
Loading

0 comments on commit 07947b6

Please sign in to comment.