I can run this on my machine using node.js and return the message successfully to console. But how do I return the console.log into a msg.payload instead in a node-red function?
In my function I tried:
const RainBirdClass = require('node-rainbird');
let rainbird = new RainBirdClass("MY_IP", "MY_PASSWORD");
let temp = rainbird.getSerialNumber();
msg.payload = temp;
return msg;
The functions in the README dont say they return a promise but a quick glance at the package reveals they return a request promise. Therefore you eaither need to await or do the then().catch
If you want to do promise chain then its like this...
const rainbird = new RainBirdClass.RainBirdClass("MY_IP", "MY_PASSWORD");
rainbird.getSerialNumber().then(result => {
msg.payload = result
node.send(msg)
}).catch(err => {
node.error(err, msg)
})