Skip to content

Commit

Permalink
fix channelGroupTypeUUID for multiple device types
Browse files Browse the repository at this point in the history
Signed-off-by: Laurent ARNAL <[email protected]>
  • Loading branch information
lo92fr committed Dec 6, 2024
1 parent db9ee7d commit 69846ee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,18 @@ public void startScan() {
if (components == null || !components.isJsonArray()) {
return;
}
if (label.indexOf("Bureau") < 0) {
continue;

Boolean enabled = false;
if (label.equals("Four")) {
enabled = true;
}
if (label.equals("Petrole")) {
enabled = true;
}

//if (!enabled) {
// continue;
//}

JsonArray componentsArray = (JsonArray) components;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,11 @@ private String readTemplate(String templateName) throws IOException {

@Override
public void Register(SmartthingsDeviceData deviceData, JsonObject devObj) {
generateThingsType(deviceData.id, deviceData.deviceType, deviceData.description, devObj);
generateThingsType(deviceData.id, deviceData.label, deviceData.deviceType, deviceData.description, devObj);

}

private void generateThingsType(String deviceLabel, String deviceType, String deviceDescription,
private void generateThingsType(String deviceId, String deviceLabel, String deviceType, String deviceDescription,
JsonObject devObj) {

SmartthingsThingTypeProvider lcThingTypeProvider = thingTypeProvider;
Expand Down Expand Up @@ -371,22 +371,22 @@ private void generateThingsType(String deviceLabel, String deviceType, String de

SmartthingsJSonCapabilities capa = capabilitiesDict.get(capId);

addChannel(groupTypes, channelDefinitions, capId + "channel", capId);
addChannel(deviceType, groupTypes, channelDefinitions, capId + "channel", capId);

logger.info("");
}
}

}

tt = createThingType(deviceType, deviceLabel, deviceDescription, groupTypes);
tt = createThingType(deviceType, deviceId, deviceDescription, groupTypes);
lcThingTypeProvider.addThingType(tt);
}
}
}

private void addChannel(List<ChannelGroupType> groupTypes, List<ChannelDefinition> channelDefinitions,
String channelTp, String channel) {
private void addChannel(String deviceType, List<ChannelGroupType> groupTypes,
List<ChannelDefinition> channelDefinitions, String channelTp, String channel) {
SmartthingsChannelTypeProvider lcChannelTypeProvider = channelTypeProvider;
SmartthingsChannelGroupTypeProvider lcChannelGroupTypeProvider = channelGroupTypeProvider;

Expand All @@ -409,16 +409,18 @@ private void addChannel(List<ChannelGroupType> groupTypes, List<ChannelDefinitio
}

// generate group
ChannelGroupTypeUID groupTypeUID = UidUtils.generateChannelGroupTypeUID("default");
String groupdId = deviceType + "_default";
ChannelGroupTypeUID groupTypeUID = UidUtils.generateChannelGroupTypeUID(groupdId);
ChannelGroupType groupType = null;

if (lcChannelGroupTypeProvider != null) {
groupType = lcChannelGroupTypeProvider.getInternalChannelGroupType(groupTypeUID);

if (groupType == null) {
String groupLabel = "default";
String groupLabel = groupdId + "Label";
groupType = ChannelGroupTypeBuilder.instance(groupTypeUID, groupLabel)
.withChannelDefinitions(channelDefinitions).withCategory("").withDescription("default").build();
.withChannelDefinitions(channelDefinitions).withCategory("").withDescription(groupdId + "Desc")
.build();
lcChannelGroupTypeProvider.addChannelGroupType(groupType);
groupTypes.add(groupType);
}
Expand Down

0 comments on commit 69846ee

Please sign in to comment.