0.1.4 • Published 9 years ago
knxnetjs v0.1.4
knxnetjs -- A pure Javascript KNXnet/IP routing (multicast) implementation
Install
npm install knxnetjs
Example how to use
In this example you can see, how to register for group object updates and how to send updates.
var knx=require ('knxnetjs');
//open KNXnet/IP connection
var KNX = knx.openKNX();
//start datapoint engine used to easily send and receive knx group addresses
var DPE = knx.createDPEngine(KNX);
//register a datapoint under a name with a datapoint type to a specific group address
DPE.registerDP("Scenes", "5.010", "1/0/1");
DPE.registerDP("switchable_light", "1.001", "1/1/1");
DPE.registerDP("dimmable_light", "5.001", "1/1/2");
//the following event is called for incoming group address write to a known group address
DPE.on("updateDP", function (dp, value) {
//check which datapoint is written
if (dp === "Scenes") {
//check value, in this case the scene number
if (value == 0) {
//everything off
DPE.sendDP("switchable_light", "OFF");
DPE.sendDP("dimmable_light", 0);
} else if (value == 1) {
//some light scene
DPE.sendDP("switchable_light", "ON");
DPE.sendDP("dimmable_light", 127);
}
}
}