Unifi presence control stopped working (after upgrade to node-red 3.0.2)

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 ?

1 Like

Hi all, I just found it, in the array that is received from unifi, the device.name is now device.mac.
Now works just fine again.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.