Skip to content

Instantly share code, notes, and snippets.

View wittekind's full-sized avatar

Daniel Wittekind wittekind

View GitHub Profile
@wittekind
wittekind / extract-port-overrides.json
Created July 22, 2020 19:30
node-red function, that gets the port_overrides array of a specific Unifi device from the output of the node-red-contrib-unifi node's AccessDevices command.
[
{
"id": "76e8dd64.3526ac",
"type": "function",
"z": "3eed02d1.e6900e",
"name": "extract port_overrides",
"func": "const deviceId = \"your device id\";\n\nconst port_overrides = msg.payload.flatMap(site => site) \n .filter(device => device._id == deviceId)\n .flatMap(device => device.port_overrides);\nmsg.payload = port_overrides;\nmsg.device_id = deviceId;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",