Cluster

The base cluster class every other cluster implementation must extend from.

Constructor

Cluster

new Cluster(endpoint)

Create a new cluster instance.

Parameters

Name Type Description
endpoint
Endpoint

A node Endpoint instance

Properties

DIRECTION_SERVER_TO_CLIENT

DIRECTION_SERVER_TO_CLIENT

Constants that refer to the direction of a frame. The direction of a frame is read from the frameControl property in the ZCL header. Usually a client cluster sends commands to a server cluster (the cluster holding the attribute values), but this can also be the other way around.

logId

logId

Returns log id string for this cluster.

Methods

addCluster

(static) addCluster(clusterClass)

Add a cluster class. This should be called whenever a custom Cluster implementation has been created before it will be available on the node.

Parameters

Name Type Description
clusterClass
Cluster

The class, not an instance.

Example

const { Cluster } = require('zigbee-clusters');

const MyCluster extends Cluster {
 // Implement custom cluster logic here
 get NAME() {
   return 'myClusterName';
 }
}

Cluster.addCluster(MyCluster);

// Now it will be available
zclNode.endpoints[1].clusters['myClusterName'].doSomething();

getCluster

(static) getCluster(clusterIdOrName): Cluster

Get a cluster instance by ID or NAME.

Parameters

Name Type Description
clusterIdOrName
string | number

Returns

removeCluster

(static) removeCluster(clusterIdOrName)

Remove cluster by ID or NAME.

Parameters

Name Type Description
clusterIdOrName
string | number

configureReporting

(async) configureReporting(attributes): Promise.<void>

Command which configures attribute reporting for the given attributes on the remote cluster. Note: do not mix regular and manufacturer specific attributes.

Parameters

Name Type Description
attributes
object

Attribute reporting configuration (e.g. { onOff: { minInterval: 0, maxInterval: 300, minChange: 1 } })

Returns

Promise.<void>

discoverAttributes

(async) discoverAttributes(): Promise.<Array>

Command which discovers the implemented attributes on the remote cluster.

TODO: handle the case where lastResponse===false. It might be possible that there are more commands to be reported than can be transmitted in one report (in practice very unlikely though). If lastResponse===false invoke discoverCommandsGenerated again starting from the index where the previous invocation stopped (maxResults).

TODO: The manufacturer specific sub-field SHALL be set to 0 to discover standard attributes in a ZigBee cluster or 1 to discover manufacturer specific attributes in either a standard or a manufacturer specific cluster.

Returns

  • Array with string or number values (depending on if the attribute is implemented in zigbee-clusters or not).
Promise.<Array>

discoverAttributesExtended

(async) discoverAttributesExtended(): Promise.<Array>

Command which discovers the implemented attributes on the remote cluster, the difference with discoverAttributes is that this command also reports the access control field of the attribute (whether it is readable/writable/reportable).

TODO: handle the case where lastResponse===false. It might be possible that there are more commands to be reported than can be transmitted in one report (in practice very unlikely though). If lastResponse===false invoke discoverCommandsGenerated again starting from the index where the previous invocation stopped (maxResults).

TODO: The manufacturer-specific sub-field SHALL be set to 0 to discover standard attributes in a ZigBee cluster or 1 to discover manufacturer-specific attributes in either a standard or a manufacturer- specific cluster. A manufacturer ID in this field of 0xffff (wildcard) will discover any manufacture-specific attributes.

Returns

  • Returns an array with objects with attribute names as keys and following object as values: {name: string, id: number, acl: { readable: boolean, writable: boolean, reportable: boolean } }. Note that name is optional based on whether the attribute is implemented in zigbee-clusters.
Promise.<Array>

discoverCommandsGenerated

(async) discoverCommandsGenerated(opts=opt): Promise.<Array.<number>>

Command which requests the remote cluster to report its generated commands. Generated commands are commands which may be sent by the remote cluster.

TODO: handle the case where lastResponse===false. It might be possible that there are more commands to be reported than can be transmitted in one report (in practice very unlikely though). If lastResponse===false invoke discoverCommandsGenerated again starting from the index where the previous invocation stopped (maxResults).

TODO: The manufacturer-specific sub-field SHALL be set to 0 to discover standard commands in a ZigBee cluster or 1 to discover manufacturer-specific commands in either a standard or a manufacturer-specific cluster. A manufacturer ID in this field of 0xffff (wildcard) will discover any manufacture- specific commands.

Parameters

Name Type Description
opts=
object <optional>
opts.startValue
number <optional>
default:0
opts.maxResults
number <optional>
default:250

Returns

Promise.<Array.<number>>

discoverCommandsReceived

(async) discoverCommandsReceived(opts=opt): Promise.<Array.<number>>

Command which requests the remote cluster to report its received commands. Received commands are commands which may be received by the remote cluster.

TODO: handle the case where lastResponse===false. It might be possible that there are more commands to be reported than can be transmitted in one report (in practice very unlikely though). If lastResponse===false invoke discoverCommandsGenerated again starting from the index where the previous invocation stopped (maxResults).

TODO: The manufacturer-specific sub-field SHALL be set to 0 to discover standard commands in a ZigBee cluster or 1 to discover manufacturer-specific commands in either a standard or a manufacturer-specific cluster. A manufacturer ID in this field of 0xffff (wildcard) will discover any manufacture- specific commands.

Parameters

Name Type Description
opts=
object <optional>
opts.startValue
number <optional>
default:0
opts.maxResults
number <optional>
default:255

Returns

Promise.<Array.<number>>

readAttributes

(async) readAttributes(attributeNames, opts=opt): Promise.<Object.<string, unknown>>

Command which reads a given set of attributes from the remote cluster. Note: do not mix regular and manufacturer specific attributes.

Parameters

Name Type Description
attributeNames
Array.<string>
opts=
Object <optional>

Returns

  • Object with values (e.g. { onOff: true })
Promise.<Object.<string, unknown>>

readReportingConfiguration

(async) readReportingConfiguration(attributes): Promise.<Array.<ReadReportingConfiguration>>

Command which retrieves the reporting configurations for the given attributes from the remote cluster. Currently this only takes the 'reported' into account, this represents the reports the remote cluster would sent out, instead of receive (which is likely the most interesting). Note: do not mix regular and manufacturer specific attributes.

Parameters

Name Type Description
attributes
Array

Array with number/strings (either attribute id, or attribute name).

Returns

  • Returns array with ReadReportingConfiguration objects per attribute.
Promise.<Array.<ReadReportingConfiguration>>

writeAttributes

(async) writeAttributes(attributes): Promise.<(*|{attributes: *})>

Command which writes a given set of attribute key-value pairs to the remote cluster. Note: do not mix regular and manufacturer specific attributes.

Parameters

Name Type Description
attributes
object

Object with attribute names as keys and their values (e.g. { onOff: true, fakeAttributeName: 10 }.

Returns

Promise.<(*|{attributes: *})>