try {
String programKey = event.getValue();
if (programKey != null) {
- updateProgramOptionsStateDescriptions(programKey);
+ updateProgramOptionsStateDescriptions(programKey, null);
}
} catch (CommunicationException | ApplianceOfflineException | AuthorizationException e) {
logger.debug("Could not update program options. {}", e.getMessage());
Program program = apiClient.get().getSelectedProgram(getThingHaId());
if (program != null) {
- updateProgramOptionsStateDescriptions(program.getKey());
+ updateProgramOptionsStateDescriptions(program.getKey(), program.getOptions());
processProgramOptions(program.getOptions());
return new StringType(program.getKey());
return mapStringType(value);
}
- protected void updateProgramOptionsStateDescriptions(String programKey)
+ protected void updateProgramOptionsStateDescriptions(String programKey, @Nullable List<Option> optionsValues)
throws CommunicationException, AuthorizationException, ApplianceOfflineException {
Optional<HomeConnectApiClient> apiClient = getApiClient();
if (apiClient.isPresent()) {
Optional<Channel> channelDryingTarget = getThingChannel(CHANNEL_DRYER_DRYING_TARGET);
if (availableProgramOptions.isEmpty()) {
- channelSpinSpeed.ifPresent(
- channel -> dynamicStateDescriptionProvider.setStateOptions(channel.getUID(), emptyList()));
- channelTemperature.ifPresent(
- channel -> dynamicStateDescriptionProvider.setStateOptions(channel.getUID(), emptyList()));
- channelDryingTarget.ifPresent(
- channel -> dynamicStateDescriptionProvider.setStateOptions(channel.getUID(), emptyList()));
+ List<Option> options;
+ if (optionsValues != null) {
+ options = optionsValues;
+ } else if (channelSpinSpeed.isPresent() || channelTemperature.isPresent()
+ || channelDryingTarget.isPresent()) {
+ Program program = apiClient.get().getSelectedProgram(getThingHaId());
+ options = program != null ? program.getOptions() : emptyList();
+ } else {
+ options = emptyList();
+ }
+
+ channelSpinSpeed.ifPresent(channel -> dynamicStateDescriptionProvider.setStateOptions(channel.getUID(),
+ options.stream()
+ .filter(option -> option.getKey() != null && option.getValue() != null
+ && OPTION_WASHER_SPIN_SPEED.equals(option.getKey()))
+ .map(option -> option.getValue())
+ .map(value -> new StateOption(value == null ? "" : value,
+ convertWasherSpinSpeed(value == null ? "" : value)))
+ .collect(Collectors.toList())));
+ channelTemperature
+ .ifPresent(channel -> dynamicStateDescriptionProvider.setStateOptions(channel.getUID(),
+ options.stream()
+ .filter(option -> option.getKey() != null && option.getValue() != null
+ && OPTION_WASHER_TEMPERATURE.equals(option.getKey()))
+ .map(option -> option.getValue())
+ .map(value -> new StateOption(value == null ? "" : value,
+ convertWasherTemperature(value == null ? "" : value)))
+ .collect(Collectors.toList())));
+ channelDryingTarget
+ .ifPresent(channel -> dynamicStateDescriptionProvider.setStateOptions(channel.getUID(),
+ options.stream()
+ .filter(option -> option.getKey() != null && option.getValue() != null
+ && OPTION_DRYER_DRYING_TARGET.equals(option.getKey()))
+ .map(option -> option.getValue())
+ .map(value -> new StateOption(value == null ? "" : value,
+ mapStringType(value == null ? "" : value)))
+ .collect(Collectors.toList())));
}
availableProgramOptions.forEach(option -> {