From 3d33ee0ab8309b6fcb611a6f7d11f71a5d4a1cd8 Mon Sep 17 00:00:00 2001 From: lolodomo Date: Sun, 20 Jun 2021 20:03:05 +0200 Subject: [PATCH] [homeconnect] 9 channels added for washer appliance (#10809) * [homeconnect] 9 channels added for washer appliance Corresponding to 9 program options not fully supported by the API. Fix #10704 Signed-off-by: Laurent Garnier * Review comment: formatting in XML thing file Signed-off-by: Laurent Garnier * Review comment: add these new channels (except i-DOS) to washerdryer appliance Signed-off-by: Laurent Garnier * Review comment: method isLinkedChannelsForUnsupportedFeatures renamed Signed-off-by: Laurent Garnier * Change state options for rinse plus channel Signed-off-by: Laurent Garnier * Update the new channels when the active program is updated Signed-off-by: Laurent Garnier * Review comment: update documentation Signed-off-by: Laurent Garnier * Review comment: typo in channel description Signed-off-by: Laurent Garnier --- .../org.openhab.binding.homeconnect/README.md | 13 +- .../internal/HomeConnectBindingConstants.java | 18 +++ .../AbstractHomeConnectThingHandler.java | 122 +++++++++++++++--- .../HomeConnectWasherDryerHandler.java | 34 ++++- .../handler/HomeConnectWasherHandler.java | 50 ++++++- .../resources/OH-INF/thing/thing-types.xml | 88 ++++++++++++- 6 files changed, 299 insertions(+), 26 deletions(-) diff --git a/bundles/org.openhab.binding.homeconnect/README.md b/bundles/org.openhab.binding.homeconnect/README.md index 2f349d4e2..db94adb94 100644 --- a/bundles/org.openhab.binding.homeconnect/README.md +++ b/bundles/org.openhab.binding.homeconnect/README.md @@ -56,8 +56,17 @@ After the bridge has been added and authorized, devices are discovered automatic | setpoint_temperature | Number:Temperature | false | This status describes the setpoint/target temperature of the home appliance. | oven | | laundry_care_washer_temperature | String | false | This status describes the temperature of the washing program of the home appliance. | washer, washerdryer | | laundry_care_washer_spin_speed | String | false | This status defines the spin speed of a washer program of the home appliance. | washer, washerdryer | -| laundry_care_washer_idos1 | String | false | This status defines the i-Dos 1 dosing level of a washer program of the home appliance (if appliance supports i-Dos). | washer | -| laundry_care_washer_idos2 | String | false | This status defines the i-Dos 2 dosing level of a washer program of the home appliance (if appliance supports i-Dos). | washer | +| laundry_care_washer_idos1_level | String | false | This status defines the i-Dos 1 dosing level of a washer program of the home appliance (if appliance supports i-Dos). | washer | +| laundry_care_washer_idos2_level | String | false | This status defines the i-Dos 2 dosing level of a washer program of the home appliance (if appliance supports i-Dos). | washer | +| laundry_care_washer_idos1 | Switch | true | This status indicates whether i-Dos 1 is activated for a washer program of the home appliance. (If appliance supports i-Dos) | washer | +| laundry_care_washer_idos2 | Switch | true | This status indicates whether i-Dos 2 is activated for a washer program of the home appliance. (If appliance supports i-Dos) | washer | +| laundry_care_washer_vario_perfect | String | true | This status defines the vario perfect mode of a washer program of the home appliance. | washer, washerdryer | +| laundry_care_washer_less_ironing | Switch | true | This status indicates whether less ironing is activated for a washer program of the home appliance. | washer, washerdryer | +| laundry_care_washer_pre_wash | Switch | true | This status indicates whether the pre-wash is activated for a washer program of the home appliance. | washer, washerdryer | +| laundry_care_washer_rinse_plus | String | true | This status defines the number of additional rinses of a washer program of the home appliance. | washer, washerdryer | +| laundry_care_washer_soak | Switch | true | This status indicates whether the soaking is activated for a washer program of the home appliance. | washer, washerdryer | +| program_energy | Number:Dimensionless | true | This channel provides the estimated energy required in percentage for a program of the home appliance. | washer, washerdryer | +| program_water | Number:Dimensionless | true | This channel provides the estimated water required in percentage for a program of the home appliance. | washer, washerdryer | | dryer_drying_target | String | false | This status defines the desired dryness of a program of the home appliance. | dryer, washerdryer | | setpoint_temperature_refrigerator | Number:Temperature | false | Target temperature of the refrigerator compartment (range depends on appliance - common range 2 to 8°C). | fridgefreezer | | setpoint_temperature_freezer | Number:Temperature | false | Target temperature of the freezer compartment (range depends on appliance - common range -16 to -24°C). | fridgefreezer | diff --git a/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/HomeConnectBindingConstants.java b/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/HomeConnectBindingConstants.java index 7ecdbec37..4d2dd432c 100644 --- a/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/HomeConnectBindingConstants.java +++ b/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/HomeConnectBindingConstants.java @@ -120,8 +120,17 @@ public class HomeConnectBindingConstants { public static final String CHANNEL_DURATION = "duration"; public static final String CHANNEL_WASHER_TEMPERATURE = "laundry_care_washer_temperature"; public static final String CHANNEL_WASHER_SPIN_SPEED = "laundry_care_washer_spin_speed"; + public static final String CHANNEL_WASHER_IDOS1_LEVEL = "laundry_care_washer_idos1_level"; + public static final String CHANNEL_WASHER_IDOS2_LEVEL = "laundry_care_washer_idos2_level"; public static final String CHANNEL_WASHER_IDOS1 = "laundry_care_washer_idos1"; public static final String CHANNEL_WASHER_IDOS2 = "laundry_care_washer_idos2"; + public static final String CHANNEL_WASHER_VARIO_PERFECT = "laundry_care_washer_vario_perfect"; + public static final String CHANNEL_WASHER_LESS_IRONING = "laundry_care_washer_less_ironing"; + public static final String CHANNEL_WASHER_PRE_WASH = "laundry_care_washer_pre_wash"; + public static final String CHANNEL_WASHER_RINSE_PLUS = "laundry_care_washer_rinse_plus"; + public static final String CHANNEL_WASHER_SOAK = "laundry_care_washer_soak"; + public static final String CHANNEL_PROGRAM_ENERGY = "program_energy"; + public static final String CHANNEL_PROGRAM_WATER = "program_water"; public static final String CHANNEL_REFRIGERATOR_SETPOINT_TEMPERATURE = "setpoint_temperature_refrigerator"; public static final String CHANNEL_REFRIGERATOR_SUPER_MODE = "super_mode_refrigerator"; public static final String CHANNEL_FREEZER_SETPOINT_TEMPERATURE = "setpoint_temperature_freezer"; @@ -173,6 +182,15 @@ public class HomeConnectBindingConstants { public static final String OPTION_WASHER_SPIN_SPEED = "LaundryCare.Washer.Option.SpinSpeed"; public static final String OPTION_WASHER_IDOS_1_DOSING_LEVEL = "LaundryCare.Washer.Option.IDos1DosingLevel"; public static final String OPTION_WASHER_IDOS_2_DOSING_LEVEL = "LaundryCare.Washer.Option.IDos2DosingLevel"; + public static final String OPTION_WASHER_IDOS_1_ACTIVE = "LaundryCare.Washer.Option.IDos1.Active"; + public static final String OPTION_WASHER_IDOS_2_ACTIVE = "LaundryCare.Washer.Option.IDos2.Active"; + public static final String OPTION_WASHER_VARIO_PERFECT = "LaundryCare.Common.Option.VarioPerfect"; + public static final String OPTION_WASHER_LESS_IRONING = "LaundryCare.Washer.Option.LessIroning"; + public static final String OPTION_WASHER_PRE_WASH = "LaundryCare.Washer.Option.Prewash"; + public static final String OPTION_WASHER_RINSE_PLUS = "LaundryCare.Washer.Option.RinsePlus"; + public static final String OPTION_WASHER_SOAK = "LaundryCare.Washer.Option.Soak"; + public static final String OPTION_WASHER_ENERGY_FORECAST = "BSH.Common.Option.EnergyForecast"; + public static final String OPTION_WASHER_WATER_FORECAST = "BSH.Common.Option.WaterForecast"; public static final String OPTION_DRYER_DRYING_TARGET = "LaundryCare.Dryer.Option.DryingTarget"; public static final String OPTION_HOOD_VENTING_LEVEL = "Cooking.Common.Option.Hood.VentingLevel"; public static final String OPTION_HOOD_INTENSIVE_LEVEL = "Cooking.Common.Option.Hood.IntensiveLevel"; diff --git a/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/AbstractHomeConnectThingHandler.java b/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/AbstractHomeConnectThingHandler.java index 8c15a57ef..9db0f0dd3 100644 --- a/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/AbstractHomeConnectThingHandler.java +++ b/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/AbstractHomeConnectThingHandler.java @@ -485,6 +485,10 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i */ protected abstract void configureEventHandlers(final Map handlers); + protected boolean isChannelLinkedToProgramOptionNotFullySupportedByApi() { + return false; + } + /** * Update all channels via API. * @@ -795,16 +799,16 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i getThingChannel(CHANNEL_OPERATION_STATE).ifPresent(channel -> updateState(channel.getUID(), value == null ? UnDefType.UNDEF : new StringType(mapStringType(value)))); - if (STATE_OPERATION_FINISHED.equals(event.getValue())) { + if (STATE_OPERATION_FINISHED.equals(value)) { getThingChannel(CHANNEL_PROGRAM_PROGRESS_STATE) .ifPresent(c -> updateState(c.getUID(), new QuantityType<>(100, PERCENT))); getThingChannel(CHANNEL_REMAINING_PROGRAM_TIME_STATE) .ifPresent(c -> updateState(c.getUID(), new QuantityType<>(0, SECOND))); - } else if (STATE_OPERATION_RUN.equals(event.getValue())) { + } else if (STATE_OPERATION_RUN.equals(value)) { getThingChannel(CHANNEL_PROGRAM_PROGRESS_STATE) .ifPresent(c -> updateState(c.getUID(), new QuantityType<>(0, PERCENT))); getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(c -> updateChannel(c.getUID())); - } else if (STATE_OPERATION_READY.equals(event.getValue())) { + } else if (STATE_OPERATION_READY.equals(value)) { resetProgramStateChannels(false); } }; @@ -815,12 +819,37 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i String value = event.getValue(); getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(channel -> updateState(channel.getUID(), value == null ? UnDefType.UNDEF : new StringType(mapStringType(value)))); - if (event.getValue() == null) { + if (value == null) { resetProgramStateChannels(false); } }; } + protected EventHandler updateProgramOptionsAndActiveProgramStateEventHandler() { + return event -> { + String value = event.getValue(); + getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(channel -> updateState(channel.getUID(), + value == null ? UnDefType.UNDEF : new StringType(mapStringType(value)))); + if (value == null) { + resetProgramStateChannels(false); + } else { + try { + Optional apiClient = getApiClient(); + if (apiClient.isPresent() && isChannelLinkedToProgramOptionNotFullySupportedByApi() + && apiClient.get().isRemoteControlActive(getThingHaId())) { + // update channels linked to program options + Program program = apiClient.get().getSelectedProgram(getThingHaId()); + if (program != null) { + processProgramOptions(program.getOptions()); + } + } + } catch (CommunicationException | ApplianceOfflineException | AuthorizationException e) { + logger.debug("Could not update program options. {}", e.getMessage()); + } + } + }; + } + protected EventHandler defaultEventPresentStateEventHandler(String channelId) { return event -> getThingChannel(channelId).ifPresent(channel -> updateState(channel.getUID(), OnOffType.from(!STATE_EVENT_PRESENT_STATE_OFF.equals(event.getValue())))); @@ -863,13 +892,25 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i return event -> { defaultBooleanEventHandler(CHANNEL_REMOTE_CONTROL_ACTIVE_STATE).handle(event); - // update available program options if update was previously delayed and remote control is enabled try { - String programKey = programOptionsDelayedUpdate; - if (programKey != null && Boolean.parseBoolean(event.getValue())) { - logger.debug("Delayed update of options for program {}", programKey); - updateProgramOptionsStateDescriptions(programKey); - programOptionsDelayedUpdate = null; + if (Boolean.parseBoolean(event.getValue())) { + // update available program options if update was previously delayed and remote control is enabled + String programKey = programOptionsDelayedUpdate; + if (programKey != null) { + logger.debug("Delayed update of options for program {}", programKey); + updateProgramOptionsStateDescriptions(programKey); + programOptionsDelayedUpdate = null; + } + + if (isChannelLinkedToProgramOptionNotFullySupportedByApi()) { + Optional apiClient = getApiClient(); + if (apiClient.isPresent()) { + Program program = apiClient.get().getSelectedProgram(getThingHaId()); + if (program != null) { + processProgramOptions(program.getOptions()); + } + } + } } } catch (CommunicationException | ApplianceOfflineException | AuthorizationException e) { logger.debug("Could not update program options. {}", e.getMessage()); @@ -881,19 +922,32 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i return event -> { defaultSelectedProgramStateEventHandler().handle(event); - // update available program options try { Optional apiClient = getApiClient(); String programKey = event.getValue(); + if (apiClient.isPresent() && programKey != null) { - // Delay the update if options are not yet cached and remote control is disabled - if (availableProgramOptionsCache.get(programKey) == null - && !apiClient.get().isRemoteControlActive(getThingHaId())) { + Boolean remoteControl = (availableProgramOptionsCache.get(programKey) == null + || isChannelLinkedToProgramOptionNotFullySupportedByApi()) + ? apiClient.get().isRemoteControlActive(getThingHaId()) + : false; + + // Delay the update of available program options if options are not yet cached and remote control is + // disabled + if (availableProgramOptionsCache.get(programKey) == null && !remoteControl) { logger.debug("Delay update of options for program {}", programKey); programOptionsDelayedUpdate = programKey; } else { updateProgramOptionsStateDescriptions(programKey); } + + if (isChannelLinkedToProgramOptionNotFullySupportedByApi() && remoteControl) { + // update channels linked to program options + Program program = apiClient.get().getSelectedProgram(getThingHaId()); + if (program != null) { + processProgramOptions(program.getOptions()); + } + } } } catch (CommunicationException | ApplianceOfflineException | AuthorizationException e) { logger.debug("Could not update program options. {}", e.getMessage()); @@ -1288,11 +1342,11 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i .ifPresent(channel -> updateState(channel.getUID(), new StringType(option.getValue()))); break; case OPTION_WASHER_IDOS_1_DOSING_LEVEL: - getThingChannel(CHANNEL_WASHER_IDOS1) + getThingChannel(CHANNEL_WASHER_IDOS1_LEVEL) .ifPresent(channel -> updateState(channel.getUID(), new StringType(option.getValue()))); break; case OPTION_WASHER_IDOS_2_DOSING_LEVEL: - getThingChannel(CHANNEL_WASHER_IDOS2) + getThingChannel(CHANNEL_WASHER_IDOS2_LEVEL) .ifPresent(channel -> updateState(channel.getUID(), new StringType(option.getValue()))); break; case OPTION_DRYER_DRYING_TARGET: @@ -1338,6 +1392,42 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i .ifPresent(channel -> updateState(channel.getUID(), new QuantityType<>(option.getValueAsInt(), PERCENT))); break; + case OPTION_WASHER_IDOS_1_ACTIVE: + getThingChannel(CHANNEL_WASHER_IDOS1).ifPresent( + channel -> updateState(channel.getUID(), OnOffType.from(option.getValueAsBoolean()))); + break; + case OPTION_WASHER_IDOS_2_ACTIVE: + getThingChannel(CHANNEL_WASHER_IDOS2).ifPresent( + channel -> updateState(channel.getUID(), OnOffType.from(option.getValueAsBoolean()))); + break; + case OPTION_WASHER_VARIO_PERFECT: + getThingChannel(CHANNEL_WASHER_VARIO_PERFECT) + .ifPresent(channel -> updateState(channel.getUID(), new StringType(option.getValue()))); + break; + case OPTION_WASHER_LESS_IRONING: + getThingChannel(CHANNEL_WASHER_LESS_IRONING).ifPresent( + channel -> updateState(channel.getUID(), OnOffType.from(option.getValueAsBoolean()))); + break; + case OPTION_WASHER_PRE_WASH: + getThingChannel(CHANNEL_WASHER_PRE_WASH).ifPresent( + channel -> updateState(channel.getUID(), OnOffType.from(option.getValueAsBoolean()))); + break; + case OPTION_WASHER_RINSE_PLUS: + getThingChannel(CHANNEL_WASHER_RINSE_PLUS) + .ifPresent(channel -> updateState(channel.getUID(), new StringType(option.getValue()))); + break; + case OPTION_WASHER_SOAK: + getThingChannel(CHANNEL_WASHER_SOAK).ifPresent( + channel -> updateState(channel.getUID(), OnOffType.from(option.getValueAsBoolean()))); + break; + case OPTION_WASHER_ENERGY_FORECAST: + getThingChannel(CHANNEL_PROGRAM_ENERGY).ifPresent(channel -> updateState(channel.getUID(), + new QuantityType<>(option.getValueAsInt(), PERCENT))); + break; + case OPTION_WASHER_WATER_FORECAST: + getThingChannel(CHANNEL_PROGRAM_WATER).ifPresent(channel -> updateState(channel.getUID(), + new QuantityType<>(option.getValueAsInt(), PERCENT))); + break; } } }); diff --git a/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/HomeConnectWasherDryerHandler.java b/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/HomeConnectWasherDryerHandler.java index bdb1a9e5e..5764d2934 100644 --- a/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/HomeConnectWasherDryerHandler.java +++ b/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/HomeConnectWasherDryerHandler.java @@ -67,6 +67,20 @@ public class HomeConnectWasherDryerHandler extends AbstractHomeConnectThingHandl getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); handlers.put(CHANNEL_WASHER_TEMPERATURE, getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_WASHER_VARIO_PERFECT, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_WASHER_LESS_IRONING, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_WASHER_PRE_WASH, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_WASHER_RINSE_PLUS, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_WASHER_SOAK, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_PROGRAM_ENERGY, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_PROGRAM_WATER, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); // register dryer specific handlers handlers.put(CHANNEL_DRYER_DRYING_TARGET, getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); @@ -83,7 +97,7 @@ public class HomeConnectWasherDryerHandler extends AbstractHomeConnectThingHandl handlers.put(EVENT_REMAINING_PROGRAM_TIME, defaultRemainingProgramTimeEventHandler()); handlers.put(EVENT_PROGRAM_PROGRESS, defaultPercentQuantityTypeEventHandler(CHANNEL_PROGRAM_PROGRESS_STATE)); handlers.put(EVENT_LOCAL_CONTROL_ACTIVE, defaultBooleanEventHandler(CHANNEL_LOCAL_CONTROL_ACTIVE_STATE)); - handlers.put(EVENT_ACTIVE_PROGRAM, defaultActiveProgramEventHandler()); + handlers.put(EVENT_ACTIVE_PROGRAM, updateProgramOptionsAndActiveProgramStateEventHandler()); handlers.put(EVENT_OPERATION_STATE, defaultOperationStateEventHandler()); handlers.put(EVENT_SELECTED_PROGRAM, updateProgramOptionsAndSelectedProgramStateEventHandler()); @@ -100,6 +114,17 @@ public class HomeConnectWasherDryerHandler extends AbstractHomeConnectThingHandl event.getValue() == null ? UnDefType.UNDEF : new StringType(event.getValue())))); } + @Override + protected boolean isChannelLinkedToProgramOptionNotFullySupportedByApi() { + return (getThingChannel(CHANNEL_WASHER_VARIO_PERFECT).isPresent() && isLinked(CHANNEL_WASHER_VARIO_PERFECT)) + || (getThingChannel(CHANNEL_WASHER_LESS_IRONING).isPresent() && isLinked(CHANNEL_WASHER_LESS_IRONING)) + || (getThingChannel(CHANNEL_WASHER_PRE_WASH).isPresent() && isLinked(CHANNEL_WASHER_PRE_WASH)) + || (getThingChannel(CHANNEL_WASHER_RINSE_PLUS).isPresent() && isLinked(CHANNEL_WASHER_RINSE_PLUS)) + || (getThingChannel(CHANNEL_WASHER_SOAK).isPresent() && isLinked(CHANNEL_WASHER_SOAK)) + || (getThingChannel(CHANNEL_PROGRAM_ENERGY).isPresent() && isLinked(CHANNEL_PROGRAM_ENERGY)) + || (getThingChannel(CHANNEL_PROGRAM_WATER).isPresent() && isLinked(CHANNEL_PROGRAM_WATER)); + } + @Override protected void handleCommand(final ChannelUID channelUID, final Command command, final HomeConnectApiClient apiClient) @@ -143,6 +168,13 @@ public class HomeConnectWasherDryerHandler extends AbstractHomeConnectThingHandl if (offline) { getThingChannel(CHANNEL_WASHER_TEMPERATURE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); getThingChannel(CHANNEL_WASHER_SPIN_SPEED).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_WASHER_VARIO_PERFECT).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_WASHER_LESS_IRONING).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_WASHER_PRE_WASH).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_WASHER_RINSE_PLUS).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_WASHER_SOAK).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_PROGRAM_ENERGY).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_PROGRAM_WATER).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); getThingChannel(CHANNEL_DRYER_DRYING_TARGET).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); } } diff --git a/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/HomeConnectWasherHandler.java b/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/HomeConnectWasherHandler.java index beda8976f..4d62ede7d 100644 --- a/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/HomeConnectWasherHandler.java +++ b/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/HomeConnectWasherHandler.java @@ -67,10 +67,28 @@ public class HomeConnectWasherHandler extends AbstractHomeConnectThingHandler { getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); handlers.put(CHANNEL_WASHER_TEMPERATURE, getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_WASHER_IDOS1_LEVEL, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_WASHER_IDOS2_LEVEL, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); handlers.put(CHANNEL_WASHER_IDOS1, getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); handlers.put(CHANNEL_WASHER_IDOS2, getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_WASHER_VARIO_PERFECT, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_WASHER_LESS_IRONING, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_WASHER_PRE_WASH, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_WASHER_RINSE_PLUS, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_WASHER_SOAK, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_PROGRAM_ENERGY, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); + handlers.put(CHANNEL_PROGRAM_WATER, + getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler()); } @Override @@ -84,7 +102,7 @@ public class HomeConnectWasherHandler extends AbstractHomeConnectThingHandler { handlers.put(EVENT_REMAINING_PROGRAM_TIME, defaultRemainingProgramTimeEventHandler()); handlers.put(EVENT_PROGRAM_PROGRESS, defaultPercentQuantityTypeEventHandler(CHANNEL_PROGRAM_PROGRESS_STATE)); handlers.put(EVENT_LOCAL_CONTROL_ACTIVE, defaultBooleanEventHandler(CHANNEL_LOCAL_CONTROL_ACTIVE_STATE)); - handlers.put(EVENT_ACTIVE_PROGRAM, defaultActiveProgramEventHandler()); + handlers.put(EVENT_ACTIVE_PROGRAM, updateProgramOptionsAndActiveProgramStateEventHandler()); handlers.put(EVENT_OPERATION_STATE, defaultOperationStateEventHandler()); handlers.put(EVENT_SELECTED_PROGRAM, updateProgramOptionsAndSelectedProgramStateEventHandler()); @@ -96,13 +114,26 @@ public class HomeConnectWasherHandler extends AbstractHomeConnectThingHandler { event -> getThingChannel(CHANNEL_WASHER_SPIN_SPEED).ifPresent(channel -> updateState(channel.getUID(), event.getValue() == null ? UnDefType.UNDEF : new StringType(event.getValue())))); handlers.put(EVENT_WASHER_IDOS_1_DOSING_LEVEL, - event -> getThingChannel(CHANNEL_WASHER_IDOS1).ifPresent(channel -> updateState(channel.getUID(), + event -> getThingChannel(CHANNEL_WASHER_IDOS1_LEVEL).ifPresent(channel -> updateState(channel.getUID(), event.getValue() == null ? UnDefType.UNDEF : new StringType(event.getValue())))); handlers.put(EVENT_WASHER_IDOS_2_DOSING_LEVEL, - event -> getThingChannel(CHANNEL_WASHER_IDOS2).ifPresent(channel -> updateState(channel.getUID(), + event -> getThingChannel(CHANNEL_WASHER_IDOS2_LEVEL).ifPresent(channel -> updateState(channel.getUID(), event.getValue() == null ? UnDefType.UNDEF : new StringType(event.getValue())))); } + @Override + protected boolean isChannelLinkedToProgramOptionNotFullySupportedByApi() { + return (getThingChannel(CHANNEL_WASHER_IDOS1).isPresent() && isLinked(CHANNEL_WASHER_IDOS1)) + || (getThingChannel(CHANNEL_WASHER_IDOS2).isPresent() && isLinked(CHANNEL_WASHER_IDOS2)) + || (getThingChannel(CHANNEL_WASHER_VARIO_PERFECT).isPresent() && isLinked(CHANNEL_WASHER_VARIO_PERFECT)) + || (getThingChannel(CHANNEL_WASHER_LESS_IRONING).isPresent() && isLinked(CHANNEL_WASHER_LESS_IRONING)) + || (getThingChannel(CHANNEL_WASHER_PRE_WASH).isPresent() && isLinked(CHANNEL_WASHER_PRE_WASH)) + || (getThingChannel(CHANNEL_WASHER_RINSE_PLUS).isPresent() && isLinked(CHANNEL_WASHER_RINSE_PLUS)) + || (getThingChannel(CHANNEL_WASHER_SOAK).isPresent() && isLinked(CHANNEL_WASHER_SOAK)) + || (getThingChannel(CHANNEL_PROGRAM_ENERGY).isPresent() && isLinked(CHANNEL_PROGRAM_ENERGY)) + || (getThingChannel(CHANNEL_PROGRAM_WATER).isPresent() && isLinked(CHANNEL_PROGRAM_WATER)); + } + @Override protected void handleCommand(final ChannelUID channelUID, final Command command, final HomeConnectApiClient apiClient) @@ -121,11 +152,11 @@ public class HomeConnectWasherHandler extends AbstractHomeConnectThingHandler { apiClient.setProgramOptions(getThingHaId(), OPTION_WASHER_SPIN_SPEED, command.toFullString(), null, false, false); break; - case CHANNEL_WASHER_IDOS1: + case CHANNEL_WASHER_IDOS1_LEVEL: apiClient.setProgramOptions(getThingHaId(), OPTION_WASHER_IDOS_1_DOSING_LEVEL, command.toFullString(), null, false, false); break; - case CHANNEL_WASHER_IDOS2: + case CHANNEL_WASHER_IDOS2_LEVEL: apiClient.setProgramOptions(getThingHaId(), OPTION_WASHER_IDOS_2_DOSING_LEVEL, command.toFullString(), null, false, false); break; @@ -150,8 +181,17 @@ public class HomeConnectWasherHandler extends AbstractHomeConnectThingHandler { if (offline) { getThingChannel(CHANNEL_WASHER_TEMPERATURE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); getThingChannel(CHANNEL_WASHER_SPIN_SPEED).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_WASHER_IDOS1_LEVEL).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_WASHER_IDOS2_LEVEL).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); getThingChannel(CHANNEL_WASHER_IDOS1).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); getThingChannel(CHANNEL_WASHER_IDOS2).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_WASHER_VARIO_PERFECT).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_WASHER_LESS_IRONING).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_WASHER_PRE_WASH).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_WASHER_RINSE_PLUS).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_WASHER_SOAK).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_PROGRAM_ENERGY).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); + getThingChannel(CHANNEL_PROGRAM_WATER).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF)); } } } diff --git a/bundles/org.openhab.binding.homeconnect/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.homeconnect/src/main/resources/OH-INF/thing/thing-types.xml index 54c90e0a1..99ed635b4 100644 --- a/bundles/org.openhab.binding.homeconnect/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.homeconnect/src/main/resources/OH-INF/thing/thing-types.xml @@ -108,8 +108,17 @@ + + + + + + + + + @@ -140,6 +149,13 @@ + + + + + + + @@ -451,7 +467,7 @@ veto - + String This status defines the i-Dos dosing level of a washer program of the home appliance. (If appliance @@ -466,7 +482,7 @@ veto - + String This status defines the i-Dos dosing level of a washer program of the home appliance. (If appliance @@ -481,6 +497,74 @@ veto + + Switch + + This status indicates whether i-Dos 1 is activated for a washer program of the home appliance. (If + appliance supports i-Dos) + + + + Switch + + This status indicates whether i-Dos 2 is activated for a washer program of the home appliance. (If + appliance supports i-Dos) + + + + String + + This status defines the vario perfect mode of a washer program of the home appliance. + + + + + + + + + Switch + + This status indicates whether less ironing is activated for a washer program of the home appliance. + + + + Switch + + This status indicates whether the pre-wash is activated for a washer program of the home appliance. + + + + String + + This status defines the number of additional rinses of a washer program of the home appliance. + + + + + + + + + + + Switch + + This status indicates whether the soaking is activated for a washer program of the home appliance. + + + + Number:Dimensionless + + This channel provides the estimated energy required in percentage for a program of the home appliance. + + + + Number:Dimensionless + + This channel provides the estimated water required in percentage for a program of the home appliance. + + Number:Temperature