diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/LGThinQBindingConstants.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/LGThinQBindingConstants.java index 48d67248351..42b091ee39f 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/LGThinQBindingConstants.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/LGThinQBindingConstants.java @@ -46,8 +46,7 @@ public class LGThinQBindingConstants extends LGServicesConstants { public static final ThingTypeUID THING_TYPE_DRYER_TOWER = new ThingTypeUID(BINDING_ID, DeviceTypes.DRYER_TOWER.thingTypeId()); - public static final ThingTypeUID THING_TYPE_FRIDGE = new ThingTypeUID(BINDING_ID, - DeviceTypes.REFRIGERATOR.thingTypeId()); + public static final ThingTypeUID THING_TYPE_FRIDGE = new ThingTypeUID(BINDING_ID, DeviceTypes.FRIDGE.thingTypeId()); public static final ThingTypeUID THING_TYPE_DISHWASHER = new ThingTypeUID(BINDING_ID, DeviceTypes.DISH_WASHER.thingTypeId()); public static final Set SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_AIR_CONDITIONER, @@ -97,36 +96,36 @@ public class LGThinQBindingConstants extends LGServicesConstants { public static final String CHANNEL_AC_TARGET_TEMP_ID = "target-temperature"; /** - * ============ Refrigerator's Channels & Constant Definition ============= + * ============ Fridge's Channels & Constant Definition ============= */ - public static final String CHANNEL_RE_ACTIVE_SAVING = "fr-active-saving"; - public static final String CHANNEL_RE_DOOR_OPEN = "some-door-open"; - public static final String CHANNEL_RE_EXPRESS_COOL_MODE = "fr-express-cool-mode"; - public static final String CHANNEL_RE_EXPRESS_FREEZE_MODE = "fr-express-mode"; - public static final String CHANNEL_RE_FREEZER_TEMP_ID = "freezer-temperature"; - public static final String CHANNEL_RE_FRESH_AIR_FILTER = "fr-fresh-air-filter"; - public static final String CHANNEL_RE_FRIDGE_TEMP_ID = "fridge-temperature"; - public static final String CHANNEL_RE_ICE_PLUS = "fr-ice-plus"; - public static final String CHANNEL_RE_REF_TEMP_UNIT = "temp-unit"; - public static final String CHANNEL_RE_SMART_SAVING_MODE_V2 = "fr-smart-saving-mode"; - public static final String CHANNEL_RE_SMART_SAVING_SWITCH_V1 = "fr-smart-saving-switch"; - public static final String CHANNEL_RE_VACATION_MODE = "fr-eco-friendly-mode"; - public static final String CHANNEL_RE_WATER_FILTER = "fr-water-filter"; + public static final String CHANNEL_FR_ACTIVE_SAVING = "fr-active-saving"; + public static final String CHANNEL_FR_DOOR_OPEN = "fr-some-door-open"; + public static final String CHANNEL_FR_EXPRESS_COOL_MODE = "fr-express-cool-mode"; + public static final String CHANNEL_FR_EXPRESS_FREEZE_MODE = "fr-express-mode"; + public static final String CHANNEL_FR_FREEZER_TEMP_ID = "fr-freezer-temperature"; + public static final String CHANNEL_FR_FRESH_AIR_FILTER = "fr-fresh-air-filter"; + public static final String CHANNEL_FR_FRIDGE_TEMP_ID = "fr-fridge-temperature"; + public static final String CHANNEL_FR_ICE_PLUS = "fr-ice-plus"; + public static final String CHANNEL_FR_REF_TEMP_UNIT = "fr-temp-unit"; + public static final String CHANNEL_FR_SMART_SAVING_MODE_V2 = "fr-smart-saving-mode"; + public static final String CHANNEL_FR_SMART_SAVING_SWITCH_V1 = "fr-smart-saving-switch"; + public static final String CHANNEL_FR_VACATION_MODE = "fr-eco-friendly-mode"; + public static final String CHANNEL_FR_WATER_FILTER = "fr-water-filter"; /** * ============ Washing Machine/Dryer and DishWasher Channels & Constant Definition ============= * DishWasher, Washing Machine and Dryer have the same channel core and features */ - public static final String CHANNEL_DR_CHILD_LOCK_ID = "child-lock"; - public static final String CHANNEL_DR_DRY_LEVEL_ID = "dry-level"; + public static final String CHANNEL_WMD_CHILD_LOCK_ID = "child-lock"; + public static final String CHANNEL_WMD_DRY_LEVEL_ID = "dry-level"; public static final String CHANNEL_WMD_COURSE_ID = "course"; public static final String CHANNEL_WMD_DELAY_TIME_ID = "delay-time"; public static final String CHANNEL_WMD_DOOR_LOCK_ID = "door-lock"; public static final String CHANNEL_WMD_PROCESS_STATE_ID = "process-state"; public static final String CHANNEL_WMD_REMAIN_TIME_ID = "remain-time"; public static final String CHANNEL_WMD_REMOTE_COURSE = "rs-course"; - public static final String CHANNEL_WMD_REMOTE_START_GRP_ID = "remote-start-grp"; - public static final String CHANNEL_WMD_REMOTE_START_ID = "remote-start-flag"; + public static final String CHANNEL_WMD_REMOTE_START_GRP_ID = "rs-grp"; + public static final String CHANNEL_WMD_REMOTE_START_ID = "rs-flag"; public static final String CHANNEL_WMD_REMOTE_START_START_STOP = "rs-start-stop"; public static final String CHANNEL_WMD_RINSE_ID = "rinse"; public static final String CHANNEL_WMD_SMART_COURSE_ID = "smart-course"; @@ -134,9 +133,9 @@ public class LGThinQBindingConstants extends LGServicesConstants { public static final String CHANNEL_WMD_STAND_BY_ID = "stand-by"; public static final String CHANNEL_WMD_STATE_ID = "state"; public static final String CHANNEL_WMD_TEMP_LEVEL_ID = "temperature-level"; - public static final String CHANNEL_WM_REMOTE_START_RINSE = "rs-rinse"; - public static final String CHANNEL_WM_REMOTE_START_SPIN = "rs-spin"; - public static final String CHANNEL_WM_REMOTE_START_TEMP = "rs-temperature-level"; + public static final String CHANNEL_WMD_REMOTE_START_RINSE = "rs-rinse"; + public static final String CHANNEL_WMD_REMOTE_START_SPIN = "rs-spin"; + public static final String CHANNEL_WMD_REMOTE_START_TEMP = "rs-temperature-level"; // ============================================================================== // DIGEST CONSTANTS diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/LGThinQBridgeConfiguration.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/LGThinQBridgeConfiguration.java index e748971376f..024a83bcfd0 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/LGThinQBridgeConfiguration.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/LGThinQBridgeConfiguration.java @@ -28,8 +28,8 @@ public class LGThinQBridgeConfiguration { public String password = ""; public String country = ""; public String language = ""; - public final String manualCountry = ""; - public final String manualLanguage = ""; + public String manualCountry = ""; + public String manualLanguage = ""; public int pollingIntervalSec = 0; public String alternativeServer = ""; @@ -72,31 +72,7 @@ public class LGThinQBridgeConfiguration { return pollingIntervalSec; } - public void setUsername(String username) { - this.username = username; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setCountry(String country) { - this.country = country; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setPollingIntervalSec(int pollingIntervalSec) { - this.pollingIntervalSec = pollingIntervalSec; - } - public String getAlternativeServer() { return alternativeServer; } - - public void setAlternativeServer(String alternativeServer) { - this.alternativeServer = alternativeServer; - } } diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/LGThinQHandlerFactory.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/LGThinQHandlerFactory.java index 1c958820414..197ffc82c55 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/LGThinQHandlerFactory.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/LGThinQHandlerFactory.java @@ -31,8 +31,6 @@ import org.openhab.binding.lgthinq.internal.handler.LGThinQBridgeHandler; import org.openhab.binding.lgthinq.internal.handler.LGThinQDishWasherHandler; import org.openhab.binding.lgthinq.internal.handler.LGThinQFridgeHandler; import org.openhab.binding.lgthinq.internal.handler.LGThinQWasherDryerHandler; -import org.openhab.binding.lgthinq.internal.type.ThinqChannelGroupTypeProvider; -import org.openhab.binding.lgthinq.internal.type.ThinqChannelTypeProvider; import org.openhab.core.config.core.Configuration; import org.openhab.core.io.net.http.HttpClientFactory; import org.openhab.core.thing.Bridge; @@ -65,12 +63,6 @@ public class LGThinQHandlerFactory extends BaseThingHandlerFactory { private final LGThinQStateDescriptionProvider stateDescriptionProvider; - @Nullable - @Reference - protected ThinqChannelTypeProvider thinqChannelProvider; - @Nullable - @Reference - protected ThinqChannelGroupTypeProvider thinqChannelGroupProvider; @Nullable @Reference protected ItemChannelLinkRegistry itemChannelLinkRegistry; @@ -97,18 +89,15 @@ public class LGThinQHandlerFactory extends BaseThingHandlerFactory { return new LGThinQBridgeHandler((Bridge) thing, httpClientFactory); } else if (THING_TYPE_WASHING_MACHINE.equals(thingTypeUID) || THING_TYPE_WASHING_TOWER.equals(thingTypeUID)) { return new LGThinQWasherDryerHandler(thing, stateDescriptionProvider, - Objects.requireNonNull(thinqChannelProvider), Objects.requireNonNull(thinqChannelGroupProvider), Objects.requireNonNull(itemChannelLinkRegistry), httpClientFactory); } else if (THING_TYPE_DRYER.equals(thingTypeUID) || THING_TYPE_DRYER_TOWER.equals(thingTypeUID)) { return new LGThinQWasherDryerHandler(thing, stateDescriptionProvider, - Objects.requireNonNull(thinqChannelProvider), Objects.requireNonNull(thinqChannelGroupProvider), Objects.requireNonNull(itemChannelLinkRegistry), httpClientFactory); } else if (THING_TYPE_FRIDGE.equals(thingTypeUID)) { return new LGThinQFridgeHandler(thing, stateDescriptionProvider, Objects.requireNonNull(itemChannelLinkRegistry), httpClientFactory); } else if (THING_TYPE_DISHWASHER.equals(thingTypeUID)) { return new LGThinQDishWasherHandler(thing, stateDescriptionProvider, - Objects.requireNonNull(thinqChannelProvider), Objects.requireNonNull(thinqChannelGroupProvider), Objects.requireNonNull(itemChannelLinkRegistry), httpClientFactory); } logger.warn("Thing not supported by this Factory: {}", thingTypeUID.getId()); diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/discovery/LGThinqDiscoveryService.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/discovery/LGThinqDiscoveryService.java index 9a7f8c8e324..b7dcd1d1624 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/discovery/LGThinqDiscoveryService.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/discovery/LGThinqDiscoveryService.java @@ -51,7 +51,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The {@link LGThinqDiscoveryService} + * The {@link LGThinqDiscoveryService} - Responsable to discovery new LG Thinq Devices for the registered Bridge * * @author Nemer Daud - Initial contribution */ @@ -147,7 +147,7 @@ public class LGThinqDiscoveryService extends AbstractThingHandlerDiscoveryServic case WASHER_TOWER -> THING_TYPE_WASHING_TOWER; case DRYER_TOWER -> THING_TYPE_DRYER_TOWER; case DRYER -> THING_TYPE_DRYER; - case REFRIGERATOR -> THING_TYPE_FRIDGE; + case FRIDGE -> THING_TYPE_FRIDGE; case DISH_WASHER -> THING_TYPE_DISHWASHER; default -> throw new LGThinqException(String.format("device type [%s] not supported", device.getDeviceType())); diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQAbstractDeviceHandler.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQAbstractDeviceHandler.java index 854cecaeb5b..40e91caee13 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQAbstractDeviceHandler.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQAbstractDeviceHandler.java @@ -42,9 +42,8 @@ import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.lgthinq.internal.LGThinQStateDescriptionProvider; -import org.openhab.binding.lgthinq.internal.type.ThinqChannelGroupTypeProvider; -import org.openhab.binding.lgthinq.internal.type.ThinqChannelTypeProvider; import org.openhab.binding.lgthinq.lgservices.LGThinQApiClientService; +import org.openhab.binding.lgthinq.lgservices.errors.LGThinqAccessException; import org.openhab.binding.lgthinq.lgservices.errors.LGThinqApiException; import org.openhab.binding.lgthinq.lgservices.errors.LGThinqApiExhaustionException; import org.openhab.binding.lgthinq.lgservices.errors.LGThinqDeviceV1MonitorExpiredException; @@ -114,10 +113,6 @@ public abstract class LGThinQAbstractDeviceHandler<@NonNull C extends Capability ThingStatusDetail.CONFIGURATION_ERROR); protected final LGThinQStateDescriptionProvider stateDescriptionProvider; - @Nullable - protected ThinqChannelTypeProvider thinqChannelProvider; - @Nullable - protected ThinqChannelGroupTypeProvider thinqChannelGroupProvider; protected S getLastShot() { return Objects.requireNonNull(lastShot, "LastShot shouldn't be null. It most likely a bug."); @@ -513,6 +508,8 @@ public abstract class LGThinQAbstractDeviceHandler<@NonNull C extends Capability updateStatus(ThingStatus.ONLINE); } + } catch (LGThinqAccessException e) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); } catch (LGThinqApiExhaustionException e) { fetchMonitorRetries++; getLogger().warn("LG API returns null monitoring data for the thing {}/{}. No data available yet ?", diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQAirConditionerHandler.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQAirConditionerHandler.java index 9057fba6967..1f0786b5b45 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQAirConditionerHandler.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQAirConditionerHandler.java @@ -86,8 +86,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; /** - * The {@link LGThinQAirConditionerHandler} is responsible for handling commands, which are - * sent to one of the channels. + * The {@link LGThinQAirConditionerHandler} Handle Air Conditioner and HeatPump Things * * @author Nemer Daud - Initial contribution */ diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQBridge.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQBridge.java index 526a8841bff..81f928803f5 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQBridge.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQBridge.java @@ -18,22 +18,32 @@ import org.openhab.binding.lgthinq.lgservices.model.CapabilityDefinition; import org.openhab.binding.lgthinq.lgservices.model.SnapshotDefinition; /** - * The {@link LGThinQBridge} + * The {@link LGThinQBridge} - Specific methods for discovery integration * * @author Nemer Daud - Initial contribution */ @NonNullByDefault public interface LGThinQBridge { /** - * Register + * Register Discovery Listener * * @param listener */ void registerDiscoveryListener(LGThinqDiscoveryService listener); + /** + * Registry a device Thing to the bridge + * + * @param thing Thing to be registered. + */ void registryListenerThing( LGThinQAbstractDeviceHandler thing); + /** + * Unregistry the thing + * + * @param thing to be unregistered + */ void unRegistryListenerThing( LGThinQAbstractDeviceHandler thing); } diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQBridgeHandler.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQBridgeHandler.java index 6a001656678..6cc72119b73 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQBridgeHandler.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQBridgeHandler.java @@ -54,7 +54,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The {@link LGThinQBridgeHandler} + * The {@link LGThinQBridgeHandler} - connect to the LG Account and get information about the user and registered + * devices of that user. * * @author Nemer Daud - Initial contribution */ @@ -129,6 +130,7 @@ public class LGThinQBridgeHandler extends ConfigStatusBridgeHandler implements L } catch (RefreshTokenException e) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.HANDLER_INITIALIZING_ERROR, "@text/error.toke-refresh"); + logger.error("Error refreshing token", e); return; } } else { diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQDishWasherHandler.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQDishWasherHandler.java index 4ecf4cfbd8e..05eae198b51 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQDishWasherHandler.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/handler/LGThinQDishWasherHandler.java @@ -34,8 +34,6 @@ import java.util.List; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.lgthinq.internal.LGThinQStateDescriptionProvider; -import org.openhab.binding.lgthinq.internal.type.ThinqChannelGroupTypeProvider; -import org.openhab.binding.lgthinq.internal.type.ThinqChannelTypeProvider; import org.openhab.binding.lgthinq.lgservices.LGThinQApiClientService; import org.openhab.binding.lgthinq.lgservices.LGThinQApiClientServiceFactory; import org.openhab.binding.lgthinq.lgservices.LGThinQDishWasherApiClientService; @@ -56,8 +54,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The {@link LGThinQDishWasherHandler} is responsible for handling commands, which are - * sent to one of the channels. + * The {@link LGThinQDishWasherHandler} Handle the Dish Washer Things * * @author Nemer Daud - Initial contribution */ @@ -78,11 +75,8 @@ public class LGThinQDishWasherHandler extends LGThinQAbstractDeviceHandler getTemperatureUnit(FridgeCanonicalSnapshot shot) { @@ -198,8 +197,7 @@ public class LGThinQFridgeHandler extends LGThinQAbstractDeviceHandler convertionMap = new HashMap<>(); - convertionMap = getConvertionMap(ch, refCap); + Map convertionMap = getConvertionMap(ch, refCap); String strValue = convertionMap.get(value.toString()); if (strValue == null) { logger.error( @@ -224,8 +222,7 @@ public class LGThinQFridgeHandler extends LGThinQAbstractDeviceHandler convertionMap = new HashMap<>(); - getConvertionMap(ch, refCap); + final Map convertionMap = getConvertionMap(ch, refCap); final Map invertedMap = new HashMap<>(); convertionMap.forEach((k, v) -> { invertedMap.put(v, k); @@ -293,12 +290,12 @@ public class LGThinQFridgeHandler extends LGThinQAbstractDeviceHandler unTemp = getTemperatureUnit(getLastShot()); if (SIUnits.CELSIUS.equals(unTemp)) { @@ -344,8 +341,8 @@ public class LGThinQFridgeHandler extends LGThinQAbstractDeviceHandler options; - - public DataType(String name, boolean isNumeric, boolean isEnum, @Nullable List options) { - this.name = name; - this.isNumeric = isNumeric; - this.isEnum = isEnum; - this.options = options; - } - - public @Nullable List getOptions() { - return options; - } - - public String getName() { - return name; - } - - public boolean isNumeric() { - return isNumeric; - } - - public boolean isEnum() { - return isEnum; - } -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/DeviceParameter.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/DeviceParameter.java deleted file mode 100644 index 0a59b00de31..00000000000 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/DeviceParameter.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.lgthinq.internal.model; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.core.config.core.ConfigDescriptionParameter.Type; -import org.openhab.core.config.core.ParameterOption; - -/** - * The {@link DeviceParameter} class. - * - * @author Nemer Daud - Initial contribution - */ -@NonNullByDefault -public class DeviceParameter { - - private final String name; - private final Type type; - private final String label; - private final String description; - private final String defaultValue; - private DeviceParameterGroup group = new DeviceParameterGroup("", ""); - private final List options = new ArrayList(); - - private final boolean isReadOnly; - - public DeviceParameter(String name, Type type, String label, String description, String defaultValue, - List options, boolean isReadOnly) { - this.name = name; - this.type = type; - this.label = label; - this.description = description; - this.defaultValue = defaultValue; - this.options.addAll(options); - this.isReadOnly = isReadOnly; - } - - public DeviceParameterGroup getGroup() { - return group; - } - - public void setGroup(DeviceParameterGroup group) { - this.group = group; - } - - public List getOptions() { - return options; - } - - public boolean isReadOnly() { - return isReadOnly; - } - - public String getName() { - return name; - } - - public Type getType() { - return type; - } - - public String getLabel() { - return label; - } - - public String getDescription() { - return description; - } - - public String getDefaultValue() { - return defaultValue; - } -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/DeviceParameterGroup.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/DeviceParameterGroup.java deleted file mode 100644 index 882c76d00fd..00000000000 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/DeviceParameterGroup.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.lgthinq.internal.model; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * The {@link DeviceParameterGroup} class. - * - * @author Nemer Daud - Initial contribution - */ -@NonNullByDefault -public class DeviceParameterGroup { - - private final String groupName; - private final String groupLabel; - - public DeviceParameterGroup(String groupName, String groupLabel) { - this.groupName = groupName; - this.groupLabel = groupLabel; - } - - public String getGroupName() { - return groupName; - } - - public String getGroupLabel() { - return groupLabel; - } -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/ThinqChannel.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/ThinqChannel.java deleted file mode 100644 index 980f534e459..00000000000 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/ThinqChannel.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.lgthinq.internal.model; - -import java.util.Objects; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; - -/** - * The {@link ThinqChannel} class. - * - * @author Nemer Daud - Initial contribution - */ -@NonNullByDefault -public class ThinqChannel { - - @Nullable - ThinqDevice device; - private final DataType type; - @Nullable - private final String unitDisplayPattern; - private final String name; - private final String label; - private final String description; - private final boolean isDynamic; - private final boolean isReadOnly; - private final boolean isAdvanced; - @Nullable - private final ThinqChannelGroup channelGroup; - - @Override - public boolean equals(@Nullable Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ThinqChannel that = (ThinqChannel) o; - return Objects.equals(name, that.name); - } - - @Override - public int hashCode() { - return Objects.hash(name); - } - - public ThinqChannel(DataType type, @Nullable String unitDisplayPattern, String name, String label, - String description, boolean isDynamic, boolean isReadOnly, boolean isAdvanced, - @Nullable ThinqChannelGroup channelGroup) { - this.type = type; - this.unitDisplayPattern = unitDisplayPattern; - this.name = name; - this.label = label; - this.description = description; - this.isDynamic = isDynamic; - this.isReadOnly = isReadOnly; - this.isAdvanced = isAdvanced; - this.channelGroup = channelGroup; - if (channelGroup != null && !channelGroup.getChannels().contains(this)) { - channelGroup.getChannels().add(this); - } - } - - public @Nullable ThinqChannelGroup getChannelGroup() { - return channelGroup; - } - - public boolean isAdvanced() { - return isAdvanced; - } - - public String getLabel() { - return label; - } - - public boolean isReadOnly() { - return isReadOnly; - } - - public @Nullable String getUnitDisplayPattern() { - return unitDisplayPattern; - } - - public @Nullable ThinqDevice getDevice() { - return device; - } - - public DataType getType() { - return type; - } - - public boolean isDynamic() { - return isDynamic; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/ThinqChannelGroup.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/ThinqChannelGroup.java deleted file mode 100644 index fb3691348f0..00000000000 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/ThinqChannelGroup.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.lgthinq.internal.model; - -import java.util.List; -import java.util.Objects; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; - -/** - * The {@link ThinqChannelGroup} class. - * - * @author Nemer Daud - Initial contribution - */ -@NonNullByDefault -public class ThinqChannelGroup { - private final List channels; - private ThinqDevice device; - private final String name; - private final String description; - private final String label; - - public ThinqChannelGroup(List channels, ThinqDevice device, String name, String description, - String label) { - this.channels = channels; - this.device = device; - this.name = name; - this.description = description; - this.label = label; - } - - @Override - public boolean equals(@Nullable Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - ThinqChannelGroup that = (ThinqChannelGroup) o; - return Objects.equals(name, that.name); - } - - @Override - public int hashCode() { - return Objects.hash(name); - } - - public String getLabel() { - return label; - } - - public List getChannels() { - return channels; - } - - public ThinqDevice getDevice() { - return device; - } - - public void setDevice(ThinqDevice device) { - this.device = device; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/ThinqDevice.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/ThinqDevice.java deleted file mode 100644 index c1dc92f86b7..00000000000 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/model/ThinqDevice.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.lgthinq.internal.model; - -import java.util.List; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * The {@link ThinqDevice} class. - * - * @author Nemer Daud - Initial contribution - */ -@NonNullByDefault -public class ThinqDevice { - private final String type; - private final String label; - private final String description; - - private final List channels; - private final List configParameter; - private final List groups; - - public String getType() { - return type; - } - - public String getDescription() { - return description; - } - - public List getChannels() { - return channels; - } - - public List getGroups() { - return groups; - } - - public ThinqDevice(String type, String label, String description, List channels, - List configParameter, List groups) { - this.type = type; - this.label = label; - this.description = description; - this.channels = channels; - this.configParameter = configParameter; - this.groups = groups; - this.channels.forEach(c -> { - c.device = this; - }); - this.groups.forEach(g -> { - g.setDevice(this); - }); - } - - public String getLabel() { - return label; - } - - public List getConfigParameter() { - return configParameter; - } -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqChannelGroupTypeProvider.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqChannelGroupTypeProvider.java deleted file mode 100644 index 952ef769785..00000000000 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqChannelGroupTypeProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.lgthinq.internal.type; - -import java.util.List; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.core.thing.type.ChannelGroupType; -import org.openhab.core.thing.type.ChannelGroupTypeProvider; - -/** - * The ThinqChannelGroupTypeProvider interface. - * - * @author Nemer Daud - Initial contribution - */ -@NonNullByDefault -public interface ThinqChannelGroupTypeProvider extends ChannelGroupTypeProvider { - - void addChannelGroupType(ChannelGroupType channelGroupType); - - List internalGroupTypes(); -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqChannelTypeProvider.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqChannelTypeProvider.java deleted file mode 100644 index d291b21e262..00000000000 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqChannelTypeProvider.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.lgthinq.internal.type; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.core.thing.type.ChannelType; -import org.openhab.core.thing.type.ChannelTypeProvider; - -/** - * The ThinqChannelTypeProvider interface. - * - * @author Nemer Daud - Initial contribution - */ -@NonNullByDefault -public interface ThinqChannelTypeProvider extends ChannelTypeProvider { - void addChannelType(final ChannelType channelType); -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqConfigDescriptionProvider.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqConfigDescriptionProvider.java deleted file mode 100644 index e2c699faf8d..00000000000 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqConfigDescriptionProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.lgthinq.internal.type; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.core.config.core.ConfigDescription; -import org.openhab.core.config.core.ConfigDescriptionProvider; - -/** - * The ThinqConfigDescriptionProvider interface. - * - * @author Nemer Daud - Initial contribution - */ -@NonNullByDefault -public interface ThinqConfigDescriptionProvider extends ConfigDescriptionProvider { - - void addConfigDescription(ConfigDescription configDescription); -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqThingTypeProvider.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqThingTypeProvider.java deleted file mode 100644 index baa2c9bbc1c..00000000000 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqThingTypeProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.lgthinq.internal.type; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.core.thing.binding.ThingTypeProvider; -import org.openhab.core.thing.type.ThingType; - -/** - * The ThinqThingTypeProvider interface. - * - * @author Nemer Daud - Initial contribution - */ -@NonNullByDefault -public interface ThinqThingTypeProvider extends ThingTypeProvider { - - void addThingType(ThingType thingType); -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqTypesProviderImpl.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqTypesProviderImpl.java deleted file mode 100644 index 982b1421342..00000000000 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/ThinqTypesProviderImpl.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.lgthinq.internal.type; - -import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; -import org.openhab.core.config.core.ConfigDescription; -import org.openhab.core.config.core.ConfigDescriptionProvider; -import org.openhab.core.thing.ThingTypeUID; -import org.openhab.core.thing.binding.ThingTypeProvider; -import org.openhab.core.thing.type.ChannelGroupType; -import org.openhab.core.thing.type.ChannelGroupTypeProvider; -import org.openhab.core.thing.type.ChannelGroupTypeUID; -import org.openhab.core.thing.type.ChannelType; -import org.openhab.core.thing.type.ChannelTypeProvider; -import org.openhab.core.thing.type.ChannelTypeUID; -import org.openhab.core.thing.type.ThingType; -import org.osgi.service.component.annotations.Component; - -/** - * Provider class to provide model types for custom things (not in XML). - * - * @author Nemer Daud - Initial contribution - */ -@NonNullByDefault -@Component(service = { ThinqChannelTypeProvider.class, ChannelTypeProvider.class, ChannelGroupTypeProvider.class, - ThinqChannelGroupTypeProvider.class, ThinqConfigDescriptionProvider.class, ConfigDescriptionProvider.class, - ThinqThingTypeProvider.class, ThingTypeProvider.class }) -public class ThinqTypesProviderImpl implements ThinqChannelTypeProvider, ThinqChannelGroupTypeProvider, - ThinqConfigDescriptionProvider, ThinqThingTypeProvider { - - private final Map thingTypesByUID = new ConcurrentHashMap<>(); - private final Map channelTypesByUID = new ConcurrentHashMap<>(); - private final Map channelGroupTypesByUID = new ConcurrentHashMap<>(); - - private final Map configDescriptionsByURI = new ConcurrentHashMap<>(); - - @Override - public Collection getChannelTypes(@Nullable final Locale locale) { - return Collections.unmodifiableCollection(channelTypesByUID.values()); - } - - @Override - public @Nullable ChannelType getChannelType(final ChannelTypeUID channelTypeUID, @Nullable final Locale locale) { - return channelTypesByUID.get(channelTypeUID); - } - - /** - * Add a channel type for a user configured channel. - * - * @param channelType channelType - */ - @Override - public void addChannelType(final ChannelType channelType) { - channelTypesByUID.put(channelType.getUID(), channelType); - } - - @Override - @Nullable - public ChannelGroupType getChannelGroupType(ChannelGroupTypeUID channelGroupTypeUID, @Nullable Locale locale) { - return channelGroupTypesByUID.get(channelGroupTypeUID); - } - - @Override - public Collection getChannelGroupTypes(@Nullable Locale locale) { - return Collections.unmodifiableCollection(channelGroupTypesByUID.values()); - } - - @Override - public void addChannelGroupType(ChannelGroupType channelGroupType) { - channelGroupTypesByUID.put(channelGroupType.getUID(), channelGroupType); - } - - @Override - public List internalGroupTypes() { - return new ArrayList<>(channelGroupTypesByUID.values()); - } - - @Override - public void addConfigDescription(ConfigDescription configDescription) { - configDescriptionsByURI.put(configDescription.getUID(), configDescription); - } - - @Override - public Collection getConfigDescriptions(@Nullable Locale locale) { - return Collections.unmodifiableCollection(configDescriptionsByURI.values()); - } - - @Override - public @Nullable ConfigDescription getConfigDescription(URI uri, @Nullable Locale locale) { - return configDescriptionsByURI.get(uri); - } - - @Override - public void addThingType(ThingType thingType) { - thingTypesByUID.put(thingType.getUID(), thingType); - } - - @Override - public Collection getThingTypes(@Nullable Locale locale) { - return Collections.unmodifiableCollection(thingTypesByUID.values()); - } - - @Override - public @Nullable ThingType getThingType(ThingTypeUID thingTypeUID, @Nullable Locale locale) { - return thingTypesByUID.get(thingTypeUID); - } -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/UidUtils.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/UidUtils.java deleted file mode 100644 index 6ae02eda4fc..00000000000 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/internal/type/UidUtils.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.lgthinq.internal.type; - -import static org.openhab.binding.lgthinq.internal.LGThinQBindingConstants.BINDING_ID; - -import java.util.Objects; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.lgthinq.internal.model.ThinqChannel; -import org.openhab.binding.lgthinq.internal.model.ThinqChannelGroup; -import org.openhab.binding.lgthinq.internal.model.ThinqDevice; -import org.openhab.core.thing.ChannelUID; -import org.openhab.core.thing.ThingTypeUID; -import org.openhab.core.thing.ThingUID; -import org.openhab.core.thing.type.ChannelGroupTypeUID; -import org.openhab.core.thing.type.ChannelTypeUID; - -/** - * Utility class for generating some UIDs. - * - * @author Nemer Daud - Initial contribution - */ -@NonNullByDefault -public class UidUtils { - - /** - * Generates the ThingTypeUID for the given device. - */ - public static ThingTypeUID generateThingTypeUID(ThinqDevice device) { - return new ThingTypeUID(BINDING_ID, device.getType()); - } - - /** - * Generates the ChannelTypeUID. - */ - public static ChannelTypeUID generateChannelTypeUID(ThinqChannel channel) { - return new ChannelTypeUID(BINDING_ID, - String.format("%s_%s", - Objects.requireNonNull(channel.getDevice(), "unexpected null device type here").getType(), - channel.getName())); - } - - /** - * Generates the ChannelTypeUID for the given channel group. - */ - public static ChannelGroupTypeUID generateChannelGroupTypeUID(ThinqChannelGroup grpChannel) { - return new ChannelGroupTypeUID(BINDING_ID, - String.format("%s_%s", grpChannel.getDevice().getType(), grpChannel.getName())); - } - - /** - * Generates the ChannelUID for the given datapoint with channelNumber and datapointName. - */ - public static ChannelUID generateChannelUID(ThinqChannel dp, ThingUID thingUID) { - return new ChannelUID(thingUID, dp.getName(), dp.getName()); - } -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQACApiClientService.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQACApiClientService.java index a5338c3aa2e..f2c74224aba 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQACApiClientService.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQACApiClientService.java @@ -20,32 +20,116 @@ import org.openhab.binding.lgthinq.lgservices.model.devices.ac.ACTargetTmp; import org.openhab.binding.lgthinq.lgservices.model.devices.ac.ExtendedDeviceInfo; /** - * The {@link LGThinQACApiClientService} + * The {@link LGThinQACApiClientService} - Common interface to be used by the AC Handle to access LG API Services in V1 + * & v2 + * protocol versions * * @author Nemer Daud - Initial contribution */ @NonNullByDefault public interface LGThinQACApiClientService extends LGThinQApiClientService { + /** + * Change AC Operation Mode (Cool, Heat, etc.) + * + * @param bridgeName - name of the bridge + * @param deviceId - ID of the LG Thinq Device + * @param newOpMode - The new operation mode to be setup + * @throws LGThinqApiException - If some error invoking LG API. + */ void changeOperationMode(String bridgeName, String deviceId, int newOpMode) throws LGThinqApiException; + /** + * Change the AC Fan Speed. + * + * @param bridgeName - name of the bridge + * @param deviceId - ID of the LG Thinq Device + * @param newFanSpeed - new Fan Speed to be setup + * @throws LGThinqApiException - If some error invoking LG API. + */ void changeFanSpeed(String bridgeName, String deviceId, int newFanSpeed) throws LGThinqApiException; + /** + * Change the fan vertical orientation + * + * @param bridgeName - name of the bridge + * @param deviceId - ID of the LG Thinq Device + * @param currentSnap - Current data snapshot + * @param newStep - new vertical position + * @throws LGThinqApiException - If some error invoking LG API. + */ void changeStepUpDown(String bridgeName, String deviceId, ACCanonicalSnapshot currentSnap, int newStep) throws LGThinqApiException; + /** + * Change the fan horizontal orientation + * + * @param bridgeName - name of the bridge + * @param deviceId - ID of the LG Thinq Device + * @param currentSnap - Current data snapshot + * @param newStep - new horizontal position + * @throws LGThinqApiException - If some error invoking LG API. + */ void changeStepLeftRight(String bridgeName, String deviceId, ACCanonicalSnapshot currentSnap, int newStep) throws LGThinqApiException; + /** + * Change the target temperature + * + * @param bridgeName - name of the bridge + * @param deviceId - ID of the LG Thinq Device + * @param newTargetTemp - new target temperature + * @throws LGThinqApiException - If some error invoking LG API. + */ void changeTargetTemperature(String bridgeName, String deviceId, ACTargetTmp newTargetTemp) throws LGThinqApiException; + /** + * Turn On/Off the Jet Mode feature + * + * @param bridgeName - name of the bridge + * @param deviceId - ID of the LG Thinq Device + * @param modeOnOff - turn on/off + * @throws LGThinqApiException - If some error invoking LG API. + */ void turnCoolJetMode(String bridgeName, String deviceId, String modeOnOff) throws LGThinqApiException; + /** + * Turn On/Off the Air Clean feature + * + * @param bridgeName - name of the bridge + * @param deviceId - ID of the LG Thinq Device + * @param modeOnOff - turn on/off + * @throws LGThinqApiException - If some error invoking LG API. + */ void turnAirCleanMode(String bridgeName, String deviceId, String modeOnOff) throws LGThinqApiException; + /** + * Turn On/Off the Auto Dry feature + * + * @param bridgeName - name of the bridge + * @param deviceId - ID of the LG Thinq Device + * @param modeOnOff - turn on/off + * @throws LGThinqApiException - If some error invoking LG API. + */ void turnAutoDryMode(String bridgeName, String deviceId, String modeOnOff) throws LGThinqApiException; + /** + * Turn On/Off the Energy Saving feature + * + * @param bridgeName - name of the bridge + * @param deviceId - ID of the LG Thinq Device + * @param modeOnOff - turn on/off + * @throws LGThinqApiException - If some error invoking LG API. + */ void turnEnergySavingMode(String bridgeName, String deviceId, String modeOnOff) throws LGThinqApiException; + /** + * Get Extended Device Information (Energy consumption, filter level, etc). + * + * @param bridgeName Bridge name + * @param deviceId - ID of the LG Thinq Device + * @return ExtendedDeviceInfo containing the device extended data + * @throws LGThinqApiException - If some error invoking LG API. + */ ExtendedDeviceInfo getExtendedDeviceInfo(String bridgeName, String deviceId) throws LGThinqApiException; } diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQAbstractApiClientService.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQAbstractApiClientService.java index 07e0ae92e6b..5cf920886d3 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQAbstractApiClientService.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQAbstractApiClientService.java @@ -51,6 +51,7 @@ import org.openhab.binding.lgthinq.lgservices.api.RestResult; import org.openhab.binding.lgthinq.lgservices.api.RestUtils; import org.openhab.binding.lgthinq.lgservices.api.TokenManager; import org.openhab.binding.lgthinq.lgservices.api.TokenResult; +import org.openhab.binding.lgthinq.lgservices.errors.LGThinqAccessException; import org.openhab.binding.lgthinq.lgservices.errors.LGThinqApiException; import org.openhab.binding.lgthinq.lgservices.errors.LGThinqDeviceV1MonitorExpiredException; import org.openhab.binding.lgthinq.lgservices.errors.LGThinqDeviceV1OfflineException; @@ -75,7 +76,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; /** - * The {@link LGThinQACApiV1ClientServiceImpl} + * The {@link LGThinQAbstractApiClientService} - base class for all LG API client service. It's provide commons methods + * to + * communicate to the LG Cloud and exchange basic data. * * @author Nemer Daud - Initial contribution */ @@ -174,6 +177,8 @@ public abstract class LGThinQAbstractApiClientService() { diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQAbstractApiV1ClientService.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQAbstractApiV1ClientService.java index fc7041b3036..125c67e6588 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQAbstractApiV1ClientService.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQAbstractApiV1ClientService.java @@ -46,7 +46,8 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; /** - * The {@link LGThinQAbstractApiV1ClientService} + * The {@link LGThinQAbstractApiV1ClientService} - Specialized abstract class that implements methods and services to + * handle LG API V1 communication and convention. * * @author Nemer Daud - Initial contribution */ diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQAbstractApiV2ClientService.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQAbstractApiV2ClientService.java index 83273197b93..6634d4fd001 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQAbstractApiV2ClientService.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQAbstractApiV2ClientService.java @@ -39,7 +39,8 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; /** - * The {@link LGThinQAbstractApiV2ClientService} + * The {@link LGThinQAbstractApiV2ClientService} - Specialized abstract class that implements methods and services to + * * handle LG API V2 communication and convention. * * @author Nemer Daud - Initial contribution */ diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQApiClientService.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQApiClientService.java index dfa81c4f5db..c834ff69e33 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQApiClientService.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQApiClientService.java @@ -30,15 +30,29 @@ import org.openhab.binding.lgthinq.lgservices.model.LGDevice; import org.openhab.binding.lgthinq.lgservices.model.SnapshotDefinition; /** - * The {@link LGThinQApiClientService} + * The {@link LGThinQApiClientService} - defines the basic methods to manage devices in the LG Cloud * * @author Nemer Daud - Initial contribution */ @NonNullByDefault public interface LGThinQApiClientService { - + /** + * List all devices registers in the LG Account + * + * @param bridgeName bridge name + * @return return a List off all devices registered for the user account. + * @throws LGThinqApiException if some error occur accessing LG API + */ List listAccountDevices(String bridgeName) throws LGThinqApiException; + /** + * Get the LG device metadata about the settings and capabilities of the Device + * + * @param bridgeName bridge name + * @param deviceId LG Device ID + * @return A map containing all the device settings. + * @throws LGThinqApiException + */ Map getDeviceSettings(String bridgeName, String deviceId) throws LGThinqApiException; void initializeDevice(String bridgeName, String deviceId) throws LGThinqApiException; @@ -47,25 +61,88 @@ public interface LGThinQApiClientService { - void remoteStart(String bridgeName, String deviceId) throws LGThinqApiException; - - void wakeUp(String bridgeName, String deviceId) throws LGThinqApiException; -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDRApiV2ClientServiceImpl.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDRApiV2ClientServiceImpl.java deleted file mode 100644 index 480ba186854..00000000000 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDRApiV2ClientServiceImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.lgthinq.lgservices; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jetty.client.HttpClient; -import org.openhab.binding.lgthinq.lgservices.api.RestResult; -import org.openhab.binding.lgthinq.lgservices.errors.LGThinqApiException; -import org.openhab.binding.lgthinq.lgservices.model.DevicePowerState; -import org.openhab.binding.lgthinq.lgservices.model.devices.washerdryer.WasherDryerCapability; -import org.openhab.binding.lgthinq.lgservices.model.devices.washerdryer.WasherDryerSnapshot; - -/** - * The {@link LGThinQDRApiV2ClientServiceImpl} - * - * @author Nemer Daud - Initial contribution - */ -@NonNullByDefault -public class LGThinQDRApiV2ClientServiceImpl - extends LGThinQAbstractApiV2ClientService - implements LGThinQDRApiClientService { - - protected LGThinQDRApiV2ClientServiceImpl(HttpClient httpClient) { - super(WasherDryerCapability.class, WasherDryerSnapshot.class, httpClient); - } - - @Override - protected boolean beforeGetDataDevice(String bridgeName, String deviceId) { - // there's no before settings to send command - return false; - } - - @Override - public void turnDevicePower(String bridgeName, String deviceId, DevicePowerState newPowerState) { - throw new UnsupportedOperationException("Not implemented yet."); - } - - @Override - public void remoteStart(String bridgeName, String deviceId) throws LGThinqApiException { - try { - RestResult result = sendCommand(bridgeName, deviceId, "control-sync", "WMStart", "WMStart", "WMStart", ""); - handleGenericErrorResult(result); - } catch (LGThinqApiException e) { - throw e; - } catch (Exception e) { - throw new LGThinqApiException("Error sending remote start", e); - } - } - - @Override - public void wakeUp(String bridgeName, String deviceId) throws LGThinqApiException { - try { - RestResult result = sendCommand(bridgeName, deviceId, "control-sync", "WMWakeup", "WMWakeup", "", ""); - handleGenericErrorResult(result); - } catch (LGThinqApiException e) { - throw e; - } catch (Exception e) { - throw new LGThinqApiException("Error sending remote start", e); - } - } -} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDishWasherApiClientService.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDishWasherApiClientService.java index 452a837bd06..ecbbccc7c0f 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDishWasherApiClientService.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDishWasherApiClientService.java @@ -19,14 +19,20 @@ import org.openhab.binding.lgthinq.lgservices.model.devices.dishwasher.DishWashe import org.openhab.binding.lgthinq.lgservices.model.devices.dishwasher.DishWasherSnapshot; /** - * The {@link LGThinQDishWasherApiClientService} + * The {@link LGThinQDishWasherApiClientService} - implements specific methods for DishWashers * * @author Nemer Daud - Initial contribution */ @NonNullByDefault public interface LGThinQDishWasherApiClientService extends LGThinQApiClientService { + /** + * Remote start machine funcion + * + * @param bridgeName Bridge name + * @param cap Capabilities of the device + * @param deviceId LG Device ID + * @param data data to sent to remote start + */ void remoteStart(String bridgeName, DishWasherCapability cap, String deviceId, Map data); - - void wakeUp(String bridgeName, String deviceId, Boolean wakeUp); } diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDishWasherApiV1ClientServiceImpl.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDishWasherApiV1ClientServiceImpl.java index dcbd4be9899..791a0a2a5b7 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDishWasherApiV1ClientServiceImpl.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDishWasherApiV1ClientServiceImpl.java @@ -57,9 +57,4 @@ public class LGThinQDishWasherApiV1ClientServiceImpl public void remoteStart(String bridgeName, DishWasherCapability cap, String deviceId, Map data) { throw new UnsupportedOperationException("Not implemented yet"); } - - @Override - public void wakeUp(String bridgeName, String deviceId, Boolean wakeUp) { - throw new UnsupportedOperationException("Not implemented yet"); - } } diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDishWasherApiV2ClientServiceImpl.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDishWasherApiV2ClientServiceImpl.java index a1f90c183ab..238f6d2b7c8 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDishWasherApiV2ClientServiceImpl.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQDishWasherApiV2ClientServiceImpl.java @@ -49,9 +49,4 @@ public class LGThinQDishWasherApiV2ClientServiceImpl public void remoteStart(String bridgeName, DishWasherCapability cap, String deviceId, Map data) { throw new UnsupportedOperationException("Not implemented yet"); } - - @Override - public void wakeUp(String bridgeName, String deviceId, Boolean wakeUp) { - throw new UnsupportedOperationException("Not implemented yet"); - } } diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQFridgeApiClientService.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQFridgeApiClientService.java index 077da8a6088..18f826538ec 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQFridgeApiClientService.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQFridgeApiClientService.java @@ -21,27 +21,82 @@ import org.openhab.binding.lgthinq.lgservices.model.devices.fridge.FridgeCanonic import org.openhab.binding.lgthinq.lgservices.model.devices.fridge.FridgeCapability; /** - * The {@link LGThinQFridgeApiClientService} + * The {@link LGThinQFridgeApiClientService} - Interface with specific methods for Fridge Devices * * @author Nemer Daud - Initial contribution */ @NonNullByDefault public interface LGThinQFridgeApiClientService extends LGThinQApiClientService { + /** + * Set fridge temperature + * + * @param bridgeId Bridge ID + * @param deviceId LG Device ID + * @param fridgeCapability Fridge Capabilities + * @param targetTemperatureIndex target temperature + * @param tempUnit Temperature Unit + * @param snapCmdData Snapshot template for the target temperature command + * @throws LGThinqApiException If some error is reported from LG API + */ void setFridgeTemperature(String bridgeId, String deviceId, FridgeCapability fridgeCapability, Integer targetTemperatureIndex, String tempUnit, @Nullable Map snapCmdData) throws LGThinqApiException; + /** + * Set fridge temperature + * + * @param bridgeId Bridge ID + * @param deviceId LG Device ID + * @param fridgeCapability Fridge Capabilities + * @param targetTemperatureIndex target temperature + * @param tempUnit Temperature Unit + * @param snapCmdData Snapshot template for the target temperature command + * @throws LGThinqApiException If some error is reported from LG API + */ void setFreezerTemperature(String bridgeId, String deviceId, FridgeCapability fridgeCapability, Integer targetTemperatureIndex, String tempUnit, @Nullable Map snapCmdData) throws LGThinqApiException; + /** + * Setup Express Mode + * + * @param bridgeId Bridge ID + * @param deviceId LG Device ID + * @param expressModeIndex Empress mode desired + * @throws LGThinqApiException If some error is reported from LG API + */ void setExpressMode(String bridgeId, String deviceId, String expressModeIndex) throws LGThinqApiException; + /** + * Set the Express Cool Mode + * + * @param bridgeId Bridge ID + * @param deviceId LG Device id + * @param trueOnFalseOff ON/OFF the Cool Mode + * @throws LGThinqApiException If some error is reported from LG API + */ void setExpressCoolMode(String bridgeId, String deviceId, boolean trueOnFalseOff) throws LGThinqApiException; + /** + * Set the Express Cool Mode + * + * @param bridgeId Bridge ID + * @param deviceId LG Device id + * @param trueOnFalseOff ON/OFF the Eco Mode + * @throws LGThinqApiException If some error is reported from LG API + */ void setEcoFriendlyMode(String bridgeId, String deviceId, boolean trueOnFalseOff) throws LGThinqApiException; + /** + * + * @param bridgeId Bridge ID + * @param deviceId LG Thinq Device ID + * @param fridgeCapability Fridge Capabilities + * @param trueOnFalseOff Set ON/OFF the ICE Plus + * @param snapCmdData Snapshot template for the ICE Plus Command + * @throws LGThinqApiException If some error is reported from LG API + */ void setIcePlus(String bridgeId, String deviceId, FridgeCapability fridgeCapability, boolean trueOnFalseOff, Map snapCmdData) throws LGThinqApiException; } diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQWMApiClientService.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQWMApiClientService.java index df88d80ed7d..02c32aed25a 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQWMApiClientService.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/LGThinQWMApiClientService.java @@ -20,14 +20,31 @@ import org.openhab.binding.lgthinq.lgservices.model.devices.washerdryer.WasherDr import org.openhab.binding.lgthinq.lgservices.model.devices.washerdryer.WasherDryerSnapshot; /** - * The {@link LGThinQWMApiClientService} + * The {@link LGThinQWMApiClientService} - Methods specifics for Washing/Drier Machines * * @author Nemer Daud - Initial contribution */ @NonNullByDefault public interface LGThinQWMApiClientService extends LGThinQApiClientService { + /** + * Control the remote start feature + * + * @param bridgeName Bridge Name + * @param cap Capabilities of the device + * @param deviceId LG Device ID + * @param data Data to control the remote start + * @throws LGThinqApiException if some error is reported from the LG API + */ void remoteStart(String bridgeName, WasherDryerCapability cap, String deviceId, Map data) throws LGThinqApiException; + /** + * Waking UP feature + * + * @param bridgeName Bridge Name + * @param deviceId LG Device Name + * @param wakeUp to Wake Up (true/false) + * @throws LGThinqApiException if some error is reported from the LG API + */ void wakeUp(String bridgeName, String deviceId, Boolean wakeUp) throws LGThinqApiException; } diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/api/LGThinqCanonicalModelUtil.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/api/LGThinqCanonicalModelUtil.java index 816a427daa7..d46624d5867 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/api/LGThinqCanonicalModelUtil.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/api/LGThinqCanonicalModelUtil.java @@ -23,7 +23,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; /** - * The {@link LGThinqCanonicalModelUtil} class + * The {@link LGThinqCanonicalModelUtil} class - Utilities to help communication with LG API * * @author Nemer Daud - Initial contribution */ @@ -31,13 +31,20 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class LGThinqCanonicalModelUtil { public static final ObjectMapper mapper = new ObjectMapper(); + /** + * Get structured result from the LG Authentication Gateway + * + * @param rawJson RAW Json to process + * @return Structured Object returned from the API + * @throws IOException If some error happen procession token from file. + */ public static GatewayResult getGatewayResult(String rawJson) throws IOException { Map map = mapper.readValue(rawJson, new TypeReference<>() { }); - Map content = mapper.convertValue(map, new TypeReference<>() { - }); + @SuppressWarnings("unchecked") + Map content = (Map) map.get("result"); String resultCode = (String) map.get("resultCode"); - if (content == null) { + if (content == null || content.isEmpty()) { throw new IllegalArgumentException("Unexpected result. Gateway Content Result is null"); } else if (resultCode == null) { throw new IllegalArgumentException("Unexpected result. resultCode code is null"); diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/api/LGThinqGateway.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/api/LGThinqGateway.java index d5df36e97d8..ce5a2f95e4b 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/api/LGThinqGateway.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/api/LGThinqGateway.java @@ -24,7 +24,7 @@ import org.openhab.binding.lgthinq.lgservices.api.model.GatewayResult; import com.fasterxml.jackson.annotation.JsonIgnore; /** - * The {@link LGThinqGateway} hold informations about the LG Gateway + * The {@link LGThinqGateway} hold information about the LG Gateway * * @author Nemer Daud - Initial contribution */ diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/api/LGThinqOauthEmpAuthenticator.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/api/LGThinqOauthEmpAuthenticator.java index 594edb75aef..966edd2af8c 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/api/LGThinqOauthEmpAuthenticator.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/api/LGThinqOauthEmpAuthenticator.java @@ -114,7 +114,8 @@ public class LGThinqOauthEmpAuthenticator { if (result.getStatusCode() != 200) { throw new IllegalStateException( - "Expected HTTP OK return, but received result core:" + result.getJsonResponse()); + String.format("Expected HTTP OK return, but received result core:[%s] - error message:[%s]", + result.getJsonResponse(), ResultCodes.getReasonResponse(result.getJsonResponse()))); } else { GatewayResult gwResult = LGThinqCanonicalModelUtil.getGatewayResult(result.getJsonResponse()); ResultCodes resultCode = ResultCodes.fromCode(gwResult.getReturnedCode()); @@ -176,9 +177,8 @@ public class LGThinqOauthEmpAuthenticator { } Map loginResult = objectMapper.readValue(resp.getJsonResponse(), new TypeReference<>() { }); - Map accountResult = objectMapper.convertValue(loginResult.get("account"), - new TypeReference<>() { - }); + @SuppressWarnings("unchecked") + Map accountResult = (Map) loginResult.get("account"); if (accountResult == null) { throw new IllegalStateException("Error getting account from Login"); } @@ -277,8 +277,8 @@ public class LGThinqOauthEmpAuthenticator { || ((Map) result.getOrDefault("account", Collections.emptyMap())).get("userNo") == null) { throw new IllegalStateException("Error retrieving the account user information from access token"); } - Map accountInfo = objectMapper.convertValue(result.get("account"), new TypeReference<>() { - }); + @SuppressWarnings("unchecked") + Map accountInfo = (Map) result.getOrDefault("account", Collections.emptyMap()); return new UserInfo( Objects.requireNonNullElse(accountInfo.get("userNo"), diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/errors/LGThinqAccessException.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/errors/LGThinqAccessException.java new file mode 100644 index 00000000000..93911b25de7 --- /dev/null +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/errors/LGThinqAccessException.java @@ -0,0 +1,21 @@ +package org.openhab.binding.lgthinq.lgservices.errors; + +import org.openhab.binding.lgthinq.lgservices.model.ResultCodes; + +public class LGThinqAccessException extends LGThinqApiException { + public LGThinqAccessException(String message, Throwable cause) { + super(message, cause); + } + + public LGThinqAccessException(String message, Throwable cause, ResultCodes reasonCode) { + super(message, cause, reasonCode); + } + + public LGThinqAccessException(String message) { + super(message); + } + + public LGThinqAccessException(String message, ResultCodes resultCode) { + super(message, resultCode); + } +} diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/DeviceTypes.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/DeviceTypes.java index 956034987de..66550f3f384 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/DeviceTypes.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/DeviceTypes.java @@ -27,7 +27,7 @@ public enum DeviceTypes { WASHER_TOWER(221, "WM", "", "washer-tower-221"), DRYER(202, "DR", "Dryer", "dryer-202"), DRYER_TOWER(222, "DR", "Dryer", "dryer-tower-222"), - REFRIGERATOR(101, "REF", "Fridge", "fridge-101"), + FRIDGE(101, "REF", "Fridge", "fridge-101"), DISH_WASHER(204, "DW", "DishWasher", "dishwasher-204"), UNKNOWN(-1, "", "", ""); @@ -70,7 +70,7 @@ public enum DeviceTypes { case 222: return DRYER_TOWER; case 101: - return REFRIGERATOR; + return FRIDGE; default: return UNKNOWN; } @@ -90,7 +90,7 @@ public enum DeviceTypes { } yield WASHERDRYER_MACHINE; } - case "REF" -> REFRIGERATOR; + case "REF" -> FRIDGE; case "DW" -> DISH_WASHER; default -> UNKNOWN; }; diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/ModelUtils.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/ModelUtils.java index f14d2c8cefc..260003518a8 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/ModelUtils.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/ModelUtils.java @@ -72,7 +72,7 @@ public class ModelUtils { case WASHERDRYER_MACHINE: case DRYER: - case REFRIGERATOR: + case FRIDGE: if (rootMap.containsKey("Value")) { return LGAPIVerion.V1_0; } else if (rootMap.containsKey("MonitoringValue")) { diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/ResultCodes.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/ResultCodes.java index e1a2f3265b2..2ae0e48186a 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/ResultCodes.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/ResultCodes.java @@ -102,93 +102,43 @@ public enum ResultCodes { } public static ResultCodes fromCode(String code) { - switch (code) { - case "0000": - case "0001": - return OK; - case "0002": - return INVALID_PAYLOAD; - case "0003": - return INVALID_HEAD; - case "0110": // Update Terms - return UPDATE_TERMS_NEEDED; - case "0004": // Duplicated Login - return LOGIN_DUPLICATED; - case "0102": // Not Logged in - case "0114": // Mismatch Login Session - return LOGIN_FAILED; - case "0100": - return GENERAL_FAILURE; - case "0116": - return INVALID_REQUEST; - case "0108": - case "0109": - return NO_INFORMATION_FOUND; - case "0115": - case "0006": - case "0009": - case "0117": - case "0014": - case "0101": - return DEVICE_MISMATCH; - case "0010": - return INVALID_CUSTOMER_DATA; - case "0112": - return LIMIT_EXCEEDED_ERROR; - case "0118": - case "0120": - return INVALID_CUSTOMER_NUMBER; - case "0121": - return NOT_REGISTERED_SMART_CARE; - case "0007": - return PORTAL_INTERWORKING_ERROR; - case "0008": - case "0013": - return DUPLICATED_DATA; - case "0005": - case "0012": - case "8001": - return NOT_SUPPORTED_CONTROL; - case "0111": - case "0103": - case "0104": - case "0106": - return DEVICE_NOT_RESPONSE; - case "0105": - return CONTROL_ERROR; - case "9001": - case "9002": - return BASE64_CODING_ERROR; - case "0107": - case "8101": - case "8102": - case "8203": - case "8204": - case "8205": - case "8206": - case "8207": - case "8900": - case "9000": - case "9003": - case "9004": - case "9005": - return LG_SERVER_ERROR; - case "9999": - return PAYLOAD_ERROR; - case "9006": - case "0011": - case "0113": - return ACCESS_DENIED; - case "9010": - return INVALID_CSR; - case "0301": - return INVALID_PUSH_TOKEN; - default: + return switch (code) { + case "0000", "0001" -> OK; + case "0002" -> INVALID_PAYLOAD; + case "0003" -> INVALID_HEAD; + case "0110" -> // Update Terms + UPDATE_TERMS_NEEDED; + case "0004" -> // Duplicated Login + LOGIN_DUPLICATED; // Not Logged in + case "0102", "0114" -> // Mismatch Login Session + LOGIN_FAILED; + case "0100" -> GENERAL_FAILURE; + case "0116" -> INVALID_REQUEST; + case "0108", "0109" -> NO_INFORMATION_FOUND; + case "0115", "0006", "0009", "0117", "0014", "0101" -> DEVICE_MISMATCH; + case "0010" -> INVALID_CUSTOMER_DATA; + case "0112" -> LIMIT_EXCEEDED_ERROR; + case "0118", "0120" -> INVALID_CUSTOMER_NUMBER; + case "0121" -> NOT_REGISTERED_SMART_CARE; + case "0007" -> PORTAL_INTERWORKING_ERROR; + case "0008", "0013" -> DUPLICATED_DATA; + case "0005", "0012", "8001" -> NOT_SUPPORTED_CONTROL; + case "0111", "0103", "0104", "0106" -> DEVICE_NOT_RESPONSE; + case "0105" -> CONTROL_ERROR; + case "9001", "9002" -> BASE64_CODING_ERROR; + case "0107", "8101", "8102", "8203", "8204", "8205", "8206", "8207", "8900", "9000", "9003", "9004", + "9005" -> + LG_SERVER_ERROR; + case "9999" -> PAYLOAD_ERROR; + case "9006", "0011", "0113" -> ACCESS_DENIED; + case "9010" -> INVALID_CSR; + case "0301" -> INVALID_PUSH_TOKEN; + default -> { if (OTHER_ERROR_CODE_RESPONSE.containsKey(code)) { - return OTHER; + yield OTHER; } - return UNKNOWN; - - } + yield UNKNOWN; + } + }; } } diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/fridge/AbstractFridgeCapabilityFactory.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/fridge/AbstractFridgeCapabilityFactory.java index 2ca058033a1..32f09196df8 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/fridge/AbstractFridgeCapabilityFactory.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/fridge/AbstractFridgeCapabilityFactory.java @@ -141,7 +141,7 @@ public abstract class AbstractFridgeCapabilityFactory extends AbstractCapability @Override protected List getSupportedDeviceTypes() { - return List.of(DeviceTypes.REFRIGERATOR); + return List.of(DeviceTypes.FRIDGE); } protected abstract String getMonitorValueNodeName(); diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/fridge/FridgeCapabilityFactoryV2.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/fridge/FridgeCapabilityFactoryV2.java index b0a19945d42..d881b147472 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/fridge/FridgeCapabilityFactoryV2.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/fridge/FridgeCapabilityFactoryV2.java @@ -129,8 +129,7 @@ public class FridgeCapabilityFactoryV2 extends AbstractFridgeCapabilityFactory { } protected String getFridgeTempNodeName() { - throw new UnsupportedOperationException( - "Refrigerator Thinq2 doesn't support FridgeTemp node. It most likely a bug"); + throw new UnsupportedOperationException("Fridge Thinq2 doesn't support FridgeTemp node. It most likely a bug"); } @Override @@ -145,8 +144,7 @@ public class FridgeCapabilityFactoryV2 extends AbstractFridgeCapabilityFactory { @Override protected String getFreezerTempNodeName() { - throw new UnsupportedOperationException( - "Refrigerator Thinq2 doesn't support FreezerTemp node. It most likely a bug"); + throw new UnsupportedOperationException("Fridge Thinq2 doesn't support FreezerTemp node. It most likely a bug"); } @Override diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/fridge/FridgeSnapshotBuilder.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/fridge/FridgeSnapshotBuilder.java index 132d4998b9f..51b8806a7eb 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/fridge/FridgeSnapshotBuilder.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/fridge/FridgeSnapshotBuilder.java @@ -13,7 +13,7 @@ package org.openhab.binding.lgthinq.lgservices.model.devices.fridge; import static org.openhab.binding.lgthinq.lgservices.LGServicesConstants.RE_SNAPSHOT_NODE_V2; -import static org.openhab.binding.lgthinq.lgservices.model.DeviceTypes.REFRIGERATOR; +import static org.openhab.binding.lgthinq.lgservices.model.DeviceTypes.FRIDGE; import java.util.List; import java.util.Map; @@ -48,7 +48,7 @@ public class FridgeSnapshotBuilder extends DefaultSnapshotBuilder snapMap, CapabilityDefinition capDef) { FridgeCanonicalSnapshot snap; - if (REFRIGERATOR.equals(capDef.getDeviceType())) { + if (FRIDGE.equals(capDef.getDeviceType())) { switch (capDef.getDeviceVersion()) { case V1_0: throw new IllegalArgumentException("Version 1.0 for Fridge driver is not supported yet."); diff --git a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/washerdryer/AbstractWasherDryerCapabilityFactory.java b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/washerdryer/AbstractWasherDryerCapabilityFactory.java index 497b95d40c7..dc2dabd197c 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/washerdryer/AbstractWasherDryerCapabilityFactory.java +++ b/bundles/org.openhab.binding.lgthinq/src/main/java/org/openhab/binding/lgthinq/lgservices/model/devices/washerdryer/AbstractWasherDryerCapabilityFactory.java @@ -12,12 +12,12 @@ */ package org.openhab.binding.lgthinq.lgservices.model.devices.washerdryer; +import static org.openhab.binding.lgthinq.internal.LGThinQBindingConstants.CHANNEL_WMD_REMOTE_START_RINSE; +import static org.openhab.binding.lgthinq.internal.LGThinQBindingConstants.CHANNEL_WMD_REMOTE_START_SPIN; +import static org.openhab.binding.lgthinq.internal.LGThinQBindingConstants.CHANNEL_WMD_REMOTE_START_TEMP; import static org.openhab.binding.lgthinq.internal.LGThinQBindingConstants.CHANNEL_WMD_RINSE_ID; import static org.openhab.binding.lgthinq.internal.LGThinQBindingConstants.CHANNEL_WMD_SPIN_ID; import static org.openhab.binding.lgthinq.internal.LGThinQBindingConstants.CHANNEL_WMD_TEMP_LEVEL_ID; -import static org.openhab.binding.lgthinq.internal.LGThinQBindingConstants.CHANNEL_WM_REMOTE_START_RINSE; -import static org.openhab.binding.lgthinq.internal.LGThinQBindingConstants.CHANNEL_WM_REMOTE_START_SPIN; -import static org.openhab.binding.lgthinq.internal.LGThinQBindingConstants.CHANNEL_WM_REMOTE_START_TEMP; import static org.openhab.binding.lgthinq.lgservices.LGServicesConstants.WM_LOST_WASHING_STATE_KEY; import static org.openhab.binding.lgthinq.lgservices.LGServicesConstants.WM_LOST_WASHING_STATE_VALUE; @@ -97,11 +97,11 @@ public abstract class AbstractWasherDryerCapabilityFactory extends AbstractCapab wdCap.setProcessState(newFeatureDefinition(getProcessStateNodeName(), monitorValueNode)); // --- Selectable features ----- wdCap.setRinseFeat(newFeatureDefinition(getRinseFeatureNodeName(), monitorValueNode, - CHANNEL_WM_REMOTE_START_RINSE, CHANNEL_WMD_RINSE_ID)); + CHANNEL_WMD_REMOTE_START_RINSE, CHANNEL_WMD_RINSE_ID)); wdCap.setTemperatureFeat(newFeatureDefinition(getTemperatureFeatureNodeName(), monitorValueNode, - CHANNEL_WM_REMOTE_START_TEMP, CHANNEL_WMD_TEMP_LEVEL_ID)); - wdCap.setSpinFeat(newFeatureDefinition(getSpinFeatureNodeName(), monitorValueNode, CHANNEL_WM_REMOTE_START_SPIN, - CHANNEL_WMD_SPIN_ID)); + CHANNEL_WMD_REMOTE_START_TEMP, CHANNEL_WMD_TEMP_LEVEL_ID)); + wdCap.setSpinFeat(newFeatureDefinition(getSpinFeatureNodeName(), monitorValueNode, + CHANNEL_WMD_REMOTE_START_SPIN, CHANNEL_WMD_SPIN_ID)); // ---------------------------- wdCap.setDryLevel(newFeatureDefinition(getDryLevelNodeName(), monitorValueNode)); wdCap.setSoilWash(newFeatureDefinition(getSoilWashFeatureNodeName(), monitorValueNode)); diff --git a/bundles/org.openhab.binding.lgthinq/src/main/resources/OH-INF/i18n/lgthinq.properties b/bundles/org.openhab.binding.lgthinq/src/main/resources/OH-INF/i18n/lgthinq.properties index 8e1c1f08f63..8fa2789a82a 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/resources/OH-INF/i18n/lgthinq.properties +++ b/bundles/org.openhab.binding.lgthinq/src/main/resources/OH-INF/i18n/lgthinq.properties @@ -271,3 +271,7 @@ channel-type.lgthinq.washerdryer-temp-level.description = Target Temperature Lev error.lgapi-getting-devices = Error getting device list from the account error.toke-file-corrupted = LGThinq Bridge Token File corrupted error.toke-refresh = Error refreshing LGThinq Bridge Token +error.toke-file-access-error = Error reading token file. +error.lgapi-communication-error = Communication Error with LG API +error.mandotory-fields-missing = Mandatory Fields Configuration Missing +offline.device-disconnected = Device is Offline diff --git a/bundles/org.openhab.binding.lgthinq/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.lgthinq/src/main/resources/OH-INF/thing/channels.xml index 3590a499c12..3f246f17e24 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.lgthinq/src/main/resources/OH-INF/thing/channels.xml @@ -333,7 +333,7 @@ - + Contact Door status (at least one if combined fridge/freezer) @@ -344,7 +344,7 @@ - + String Temperature Unit @@ -356,20 +356,20 @@ - + Number:Temperature Freezer setpoint temperature Temperature - + - + Number:Temperature Fridge setpoint temperature. Temperature - + diff --git a/bundles/org.openhab.binding.lgthinq/src/main/resources/OH-INF/thing/fridge.xml b/bundles/org.openhab.binding.lgthinq/src/main/resources/OH-INF/thing/fridge.xml index 818d021bb5c..7bffe8093ec 100644 --- a/bundles/org.openhab.binding.lgthinq/src/main/resources/OH-INF/thing/fridge.xml +++ b/bundles/org.openhab.binding.lgthinq/src/main/resources/OH-INF/thing/fridge.xml @@ -23,10 +23,10 @@ This is the Displayed Information. - - - - + + + +