How to use the zigbee-herdsman/dist/zcl.getClusterLegacy function in zigbee-herdsman

To help you get started, we’ve selected a few zigbee-herdsman examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Koenkk / zigbee2mqtt / lib / extension / responder.js View on Github external
readResponse(message, endpoint) {
        const clusterID = message.clusterid;
        const cluster = Zcl.getClusterLegacy(clusterID).key;
        const attributes = message.zclMsg.payload.map((p) => Zcl.getAttributeLegacy(message.clusterid, p.attrId));
        const response = [];

        attributes.forEach((attribute) => {
            if (cluster === 'genTime' && attribute.key === 'time') {
                const time = Math.round(((new Date()).getTime() - OneJanuary2000) / 1000);
                response.push(this.createReadResponseRec(clusterID, attribute.value, time));
            }
        });

        this.zigbee.publish(
            endpoint.device.ieeeAddr, 'device', cluster, 'readRsp', 'foundation', response,
            {direction: 1, seqNum: message.zclMsg.seqNum, disDefaultRsp: 1}, endpoint.epId,
        );
    }

zigbee-herdsman

An open source ZigBee gateway solution with node.js.

MIT
Latest version published 8 days ago

Package Health Score

81 / 100
Full package analysis