@@ -1250,13 +1250,17 @@ async function selectAttributeMappingsByPackageIds(db, packageIds) {
12501250
12511251/**
12521252 * Get all attributes in an endpoint type cluster
1253+ * Disabled attributes are not loaded into ENDPOINT_TYPE_ATTRIBUTE table
1254+ * when opening a ZAP file, so we need to join DEVICE_TYPE_CLUSTER table
12531255 * @param {* } db
12541256 * @param {* } endpointTyeClusterId
1257+ * @param {* } deviceTypeClusterId
12551258 * @returns all attributes in an endpoint type cluster
12561259 */
1257- async function selectAttributesByEndpointTypeClusterId (
1260+ async function selectAttributesByEndpointTypeClusterIdAndDeviceTypeClusterId (
12581261 db ,
1259- endpointTyeClusterId
1262+ endpointTypeClusterId ,
1263+ deviceTypeClusterId
12601264) {
12611265 let rows = await dbApi . dbAll (
12621266 db ,
@@ -1274,13 +1278,19 @@ async function selectAttributesByEndpointTypeClusterId(
12741278 FROM
12751279 ATTRIBUTE
12761280 JOIN
1281+ DEVICE_TYPE_CLUSTER
1282+ ON
1283+ ATTRIBUTE.CLUSTER_REF = DEVICE_TYPE_CLUSTER.CLUSTER_REF
1284+ LEFT JOIN
12771285 ENDPOINT_TYPE_ATTRIBUTE
12781286 ON
1279- ATTRIBUTE.ATTRIBUTE_ID = ENDPOINT_TYPE_ATTRIBUTE.ATTRIBUTE_REF
1287+ ATTRIBUTE.ATTRIBUTE_ID = ENDPOINT_TYPE_ATTRIBUTE.ATTRIBUTE_REF
1288+ AND
1289+ ENDPOINT_TYPE_ATTRIBUTE.ENDPOINT_TYPE_CLUSTER_REF = ?
12801290 WHERE
1281- ENDPOINT_TYPE_ATTRIBUTE.ENDPOINT_TYPE_CLUSTER_REF = ?
1291+ DEVICE_TYPE_CLUSTER.DEVICE_TYPE_CLUSTER_ID = ?
12821292 ` ,
1283- [ endpointTyeClusterId ]
1293+ [ endpointTypeClusterId , deviceTypeClusterId ]
12841294 )
12851295 return rows . map ( dbMapping . map . endpointTypeAttributeExtended )
12861296}
@@ -1311,5 +1321,5 @@ exports.selectTokenAttributesForEndpoint = selectTokenAttributesForEndpoint
13111321exports . selectAllUserTokenAttributes = selectAllUserTokenAttributes
13121322exports . selectAttributeMappingsByPackageIds =
13131323 selectAttributeMappingsByPackageIds
1314- exports . selectAttributesByEndpointTypeClusterId =
1315- selectAttributesByEndpointTypeClusterId
1324+ exports . selectAttributesByEndpointTypeClusterIdAndDeviceTypeClusterId =
1325+ selectAttributesByEndpointTypeClusterIdAndDeviceTypeClusterId
0 commit comments