@@ -393,6 +393,8 @@ export class Endpoint extends ZigbeeEntity {
393393 const cluster = this . getCluster ( clusterKey , undefined , options ?. manufacturerCode ) ;
394394 const payload : TFoundation [ "report" ] = [ ] ;
395395
396+ // TODO: handle `attr.reportRequired !== true`
397+
396398 for ( const nameOrID in attributes ) {
397399 const attribute = cluster . getAttribute ( nameOrID ) ;
398400
@@ -429,7 +431,11 @@ export class Endpoint extends ZigbeeEntity {
429431 const attribute = cluster . getAttribute ( nameOrID ) ;
430432
431433 if ( attribute ) {
432- payload . push ( { attrId : attribute . ID , attrData : attributes [ nameOrID ] , dataType : attribute . type } ) ;
434+ // TODO: refs are not processed (pre-loop?)
435+ // TODO: handle `attr.writeOptional !== true`
436+ const attrData = Zcl . Utils . processAttributeWrite ( attribute , attributes [ nameOrID ] , attributes ) ;
437+
438+ payload . push ( { attrId : attribute . ID , attrData, dataType : attribute . type } ) ;
433439 } else if ( ! Number . isNaN ( Number ( nameOrID ) ) ) {
434440 const value = attributes [ nameOrID ] ;
435441
@@ -498,13 +504,17 @@ export class Endpoint extends ZigbeeEntity {
498504 ) ;
499505 const payload : TFoundation [ "read" ] = [ ] ;
500506
507+ // TODO: handle `attr.required !== true` => should not throw
508+
501509 for ( const attribute of attributes ) {
502510 if ( typeof attribute === "number" ) {
503511 payload . push ( { attrId : attribute } ) ;
504512 } else {
505513 const attr = cluster . getAttribute ( attribute ) ;
506514
507515 if ( attr ) {
516+ // TODO: force to also read *Ref if attribute has any and not already present in array for PostRead refs?
517+ Zcl . Utils . processAttributePreRead ( attr ) ;
508518 payload . push ( { attrId : attr . ID } ) ;
509519 } else {
510520 logger . warning ( `Ignoring unknown attribute ${ attribute } in cluster ${ cluster . name } ` , NS ) ;
0 commit comments