lib/profile/Cluster.js
function ZCLCluster(endpoint, clusterId) {
  this.endpoint = endpoint;
  this.device = this.endpoint.device;
  this.client = this.device.client;
  this.comms = this.client.comms;

  // XXX: Horrible hack, fix me.
  this.client.on('command.' + this.device.shortAddress + '.' + endpoint.endpointId + '.' + clusterId, function(command) {
    debug(this, 'command received', command);
    this.emit('command', command);
  }.bind(this));

  this.clusterId = clusterId;

  this.description = profileStore.getCluster(clusterId) || {
    name: 'UNKNOWN DEVICE'
  };

  this.name = this.description.name;

  this.attributes = {};

  if (this.description.attribute) {
    this.description.attribute.forEach(function(attr) {
      var attrId = attr.id;

      this.attributes[attr.name] = this.attributes[attrId] = {
        name: attr.name,
        id: attr.id,
        read: function() {
          return this.readAttributes(attrId).then(function(responses) {
            var response = responses[attrId];
            //debug('Responses', responses);
            if (response.status.key !== 'SUCCESS') {
              throw new Error('Failed to get attribute. Status', status);
            }
            return response.value;
          });
        }.bind(this)
        /*,

        write: function(value) {
          return this.writeAttributes(attrId).then(function(responses) {
            var response = responses[0];
            if (response.status.key !== 'SUCCESS') {
              throw new Error('Failed to get attribute. Status', status);
            }
            return response.value;
          });
        }.bind(this)*/

      };
    }.bind(this));
  }

  this.commands = {};

  if (this.description.command) {
    this.description.command.forEach(function(command) {
      var commandId = command.id;
      this.commands[command.name] = this.commands[commandId] = function(payload) {
        debug(this, 'Sending command', command, command.id, commandId);
        return this.sendClusterSpecificCommand(commandId, payload);
      }.bind(this);
    }.bind(this));
  }

}
function ZCLCluster(endpoint, clusterId) {
  this.endpoint = endpoint;
  this.device = this.endpoint.device;
  this.client = this.device.client;
  this.comms = this.client.comms;

  // XXX: Horrible hack, fix me.
  this.client.on('command.' + this.device.shortAddress + '.' + endpoint.endpointId + '.' + clusterId, function(command) {
    debug(this, 'command received', command);
    this.emit('command', command);
  }.bind(this));

  this.clusterId = clusterId;

  this.description = profileStore.getCluster(clusterId) || {
    name: 'UNKNOWN DEVICE'
  };

  this.name = this.description.name;

  this.attributes = {};

  if (this.description.attribute) {
    this.description.attribute.forEach(function(attr) {
      var attrId = attr.id;

      this.attributes[attr.name] = this.attributes[attrId] = {
        name: attr.name,
        id: attr.id,
        read: function() {
          return this.readAttributes(attrId).then(function(responses) {
            var response = responses[attrId];
            //debug('Responses', responses);
            if (response.status.key !== 'SUCCESS') {
              throw new Error('Failed to get attribute. Status', status);
            }
            return response.value;
          });
        }.bind(this)
        /*,

        write: function(value) {
          return this.writeAttributes(attrId).then(function(responses) {
            var response = responses[0];
            if (response.status.key !== 'SUCCESS') {
              throw new Error('Failed to get attribute. Status', status);
            }
            return response.value;
          });
        }.bind(this)*/

      };
    }.bind(this));
  }

  this.commands = {};

  if (this.description.command) {
    this.description.command.forEach(function(command) {
      var commandId = command.id;
      this.commands[command.name] = this.commands[commandId] = function(payload) {
        debug(this, 'Sending command', command, command.id, commandId);
        return this.sendClusterSpecificCommand(commandId, payload);
      }.bind(this);
    }.bind(this));
  }

}
function ZCLCluster ( endpoint , clusterId ) { this . endpoint = endpoint ; this . device = this . endpoint . device ; this . client = this . device . client ; this . comms = this . client . comms ; // XXX: Horrible hack, fix me. this . client . on ( 'command.' + this . device . shortAddress + '.' + endpoint . endpointId + '.' + clusterId , function ( command ) { debug ( this , 'command received' , command ) ; this . emit ( 'command' , command ) ; } . bind ( this ) ) ; this . clusterId = clusterId ; this . description = profileStore . getCluster ( clusterId ) || { name : 'UNKNOWN DEVICE' } ; this . name = this . description . name ; this . attributes = { } ; if ( this . description . attribute ) { this . description . attribute . forEach ( function ( attr ) { var attrId = attr . id ; this . attributes [ attr . name ] = this . attributes [ attrId ] = { name : attr . name , id : attr . id , read : function ( ) { return this . readAttributes ( attrId ) . then ( function ( responses ) { var response = responses [ attrId ] ; //debug('Responses', responses); if ( response . status . key !== 'SUCCESS' ) { throw new Error ( 'Failed to get attribute. Status' , status ) ; } return response . value ; } ) ; } . bind ( this ) /*,

        write: function(value) {
          return this.writeAttributes(attrId).then(function(responses) {
            var response = responses[0];
            if (response.status.key !== 'SUCCESS') {
              throw new Error('Failed to get attribute. Status', status);
            }
            return response.value;
          });
        }.bind(this)*/ } ; } . bind ( this ) ) ; } this . commands = { } ; if ( this . description . command ) { this . description . command . forEach ( function ( command ) { var commandId = command . id ; this . commands [ command . name ] = this . commands [ commandId ] = function ( payload ) { debug ( this , 'Sending command' , command , command . id , commandId ) ; return this . sendClusterSpecificCommand ( commandId , payload ) ; } . bind ( this ) ; } . bind ( this ) ) ; } }
Represents a ZCL cluster on a specific endpoint on a device.

@param {Endpoint} endpoint
@param {Number} clusterId
Represents a ZCL cluster on a specific endpoint on a device .