The RPi rebooted, I'm back in.
This is the function node that is fed from the Unifi node and has multiple outputs:
const lastSeenSeconds = 20;
let presenceCutoff = (Date.now() - (lastSeenSeconds * 1000)) / 1000;
const people = {
"presence/Phone1" : "xx:xx:xx:xx:xx:xx",
"presence/Phone2" : "xx:xx:xx:xx:xx:xx",
"presence/Phone3" : "xx:xx:xx:xx:xx:xx",
"presence/Phone4" : "xx:xx:xx:xx:xx:xx",
"presence/Phone5" : "xx:xx:xx:xx:xx:xx"
};
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
};
});