[homeconnect] Undo PR 10754 (#10792)

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2021-06-05 20:08:51 +02:00 committed by GitHub
parent d454fe3331
commit 33b7fd6e98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 41 deletions

View File

@ -868,7 +868,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
String programKey = programOptionsDelayedUpdate;
if (programKey != null && Boolean.parseBoolean(event.getValue())) {
logger.debug("Delayed update of options for program {}", programKey);
updateProgramOptionsStateDescriptions(programKey, null);
updateProgramOptionsStateDescriptions(programKey);
programOptionsDelayedUpdate = null;
}
} catch (CommunicationException | ApplianceOfflineException | AuthorizationException e) {
@ -892,7 +892,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
logger.debug("Delay update of options for program {}", programKey);
programOptionsDelayedUpdate = programKey;
} else {
updateProgramOptionsStateDescriptions(programKey, null);
updateProgramOptionsStateDescriptions(programKey);
}
}
} catch (CommunicationException | ApplianceOfflineException | AuthorizationException e) {
@ -1061,7 +1061,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
Program program = apiClient.get().getSelectedProgram(getThingHaId());
if (program != null) {
updateProgramOptionsStateDescriptions(program.getKey(), program.getOptions());
updateProgramOptionsStateDescriptions(program.getKey());
processProgramOptions(program.getOptions());
return new StringType(program.getKey());
@ -1367,7 +1367,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
return mapStringType(value);
}
protected void updateProgramOptionsStateDescriptions(String programKey, @Nullable List<Option> optionsValues)
protected void updateProgramOptionsStateDescriptions(String programKey)
throws CommunicationException, AuthorizationException, ApplianceOfflineException {
Optional<HomeConnectApiClient> apiClient = getApiClient();
if (apiClient.isPresent()) {
@ -1387,43 +1387,12 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
Optional<Channel> channelDryingTarget = getThingChannel(CHANNEL_DRYER_DRYING_TARGET);
if (availableProgramOptions.isEmpty()) {
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())));
channelSpinSpeed.ifPresent(
channel -> dynamicStateDescriptionProvider.setStateOptions(channel.getUID(), emptyList()));
channelTemperature.ifPresent(
channel -> dynamicStateDescriptionProvider.setStateOptions(channel.getUID(), emptyList()));
channelDryingTarget.ifPresent(
channel -> dynamicStateDescriptionProvider.setStateOptions(channel.getUID(), emptyList()));
}
availableProgramOptions.forEach(option -> {