Skip to content

Commit 62c795a

Browse files
authored
Generate PowerTopology cluster with Alchemy (project-chip#41388)
1 parent 1de1c67 commit 62c795a

45 files changed

Lines changed: 1358 additions & 24 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/all-clusters-app/realtek/data_model/all-clusters-app.matter

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5106,10 +5106,19 @@ cluster PowerTopology = 156 {
51065106
kTreeTopology = 0x2;
51075107
kSetTopology = 0x4;
51085108
kDynamicPowerFlow = 0x8;
5109+
kElectricalCircuit = 0x10;
5110+
}
5111+
5112+
fabric_scoped struct CircuitNodeStruct {
5113+
node_id node = 1;
5114+
optional endpoint_no endpoint = 2;
5115+
optional char_string<128> label = 3;
5116+
fabric_idx fabricIndex = 254;
51095117
}
51105118

51115119
readonly attribute optional endpoint_no availableEndpoints[] = 0;
51125120
readonly attribute optional endpoint_no activeEndpoints[] = 1;
5121+
attribute optional CircuitNodeStruct electricalCircuitNodes[] = 2;
51135122
readonly attribute command_id generatedCommandList[] = 65528;
51145123
readonly attribute command_id acceptedCommandList[] = 65529;
51155124
readonly attribute attrib_id attributeList[] = 65531;

examples/chef/devices/rootnode_heatpump_87ivjRAECh.matter

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,10 +2066,19 @@ cluster PowerTopology = 156 {
20662066
kTreeTopology = 0x2;
20672067
kSetTopology = 0x4;
20682068
kDynamicPowerFlow = 0x8;
2069+
kElectricalCircuit = 0x10;
2070+
}
2071+
2072+
fabric_scoped struct CircuitNodeStruct {
2073+
node_id node = 1;
2074+
optional endpoint_no endpoint = 2;
2075+
optional char_string<128> label = 3;
2076+
fabric_idx fabricIndex = 254;
20692077
}
20702078

20712079
readonly attribute optional endpoint_no availableEndpoints[] = 0;
20722080
readonly attribute optional endpoint_no activeEndpoints[] = 1;
2081+
attribute optional CircuitNodeStruct electricalCircuitNodes[] = 2;
20732082
readonly attribute command_id generatedCommandList[] = 65528;
20742083
readonly attribute command_id acceptedCommandList[] = 65529;
20752084
readonly attribute attrib_id attributeList[] = 65531;

examples/dishwasher-app/silabs/data_model/dishwasher-thread-app.matter

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,10 +2307,19 @@ cluster PowerTopology = 156 {
23072307
kTreeTopology = 0x2;
23082308
kSetTopology = 0x4;
23092309
kDynamicPowerFlow = 0x8;
2310+
kElectricalCircuit = 0x10;
2311+
}
2312+
2313+
fabric_scoped struct CircuitNodeStruct {
2314+
node_id node = 1;
2315+
optional endpoint_no endpoint = 2;
2316+
optional char_string<128> label = 3;
2317+
fabric_idx fabricIndex = 254;
23102318
}
23112319

23122320
readonly attribute optional endpoint_no availableEndpoints[] = 0;
23132321
readonly attribute optional endpoint_no activeEndpoints[] = 1;
2322+
attribute optional CircuitNodeStruct electricalCircuitNodes[] = 2;
23142323
readonly attribute command_id generatedCommandList[] = 65528;
23152324
readonly attribute command_id acceptedCommandList[] = 65529;
23162325
readonly attribute attrib_id attributeList[] = 65531;

examples/dishwasher-app/silabs/data_model/dishwasher-wifi-app.matter

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,10 +2216,19 @@ cluster PowerTopology = 156 {
22162216
kTreeTopology = 0x2;
22172217
kSetTopology = 0x4;
22182218
kDynamicPowerFlow = 0x8;
2219+
kElectricalCircuit = 0x10;
2220+
}
2221+
2222+
fabric_scoped struct CircuitNodeStruct {
2223+
node_id node = 1;
2224+
optional endpoint_no endpoint = 2;
2225+
optional char_string<128> label = 3;
2226+
fabric_idx fabricIndex = 254;
22192227
}
22202228

22212229
readonly attribute optional endpoint_no availableEndpoints[] = 0;
22222230
readonly attribute optional endpoint_no activeEndpoints[] = 1;
2231+
attribute optional CircuitNodeStruct electricalCircuitNodes[] = 2;
22232232
readonly attribute command_id generatedCommandList[] = 65528;
22242233
readonly attribute command_id acceptedCommandList[] = 65529;
22252234
readonly attribute attrib_id attributeList[] = 65531;

examples/energy-management-app/energy-management-common/energy-management-app.matter

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,10 +2454,19 @@ cluster PowerTopology = 156 {
24542454
kTreeTopology = 0x2;
24552455
kSetTopology = 0x4;
24562456
kDynamicPowerFlow = 0x8;
2457+
kElectricalCircuit = 0x10;
2458+
}
2459+
2460+
fabric_scoped struct CircuitNodeStruct {
2461+
node_id node = 1;
2462+
optional endpoint_no endpoint = 2;
2463+
optional char_string<128> label = 3;
2464+
fabric_idx fabricIndex = 254;
24572465
}
24582466

24592467
readonly attribute optional endpoint_no availableEndpoints[] = 0;
24602468
readonly attribute optional endpoint_no activeEndpoints[] = 1;
2469+
attribute optional CircuitNodeStruct electricalCircuitNodes[] = 2;
24612470
readonly attribute command_id generatedCommandList[] = 65528;
24622471
readonly attribute command_id acceptedCommandList[] = 65529;
24632472
readonly attribute attrib_id attributeList[] = 65531;

src/app/zap-templates/zcl/data-model/chip/power-topology-cluster.xml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<!--
3-
Copyright (c) 2024 Project CHIP Authors
3+
Copyright (c) 2024-2025 Project CHIP Authors
44
55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
@@ -14,8 +14,21 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17-
<configurator>
17+
<!--
18+
XML generated by Alchemy; DO NOT EDIT.
19+
Source: src/app_clusters/PowerTopology.adoc
20+
Parameters: zap attribute=in-progress ignore-errored provisional-policy=loose sdkRoot=./connectedhomeip/ specRoot=./connectedhomeip-spec/ ./connectedhomeip-spec/src/app_clusters/PowerTopology.adoc
21+
Git: 0.9-fall2025-ncr-54-ge55408848
22+
Alchemy: v1.5.55
23+
-->
24+
<configurator xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../zcl.xsd">
1825
<domain name="Measurement &amp; Sensing"/>
26+
<struct name="CircuitNodeStruct" isFabricScoped="true">
27+
<cluster code="0x009C"/>
28+
<item fieldId="1" name="Node" type="node_id" apiMaturity="provisional"/>
29+
<item fieldId="2" name="Endpoint" type="endpoint_no" optional="true" apiMaturity="provisional"/>
30+
<item fieldId="3" name="Label" type="char_string" optional="true" length="128" apiMaturity="provisional"/>
31+
</struct>
1932

2033
<cluster code="0x009C">
2134
<domain>Measurement &amp; Sensing</domain>
@@ -26,7 +39,6 @@ limitations under the License.
2639
<client init="false" tick="false">true</client>
2740
<server init="false" tick="false">true</server>
2841
<globalAttribute code="0xFFFD" side="either" value="1"/>
29-
3042
<features>
3143
<feature bit="0" code="NODE" name="NodeTopology" summary="This endpoint provides or consumes power to/from the entire node">
3244
<optionalConform choice="a"/>
@@ -42,8 +54,10 @@ limitations under the License.
4254
<feature name="SET"/>
4355
</optionalConform>
4456
</feature>
57+
<feature bit="4" code="CIRC" name="ElectricalCircuit" summary="This endpoint provides information about downstream nodes on its circuit">
58+
<optionalConform/>
59+
</feature>
4560
</features>
46-
4761
<attribute code="0x0000" side="server" name="AvailableEndpoints" define="AVAILABLE_ENDPOINTS" type="array" entryType="endpoint_no" length="20" optional="true">
4862
<mandatoryConform>
4963
<feature name="SET"/>
@@ -54,5 +68,10 @@ limitations under the License.
5468
<feature name="DYPF"/>
5569
</mandatoryConform>
5670
</attribute>
71+
<attribute code="0x0002" side="server" name="ElectricalCircuitNodes" define="ELECTRICAL_CIRCUIT_NODES" type="array" entryType="CircuitNodeStruct" length="50" writable="true" optional="true">
72+
<mandatoryConform>
73+
<feature name="CIRC"/>
74+
</mandatoryConform>
75+
</attribute>
5776
</cluster>
5877
</configurator>

src/controller/data_model/controller-clusters.matter

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5496,10 +5496,19 @@ cluster PowerTopology = 156 {
54965496
kTreeTopology = 0x2;
54975497
kSetTopology = 0x4;
54985498
kDynamicPowerFlow = 0x8;
5499+
kElectricalCircuit = 0x10;
5500+
}
5501+
5502+
fabric_scoped struct CircuitNodeStruct {
5503+
node_id node = 1;
5504+
optional endpoint_no endpoint = 2;
5505+
optional char_string<128> label = 3;
5506+
fabric_idx fabricIndex = 254;
54995507
}
55005508

55015509
readonly attribute optional endpoint_no availableEndpoints[] = 0;
55025510
readonly attribute optional endpoint_no activeEndpoints[] = 1;
5511+
attribute optional CircuitNodeStruct electricalCircuitNodes[] = 2;
55035512
readonly attribute command_id generatedCommandList[] = 65528;
55045513
readonly attribute command_id acceptedCommandList[] = 65529;
55055514
readonly attribute attrib_id attributeList[] = 65531;

src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31023,6 +31023,7 @@ public static class PowerTopologyCluster extends BaseChipCluster {
3102331023

3102431024
private static final long AVAILABLE_ENDPOINTS_ATTRIBUTE_ID = 0L;
3102531025
private static final long ACTIVE_ENDPOINTS_ATTRIBUTE_ID = 1L;
31026+
private static final long ELECTRICAL_CIRCUIT_NODES_ATTRIBUTE_ID = 2L;
3102631027
private static final long GENERATED_COMMAND_LIST_ATTRIBUTE_ID = 65528L;
3102731028
private static final long ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID = 65529L;
3102831029
private static final long ATTRIBUTE_LIST_ATTRIBUTE_ID = 65531L;
@@ -31047,6 +31048,10 @@ public interface ActiveEndpointsAttributeCallback extends BaseAttributeCallback
3104731048
void onSuccess(List<Integer> value);
3104831049
}
3104931050

31051+
public interface ElectricalCircuitNodesAttributeCallback extends BaseAttributeCallback {
31052+
void onSuccess(List<ChipStructs.PowerTopologyClusterCircuitNodeStruct> value);
31053+
}
31054+
3105031055
public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback {
3105131056
void onSuccess(List<Long> value);
3105231057
}
@@ -31111,6 +31116,46 @@ public void onSuccess(byte[] tlv) {
3111131116
}, ACTIVE_ENDPOINTS_ATTRIBUTE_ID, minInterval, maxInterval);
3111231117
}
3111331118

31119+
public void readElectricalCircuitNodesAttribute(
31120+
ElectricalCircuitNodesAttributeCallback callback) {
31121+
readElectricalCircuitNodesAttributeWithFabricFilter(callback, true);
31122+
}
31123+
31124+
public void readElectricalCircuitNodesAttributeWithFabricFilter(
31125+
ElectricalCircuitNodesAttributeCallback callback, boolean isFabricFiltered) {
31126+
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ELECTRICAL_CIRCUIT_NODES_ATTRIBUTE_ID);
31127+
31128+
readAttribute(new ReportCallbackImpl(callback, path) {
31129+
@Override
31130+
public void onSuccess(byte[] tlv) {
31131+
List<ChipStructs.PowerTopologyClusterCircuitNodeStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
31132+
callback.onSuccess(value);
31133+
}
31134+
}, ELECTRICAL_CIRCUIT_NODES_ATTRIBUTE_ID, isFabricFiltered);
31135+
}
31136+
31137+
public void writeElectricalCircuitNodesAttribute(DefaultClusterCallback callback, ArrayList<ChipStructs.PowerTopologyClusterCircuitNodeStruct> value) {
31138+
writeElectricalCircuitNodesAttribute(callback, value, 0);
31139+
}
31140+
31141+
public void writeElectricalCircuitNodesAttribute(DefaultClusterCallback callback, ArrayList<ChipStructs.PowerTopologyClusterCircuitNodeStruct> value, int timedWriteTimeoutMs) {
31142+
BaseTLVType tlvValue = ArrayType.generateArrayType(value, (elementvalue) -> elementvalue.encodeTlv());
31143+
writeAttribute(new WriteAttributesCallbackImpl(callback), ELECTRICAL_CIRCUIT_NODES_ATTRIBUTE_ID, tlvValue, timedWriteTimeoutMs);
31144+
}
31145+
31146+
public void subscribeElectricalCircuitNodesAttribute(
31147+
ElectricalCircuitNodesAttributeCallback callback, int minInterval, int maxInterval) {
31148+
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ELECTRICAL_CIRCUIT_NODES_ATTRIBUTE_ID);
31149+
31150+
subscribeAttribute(new ReportCallbackImpl(callback, path) {
31151+
@Override
31152+
public void onSuccess(byte[] tlv) {
31153+
List<ChipStructs.PowerTopologyClusterCircuitNodeStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
31154+
callback.onSuccess(value);
31155+
}
31156+
}, ELECTRICAL_CIRCUIT_NODES_ATTRIBUTE_ID, minInterval, maxInterval);
31157+
}
31158+
3111431159
public void readGeneratedCommandListAttribute(
3111531160
GeneratedCommandListAttributeCallback callback) {
3111631161
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID);

src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8606,6 +8606,97 @@ public String toString() {
86068606
return output.toString();
86078607
}
86088608
}
8609+
public static class PowerTopologyClusterCircuitNodeStruct {
8610+
public Long node;
8611+
public Optional<Integer> endpoint;
8612+
public Optional<String> label;
8613+
public Integer fabricIndex;
8614+
private static final long NODE_ID = 1L;
8615+
private static final long ENDPOINT_ID = 2L;
8616+
private static final long LABEL_ID = 3L;
8617+
private static final long FABRIC_INDEX_ID = 254L;
8618+
8619+
public PowerTopologyClusterCircuitNodeStruct(
8620+
Long node,
8621+
Optional<Integer> endpoint,
8622+
Optional<String> label,
8623+
Integer fabricIndex
8624+
) {
8625+
this.node = node;
8626+
this.endpoint = endpoint;
8627+
this.label = label;
8628+
this.fabricIndex = fabricIndex;
8629+
}
8630+
8631+
public StructType encodeTlv() {
8632+
ArrayList<StructElement> values = new ArrayList<>();
8633+
values.add(new StructElement(NODE_ID, new UIntType(node)));
8634+
values.add(new StructElement(ENDPOINT_ID, endpoint.<BaseTLVType>map((nonOptionalendpoint) -> new UIntType(nonOptionalendpoint)).orElse(new EmptyType())));
8635+
values.add(new StructElement(LABEL_ID, label.<BaseTLVType>map((nonOptionallabel) -> new StringType(nonOptionallabel)).orElse(new EmptyType())));
8636+
values.add(new StructElement(FABRIC_INDEX_ID, new UIntType(fabricIndex)));
8637+
8638+
return new StructType(values);
8639+
}
8640+
8641+
public static PowerTopologyClusterCircuitNodeStruct decodeTlv(BaseTLVType tlvValue) {
8642+
if (tlvValue == null || tlvValue.type() != TLVType.Struct) {
8643+
return null;
8644+
}
8645+
Long node = null;
8646+
Optional<Integer> endpoint = Optional.empty();
8647+
Optional<String> label = Optional.empty();
8648+
Integer fabricIndex = null;
8649+
for (StructElement element: ((StructType)tlvValue).value()) {
8650+
if (element.contextTagNum() == NODE_ID) {
8651+
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
8652+
UIntType castingValue = element.value(UIntType.class);
8653+
node = castingValue.value(Long.class);
8654+
}
8655+
} else if (element.contextTagNum() == ENDPOINT_ID) {
8656+
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
8657+
UIntType castingValue = element.value(UIntType.class);
8658+
endpoint = Optional.of(castingValue.value(Integer.class));
8659+
}
8660+
} else if (element.contextTagNum() == LABEL_ID) {
8661+
if (element.value(BaseTLVType.class).type() == TLVType.String) {
8662+
StringType castingValue = element.value(StringType.class);
8663+
label = Optional.of(castingValue.value(String.class));
8664+
}
8665+
} else if (element.contextTagNum() == FABRIC_INDEX_ID) {
8666+
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
8667+
UIntType castingValue = element.value(UIntType.class);
8668+
fabricIndex = castingValue.value(Integer.class);
8669+
}
8670+
}
8671+
}
8672+
return new PowerTopologyClusterCircuitNodeStruct(
8673+
node,
8674+
endpoint,
8675+
label,
8676+
fabricIndex
8677+
);
8678+
}
8679+
8680+
@Override
8681+
public String toString() {
8682+
StringBuilder output = new StringBuilder();
8683+
output.append("PowerTopologyClusterCircuitNodeStruct {\n");
8684+
output.append("\tnode: ");
8685+
output.append(node);
8686+
output.append("\n");
8687+
output.append("\tendpoint: ");
8688+
output.append(endpoint);
8689+
output.append("\n");
8690+
output.append("\tlabel: ");
8691+
output.append(label);
8692+
output.append("\n");
8693+
output.append("\tfabricIndex: ");
8694+
output.append(fabricIndex);
8695+
output.append("\n");
8696+
output.append("}\n");
8697+
return output.toString();
8698+
}
8699+
}
86098700
public static class EnergyEvseModeClusterModeTagStruct {
86108701
public Optional<Integer> mfgCode;
86118702
public Integer value;

src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10280,6 +10280,7 @@ public long getID() {
1028010280
public enum Attribute {
1028110281
AvailableEndpoints(0L),
1028210282
ActiveEndpoints(1L),
10283+
ElectricalCircuitNodes(2L),
1028310284
GeneratedCommandList(65528L),
1028410285
AcceptedCommandList(65529L),
1028510286
AttributeList(65531L),

0 commit comments

Comments
 (0)