From df46a484a79d396b6e55c0fdd6b41579d9b1eaaa Mon Sep 17 00:00:00 2001 From: Laurent Garnier Date: Mon, 16 May 2022 17:57:13 +0200 Subject: [PATCH] [sensibo] Fix tags for target temperature channel types built dynamically Related to #12262 Signed-off-by: Laurent Garnier --- .../sensibo/internal/handler/SensiboSkyHandler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.sensibo/src/main/java/org/openhab/binding/sensibo/internal/handler/SensiboSkyHandler.java b/bundles/org.openhab.binding.sensibo/src/main/java/org/openhab/binding/sensibo/internal/handler/SensiboSkyHandler.java index 17dc7291908a0..70d06fe9f2f4e 100644 --- a/bundles/org.openhab.binding.sensibo/src/main/java/org/openhab/binding/sensibo/internal/handler/SensiboSkyHandler.java +++ b/bundles/org.openhab.binding.sensibo/src/main/java/org/openhab/binding/sensibo/internal/handler/SensiboSkyHandler.java @@ -23,6 +23,7 @@ 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 List createDynamicChannels(final SensiboSky sensiboSky) { 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 List createDynamicChannels(final SensiboSky sensiboSky) { } 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 tags) { final ChannelTypeUID channelTypeUID = new ChannelTypeUID(SensiboBindingConstants.BINDING_ID, channelTypePrefix + getThing().getUID().getId()); final List stateOptions = options.stream() @@ -390,8 +392,8 @@ private ChannelTypeUID addChannelType(final String channelTypePrefix, final Stri } 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();