Hi all, I used a flow for quite some time to check with the unifi controller for connected clients. Serch criteria was the MAC. I assume, after noder-red upgrade to 3.0.2, this function stopped working.
const lastSeenSeconds = 15;
let presenceCutoff = (new Date().getTime() - (lastSeenSeconds * 1000)) / 1000;
const people = {
"presence/s": "d2:84:23:xxxxxx",
"presence/j": "16:97:2a:xxxxxx"
};
return Object.keys(people).map(function (topic) {
let devices = msg.payload.filter(device => device.name === people[topic] && device.last_seen > presenceCutoff);
return {
topic: topic,
retain: true,
payload: devices.length > 0
};
});
The original line in the function was
let devices = msg.payload[0].filter(device => device.name === people[topic] && device.last_seen
--> Node-Red UniFi Presence.md · GitHub
Any idea why I get FALSE out of the function ?