UNPKG

node-red-contrib-kbr-ebus

Version:

KBR Gmbh - nodes for accessing ebus devices

30 lines (22 loc) 846 B
module.exports = function(RED) { var ebus= require("./ebus"); function KBREbusTelexDetector(config) { RED.nodes.createNode(this,config); var node=this; node.name=config.name; let detector=new ebus.TelexDetector(); node.on("close", function() { detector.clearBuffer(); }); node.on('input', function(msg) { msg.topic=config.topic||msg.topic||""; detector.detect(msg.payload,function(telex){ msg.payload=telex; node.send(msg); },function(){ node.status({text:"Buffer:"+detector.getBuffer().length}); }); }); } RED.nodes.registerType("kbr-ebus-telex-detector",KBREbusTelexDetector); }