Skip to content
Merged
Show file tree
Hide file tree
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 @@ -46,11 +46,11 @@ protected AbstractMessageHandler(ESPHomeHandler handler) {
this.handler = handler;
}

protected ChannelType addChannelType(final String channelTypePrefix, final String label, final String itemType,
protected ChannelType addChannelType(final String channelTypeSuffix, final String label, final String itemType,
@Nullable final Set<String> tags, String category, EntityCategory entityCategory,
boolean disabledByDefault) {
final ChannelTypeUID channelTypeUID = new ChannelTypeUID(BindingConstants.BINDING_ID,
channelTypePrefix + handler.getThing().getUID().getId());
handler.getThing().getUID().getId() + "_" + channelTypeSuffix);

final StateChannelTypeBuilder channelTypeBuilder = ChannelTypeBuilder.state(channelTypeUID, label, itemType);
if (tags != null && !tags.isEmpty()) {
Expand Down Expand Up @@ -357,7 +357,7 @@ protected DeviceClass resolveDeviceClassAndSetInConfiguration(Configuration conf
}
if (configuration != null)
configuration.put("deviceClass", deviceClass.getDeviceClass());
return defaultDeviceClass;
return deviceClass;
}

protected Set<String> createSemanticTags(String point, DeviceClass deviceClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void buildChannels(ListEntitiesBinarySensorResponse rsp) {
tags.add("Status"); // default
}

ChannelType channelType = addChannelType(rsp.getUniqueId(), rsp.getName(), deviceClass.getItemType(), tags,
ChannelType channelType = addChannelType(rsp.getObjectId(), rsp.getName(), deviceClass.getItemType(), tags,
icon, rsp.getEntityCategory(), rsp.getDisabledByDefault());

Channel channel = ChannelBuilder.create(new ChannelUID(handler.getThing().getUID(), rsp.getObjectId()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void buildChannels(ListEntitiesButtonResponse rsp) {

String icon = getChannelIcon(rsp.getIcon(), "switch");

ChannelType channelType = addChannelType(rsp.getUniqueId(), rsp.getName(), SWITCH, Set.of("Switch"), icon,
ChannelType channelType = addChannelType(rsp.getObjectId(), rsp.getName(), SWITCH, Set.of("Switch"), icon,
rsp.getEntityCategory(), rsp.getDisabledByDefault());

Channel channel = ChannelBuilder.create(new ChannelUID(handler.getThing().getUID(), rsp.getObjectId()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void buildChannels(ListEntitiesClimateResponse rsp) {
addTargetTemperatureChannel(CHANNEL_TARGET_TEMPERATURE, "Target temperature", rsp);
}
if (rsp.getSupportsCurrentTemperature()) {
ChannelType channelType = addChannelType(rsp.getUniqueId() + CHANNEL_CURRENT_TEMPERATURE,
ChannelType channelType = addChannelType(rsp.getObjectId() + CHANNEL_CURRENT_TEMPERATURE,
"Current temperature", ITEM_TYPE_TEMPERATURE, Set.of(SEMANTIC_TYPE_MEASUREMENT, "Temperature"),
"temperature", rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = numericStateDescription("%.1f %unit%",
Expand All @@ -214,7 +214,7 @@ public void buildChannels(ListEntitiesClimateResponse rsp) {
super.registerChannel(channel, channelType, stateDescription);
}
if (rsp.getSupportsTargetHumidity()) {
ChannelType channelTypeTargetHumidity = addChannelType(rsp.getUniqueId() + CHANNEL_TARGET_HUMIDITY,
ChannelType channelTypeTargetHumidity = addChannelType(rsp.getObjectId() + CHANNEL_TARGET_HUMIDITY,
"Target humidity", ITEM_TYPE_NUMBER_DIMENSIONLESS, Set.of(SEMANTIC_TYPE_SETPOINT, "Humidity"),
"humidity", rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = numericStateDescription("%.0f %unit%", null,
Expand All @@ -229,7 +229,7 @@ public void buildChannels(ListEntitiesClimateResponse rsp) {
}

if (rsp.getSupportsCurrentHumidity()) {
ChannelType channelType = addChannelType(rsp.getUniqueId() + CHANNEL_CURRENT_HUMIDITY, "Current humidity",
ChannelType channelType = addChannelType(rsp.getObjectId() + CHANNEL_CURRENT_HUMIDITY, "Current humidity",
ITEM_TYPE_NUMBER_DIMENSIONLESS, Set.of(SEMANTIC_TYPE_MEASUREMENT, "Humidity"), "humidity",
rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = patternStateDescription("%.0f %unit%", true);
Expand All @@ -242,7 +242,7 @@ public void buildChannels(ListEntitiesClimateResponse rsp) {

String itemTypeString = "String";
if (rsp.getSupportedModesCount() > 0) {
ChannelType channelType = addChannelType(rsp.getUniqueId() + CHANNEL_MODE, "Mode", itemTypeString,
ChannelType channelType = addChannelType(rsp.getObjectId() + CHANNEL_MODE, "Mode", itemTypeString,
Set.of(SEMANTIC_TYPE_CONTROL), "climate", rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = optionListStateDescription(
rsp.getSupportedModesList().stream().map(ClimateEnumHelper::stripEnumPrefix).toList());
Expand All @@ -253,7 +253,7 @@ public void buildChannels(ListEntitiesClimateResponse rsp) {
super.registerChannel(channel, channelType, stateDescription);
}
if (rsp.getSupportsAction()) {
ChannelType channelType = addChannelType(rsp.getUniqueId() + CHANNEL_ACTION, "Action", itemTypeString,
ChannelType channelType = addChannelType(rsp.getObjectId() + CHANNEL_ACTION, "Action", itemTypeString,
Set.of(SEMANTIC_TYPE_STATUS), "climate", rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = optionListStateDescription(ACTIONS, true);
Channel channel = ChannelBuilder.create(createChannelUID(rsp.getObjectId(), CHANNEL_ACTION))
Expand All @@ -263,7 +263,7 @@ public void buildChannels(ListEntitiesClimateResponse rsp) {
super.registerChannel(channel, channelType, stateDescription);
}
if (rsp.getSupportedFanModesCount() > 0) {
ChannelType channelType = addChannelType(rsp.getUniqueId() + CHANNEL_FAN_MODE, "Fan Mode", itemTypeString,
ChannelType channelType = addChannelType(rsp.getObjectId() + CHANNEL_FAN_MODE, "Fan Mode", itemTypeString,
Set.of(SEMANTIC_TYPE_CONTROL, "Wind"), "fan", rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = optionListStateDescription(
rsp.getSupportedFanModesList().stream().map(ClimateEnumHelper::stripEnumPrefix).toList());
Expand All @@ -274,7 +274,7 @@ public void buildChannels(ListEntitiesClimateResponse rsp) {
super.registerChannel(channel, channelType, stateDescription);
}
if (rsp.getSupportedCustomFanModesCount() > 0) {
ChannelType channelType = addChannelType(rsp.getUniqueId() + CHANNEL_CUSTOM_FAN_MODE, "Custom Fan Mode",
ChannelType channelType = addChannelType(rsp.getObjectId() + CHANNEL_CUSTOM_FAN_MODE, "Custom Fan Mode",
itemTypeString, Set.of(SEMANTIC_TYPE_CONTROL, "Wind"), "fan", rsp.getEntityCategory(),
rsp.getDisabledByDefault());
StateDescription stateDescription = optionListStateDescription(rsp.getSupportedCustomFanModesList());
Expand All @@ -286,7 +286,7 @@ public void buildChannels(ListEntitiesClimateResponse rsp) {
super.registerChannel(channel, channelType, stateDescription);
}
if (rsp.getSupportedPresetsCount() > 0) {
ChannelType channelType = addChannelType(rsp.getUniqueId() + CHANNEL_PRESET, "Preset", itemTypeString,
ChannelType channelType = addChannelType(rsp.getObjectId() + CHANNEL_PRESET, "Preset", itemTypeString,
Set.of(SEMANTIC_TYPE_CONTROL), "climate", rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = optionListStateDescription(
rsp.getSupportedPresetsList().stream().map(ClimateEnumHelper::stripEnumPrefix).toList());
Expand All @@ -297,7 +297,7 @@ public void buildChannels(ListEntitiesClimateResponse rsp) {
super.registerChannel(channel, channelType, stateDescription);
}
if (rsp.getSupportedCustomPresetsCount() > 0) {
ChannelType channelType = addChannelType(rsp.getUniqueId() + CHANNEL_CUSTOM_PRESET, "Custom Preset",
ChannelType channelType = addChannelType(rsp.getObjectId() + CHANNEL_CUSTOM_PRESET, "Custom Preset",
itemTypeString, Set.of(SEMANTIC_TYPE_CONTROL), "climate", rsp.getEntityCategory(),
rsp.getDisabledByDefault());
StateDescription stateDescription = optionListStateDescription(rsp.getSupportedCustomPresetsList());
Expand All @@ -308,7 +308,7 @@ public void buildChannels(ListEntitiesClimateResponse rsp) {
super.registerChannel(channel, channelType, stateDescription);
}
if (rsp.getSupportedSwingModesCount() > 0) {
ChannelType channelType = addChannelType(rsp.getUniqueId() + CHANNEL_SWING_MODE, "Swing Mode",
ChannelType channelType = addChannelType(rsp.getObjectId() + CHANNEL_SWING_MODE, "Swing Mode",
itemTypeString, Set.of(SEMANTIC_TYPE_CONTROL, "Wind"), "fan", rsp.getEntityCategory(),
rsp.getDisabledByDefault());
StateDescription stateDescription = optionListStateDescription(
Expand All @@ -322,7 +322,7 @@ public void buildChannels(ListEntitiesClimateResponse rsp) {
}

private void addTargetTemperatureChannel(String channelID, String label, ListEntitiesClimateResponse rsp) {
ChannelType channelTypeTargetTemperature = addChannelType(rsp.getUniqueId() + channelID, label,
ChannelType channelTypeTargetTemperature = addChannelType(rsp.getObjectId() + channelID, label,
ITEM_TYPE_TEMPERATURE, Set.of(SEMANTIC_TYPE_SETPOINT, "Temperature"), "temperature",
rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = numericStateDescription("%.1f %unit%",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void buildChannels(ListEntitiesCoverResponse rsp) {
if (rsp.getSupportsPosition()) {
Set<String> semanticTags = createSemanticTags("OpenLevel", deviceClass);

ChannelType channelTypePosition = addChannelType(rsp.getUniqueId() + CHANNEL_POSITION, "Position",
ChannelType channelTypePosition = addChannelType(rsp.getObjectId() + CHANNEL_POSITION, "Position",
deviceClass.getItemType(), semanticTags, icon, rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = patternStateDescription("%d %%");

Expand All @@ -192,7 +192,7 @@ public void buildChannels(ListEntitiesCoverResponse rsp) {
if (rsp.getSupportsTilt()) {
Set<String> semanticTags = createSemanticTags("Tilt", deviceClass);

ChannelType channelTypeTilt = addChannelType(rsp.getUniqueId() + CHANNEL_TILT, "Tilt",
ChannelType channelTypeTilt = addChannelType(rsp.getObjectId() + CHANNEL_TILT, "Tilt",
deviceClass.getItemType(), semanticTags, icon, rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = patternStateDescription("%d %%");

Expand All @@ -205,7 +205,7 @@ public void buildChannels(ListEntitiesCoverResponse rsp) {

// Legacy state

ChannelType channelTypeState = addChannelType(rsp.getUniqueId() + LEGACY_CHANNEL_STATE, "Legacy State",
ChannelType channelTypeState = addChannelType(rsp.getObjectId() + LEGACY_CHANNEL_STATE, "Legacy State",
deviceClass.getItemType(), createSemanticTags("OpenClose", deviceClass), icon, rsp.getEntityCategory(),
rsp.getDisabledByDefault());
StateDescription stateDescription = patternStateDescription("%s");
Expand All @@ -217,7 +217,7 @@ public void buildChannels(ListEntitiesCoverResponse rsp) {
super.registerChannel(channelState, channelTypeState, stateDescription);

// Operation status
ChannelType channelTypeCurrentOperation = addChannelType(rsp.getUniqueId() + CHANNEL_CURRENT_OPERATION,
ChannelType channelTypeCurrentOperation = addChannelType(rsp.getObjectId() + CHANNEL_CURRENT_OPERATION,
"Current operation", STRING, createSemanticTags("Status", deviceClass), "motion",
rsp.getEntityCategory(), rsp.getDisabledByDefault());
stateDescription = optionListStateDescription(Set.of("IDLE", "IS_OPENING", "IS_CLOSING"), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void buildChannels(ListEntitiesDateResponse rsp) {

String icon = getChannelIcon(rsp.getIcon(), "time");

ChannelType channelType = addChannelType(rsp.getUniqueId(), rsp.getName(), DATETIME, Set.of("Control"), icon,
ChannelType channelType = addChannelType(rsp.getObjectId(), rsp.getName(), DATETIME, Set.of("Control"), icon,
rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = patternStateDescription("%1$tY-%1$tm-%1$td");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void buildChannels(ListEntitiesDateTimeResponse rsp) {

String icon = getChannelIcon(rsp.getIcon(), "time");

ChannelType channelType = addChannelType(rsp.getUniqueId(), rsp.getName(), DATETIME, Set.of("Control"), icon,
ChannelType channelType = addChannelType(rsp.getObjectId(), rsp.getName(), DATETIME, Set.of("Control"), icon,
rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = patternStateDescription("%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void buildChannels(ListEntitiesFanResponse rsp) {

String icon = getChannelIcon(rsp.getIcon(), "fan");

ChannelType channelTypeState = addChannelType(rsp.getUniqueId() + CHANNEL_STATE, "State", SWITCH,
ChannelType channelTypeState = addChannelType(rsp.getObjectId() + CHANNEL_STATE, "State", SWITCH,
Set.of("Switch"), icon, rsp.getEntityCategory(), rsp.getDisabledByDefault());

Channel channelState = ChannelBuilder.create(createChannelUID(rsp.getObjectId(), CHANNEL_STATE))
Expand All @@ -200,7 +200,7 @@ public void buildChannels(ListEntitiesFanResponse rsp) {
super.registerChannel(channelState, channelTypeState);

if (rsp.getSupportsOscillation()) {
ChannelType channelTypeOscillation = addChannelType(rsp.getUniqueId() + CHANNEL_OSCILLATION, "Oscillation",
ChannelType channelTypeOscillation = addChannelType(rsp.getObjectId() + CHANNEL_OSCILLATION, "Oscillation",
SWITCH, Set.of("Control"), icon, rsp.getEntityCategory(), rsp.getDisabledByDefault());

Channel channelOscillation = ChannelBuilder.create(createChannelUID(rsp.getObjectId(), CHANNEL_OSCILLATION))
Expand All @@ -212,7 +212,7 @@ public void buildChannels(ListEntitiesFanResponse rsp) {
}
if (rsp.getSupportsDirection()) {

ChannelType channelTypeDirection = addChannelType(rsp.getUniqueId() + CHANNEL_DIRECTION, "Direction",
ChannelType channelTypeDirection = addChannelType(rsp.getObjectId() + CHANNEL_DIRECTION, "Direction",
STRING, Set.of("Control"), "fan", rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = optionListStateDescription(
Arrays.stream(FanDirection.values()).filter(e -> e != FanDirection.UNRECOGNIZED)
Expand All @@ -230,7 +230,7 @@ public void buildChannels(ListEntitiesFanResponse rsp) {

int supportedSpeedLevels = rsp.getSupportedSpeedCount();

ChannelType channelTypeSpeed = addChannelType(rsp.getUniqueId() + CHANNEL_SPEED_LEVEL, "Speed", DIMMER,
ChannelType channelTypeSpeed = addChannelType(rsp.getObjectId() + CHANNEL_SPEED_LEVEL, "Speed", DIMMER,
Set.of("Setpoint", "Speed"), icon, rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = numericStateDescription(null,
BigDecimal.valueOf(100 / supportedSpeedLevels), BigDecimal.ZERO, BigDecimal.valueOf(100));
Expand All @@ -244,7 +244,7 @@ public void buildChannels(ListEntitiesFanResponse rsp) {
}

if (rsp.getSupportedPresetModesCount() > 0) {
ChannelType channelTypePreset = addChannelType(rsp.getUniqueId() + CHANNEL_PRESET, "Preset", STRING,
ChannelType channelTypePreset = addChannelType(rsp.getObjectId() + CHANNEL_PRESET, "Preset", STRING,
Set.of("Setpoint"), "fan", rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = optionListStateDescription(rsp.getSupportedPresetModesList());
Channel channelPreset = ChannelBuilder.create(createChannelUID(rsp.getObjectId(), CHANNEL_PRESET))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void buildChannels(ListEntitiesLightResponse rsp) {
Set<String> semanticTags = Set.of("Control", "Light");
if (capabilities.contains(LightColorCapability.RGB)) {
// Go for a single Color channel
ChannelType channelType = addChannelType(rsp.getUniqueId(), rsp.getName(), COLOR, semanticTags, icon,
ChannelType channelType = addChannelType(rsp.getObjectId(), rsp.getName(), COLOR, semanticTags, icon,
rsp.getEntityCategory(), rsp.getDisabledByDefault());

Channel channel = ChannelBuilder.create(new ChannelUID(handler.getThing().getUID(), rsp.getObjectId()))
Expand All @@ -122,7 +122,7 @@ public void buildChannels(ListEntitiesLightResponse rsp) {
super.registerChannel(channel, channelType);
} else if (capabilities.contains(LightColorCapability.BRIGHTNESS)) {
// Go for a single Dimmer channel
ChannelType channelType = addChannelType(rsp.getUniqueId(), rsp.getName(), DIMMER, semanticTags, icon,
ChannelType channelType = addChannelType(rsp.getObjectId(), rsp.getName(), DIMMER, semanticTags, icon,
rsp.getEntityCategory(), rsp.getDisabledByDefault());

Channel channel = ChannelBuilder.create(new ChannelUID(handler.getThing().getUID(), rsp.getObjectId()))
Expand All @@ -132,7 +132,7 @@ public void buildChannels(ListEntitiesLightResponse rsp) {
super.registerChannel(channel, channelType);
} else if (capabilities.contains(LightColorCapability.ON_OFF)) {
// Go for a single Switch channel
ChannelType channelType = addChannelType(rsp.getUniqueId(), rsp.getName(), SWITCH, semanticTags, icon,
ChannelType channelType = addChannelType(rsp.getObjectId(), rsp.getName(), SWITCH, semanticTags, icon,
rsp.getEntityCategory(), rsp.getDisabledByDefault());

Channel channel = ChannelBuilder.create(new ChannelUID(handler.getThing().getUID(), rsp.getObjectId()))
Expand All @@ -144,7 +144,7 @@ public void buildChannels(ListEntitiesLightResponse rsp) {

if (rsp.getEffectsCount() > 0) {
// Create effects channel
ChannelType channelType = addChannelType(rsp.getUniqueId() + "-effects", rsp.getName(), STRING,
ChannelType channelType = addChannelType(rsp.getObjectId() + "-effects", rsp.getName(), STRING,
semanticTags, icon, rsp.getEntityCategory(), rsp.getDisabledByDefault());
StateDescription stateDescription = optionListStateDescription(rsp.getEffectsList());

Expand Down
Loading