diff --git a/src-electron/db/db-mapping.js b/src-electron/db/db-mapping.js index 7a7ad19ad7..8b9b53f1a1 100644 --- a/src-electron/db/db-mapping.js +++ b/src-electron/db/db-mapping.js @@ -94,7 +94,7 @@ exports.map = { manufacturerCode: x.MANUFACTURER_CODE, name: x.NAME, label: x.NAME, - type: x.TYPE, + type: x.TYPE != 'array' ? x.TYPE : x.ARRAY_TYPE, side: x.SIDE, define: x.DEFINE, min: x.MIN, @@ -106,15 +106,20 @@ exports.map = { reportableChange: x.REPORTABLE_CHANGE, reportableChangeLength: x.REPORTABLE_CHANGE_LENGTH, isWritable: dbApi.fromDbBool(x.IS_WRITABLE), + isWritableAttribute: dbApi.fromDbBool(x.IS_WRITABLE), isNullable: dbApi.fromDbBool(x.IS_NULLABLE), defaultValue: x.DEFAULT_VALUE, isOptional: dbApi.fromDbBool(x.IS_OPTIONAL), isReportable: x.REPORTING_POLICY == dbEnums.reportingPolicy.mandatory || x.REPORTING_POLICY == dbEnums.reportingPolicy.suggested, + isReportableAttribute: + x.REPORTING_POLICY == dbEnums.reportingPolicy.mandatory || + x.REPORTING_POLICY == dbEnums.reportingPolicy.suggested, reportingPolicy: x.REPORTING_POLICY, isSceneRequired: dbApi.fromDbBool(x.IS_SCENE_REQUIRED), entryType: x.ARRAY_TYPE, + isArray: x.ARRAY_TYPE ? 1 : 0, mustUseTimedWrite: dbApi.fromDbBool(x.MUST_USE_TIMED_WRITE), } }, diff --git a/src-electron/generator/helper-zcl.js b/src-electron/generator/helper-zcl.js index 471a68b4cd..97185ccd24 100644 --- a/src-electron/generator/helper-zcl.js +++ b/src-electron/generator/helper-zcl.js @@ -730,33 +730,38 @@ function zcl_attributes_client(options) { * Iterator over the server attributes. If it is used at toplevel, if iterates over all the server attributes * in the database. If used within zcl_cluster context, it iterates over all the server attributes * that belong to that cluster. - * + * Available Options: + * - removeKey: Removes one of the keys from the map(for eg keys in db-mapping.js) + * fo eg: (#zcl_attributes_server removeKey='isOptional') will remove 'isOptional' + * from the results * @param {*} options * @returns Promise of attribute iteration. */ -function zcl_attributes_server(options) { +async function zcl_attributes_server(options) { // If used at the toplevel, 'this' is the toplevel context object. // when used at the cluster level, 'this' is a cluster - let promise = templateUtil - .ensureZclPackageIds(this) - .then((packageIds) => { - if ('id' in this) { - // We're functioning inside a nested context with an id, so we will only query for this cluster. - return queryZcl.selectAttributesByClusterIdAndSideIncludingGlobal( - this.global.db, - this.id, - packageIds, - dbEnum.side.server - ) - } else { - return queryZcl.selectAllAttributesBySide( - this.global.db, - dbEnum.side.server, - packageIds - ) - } - }) - .then((atts) => templateUtil.collectBlocks(atts, options, this)) + let packageIds = await templateUtil.ensureZclPackageIds(this) + let serverAttributes = '' + if ('id' in this) { + // We're functioning inside a nested context with an id, so we will only query for this cluster. + serverAttributes = + await queryZcl.selectAttributesByClusterIdAndSideIncludingGlobal( + this.global.db, + this.id, + packageIds, + dbEnum.side.server + ) + } else { + serverAttributes = await queryZcl.selectAllAttributesBySide( + this.global.db, + dbEnum.side.server, + packageIds + ) + } + if ('removeKey' in options.hash) { + serverAttributes.map((attr) => delete attr[options.hash.removeKey]) + } + let promise = templateUtil.collectBlocks(serverAttributes, options, this) return templateUtil.templatePromise(this.global, promise) }