Open Csstenersen opened 5 years ago
Get the node to show "ready" status in addition to the other statuses.
var speedTest = require('speedtest-net'); module.exports = exports = function(RED) { function SpeedTest(config) { var timeout = config.maxTime || 5 * 1000; RED.nodes.createNode(this, config); this.status({ fill: 'green', shape: 'dot', text: 'Ready' }); this.on('input', msg => { this.status({ fill: 'yellow', shape: 'dot', text: 'Requesting' }); var test = speedTest({ maxTime: config.maxTime }); test.on('data', data => { var reponse = Object.assign({}, data, { config: config }); this.status({fill: 'green', shape: 'dot', text: 'Ready'}); this.send({ payload: reponse }); }); test.on('error', err => { this.status({ fill: 'red', shape: 'dot', text: err.message }); this.error(err, msg); }); }); } RED.nodes.registerType('speedtest', SpeedTest); };
Get the node to show "ready" status in addition to the other statuses.