Skip to content

Commit

Permalink
[sensibo] Fix tags for target temperature channel types built (openha…
Browse files Browse the repository at this point in the history
…b#12750)

dynamically

Related to openhab#12262

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
  • Loading branch information
lolodomo authored and andrasU committed Nov 12, 2022
1 parent aab88e9 commit 01b7b9a
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -366,7 +367,8 @@ public List<Channel> 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)
Expand All @@ -376,7 +378,7 @@ public List<Channel> 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<String> tags) {
final ChannelTypeUID channelTypeUID = new ChannelTypeUID(SensiboBindingConstants.BINDING_ID,
channelTypePrefix + getThing().getUID().getId());
final List<StateOption> stateOptions = options.stream()
Expand All @@ -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();

Expand Down

0 comments on commit 01b7b9a

Please sign in to comment.