mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[mqtt.homie] populate unit hint on dynamic channels (#17649)
Signed-off-by: Cody Cutrer <cody@cutrer.us> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
29cca2cdac
commit
993a21c3b1
@ -267,7 +267,8 @@ public class Property implements AttributeChanged {
|
||||
if (attributes.datatype.equals(DataTypeEnum.unknown)) {
|
||||
channelTypeId = MqttBindingConstants.CHANNEL_TYPE_HOMIE_STRING;
|
||||
} else if (dimension != null) {
|
||||
channelTypeId = MqttBindingConstants.CHANNEL_TYPE_HOMIE_PREFIX + "number-" + dimension.toLowerCase();
|
||||
channelTypeId = MqttBindingConstants.CHANNEL_TYPE_HOMIE_PREFIX + "number-"
|
||||
+ UIDUtils.encode(unit.toString().toLowerCase());
|
||||
channelProperties.put(MqttBindingConstants.CHANNEL_PROPERTY_DATATYPE, attributes.datatype.toString());
|
||||
} else {
|
||||
channelTypeId = MqttBindingConstants.CHANNEL_TYPE_HOMIE_PREFIX + attributes.datatype.toString();
|
||||
@ -275,8 +276,9 @@ public class Property implements AttributeChanged {
|
||||
}
|
||||
this.channelTypeUID = new ChannelTypeUID(MqttBindingConstants.BINDING_ID, channelTypeId);
|
||||
if (dimension != null) {
|
||||
this.channelType = ChannelTypeBuilder.state(channelTypeUID, dimension + " Value", "Number:" + dimension)
|
||||
.build();
|
||||
this.channelType = ChannelTypeBuilder
|
||||
.state(channelTypeUID, dimension + " Value (" + unit.toString() + ")", "Number:" + dimension)
|
||||
.withUnitHint(unit.toString()).build();
|
||||
}
|
||||
|
||||
if (attributes.retained) {
|
||||
|
Loading…
Reference in New Issue
Block a user