mirror of
https://github.com/danieldemus/openhab-addons
synced 2026-07-29 12:34:21 +02:00
[tuya] Get channel labels from schema label or map from schema code (#18654)
Signed-off-by: Mike Jagdis <mjagdis@eris-associates.co.uk>
This commit is contained in:
+1
@@ -36,6 +36,7 @@ public class DeviceSchema {
|
||||
public static class Description {
|
||||
public String code = "";
|
||||
public int dp_id = 0;
|
||||
public String label = "";
|
||||
public String type = "";
|
||||
public String values = "";
|
||||
|
||||
|
||||
+15
-2
@@ -70,6 +70,7 @@ import org.openhab.core.types.CommandOption;
|
||||
import org.openhab.core.types.RefreshType;
|
||||
import org.openhab.core.types.State;
|
||||
import org.openhab.core.types.UnDefType;
|
||||
import org.openhab.core.util.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -507,8 +508,20 @@ public class TuyaDeviceHandler extends BaseThingHandler implements DeviceInfoSub
|
||||
return Map.entry("", ChannelBuilder.create(channelUID).build());
|
||||
}
|
||||
|
||||
return Map.entry(channelId, callback.createChannelBuilder(channelUID, channeltypeUID).withLabel(channelId)
|
||||
.withConfiguration(new Configuration(configuration)).build());
|
||||
if (schemaDp.label.isEmpty()) {
|
||||
schemaDp.label = schemaDp.code;
|
||||
|
||||
String label = StringUtils.capitalizeByWhitespace(schemaDp.code.replaceAll("_", " "));
|
||||
if (label != null) {
|
||||
label = label.trim();
|
||||
if (!label.isEmpty()) {
|
||||
schemaDp.label = label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Map.entry(channelId, callback.createChannelBuilder(channelUID, channeltypeUID)
|
||||
.withLabel(schemaDp.label).withConfiguration(new Configuration(configuration)).build());
|
||||
}).filter(c -> !c.getKey().isEmpty()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
|
||||
|
||||
List<String> channelSuffixes = List.of("", "_1", "_2");
|
||||
|
||||
+1
@@ -39,6 +39,7 @@ public class SchemaDp {
|
||||
public int id = 0;
|
||||
public String code = "";
|
||||
public String type = "";
|
||||
public String label = "";
|
||||
public @Nullable Double min;
|
||||
public @Nullable Double max;
|
||||
public @Nullable List<String> range;
|
||||
|
||||
Reference in New Issue
Block a user