From 546cb3241ac45ab2152b0a35a22658e376048d0c Mon Sep 17 00:00:00 2001 From: Alexander Drent <81358972+adr001db@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:59:54 +0200 Subject: [PATCH] [ONECTA] Refactoring remove statics - Cherrypicking Some extra picking :o) Remove static from void's in OnectaConnectionClient Done due to issue creating unittests on static's Signed-off-by: Alexander Drent --- .../internal/OnectaBridgeHandlerFactory.java | 4 - .../internal/api/OnectaConnectionClient.java | 83 ++++++++++--------- .../internal/handler/OnectaBridgeHandler.java | 11 +-- .../service/DataTransportService.java | 39 ++++----- .../service/DeviceDiscoveryService.java | 7 +- 5 files changed, 72 insertions(+), 72 deletions(-) diff --git a/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/OnectaBridgeHandlerFactory.java b/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/OnectaBridgeHandlerFactory.java index 0dd6d65c69781..678badb151112 100644 --- a/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/OnectaBridgeHandlerFactory.java +++ b/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/OnectaBridgeHandlerFactory.java @@ -21,7 +21,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.onecta.internal.api.OnectaConnectionClient; import org.openhab.binding.onecta.internal.handler.*; import org.openhab.binding.onecta.internal.service.DeviceDiscoveryService; import org.openhab.core.config.discovery.DiscoveryService; @@ -53,9 +52,7 @@ public class OnectaBridgeHandlerFactory extends BaseThingHandlerFactory { GATEWAY_THING_TYPE, WATERTANK_THING_TYPE, INDOORUNIT_THING_TYPE); private HttpClientFactory httpClientFactory; private final TimeZoneProvider timeZoneProvider; - private @Nullable OnectaBridgeHandler bridgeHandler = null; - private Map> discoveryServiceRegs = new HashMap<>(); @Activate @@ -64,7 +61,6 @@ public OnectaBridgeHandlerFactory(@Reference HttpClientFactory httpClientFactory this.httpClientFactory = httpClientFactory; this.timeZoneProvider = timeZoneProvider; OnectaConfiguration.setHttpClientFactory(httpClientFactory); - OnectaConnectionClient.SetConnectionClient(); } @Override diff --git a/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/api/OnectaConnectionClient.java b/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/api/OnectaConnectionClient.java index 2931a6687b9f2..b84fa8987110d 100644 --- a/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/api/OnectaConnectionClient.java +++ b/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/api/OnectaConnectionClient.java @@ -41,31 +41,33 @@ public class OnectaConnectionClient { public static final String HTTPHEADER_BEARER = "Bearer %s"; public static final String USER_AGENT_VALUE = "Daikin/1.6.1.4681 CFNetwork/1209 Darwin/20.2.0"; public static final String HTTPHEADER_X_API_KEY_VALUE = "xw6gvOtBHq5b1pyceadRp6rujSNSZdjx2AqT03iC"; - static private JsonArray rawData = new JsonArray(); - static private Units onectaData = new Units(); - - public static Units getUnits() { - return onectaData; - } + private static JsonArray rawData = new JsonArray(); + private static Units onectaData = new Units(); private static OnectaSignInClient onectaSignInClient; - public static void SetConnectionClient() { - onectaSignInClient = new OnectaSignInClient(); + public OnectaConnectionClient() { + if (onectaSignInClient == null) { + onectaSignInClient = new OnectaSignInClient(); + } + } + + public Units getUnits() { + return onectaData; } - public static void startConnecton(String userId, String password, String refreshToken) + public void startConnecton(String userId, String password, String refreshToken) throws DaikinCommunicationException { onectaSignInClient.signIn(userId, password, refreshToken); } - public static Boolean isOnline() { + public Boolean isOnline() { return onectaSignInClient.isOnline(); } - private static Response doBearerRequestGet(Boolean refreshed) throws DaikinCommunicationException { + private Response doBearerRequestGet(Boolean refreshed) throws DaikinCommunicationException { Response response = null; - logger.debug(String.format("doBearerRequestGet : refreshed %s", refreshed.toString())); + logger.debug(String.format("doBearerRequestGet : Accesstoken refreshed %s", refreshed.toString())); try { if (!onectaSignInClient.isOnline()) { onectaSignInClient.signIn(); @@ -96,11 +98,11 @@ private static Response doBearerRequestGet(Boolean refreshed) throws DaikinCommu return response; } - private static Response doBearerRequestPatch(String url, Object body) { + private Response doBearerRequestPatch(String url, Object body) { return doBearerRequestPatch(url, body, false); } - private static Response doBearerRequestPatch(String url, Object body, Boolean refreshed) { + private Response doBearerRequestPatch(String url, Object body, Boolean refreshed) { Response response = null; try { if (!onectaSignInClient.isOnline()) { @@ -135,7 +137,7 @@ private static Response doBearerRequestPatch(String url, Object body, Boolean re return response; } - public static void refreshUnitsData(Thing bridgeThing) throws DaikinCommunicationException { + public void refreshUnitsData(Thing bridgeThing) throws DaikinCommunicationException { Response response = null; String jsonString = ""; boolean dataAvailable = false; @@ -172,11 +174,11 @@ public static void refreshUnitsData(Thing bridgeThing) throws DaikinCommunicatio } } - public static Unit getUnit(String unitId) { + public Unit getUnit(String unitId) { return onectaData.findById(unitId); } - public static JsonObject getRawData(String unitId) { + public JsonObject getRawData(String unitId) { JsonObject jsonObject = null; for (int i = 0; i < rawData.size(); i++) { jsonObject = rawData.get(i).getAsJsonObject(); @@ -188,32 +190,31 @@ public static JsonObject getRawData(String unitId) { return new JsonObject(); } - public static void setPowerOnOff(String unitId, String managementPointType, Enums.OnOff value) { + public void setPowerOnOff(String unitId, String managementPointType, Enums.OnOff value) { logger.debug(String.format("setPowerOnOff : %s, %s, %s", unitId, managementPointType, value)); CommandOnOf commandOnOf = new CommandOnOf(value); doBearerRequestPatch(getUrlOnOffTest(unitId, managementPointType), commandOnOf); } - public static void setPowerOnOff(String unitId, Enums.ManagementPoint managementPointType, Enums.OnOff value) { + public void setPowerOnOff(String unitId, Enums.ManagementPoint managementPointType, Enums.OnOff value) { logger.debug(String.format("setPowerOnOff : %s, %s, %s", unitId, managementPointType.getValue(), value)); CommandOnOf commandOnOf = new CommandOnOf(value); doBearerRequestPatch(getUrlOnOff(unitId, managementPointType), commandOnOf); } - public static void setPowerFulModeOnOff(String unitId, Enums.ManagementPoint managementPointType, - Enums.OnOff value) { + public void setPowerFulModeOnOff(String unitId, Enums.ManagementPoint managementPointType, Enums.OnOff value) { logger.debug(String.format("setPowerFulModeOnOff : %s, %s, %s", unitId, managementPointType.getValue(), value)); CommandOnOf commandOnOf = new CommandOnOf(value); doBearerRequestPatch(getUrlPowerFulModeOnOff(unitId, managementPointType), commandOnOf); } - public static void setEconoMode(String unitId, Enums.ManagementPoint managementPointType, Enums.OnOff value) { + public void setEconoMode(String unitId, Enums.ManagementPoint managementPointType, Enums.OnOff value) { logger.debug(String.format("setEconoMode: %s, %s, %s", unitId, managementPointType.getValue(), value)); CommandOnOf commandOnOf = new CommandOnOf(value); doBearerRequestPatch(getEconoMode(unitId, managementPointType), commandOnOf); } - public static void setCurrentOperationMode(String unitId, Enums.ManagementPoint managementPointType, + public void setCurrentOperationMode(String unitId, Enums.ManagementPoint managementPointType, Enums.OperationMode operationMode) { logger.debug(String.format("setCurrentOperationMode : %s, %s, %s", unitId, managementPointType.getValue(), operationMode.getValue())); @@ -221,7 +222,7 @@ public static void setCurrentOperationMode(String unitId, Enums.ManagementPoint OnectaProperties.getOperationModeCommand(operationMode)); } - public static void setCurrentTemperatureRoomSet(String unitId, String embeddedId, Enums.OperationMode currentMode, + public void setCurrentTemperatureRoomSet(String unitId, String embeddedId, Enums.OperationMode currentMode, float value) { logger.debug( String.format("setCurrentTemperatureRoomSet : %s, %s, %s", unitId, embeddedId, currentMode.getValue())); @@ -229,15 +230,15 @@ public static void setCurrentTemperatureRoomSet(String unitId, String embeddedId OnectaProperties.getTemperatureRoomControlCommand(value, currentMode)); } - public static void setCurrentTemperatureHotWaterSet(String unitId, String embeddedId, - Enums.OperationMode currentMode, float value) { + public void setCurrentTemperatureHotWaterSet(String unitId, String embeddedId, Enums.OperationMode currentMode, + float value) { logger.debug(String.format("setCurrentTemperatureHotWaterSet : %s, %s, %s", unitId, embeddedId, currentMode.getValue())); doBearerRequestPatch(OnectaProperties.getTemperatureControlUrl(unitId, embeddedId), OnectaProperties.getTemperatureHotWaterControlCommand(value, currentMode)); } - public static void setFanSpeed(String unitId, String embeddedId, Enums.OperationMode currentMode, + public void setFanSpeed(String unitId, String embeddedId, Enums.OperationMode currentMode, Enums.FanSpeed fanspeed) { logger.debug(String.format("setFanSpeed : %s, %s, %s", unitId, embeddedId, currentMode.getValue())); doBearerRequestPatch(OnectaProperties.getTFanControlUrl(unitId, embeddedId), @@ -248,7 +249,7 @@ public static void setFanSpeed(String unitId, String embeddedId, Enums.Operation } } - public static void setCurrentFanDirection(String unitId, String embeddedId, Enums.OperationMode currentMode, + public void setCurrentFanDirection(String unitId, String embeddedId, Enums.OperationMode currentMode, Enums.FanMovement fanMovement) { logger.debug(String.format("setCurrentFanDirection : %s, %s, %s", unitId, embeddedId, currentMode.getValue())); String url = getTFanControlUrl(unitId, embeddedId); @@ -286,7 +287,7 @@ public static void setCurrentFanDirection(String unitId, String embeddedId, Enum } } - public static void setCurrentFanDirectionHor(String unitId, String embeddedId, Enums.OperationMode currentMode, + public void setCurrentFanDirectionHor(String unitId, String embeddedId, Enums.OperationMode currentMode, Enums.FanMovementHor fanMovement) { logger.debug( String.format("setCurrentFanDirectionHor : %s, %s, %s", unitId, embeddedId, currentMode.getValue())); @@ -294,7 +295,7 @@ public static void setCurrentFanDirectionHor(String unitId, String embeddedId, E doBearerRequestPatch(url, OnectaProperties.getTFanDirectionHorCommand(currentMode, fanMovement)); } - public static void setCurrentFanDirectionVer(String unitId, String embeddedId, Enums.OperationMode currentMode, + public void setCurrentFanDirectionVer(String unitId, String embeddedId, Enums.OperationMode currentMode, Enums.FanMovementVer fanMovement) { logger.debug( String.format("setCurrentFanDirectionVer : %s, %s, %s", unitId, embeddedId, currentMode.getValue())); @@ -302,53 +303,53 @@ public static void setCurrentFanDirectionVer(String unitId, String embeddedId, E doBearerRequestPatch(url, OnectaProperties.getTFanDirectionVerCommand(currentMode, fanMovement)); } - public static void setStreamerMode(String unitId, String embeddedId, Enums.OnOff value) { + public void setStreamerMode(String unitId, String embeddedId, Enums.OnOff value) { logger.debug(String.format("setStreamerMode: %s, %s, %s", unitId, embeddedId, value)); CommandOnOf commandOnOf = new CommandOnOf(value); doBearerRequestPatch(getStreamerMode(unitId, embeddedId), commandOnOf); } - public static void setHolidayMode(String unitId, String embeddedId, Enums.OnOff value) { + public void setHolidayMode(String unitId, String embeddedId, Enums.OnOff value) { logger.debug(String.format("setHolidayMode: %s, %s, %s", unitId, embeddedId, value)); CommandTrueFalse commandTrueFalse = new CommandTrueFalse(value); doBearerRequestPatch(getHolidayMode(unitId, embeddedId), commandTrueFalse); } - public static void setDemandControl(String unitId, String embeddedId, Enums.DemandControl value) { + public void setDemandControl(String unitId, String embeddedId, Enums.DemandControl value) { logger.debug(String.format("setDemandControl: %s, %s, %s", unitId, embeddedId, value)); doBearerRequestPatch(getTDemandControlUrl(unitId, embeddedId), OnectaProperties.getTDemandControlCommand(value)); } - public static void setDemandControlFixedValue(String unitId, String embeddedId, Integer value) { + public void setDemandControlFixedValue(String unitId, String embeddedId, Integer value) { logger.debug(String.format("setDemandControlFixedValue: %s, %s, %s", unitId, embeddedId, value)); doBearerRequestPatch(getTDemandControlUrl(unitId, embeddedId), OnectaProperties.getTDemandControlFixedValueCommand(value)); } - public static String getRefreshToken() { + public String getRefreshToken() { return onectaSignInClient.getRefreshToken(); } - public static void setRefreshToken(String refreshToken) { + public void setRefreshToken(String refreshToken) { onectaSignInClient.setRefreshToken(refreshToken); } - public static void setTargetTemperatur(String unitId, String embeddedId, Float value) { + public void setTargetTemperatur(String unitId, String embeddedId, Float value) { logger.debug(String.format("setRefreshToken: %s, %s, %s", unitId, embeddedId, value)); doBearerRequestPatch(getTargetTemperaturUrl(unitId, embeddedId), getTargetTemperaturCommand(value)); } - public static void setSetpointLeavingWaterOffset(String unitId, String embeddedId, - Enums.OperationMode operationMode, Float value) { + public void setSetpointLeavingWaterOffset(String unitId, String embeddedId, Enums.OperationMode operationMode, + Float value) { logger.debug(String.format("setRefreshToken: %s, %s, %s, %s", unitId, embeddedId, operationMode, value)); doBearerRequestPatch(OnectaProperties.getTemperatureControlUrl(unitId, embeddedId), OnectaProperties.getSetpointLeavingWaterOffsetCommand(value, operationMode)); } - public static void setSetpointLeavingWaterTemperature(String unitId, String embeddedId, - Enums.OperationMode operationMode, Float value) { + public void setSetpointLeavingWaterTemperature(String unitId, String embeddedId, Enums.OperationMode operationMode, + Float value) { logger.debug(String.format("setRefreshToken: %s, %s, %s, %s", unitId, embeddedId, operationMode, value)); doBearerRequestPatch(OnectaProperties.getTemperatureControlUrl(unitId, embeddedId), OnectaProperties.getSetpointLeavingWaterTemperatureCommand(value, operationMode)); diff --git a/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/handler/OnectaBridgeHandler.java b/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/handler/OnectaBridgeHandler.java index 38fa691c1d593..579b0eda0dae1 100644 --- a/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/handler/OnectaBridgeHandler.java +++ b/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/handler/OnectaBridgeHandler.java @@ -46,6 +46,7 @@ public class OnectaBridgeHandler extends BaseBridgeHandler { private @Nullable ScheduledFuture pollingJob; private Units units = new Units(); + private final OnectaConnectionClient onectaConnectionClient = new OnectaConnectionClient(); public Units getUnits() { return units; @@ -83,10 +84,10 @@ public void initialize() { try { String refreshToken = thing.getConfiguration().get(CHANNEL_REFRESH_TOKEN) == null ? "" : thing.getConfiguration().get(CHANNEL_REFRESH_TOKEN).toString(); - OnectaConnectionClient.startConnecton(thing.getConfiguration().get(CHANNEL_USERID).toString(), + onectaConnectionClient.startConnecton(thing.getConfiguration().get(CHANNEL_USERID).toString(), thing.getConfiguration().get(CHANNEL_PASSWORD).toString(), refreshToken); - if (OnectaConnectionClient.isOnline()) { + if (onectaConnectionClient.isOnline()) { updateStatus(ThingStatus.ONLINE); } else { updateStatus(ThingStatus.OFFLINE); @@ -115,10 +116,10 @@ public void dispose() { private void pollDevices() { logger.debug("pollDevices."); - if (OnectaConnectionClient.isOnline()) { + if (onectaConnectionClient.isOnline()) { updateStatus(ThingStatus.ONLINE); - getThing().getConfiguration().put(CHANNEL_REFRESH_TOKEN, OnectaConnectionClient.getRefreshToken()); + getThing().getConfiguration().put(CHANNEL_REFRESH_TOKEN, onectaConnectionClient.getRefreshToken()); } else { if (getThing().getStatus() != ThingStatus.OFFLINE) { @@ -126,7 +127,7 @@ private void pollDevices() { } } try { - OnectaConnectionClient.refreshUnitsData(getThing()); + onectaConnectionClient.refreshUnitsData(getThing()); } catch (DaikinCommunicationException e) { logger.debug("DaikinCommunicationException: " + e.getMessage()); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); diff --git a/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/service/DataTransportService.java b/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/service/DataTransportService.java index 95cd740a4555e..7ed3028e79140 100644 --- a/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/service/DataTransportService.java +++ b/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/service/DataTransportService.java @@ -15,6 +15,7 @@ public class DataTransportService { private Enums.ManagementPoint managementPointType; private Unit unit; private JsonObject rawData; + private final OnectaConnectionClient onectaConnectionClient = new OnectaConnectionClient(); public DataTransportService(String unitId, Enums.ManagementPoint managementPointType) { this.unitId = unitId; @@ -22,8 +23,8 @@ public DataTransportService(String unitId, Enums.ManagementPoint managementPoint } public void refreshUnit() { - this.unit = OnectaConnectionClient.getUnit(unitId); - this.rawData = OnectaConnectionClient.getRawData(unitId); + this.unit = onectaConnectionClient.getUnit(unitId); + this.rawData = onectaConnectionClient.getRawData(unitId); } public JsonObject getRawData() { @@ -56,7 +57,7 @@ public Enums.HeatupMode getHeatupMode() { } public void setCurrentOperationMode(Enums.OperationMode value) { - OnectaConnectionClient.setCurrentOperationMode(unitId, managementPointType, value); + onectaConnectionClient.setCurrentOperationMode(unitId, managementPointType, value); } public Enums.FanSpeed getCurrentFanspeed() { @@ -73,7 +74,7 @@ public Enums.FanSpeed getCurrentFanspeed() { } public void setFanSpeed(Enums.FanSpeed value) { - OnectaConnectionClient.setFanSpeed(unitId, getEmbeddedId(), getCurrentOperationMode(), value); + onectaConnectionClient.setFanSpeed(unitId, getEmbeddedId(), getCurrentOperationMode(), value); } public Enums.FanMovementHor getCurrentFanDirectionHor() { @@ -130,15 +131,15 @@ public Enums.FanMovement getCurrentFanDirection() { } public void setCurrentFanDirection(Enums.FanMovement value) { - OnectaConnectionClient.setCurrentFanDirection(unitId, getEmbeddedId(), getCurrentOperationMode(), value); + onectaConnectionClient.setCurrentFanDirection(unitId, getEmbeddedId(), getCurrentOperationMode(), value); } public void setCurrentFanDirectionHor(Enums.FanMovementHor value) { - OnectaConnectionClient.setCurrentFanDirectionHor(unitId, getEmbeddedId(), getCurrentOperationMode(), value); + onectaConnectionClient.setCurrentFanDirectionHor(unitId, getEmbeddedId(), getCurrentOperationMode(), value); } public void setCurrentFanDirectionVer(Enums.FanMovementVer value) { - OnectaConnectionClient.setCurrentFanDirectionVer(unitId, getEmbeddedId(), getCurrentOperationMode(), value); + onectaConnectionClient.setCurrentFanDirectionVer(unitId, getEmbeddedId(), getCurrentOperationMode(), value); } public String getPowerOnOff() { @@ -158,11 +159,11 @@ public String getPowerFulModeOnOff() { } public void setPowerOnOff(Enums.OnOff value) { - OnectaConnectionClient.setPowerOnOff(unitId, getEmbeddedId(), value); + onectaConnectionClient.setPowerOnOff(unitId, getEmbeddedId(), value); } public void setPowerFulModeOnOff(Enums.OnOff value) { - OnectaConnectionClient.setPowerFulModeOnOff(unitId, managementPointType, value); + onectaConnectionClient.setPowerFulModeOnOff(unitId, managementPointType, value); } public String getEconoMode() { @@ -174,7 +175,7 @@ public String getEconoMode() { } public void setEconoMode(Enums.OnOff value) { - OnectaConnectionClient.setEconoMode(unitId, managementPointType, value); + onectaConnectionClient.setEconoMode(unitId, managementPointType, value); } public String getUnitName() { @@ -196,7 +197,7 @@ public Number getCurrentTemperatureSet() { public void setCurrentTemperatureSet(float value) { if (value <= getCurrentTemperatureSetMax().floatValue()) - OnectaConnectionClient.setCurrentTemperatureRoomSet(unitId, getEmbeddedId(), getCurrentOperationMode(), + onectaConnectionClient.setCurrentTemperatureRoomSet(unitId, getEmbeddedId(), getCurrentOperationMode(), value); } @@ -239,7 +240,7 @@ public Number getCurrentTankTemperatureSet() { public void setCurrentTankTemperatureSet(float value) { if (value <= getCurrentTankTemperatureSetMax().floatValue()) - OnectaConnectionClient.setCurrentTemperatureHotWaterSet(unitId, getEmbeddedId(), getCurrentOperationMode(), + onectaConnectionClient.setCurrentTemperatureHotWaterSet(unitId, getEmbeddedId(), getCurrentOperationMode(), value); } @@ -283,7 +284,7 @@ public Number getSetpointLeavingWaterTemperature() { } public void setSetpointLeavingWaterTemperature(float value) { - OnectaConnectionClient.setSetpointLeavingWaterTemperature(unitId, getEmbeddedId(), getCurrentOperationMode(), + onectaConnectionClient.setSetpointLeavingWaterTemperature(unitId, getEmbeddedId(), getCurrentOperationMode(), value); } @@ -297,7 +298,7 @@ public Number getSetpointLeavingWaterOffset() { } public void setSetpointLeavingWaterOffset(float value) { - OnectaConnectionClient.setSetpointLeavingWaterOffset(unitId, getEmbeddedId(), getCurrentOperationMode(), value); + onectaConnectionClient.setSetpointLeavingWaterOffset(unitId, getEmbeddedId(), getCurrentOperationMode(), value); } public Number getIndoorTemperature() { @@ -362,7 +363,7 @@ public Number getTargetTemperatur() { } public void setTargetTemperatur(float value) { - OnectaConnectionClient.setTargetTemperatur(unitId, getEmbeddedId(), value); + onectaConnectionClient.setTargetTemperatur(unitId, getEmbeddedId(), value); } public Number getTargetTemperaturMax() { @@ -398,7 +399,7 @@ public String getStreamerMode() { } public void setStreamerMode(Enums.OnOff value) { - OnectaConnectionClient.setStreamerMode(unitId, getEmbeddedId(), value); + onectaConnectionClient.setStreamerMode(unitId, getEmbeddedId(), value); } public String getHolidayMode() { @@ -426,7 +427,7 @@ public Boolean getIsPowerfulModeActive() { } public void setHolidayMode(Enums.OnOff value) { - OnectaConnectionClient.setHolidayMode(unitId, getEmbeddedId(), value); + onectaConnectionClient.setHolidayMode(unitId, getEmbeddedId(), value); } public Enums.DemandControl getDemandControl() { @@ -439,7 +440,7 @@ public Enums.DemandControl getDemandControl() { } public void setDemandControl(Enums.DemandControl value) { - OnectaConnectionClient.setDemandControl(unitId, getEmbeddedId(), value); + onectaConnectionClient.setDemandControl(unitId, getEmbeddedId(), value); } public Integer getDemandControlFixedValue() { @@ -479,7 +480,7 @@ public Integer getDemandControlFixedMaxValue() { } public void setDemandControlFixedValue(Integer value) { - OnectaConnectionClient.setDemandControlFixedValue(unitId, getEmbeddedId(), value); + onectaConnectionClient.setDemandControlFixedValue(unitId, getEmbeddedId(), value); } public Float[] getConsumptionCoolingDay() { diff --git a/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/service/DeviceDiscoveryService.java b/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/service/DeviceDiscoveryService.java index ee22929e6cdbe..9580daccac7a0 100644 --- a/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/service/DeviceDiscoveryService.java +++ b/bundles/org.openhab.binding.onecta/src/main/java/org/openhab/binding/onecta/internal/service/DeviceDiscoveryService.java @@ -23,6 +23,7 @@ public class DeviceDiscoveryService extends AbstractDiscoveryService { private final Logger logger = LoggerFactory.getLogger(OnectaBridgeHandler.class); @Nullable private OnectaBridgeHandler bridgeHandler = null; + private final OnectaConnectionClient onectaConnectionClient = new OnectaConnectionClient(); public DeviceDiscoveryService(OnectaBridgeHandler bridgeHandler) throws IllegalArgumentException { super(20); @@ -40,7 +41,7 @@ protected void startScan() throws IllegalArgumentException { return; } // Trigger no scan if offline - if (bridgeHandler.getThing().getStatus() != ThingStatus.ONLINE) { + if (bridgeHandler.getThing().getStatus() == ThingStatus.OFFLINE) { return; } @@ -49,8 +50,8 @@ protected void startScan() throws IllegalArgumentException { Map properties; String unitId; String unitName; - OnectaConnectionClient.refreshUnitsData(bridgeHandler.getThing()); - List units = OnectaConnectionClient.getUnits().getAll(); + onectaConnectionClient.refreshUnitsData(bridgeHandler.getThing()); + List units = onectaConnectionClient.getUnits().getAll(); for (int i = 0; i < units.size(); i++) { unitId = units.get(i).getId().toString(); unitName = units.get(i).findManagementPointsByType(CLIMATECONTROL).getNameValue();