[sensibo] Fix tags for target temperature channel types built (#12750)

dynamically

Related to #12262

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2022-05-16 18:29:29 +02:00 committed by GitHub
parent d7f8fe6411
commit 2fb662dab7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,6 +23,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.measure.IncommensurableException;
@ -366,7 +367,8 @@ public class SensiboSkyHandler extends SensiboBaseThingHandler implements Channe
final ChannelTypeUID targetTemperatureChannelType = addChannelType(
SensiboBindingConstants.CHANNEL_TYPE_TARGET_TEMPERATURE, TARGET_TEMPERATURE_LABEL,
ITEM_TYPE_NUMBER_TEMPERATURE, sensiboSky.getTargetTemperatures(), "%d %unit%", "TargetTemperature");
ITEM_TYPE_NUMBER_TEMPERATURE, sensiboSky.getTargetTemperatures(), "%d %unit%",
Set.of("Setpoint", "Temperature"));
newChannels.add(ChannelBuilder
.create(new ChannelUID(getThing().getUID(), SensiboBindingConstants.CHANNEL_TARGET_TEMPERATURE),
ITEM_TYPE_NUMBER_TEMPERATURE)
@ -376,7 +378,7 @@ public class SensiboSkyHandler extends SensiboBaseThingHandler implements Channe
}
private ChannelTypeUID addChannelType(final String channelTypePrefix, final String label, final String itemType,
final Collection<?> options, @Nullable final String pattern, @Nullable final String tag) {
final Collection<?> options, @Nullable final String pattern, @Nullable final Set<String> tags) {
final ChannelTypeUID channelTypeUID = new ChannelTypeUID(SensiboBindingConstants.BINDING_ID,
channelTypePrefix + getThing().getUID().getId());
final List<StateOption> stateOptions = options.stream()
@ -390,8 +392,8 @@ public class SensiboSkyHandler extends SensiboBaseThingHandler implements Channe
}
final StateChannelTypeBuilder builder = ChannelTypeBuilder.state(channelTypeUID, label, itemType)
.withStateDescriptionFragment(stateDescription.build());
if (tag != null) {
builder.withTag(tag);
if (tags != null && !tags.isEmpty()) {
builder.withTags(tags);
}
final ChannelType channelType = builder.build();