[intesis] Fix channel state options not set when channel exists (#8963)

Signed-off-by: Hans-Jörg Merk <github@hmerk.de>
This commit is contained in:
Hans-Jörg Merk 2020-11-05 20:58:41 +01:00 committed by GitHub
parent ffc48e498d
commit 39cb4fcaa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 17 deletions

View File

@ -347,16 +347,14 @@ public class IntesisBoxHandler extends BaseThingHandler implements IntesisBoxCha
.withType(channelTypeUID).withKind(ChannelKind.STATE).build();
thingBuilder.withChannel(channel);
updateThing(thingBuilder.build());
if (limits.containsKey(channelId)) {
List<StateOption> options = new ArrayList<>();
for (String mode : limits.get(channelId)) {
options.add(new StateOption(mode,
mode.substring(0, 1).toUpperCase() + mode.substring(1).toLowerCase()));
}
intesisStateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), channelId),
options);
}
if (limits.containsKey(channelId)) {
List<StateOption> options = new ArrayList<>();
for (String mode : limits.get(channelId)) {
options.add(
new StateOption(mode, mode.substring(0, 1).toUpperCase() + mode.substring(1).toLowerCase()));
}
intesisStateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), channelId), options);
}
}

View File

@ -262,14 +262,14 @@ public class IntesisHomeHandler extends BaseThingHandler {
.withType(channelTypeUID).withKind(ChannelKind.STATE).build();
thingBuilder.withChannel(channel);
updateThing(thingBuilder.build());
if (options != null) {
final List<StateOption> stateOptions = options.stream()
.map(e -> new StateOption(e, e.substring(0, 1) + e.substring(1).toLowerCase()))
.collect(Collectors.toList());
logger.trace("StateOptions : '{}'", stateOptions);
intesisStateDescriptionProvider.setStateOptions(channel.getUID(), stateOptions);
}
}
if (options != null) {
final List<StateOption> stateOptions = options.stream()
.map(e -> new StateOption(e, e.substring(0, 1) + e.substring(1).toLowerCase()))
.collect(Collectors.toList());
logger.trace("StateOptions : '{}'", stateOptions);
intesisStateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), channelId),
stateOptions);
}
}