NRCHKB / node-red-contrib-unifi-os

Nodes to access UniFi data using endpoints and websockets
Apache License 2.0
26 stars 2 forks source link

Changes for /proxy/protect/ws/updates #23

Closed Shaquu closed 2 years ago

Shaquu commented 2 years ago

Few updates to make UniFi Protect updates flow using WS.

image image

example flow ``` [ { "id": "c253ea71.d21698", "type": "unifi-web-socket", "z": "7b1a5e76.7367", "name": "", "endpoint": "/proxy/protect/ws/updates?lastUpdateId=c262fd8c-5981-480c-9230-5446c60883da", "accessControllerNodeId": "cae7c947.782d68", "reconnectTimeout": 30000, "x": 980, "y": 520, "wires": [ [ "e74799e.e258868" ] ] }, { "id": "e74799e.e258868", "type": "debug", "z": "7b1a5e76.7367", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 1150, "y": 520, "wires": [] }, { "id": "ec36d6ec.a8f628", "type": "unifi-request", "z": "7b1a5e76.7367", "name": "", "accessControllerNodeId": "cae7c947.782d68", "endpoint": "/proxy/protect/api/bootstrap", "method": "GET", "data": "", "x": 580, "y": 520, "wires": [ [ "d4788d4e.41c06" ] ] }, { "id": "b22bc1ad.e535d", "type": "inject", "z": "7b1a5e76.7367", "name": "", "props": [], "repeat": "3600", "crontab": "", "once": true, "onceDelay": "1", "topic": "", "x": 430, "y": 520, "wires": [ [ "ec36d6ec.a8f628" ] ] }, { "id": "d4788d4e.41c06", "type": "function", "z": "7b1a5e76.7367", "name": "extract lastUpdateId", "func": "if (\"lastUpdateId\" in msg.payload) {\n return {\n payload: {\n endpoint: `/proxy/protect/ws/updates?lastUpdateId=${msg.payload.lastUpdateId}`\n }\n};\n}", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 780, "y": 520, "wires": [ [ "c253ea71.d21698" ] ] }, { "id": "cae7c947.782d68", "type": "unifi-access-controller", "name": "UDM PRO", "controllerIp": "192.168.1.1" } ] ```