UNPKG

node-red-mpb10

Version:

Nodes para processamento MPB10

24 lines (21 loc) 778 B
module.exports = function(RED) { function MPB10TempNode(config) { RED.nodes.createNode(this, config); var node = this; node.on('input', function(msg) { try { const data = msg.payload.slice(10, -2).split(',').slice(0,5); const outputs = data.map((value, index) => { const newMsg = RED.util.cloneMessage(msg); newMsg.payload = parseFloat(value); newMsg.topic = `Temp${index+1}`; return newMsg; }); node.send(outputs); } catch (err) { node.error("Erro: " + err); } }); } RED.nodes.registerType("mpb10-temp", MPB10TempNode); }