klf-200-api
Version:
This module provides a wrapper to the socket API of a Velux KLF-200 interface. You will need at least firmware 0.2.0.0.71 on your KLF interface for this library to work.
47 lines • 1.91 kB
JavaScript
"use strict";
import { GW_FRAME_COMMAND_REQ } from "./common.js";
export class GW_STATUS_REQUEST_REQ extends GW_FRAME_COMMAND_REQ {
Nodes;
StatusType;
FunctionalParameters;
constructor(Nodes, StatusType, FunctionalParameters = []) {
super(26);
this.Nodes = Nodes;
this.StatusType = StatusType;
this.FunctionalParameters = FunctionalParameters;
const buff = this.Data.subarray(this.offset);
buff.writeUInt16BE(this.SessionID, 0);
// Multiple nodes are provided
if (Array.isArray(this.Nodes)) {
if (this.Nodes.length > 20)
throw new Error("Too many nodes.");
buff.writeUInt8(this.Nodes.length, 2);
for (let nodeIndex = 0; nodeIndex < this.Nodes.length; nodeIndex++) {
const node = this.Nodes[nodeIndex];
buff.writeUInt8(node, 3 + nodeIndex);
}
}
else {
buff.writeUInt8(1, 2);
buff.writeUInt8(this.Nodes, 3);
}
buff.writeUInt8(this.StatusType, 23);
let FPI1 = 0;
let FPI2 = 0;
for (let functionalParameterIndex = 0; functionalParameterIndex < this.FunctionalParameters.length; functionalParameterIndex++) {
const functionalParameter = this.FunctionalParameters[functionalParameterIndex];
const functionalParameterID = functionalParameter - 1;
if (functionalParameterID < 0 || functionalParameterID > 15)
throw new Error("Functional paramter ID out of range.");
if (functionalParameterID < 8) {
FPI1 |= 0x80 >>> functionalParameterID;
}
else {
FPI2 |= 0x80 >>> (functionalParameterID - 8);
}
}
buff.writeUInt8(FPI1, 24);
buff.writeUInt8(FPI2, 25);
}
}
//# sourceMappingURL=GW_STATUS_REQUEST_REQ.js.map