knxultimate
Version:
KNX IP protocol implementation for Node. This is the ENGINE of Node-Red KNX-Ultimate node.
90 lines • 3.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const KnxLog_1 = require("../KnxLog");
const utils_1 = require("../utils");
const logger = (0, KnxLog_1.module)('DPT213');
const config = {
id: 'DPT213',
formatAPDU(value) {
const apdu_data = Buffer.alloc(8);
if (typeof value === 'object' &&
(0, utils_1.hasProp)(value, 'Comfort') &&
value.Comfort >= -272 &&
value.Comfort <= 655.34 &&
(0, utils_1.hasProp)(value, 'Standby') &&
value.Standby >= -272 &&
value.Standby <= 655.34 &&
(0, utils_1.hasProp)(value, 'Economy') &&
value.Economy >= -272 &&
value.Economy <= 655.34 &&
(0, utils_1.hasProp)(value, 'BuildingProtection') &&
value.BuildingProtection >= -272 &&
value.BuildingProtection <= 655.34) {
const ArrComfort = (0, utils_1.getHex)(value.Comfort);
apdu_data[0] = ArrComfort[0];
apdu_data[1] = ArrComfort[1];
const ArrStandby = (0, utils_1.getHex)(value.Standby);
apdu_data[2] = ArrStandby[0];
apdu_data[3] = ArrStandby[1];
const ArrEconomy = (0, utils_1.getHex)(value.Economy);
apdu_data[4] = ArrEconomy[0];
apdu_data[5] = ArrEconomy[1];
const ArrBuildingProtection = (0, utils_1.getHex)(value.BuildingProtection);
apdu_data[6] = ArrBuildingProtection[0];
apdu_data[7] = ArrBuildingProtection[1];
return apdu_data;
}
logger.error('Must supply a payload like, for example: {Comfort:21, Standby:20, Economy:14, BuildingProtection:8}');
return null;
},
fromBuffer(buf) {
if (buf.length !== 8) {
logger.warn('fromBuffer: buf should be 4x2 bytes long (got %d bytes)', buf.length);
return null;
}
const nComfort = (0, utils_1.getFloat)(buf[0], buf[1]);
const nStandby = (0, utils_1.getFloat)(buf[2], buf[3]);
const nEconomy = (0, utils_1.getFloat)(buf[4], buf[5]);
const nbProt = (0, utils_1.getFloat)(buf[6], buf[7]);
return {
Comfort: nComfort,
Standby: nStandby,
Economy: nEconomy,
BuildingProtection: nbProt,
};
},
basetype: {
bitlength: 4 * 16,
valuetype: 'basic',
desc: '4x 16-Bit Signed Value',
help: `// Sample of 213.100.
// Set the temperatures between -272°C and 655.34°C with 0,02°C of resolution.
// These 4 property names, are valid for 213.101, 213.102 etc... as well.
// For example, for 213.101, LegioProtect is the "Comfort" property, Normal is "Standby", etc...
msg.payload = {Comfort:21.4, Standby:20, Economy:18.2, BuildingProtection:-1};
return msg;`,
helplink: 'https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki/-Sample---DPT213',
},
subtypes: {
100: {
desc: 'DPT_TempRoomSetpSet[4]',
name: 'Room temperature setpoint (Comfort, Standby, Economy, Building protection)',
unit: '°C',
range: [-272, 655.34],
},
101: {
desc: 'DPT_TempDHWSetpSet[4]',
name: 'Room temperature setpoint DHW (LegioProtect, Normal, Reduced, Off/FrostProtect)',
unit: '°C',
range: [-272, 655.34],
},
102: {
desc: 'DPT_TempRoomSetpSetShift[4]',
name: 'Room temperature setpoint shift (Comfort, Standby, Economy, Building protection)',
unit: '°C',
range: [-272, 655.34],
},
},
};
exports.default = config;
//# sourceMappingURL=dpt213.js.map