knxultimate
Version:
KNX IP protocol implementation for Node. This is the ENGINE of Node-Red KNX-Ultimate node.
60 lines • 1.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const KnxLog_1 = require("../KnxLog");
const utils_1 = require("../utils");
const logger = (0, KnxLog_1.module)('DPT3');
const config = {
id: 'DPT3',
formatAPDU: (value) => {
if (!value) {
logger.warn('cannot write null value');
return null;
}
const apdu_data = Buffer.alloc(1);
if (typeof value === 'object' &&
(0, utils_1.hasProp)(value, 'decr_incr') &&
(0, utils_1.hasProp)(value, 'data')) {
apdu_data[0] =
((value.decr_incr ? 1 : 0) << 3) | (value.data & 0b00000111);
}
else {
logger.error('Must supply a value object of {decr_incr, data}');
}
return apdu_data;
},
fromBuffer: (buf) => {
if (buf.length !== 1) {
logger.error('Buffer should be 1 byte long, got', buf.length);
return null;
}
return {
decr_incr: (buf[0] & 0b00001000) >> 3 ? 1 : 0,
data: buf[0] & 0b00000111,
};
},
basetype: {
bitlength: 4,
valuetype: 'composite',
desc: '4-bit relative dimming control',
help: `// The parameter "data" indicates the relative amount of the dimming commmand (how much to dim).
// The parameter "data" can be any integer value from 0 to 7
// The parameter decr_incr:1 increases the light
// The parameter decr_incr:0 decreases the light
// The parameter data:0 stops the dimming
msg.payload={decr_incr: 1, data: 5};
return msg;`,
helplink: 'https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki/-Sample---Dimming',
},
subtypes: {
'007': {
name: 'Dimming control',
desc: 'dimming control',
},
'008': {
name: 'Blinds control',
desc: 'blinds control',
},
},
};
exports.default = config;
//# sourceMappingURL=dpt3.js.map