Thank you for the confirmation.
This became apparent to me when I tried using the word-to-numbers module via the npm node. I had to configure the npm node like this:
However, it would have required a few failed attempts before I correctly translated that into:
wordsToNumbers.wordsToNumbers(msg.payload);
so I appreciate your assistance.
I've learned a lot from this experience but, ultimately, I chose to follow a different path. I uninstalled the words-to-numbers module and replaced it with a bespoke solution. I only need to translate numbers from zero to one hundred in increments of five. That's easily done with a map
which involves a lot less overhead than the words-to-numbers module. Plus I can share the flow with a fewer prerequisites (i.e. the installation of the words-to-numbers module).
// Convert light level from words to numbers
let words = new Map([
["zero", 0],
["five", 5],
["ten", 10],
["fifteen", 15],
["twenty", 20],
["twenty five", 25],
["thirty", 30],
["thirty five", 35],
["forty", 40],
["forty five", 45],
["fifty", 50],
["fifty five", 55],
["sixty", 60],
["sixty five", 65],
["seventy", 70],
["seventy five", 70],
["eighty", 80],
["eighty five", 85],
["ninety", 90],
["ninety five", 95],
["hundred", 100],
["one hundred", 100],
]);
var tmp = words.get(msg.payload);
if (tmp) {
msg.value = tmp;
return msg;
}
return null;