Hey gang,
I recently updated to NR v3 and now one of my function nodes is throwing the error "TypeError: msg.payload[0].filter is not a function"
This is processing the output of the Unifi node which is generating a list of connected client devices. This code is filtering them and sending to separate outputs on the function node.
const lastSeenSeconds = 20;
let presenceCutoff = (Date.now() - (lastSeenSeconds * 1000)) / 1000;
const people = {
"presence/phone1": "redacted_MAC",
"presence/phone2": "redacted_MAC",
"presence/phone3": "redacted_MAC"
};
return Object.keys(people).map(function(topic) {
let devices = msg.payload[0].filter(device => device.mac === people[topic]);
// let devices = msg.payload[0].filter(device => device.mac === people[topic]) && (device.last_seen > presenceCutoff);
return {
topic: topic,
//retain: true,
payload: devices.length > 0
};
});
Anyone have any idea how to fix this?
Thanks in advance,
Dax.