Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sensibo] Fix semantic tags for target temperature channel #12750

Merged
merged 1 commit into from
May 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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