diff --git a/src-electron/db/db-mapping.js b/src-electron/db/db-mapping.js index 9aa6b1f60d4717c29d42e17bb433cc0d803a3c21..edd4f15b12c323caa4dd673dec17719c3591962f 100644 --- a/src-electron/db/db-mapping.js +++ b/src-electron/db/db-mapping.js @@ -503,6 +503,7 @@ exports.map = { ), // Is Attribute mfg specific or not endpointId: x.ENDPOINT_IDENTIFIER, // Endpoint type attribute's endpoint Id tokenId: x.TOKEN_ID, // Endpoint type attribute's token id + smallestEndpointIdentifier: x.SMALLEST_ENDPOINT_IDENTIFIER, // Smallest endpoint Id in which the attribute is present } }, diff --git a/src-electron/db/query-attribute.js b/src-electron/db/query-attribute.js index 8173fd9427b7a5c944b418ab271578adb547ae40..21e06bb57d7dbacddc2714696477b114a2e80884 100644 --- a/src-electron/db/query-attribute.js +++ b/src-electron/db/query-attribute.js @@ -406,7 +406,6 @@ async function selectAttributeDetailsFromEnabledClusters( tokenizedAttributeSize: x.TOKENIZED_ATTRIBUTE_SIZE, maxAttributeSize: x.MAX_ATTRIBUTE_SIZE, maxTokenAttributeSize: x.MAX_TOKEN_ATTRIBUTE_SIZE, - smallestEndpointIdentifier: x.SMALLEST_ENDPOINT_IDENTIFIER, isString: x.IS_STRING, isManufacturingSpecific: dbApi.toDbBool( x.MANUFACTURER_CODE | x.CLUSTER_MANUFACTURER_CODE @@ -496,15 +495,7 @@ async function selectAttributeDetailsFromEnabledClusters( END ELSE 0 - END) OVER () AS MAX_TOKEN_ATTRIBUTE_SIZE, - ( - SELECT - MIN(ENDPOINT_IDENTIFIER) - FROM - ENDPOINT - WHERE - ENDPOINT_TYPE_ATTRIBUTE.ENDPOINT_TYPE_REF = ENDPOINT.ENDPOINT_TYPE_REF - ) AS SMALLEST_ENDPOINT_IDENTIFIER + END) OVER () AS MAX_TOKEN_ATTRIBUTE_SIZE FROM ATTRIBUTE INNER JOIN ENDPOINT_TYPE_ATTRIBUTE ON ATTRIBUTE.ATTRIBUTE_ID = ENDPOINT_TYPE_ATTRIBUTE.ATTRIBUTE_REF @@ -1031,11 +1022,22 @@ async function selectAllUserTokenAttributes( ATTRIBUTE.MANUFACTURER_CODE, ATTRIBUTE.DEFINE, ATTRIBUTE.SIDE, + ATTRIBUTE.TYPE, + CLUSTER.NAME AS CLUSTER_NAME, CLUSTER.CODE AS CLUSTER_CODE, CLUSTER.MANUFACTURER_CODE AS CLUSTER_MANUFACTURER_CODE, ENDPOINT_TYPE_ATTRIBUTE.SINGLETON, ENDPOINT.ENDPOINT_IDENTIFIER, - ENDPOINT.ENDPOINT_TYPE_REF + ENDPOINT.ENDPOINT_TYPE_REF, + MIN + (ENDPOINT.ENDPOINT_IDENTIFIER) + OVER + (PARTITION BY + CLUSTER.CODE, + CLUSTER.MANUFACTURER_CODE, + ATTRIBUTE.CODE, + ATTRIBUTE.MANUFACTURER_CODE, + ATTRIBUTE.SIDE) AS SMALLEST_ENDPOINT_IDENTIFIER FROM ATTRIBUTE INNER JOIN diff --git a/test/gen-template/zigbee/zap-tokens-version-2.zapt b/test/gen-template/zigbee/zap-tokens-version-2.zapt index b65b1ab986bd5648eb60e3a5cad57c88c62d604e..0a77d8298b901d5417b0b74020bdd104804f588f 100644 --- a/test/gen-template/zigbee/zap-tokens-version-2.zapt +++ b/test/gen-template/zigbee/zap-tokens-version-2.zapt @@ -114,13 +114,13 @@ DEFINE_BASIC_TOKEN({{define}}_{{../endpointIdentifier}}, tokType_{{as_snake_case uint8_t epNetwork; \ {{/if_compare}} {{/first}} - {{#if_compare 'NVM' storageOption operator='=='}} + {{/all_user_cluster_generated_attributes}} + {{#token_attributes}} {{#if isSingleton}} halCommonGetToken((tokType_{{as_snake_case define}} *)ptr, TOKEN_{{define}}_SINGLETON); \ emberAfWrite{{#if isManufacturingSpecific}}ManufacturerSpecific{{/if}}{{as_camel_cased side false}}Attribute({{smallestEndpointIdentifier}}, ZCL_{{as_delimited_macro clusterName}}_CLUSTER_ID, ZCL_{{define}}_ATTRIBUTE_ID, {{#if isManufacturingSpecific}}{{as_hex mfgCode 4}}, {{/if}}(uint8_t*)ptr, ZCL_{{as_delimited_macro type}}_ATTRIBUTE_TYPE); \ {{/if}} - {{/if_compare}} -{{/all_user_cluster_generated_attributes}} + {{/token_attributes}} {{#token_attribute_endpoints isSingleton=0}} {{#token_attributes endpointTypeRef isSingleton=0}} {{#first}}