node-red-contrib-unifi-ultimate 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +241 -150
- package/nodes/readme-assets/unifi-access-door-access.jpg +0 -0
- package/nodes/readme-assets/unifi-network-switching.jpg +0 -0
- package/nodes/readme-assets/unifi-protect-camera.png +0 -0
- package/nodes/unifi-access-config.html +68 -9
- package/nodes/unifi-access-config.js +22 -11
- package/nodes/unifi-access-device.html +290 -46
- package/nodes/unifi-access-device.js +175 -56
- package/nodes/unifi-network-config.html +71 -11
- package/nodes/unifi-network-config.js +1484 -7
- package/nodes/unifi-network-control-poe.html +750 -51
- package/nodes/unifi-network-control-poe.js +643 -78
- package/nodes/unifi-network-device.html +357 -55
- package/nodes/unifi-network-device.js +669 -76
- package/nodes/unifi-network-presence.html +337 -43
- package/nodes/unifi-network-presence.js +90 -34
- package/nodes/unifi-protect-config.html +68 -9
- package/nodes/unifi-protect-config.js +17 -10
- package/nodes/unifi-protect-device.html +300 -49
- package/nodes/unifi-protect-device.js +242 -63
- package/nodes/utils/unifi-access-device-registry.js +29 -18
- package/nodes/utils/unifi-network-device-registry.js +147 -29
- package/nodes/utils/unifi-protect-device-registry.js +319 -43
- package/package.json +7 -3
- package/scripts/discover-unifi-access-registry.js +24 -0
- package/scripts/discover-unifi-network-registry.js +26 -0
- package/scripts/discover-unifi-protect-registry.js +26 -0
- package/scripts/unifi-registry-discovery-common.js +1043 -0
package/README.md
CHANGED
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
<img src="nodes/icons/unifi-ultimate-logo.svg" alt="Unifi Ultimate" width="720">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
<p align="center">
|
|
6
|
-
<img src="nodes/icons/readme-overview.svg" alt="Overview of Node-RED UniFi Ultimate architecture" width="980">
|
|
7
|
-
</p>
|
|
8
|
-
|
|
9
5
|
[![NPM version][npm-version-image]][npm-url]
|
|
10
6
|
[![Node.js version][node-version-image]][npm-url]
|
|
11
7
|
[![Node-RED Flow Library][flows-image]][flows-url]
|
|
@@ -17,195 +13,290 @@
|
|
|
17
13
|
|
|
18
14
|
# node-red-contrib-unifi-ultimate
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
[View Changelog](CHANGELOG.md)
|
|
23
|
-
|
|
24
|
-
## At A Glance
|
|
16
|
+
Control and monitor `UniFi Network`, `UniFi Protect`, and `UniFi Access` from Node-RED without building API requests by hand.
|
|
25
17
|
|
|
26
|
-
|
|
27
|
-
- device-first UX: pick item, then only compatible actions are shown
|
|
28
|
-
- built-in live events for Protect and Access
|
|
29
|
-
- utility nodes for Network presence and PoE control
|
|
30
|
-
- import-ready example flows included
|
|
18
|
+
> **Beta notice:** until version `1.0.0`, this package should be considered **BETA** and may include **breaking changes** between releases.
|
|
31
19
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
- [Install](#install)
|
|
35
|
-
- [Quick Start](#quick-start)
|
|
36
|
-
- [Available Nodes](#available-nodes)
|
|
37
|
-
- [UniFi Protect](#unifi-protect)
|
|
38
|
-
- [UniFi Access](#unifi-access)
|
|
39
|
-
- [UniFi Network](#unifi-network)
|
|
40
|
-
- [Outputs](#outputs)
|
|
41
|
-
- [Example Flows](#example-flows)
|
|
42
|
-
- [Project Status](#project-status)
|
|
20
|
+
[View Changelog](CHANGELOG.md)
|
|
43
21
|
|
|
44
22
|
## Install
|
|
45
23
|
|
|
46
24
|
In Node-RED:
|
|
47
25
|
|
|
48
|
-
1. Open `Manage palette
|
|
49
|
-
2. Select `Install
|
|
50
|
-
3. Search for `node-red-contrib-unifi-ultimate
|
|
51
|
-
4. Install the package
|
|
26
|
+
1. Open `Manage palette`.
|
|
27
|
+
2. Select `Install`.
|
|
28
|
+
3. Search for `node-red-contrib-unifi-ultimate`.
|
|
29
|
+
4. Install the package.
|
|
52
30
|
|
|
53
31
|
## Quick Start
|
|
54
32
|
|
|
55
|
-
1. Add
|
|
56
|
-
2. Enter host and credentials
|
|
57
|
-
3. Add
|
|
58
|
-
4.
|
|
59
|
-
5.
|
|
60
|
-
6.
|
|
61
|
-
|
|
62
|
-
Output 2 for live events (when action is `Receive Events`)
|
|
63
|
-
|
|
64
|
-
If you want the fastest path, import one of the flows from `examples/` and replace credentials.
|
|
65
|
-
|
|
66
|
-
## Available Nodes
|
|
67
|
-
|
|
68
|
-
| Node | Purpose |
|
|
69
|
-
|---|---|
|
|
70
|
-
| `Unifi Protect Config` | stores UniFi Protect connection settings |
|
|
71
|
-
| `Unifi Protect Device` | reads state, receives events, and executes Protect actions |
|
|
72
|
-
| `Unifi Access Config` | stores UniFi Access connection settings |
|
|
73
|
-
| `Unifi Access Device` | reads state, receives events, and executes Access actions |
|
|
74
|
-
| `Unifi Network Config` | stores UniFi Network connection settings |
|
|
75
|
-
| `Unifi Network Device` | reads state/details and executes supported Network actions |
|
|
76
|
-
| `Unifi Network Presence` | emits stable `true/false` presence for one client |
|
|
77
|
-
| `Unifi Network Control POE` | enables/disables/cycles PoE on one switch port |
|
|
78
|
-
|
|
79
|
-
## UniFi Protect
|
|
80
|
-
|
|
81
|
-
Supported device types:
|
|
82
|
-
|
|
83
|
-
- `Camera`
|
|
84
|
-
- `Sensor`
|
|
85
|
-
- `Light`
|
|
86
|
-
- `Chime`
|
|
87
|
-
- `Viewer`
|
|
88
|
-
- `Live View`
|
|
89
|
-
- `NVR`
|
|
90
|
-
|
|
91
|
-
Common capabilities:
|
|
92
|
-
|
|
93
|
-
- `Receive Events`
|
|
94
|
-
- `Read Device State`
|
|
95
|
-
- `Send Raw Update`
|
|
96
|
-
|
|
97
|
-
Additional capabilities (when supported by selected device):
|
|
33
|
+
1. Add the config node for your UniFi application: `Unifi Network Config`, `Unifi Protect Config`, or `Unifi Access Config`.
|
|
34
|
+
2. Enter the UniFi host/IP and API credentials.
|
|
35
|
+
3. Add the matching device or utility node.
|
|
36
|
+
4. Select the item to control or monitor.
|
|
37
|
+
5. Select the action.
|
|
38
|
+
6. Deploy.
|
|
39
|
+
7. Send any message into the node to run the configured action.
|
|
98
40
|
|
|
99
|
-
|
|
100
|
-
- `List RTSPS Streams`
|
|
101
|
-
- `Create RTSPS Stream`
|
|
102
|
-
- `Delete RTSPS Stream`
|
|
103
|
-
- `Start Talkback Session`
|
|
104
|
-
- `Disable Microphone Permanently`
|
|
105
|
-
- `Start PTZ Patrol`
|
|
106
|
-
- `Stop PTZ Patrol`
|
|
107
|
-
- `Recall PTZ Preset`
|
|
108
|
-
- `Show Doorbell Message`
|
|
109
|
-
- `Switch Live View`
|
|
110
|
-
- `Update One Property`
|
|
111
|
-
- `Read Application Info` (NVR)
|
|
41
|
+
The incoming message is only a trigger. The node uses the item and action configured in the editor.
|
|
112
42
|
|
|
113
|
-
|
|
43
|
+
|
|
|
114
44
|
|
|
115
|
-
|
|
116
|
-
- camera observables: ring, motion, smart detections
|
|
117
|
-
- PTZ preset selector only on PTZ-capable cameras
|
|
118
|
-
- live view selector for viewers
|
|
119
|
-
- patchable property discovery from selected device
|
|
120
|
-
|
|
121
|
-
For supported observables, `msg.payload` can be normalized to `true/false`; raw context remains available in `msg.RAW`.
|
|
122
|
-
|
|
123
|
-
## UniFi Access
|
|
124
|
-
|
|
125
|
-
Supported device types:
|
|
126
|
-
|
|
127
|
-
- `Door`
|
|
128
|
-
- `Access Device`
|
|
45
|
+
## UniFi Network
|
|
129
46
|
|
|
130
|
-
|
|
47
|
+
<p align="center">
|
|
48
|
+
<a href="https://ui.com/switching">
|
|
49
|
+
<img src="nodes/readme-assets/unifi-network-switching.jpg" alt="UniFi Network switching" width="860">
|
|
50
|
+
</a>
|
|
51
|
+
</p>
|
|
131
52
|
|
|
132
|
-
|
|
133
|
-
- `Read State`
|
|
53
|
+
Use Network nodes to work with:
|
|
134
54
|
|
|
135
|
-
|
|
55
|
+
- sites
|
|
56
|
+
- UniFi devices such as switches and access points
|
|
57
|
+
- clients such as phones, computers, and IoT devices
|
|
58
|
+
- switch ports
|
|
59
|
+
- PoE control
|
|
60
|
+
- client presence
|
|
136
61
|
|
|
137
|
-
|
|
138
|
-
- `Read Lock Rule`
|
|
139
|
-
- `Set Temporary Lock Rule`
|
|
140
|
-
- `Read Emergency Mode`
|
|
141
|
-
- `Set Emergency Mode`
|
|
62
|
+
Common uses:
|
|
142
63
|
|
|
143
|
-
|
|
64
|
+
- Check whether a client is online.
|
|
65
|
+
- Restart a UniFi device.
|
|
66
|
+
- Power-cycle a PoE port.
|
|
67
|
+
- Turn PoE on or off for a selected switch port.
|
|
68
|
+
- Select a client and let the PoE node find the connected switch and port when the information is available.
|
|
144
69
|
|
|
145
|
-
|
|
146
|
-
- legacy unix `ended_time` fallback is still supported for compatibility
|
|
70
|
+
Editor conveniences:
|
|
147
71
|
|
|
148
|
-
|
|
72
|
+
- Device and client fields are searchable.
|
|
73
|
+
- Port lists show port status and connected clients when UniFi exposes that information.
|
|
74
|
+
- Selecting an item updates the node `Name` automatically.
|
|
149
75
|
|
|
150
|
-
|
|
151
|
-
- `Update Access Methods`
|
|
152
|
-
- `Trigger Doorbell`
|
|
153
|
-
- `Cancel Doorbell`
|
|
76
|
+
## UniFi Protect
|
|
154
77
|
|
|
155
|
-
|
|
78
|
+
<p align="center">
|
|
79
|
+
<a href="https://store.ui.com/us/en/products/uvc-g5-pro">
|
|
80
|
+
<img src="nodes/readme-assets/unifi-protect-camera.png" alt="UniFi Protect camera" width="520">
|
|
81
|
+
</a>
|
|
82
|
+
</p>
|
|
156
83
|
|
|
157
|
-
|
|
84
|
+
Use Protect nodes to work with:
|
|
158
85
|
|
|
159
|
-
|
|
86
|
+
- cameras
|
|
87
|
+
- sensors
|
|
88
|
+
- lights
|
|
89
|
+
- chimes
|
|
90
|
+
- viewers
|
|
91
|
+
- live views
|
|
92
|
+
- NVR information
|
|
160
93
|
|
|
161
|
-
|
|
162
|
-
- `UniFi Device`
|
|
163
|
-
- `Client`
|
|
94
|
+
Common uses:
|
|
164
95
|
|
|
165
|
-
|
|
96
|
+
- Receive motion, ring, contact, tamper, leak, and battery events.
|
|
97
|
+
- Read the current state of a camera or sensor.
|
|
98
|
+
- Take camera snapshots.
|
|
99
|
+
- Control PTZ cameras.
|
|
100
|
+
- Show doorbell messages.
|
|
101
|
+
- Switch viewer live views.
|
|
102
|
+
- Update supported device properties.
|
|
166
103
|
|
|
167
|
-
|
|
168
|
-
- `Read Details`
|
|
104
|
+
For supported observables, the node can output simple `true/false` values while still keeping the raw UniFi event details available.
|
|
169
105
|
|
|
170
|
-
|
|
106
|
+
## UniFi Access
|
|
171
107
|
|
|
172
|
-
|
|
173
|
-
-
|
|
174
|
-
-
|
|
108
|
+
<p align="center">
|
|
109
|
+
<a href="https://ui.com/door-access">
|
|
110
|
+
<img src="nodes/readme-assets/unifi-access-door-access.jpg" alt="UniFi Access door access" width="860">
|
|
111
|
+
</a>
|
|
112
|
+
</p>
|
|
175
113
|
|
|
176
|
-
|
|
114
|
+
Use Access nodes to work with:
|
|
177
115
|
|
|
178
|
-
-
|
|
179
|
-
-
|
|
116
|
+
- doors
|
|
117
|
+
- Access devices
|
|
118
|
+
- door events
|
|
119
|
+
- lock rules
|
|
120
|
+
- emergency mode
|
|
121
|
+
- doorbell actions
|
|
180
122
|
|
|
181
|
-
|
|
123
|
+
Common uses:
|
|
182
124
|
|
|
183
|
-
-
|
|
184
|
-
-
|
|
125
|
+
- Unlock a door.
|
|
126
|
+
- Read or set a temporary lock rule.
|
|
127
|
+
- Enable lockdown or evacuation mode.
|
|
128
|
+
- Receive Access events.
|
|
129
|
+
- Trigger or cancel an intercom doorbell action.
|
|
185
130
|
|
|
186
131
|
## Outputs
|
|
187
132
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
133
|
+
Most nodes send the result on output 1.
|
|
134
|
+
|
|
135
|
+
Protect and Access device nodes emit both state and live event messages on the same output pin when `Receive Events` is selected.
|
|
136
|
+
|
|
137
|
+
Useful metadata is attached to the output message, for example:
|
|
138
|
+
|
|
139
|
+
- `msg.topic` (node `Name` from the editor)
|
|
140
|
+
- `msg.deviceName` (remembered/observed client or device name)
|
|
141
|
+
- `msg.eventName` (event/trigger that produced the output message)
|
|
142
|
+
- `msg.details.unifiNetwork`
|
|
143
|
+
- `msg.details.unifiNetworkPresence`
|
|
144
|
+
- `msg.details.unifiNetworkPoe`
|
|
145
|
+
- `msg.details.unifiProtect`
|
|
146
|
+
- `msg.details.unifiAccess`
|
|
147
|
+
|
|
148
|
+
When `msg.payload` is an object, it also includes `payload.deviceName` with the same value.
|
|
149
|
+
|
|
150
|
+
## Output Examples
|
|
151
|
+
|
|
152
|
+
### Unifi Network Device
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"topic": "Switch Soffitta",
|
|
157
|
+
"deviceName": "Soffitta",
|
|
158
|
+
"eventName": "request:readState",
|
|
159
|
+
"payload": {
|
|
160
|
+
"id": "8c072de0-d71d-37bd-a6f5-eac67c95a314",
|
|
161
|
+
"name": "Soffitta",
|
|
162
|
+
"state": "READY",
|
|
163
|
+
"deviceName": "Soffitta"
|
|
164
|
+
},
|
|
165
|
+
"details": {
|
|
166
|
+
"unifiNetwork": {
|
|
167
|
+
"nodeType": "device",
|
|
168
|
+
"deviceType": "device",
|
|
169
|
+
"capability": "readState",
|
|
170
|
+
"source": "request"
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Unifi Network Presence
|
|
177
|
+
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"topic": "iPhone Massimo Presence",
|
|
181
|
+
"deviceName": "iPhone-Massimo",
|
|
182
|
+
"eventName": "connected",
|
|
183
|
+
"payload": true,
|
|
184
|
+
"present": true,
|
|
185
|
+
"details": {
|
|
186
|
+
"unifiNetworkPresence": {
|
|
187
|
+
"nodeType": "presence",
|
|
188
|
+
"source": "poll",
|
|
189
|
+
"reason": "connected"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Unifi Network Control POE
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"topic": "POE Soffitta Port 2",
|
|
200
|
+
"deviceName": "Soffitta",
|
|
201
|
+
"eventName": "request:enable",
|
|
202
|
+
"payload": {
|
|
203
|
+
"status": "ok",
|
|
204
|
+
"deviceName": "Soffitta",
|
|
205
|
+
"portIdx": 2,
|
|
206
|
+
"portName": "Port 2",
|
|
207
|
+
"portPowerW": 2.6,
|
|
208
|
+
"powerConsumptionSwitchTotal": 36.4
|
|
209
|
+
},
|
|
210
|
+
"details": {
|
|
211
|
+
"unifiNetworkPoe": {
|
|
212
|
+
"nodeType": "poe-control",
|
|
213
|
+
"action": "enable",
|
|
214
|
+
"portIdx": 2,
|
|
215
|
+
"portPowerW": 2.6,
|
|
216
|
+
"powerConsumptionSwitchTotal": 36.4
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Power fields for `Unifi Network Control POE`:
|
|
223
|
+
|
|
224
|
+
| Field | Type | Guaranteed | Notes |
|
|
225
|
+
| ------------------------------------------ | -------- | ---------- | --------------------------------------------------------------------- |
|
|
226
|
+
| `msg.payload.portIdx` | number | yes | Selected port index. |
|
|
227
|
+
| `msg.payload.portName` | string | yes | Selected port display name. |
|
|
228
|
+
| `msg.payload.portPowerW` | number | no | Current PoE power draw for the selected port (W), when UniFi exposes it. |
|
|
229
|
+
| `msg.payload.powerConsumptionSwitchTotal` | number | no | Sum of all port PoE consumptions on the switch (W), when available. |
|
|
230
|
+
| `msg.details.unifiNetworkPoe.portPowerW` | number | no | Same value as `msg.payload.portPowerW`. |
|
|
231
|
+
| `msg.details.unifiNetworkPoe.powerConsumptionSwitchTotal` | number | no | Same value as `msg.payload.powerConsumptionSwitchTotal`. |
|
|
232
|
+
|
|
233
|
+
### Unifi Protect Device
|
|
234
|
+
|
|
235
|
+
```json
|
|
236
|
+
{
|
|
237
|
+
"topic": "Front Door Camera",
|
|
238
|
+
"deviceName": "Front Door Camera",
|
|
239
|
+
"eventName": "smartDetectZone",
|
|
240
|
+
"payload": {
|
|
241
|
+
"device": {
|
|
242
|
+
"id": "camera-id"
|
|
243
|
+
},
|
|
244
|
+
"event": {
|
|
245
|
+
"type": "smartDetectZone"
|
|
246
|
+
},
|
|
247
|
+
"deviceName": "Front Door Camera"
|
|
248
|
+
},
|
|
249
|
+
"details": {
|
|
250
|
+
"unifiProtect": {
|
|
251
|
+
"nodeType": "device",
|
|
252
|
+
"deviceType": "camera",
|
|
253
|
+
"capability": "observe",
|
|
254
|
+
"source": "events"
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Unifi Access Device
|
|
261
|
+
|
|
262
|
+
```json
|
|
263
|
+
{
|
|
264
|
+
"topic": "Main Door",
|
|
265
|
+
"deviceName": "Main Door",
|
|
266
|
+
"eventName": "door.unlock",
|
|
267
|
+
"payload": {
|
|
268
|
+
"event": "door.unlock",
|
|
269
|
+
"deviceName": "Main Door"
|
|
270
|
+
},
|
|
271
|
+
"details": {
|
|
272
|
+
"unifiAccess": {
|
|
273
|
+
"nodeType": "device",
|
|
274
|
+
"deviceType": "door",
|
|
275
|
+
"capability": "observe",
|
|
276
|
+
"source": "events"
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
```
|
|
191
281
|
|
|
192
282
|
## Example Flows
|
|
193
283
|
|
|
194
284
|
Import from `examples/`:
|
|
195
285
|
|
|
196
|
-
| Flow file
|
|
197
|
-
|
|
198
|
-
| [examples/unifi-protect-info.json](examples/unifi-protect-info.json)
|
|
199
|
-
| [examples/unifi-protect-sensor-observe.json](examples/unifi-protect-sensor-observe.json)
|
|
200
|
-
| [examples/unifi-protect-camera-actions.json](examples/unifi-protect-camera-actions.json)
|
|
201
|
-
| [examples/unifi-access-door-control.json](examples/unifi-access-door-control.json)
|
|
202
|
-
| [examples/unifi-access-intercom-doorbell.json](examples/unifi-access-intercom-doorbell.json) |
|
|
286
|
+
| Flow file | What it demonstrates |
|
|
287
|
+
| -------------------------------------------------------------------------------------------- | ---------------------------------------------- |
|
|
288
|
+
| [examples/unifi-protect-info.json](examples/unifi-protect-info.json) | Read Protect camera state |
|
|
289
|
+
| [examples/unifi-protect-sensor-observe.json](examples/unifi-protect-sensor-observe.json) | Receive boolean sensor events |
|
|
290
|
+
| [examples/unifi-protect-camera-actions.json](examples/unifi-protect-camera-actions.json) | Snapshot, PTZ presets, and doorbell messages |
|
|
291
|
+
| [examples/unifi-access-door-control.json](examples/unifi-access-door-control.json) | Door state, unlock, and temporary lock rule |
|
|
292
|
+
| [examples/unifi-access-intercom-doorbell.json](examples/unifi-access-intercom-doorbell.json) | Intercom observe, trigger, and cancel doorbell |
|
|
203
293
|
|
|
204
|
-
##
|
|
294
|
+
## Notes
|
|
205
295
|
|
|
206
|
-
-
|
|
207
|
-
-
|
|
208
|
-
- UniFi
|
|
296
|
+
- You need valid API credentials for the UniFi application you want to use.
|
|
297
|
+
- Some actions depend on what the selected UniFi device supports.
|
|
298
|
+
- UniFi API behavior can vary between application versions.
|
|
299
|
+
- For safety, actions exposed by the nodes are intentionally limited to known supported operations.
|
|
209
300
|
|
|
210
301
|
[npm-version-image]: https://img.shields.io/npm/v/node-red-contrib-unifi-ultimate.svg
|
|
211
302
|
[npm-url]: https://www.npmjs.com/package/node-red-contrib-unifi-ultimate
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,11 +1,57 @@
|
|
|
1
1
|
<style>
|
|
2
|
+
.unifi-ultimate-hero {
|
|
3
|
+
margin: 0 0 14px 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.unifi-ultimate-hero-panel {
|
|
7
|
+
padding: 14px 16px;
|
|
8
|
+
border: 1px solid #d9e7f5;
|
|
9
|
+
border-radius: 14px;
|
|
10
|
+
background: linear-gradient(135deg, #eef7ff 0%, #f8fbff 58%, #f7fafc 100%);
|
|
11
|
+
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
|
|
12
|
+
color: #334155;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.unifi-ultimate-eyebrow {
|
|
16
|
+
margin-bottom: 4px;
|
|
17
|
+
color: #2563eb;
|
|
18
|
+
font-size: 11px;
|
|
19
|
+
font-weight: 700;
|
|
20
|
+
letter-spacing: 0.08em;
|
|
21
|
+
text-transform: uppercase;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.unifi-ultimate-hero-panel strong {
|
|
25
|
+
display: block;
|
|
26
|
+
color: #0f172a;
|
|
27
|
+
font-size: 15px;
|
|
28
|
+
line-height: 1.35;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.unifi-ultimate-hero-panel span {
|
|
32
|
+
display: block;
|
|
33
|
+
margin-top: 4px;
|
|
34
|
+
line-height: 1.45;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.unifi-ultimate-section-title {
|
|
38
|
+
margin: 14px 0 8px 150px;
|
|
39
|
+
color: #64748b;
|
|
40
|
+
font-size: 11px;
|
|
41
|
+
font-weight: 700;
|
|
42
|
+
letter-spacing: 0.08em;
|
|
43
|
+
text-transform: uppercase;
|
|
44
|
+
}
|
|
45
|
+
|
|
2
46
|
.unifi-ultimate-card {
|
|
3
47
|
margin-left: 150px;
|
|
4
|
-
padding:
|
|
5
|
-
border
|
|
6
|
-
|
|
48
|
+
padding: 13px 15px;
|
|
49
|
+
border: 1px solid #e2e8f0;
|
|
50
|
+
border-radius: 14px;
|
|
51
|
+
background: #f8fafc;
|
|
7
52
|
color: #334155;
|
|
8
53
|
line-height: 1.45;
|
|
54
|
+
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
|
9
55
|
}
|
|
10
56
|
|
|
11
57
|
.unifi-ultimate-card strong {
|
|
@@ -16,8 +62,8 @@
|
|
|
16
62
|
}
|
|
17
63
|
|
|
18
64
|
.unifi-ultimate-advanced {
|
|
19
|
-
margin-top:
|
|
20
|
-
padding-top:
|
|
65
|
+
margin-top: 14px;
|
|
66
|
+
padding-top: 10px;
|
|
21
67
|
border-top: 1px solid #e5e7eb;
|
|
22
68
|
}
|
|
23
69
|
|
|
@@ -89,6 +135,14 @@
|
|
|
89
135
|
</script>
|
|
90
136
|
|
|
91
137
|
<script type="text/html" data-template-name="unifi-access-config">
|
|
138
|
+
<div class="form-row unifi-ultimate-hero">
|
|
139
|
+
<div class="unifi-ultimate-hero-panel">
|
|
140
|
+
<div class="unifi-ultimate-eyebrow">UniFi Access Connection</div>
|
|
141
|
+
<strong>Connect Node-RED to your UniFi Access application.</strong>
|
|
142
|
+
<span>Use the Access host or IP address and an Access API token.</span>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
<div class="unifi-ultimate-section-title">Connection</div>
|
|
92
146
|
<div class="form-row">
|
|
93
147
|
<label for="node-config-input-host"><i class="fa fa-globe"></i> Controller</label>
|
|
94
148
|
<input type="text" id="node-config-input-host" placeholder="192.168.1.10 or access.local:12445">
|
|
@@ -107,16 +161,21 @@
|
|
|
107
161
|
</div>
|
|
108
162
|
<div id="node-config-row-advanced" class="unifi-ultimate-advanced">
|
|
109
163
|
<div class="form-row">
|
|
110
|
-
<label for="node-config-input-name"><i class="fa fa-tag"></i>
|
|
111
|
-
<input type="text" id="node-config-input-name" placeholder="
|
|
164
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
165
|
+
<input type="text" id="node-config-input-name" placeholder="Node name">
|
|
112
166
|
</div>
|
|
113
167
|
</div>
|
|
114
168
|
</script>
|
|
115
169
|
|
|
116
170
|
<script type="text/html" data-help-name="unifi-access-config">
|
|
117
|
-
<p>
|
|
171
|
+
<p>Shared connection for UniFi Access nodes.</p>
|
|
172
|
+
|
|
173
|
+
<h3>Configuration</h3>
|
|
118
174
|
<p><b>Controller</b> accepts the UniFi Access host or <code>host:port</code>. If you omit the port, the node uses the default UniFi Access port automatically.</p>
|
|
119
175
|
<p><b>API Token</b> is the bearer token used for authentication.</p>
|
|
120
176
|
<p><b>Security</b> controls certificate verification. Disable it only when your controller uses a self-signed certificate.</p>
|
|
121
|
-
<p><b>
|
|
177
|
+
<p><b>Name</b> is the config node name shown in the editor.</p>
|
|
178
|
+
|
|
179
|
+
<h3>Usage</h3>
|
|
180
|
+
<p>This config node is used by UniFi Access Device nodes for API requests and live notification events.</p>
|
|
122
181
|
</script>
|
|
@@ -512,7 +512,11 @@ module.exports = function(RED) {
|
|
|
512
512
|
node.doorbellLogPollCursor = Math.floor(Date.now() / 1000) - DOORBELL_LOG_POLL_LOOKBACK_SECONDS;
|
|
513
513
|
node.runDoorbellLogPoll();
|
|
514
514
|
node.doorbellLogPollTimer = setInterval(() => {
|
|
515
|
-
|
|
515
|
+
try {
|
|
516
|
+
node.runDoorbellLogPoll();
|
|
517
|
+
} catch (error) {
|
|
518
|
+
node.warn(`Access doorbell log poll timer failed: ${error && error.message ? error.message : error}`);
|
|
519
|
+
}
|
|
516
520
|
}, DOORBELL_LOG_POLL_INTERVAL_MS);
|
|
517
521
|
};
|
|
518
522
|
|
|
@@ -645,10 +649,13 @@ module.exports = function(RED) {
|
|
|
645
649
|
});
|
|
646
650
|
|
|
647
651
|
ws.on("close", () => {
|
|
648
|
-
|
|
649
|
-
node.wsNotifications
|
|
652
|
+
try {
|
|
653
|
+
if (node.wsNotifications === ws) {
|
|
654
|
+
node.wsNotifications = null;
|
|
655
|
+
}
|
|
656
|
+
node.scheduleReconnect();
|
|
657
|
+
} catch (error) {
|
|
650
658
|
}
|
|
651
|
-
node.scheduleReconnect();
|
|
652
659
|
});
|
|
653
660
|
|
|
654
661
|
ws.on("error", () => {
|
|
@@ -702,13 +709,17 @@ module.exports = function(RED) {
|
|
|
702
709
|
};
|
|
703
710
|
|
|
704
711
|
node.on("close", function(done) {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
+
try {
|
|
713
|
+
node.isClosing = true;
|
|
714
|
+
node.activeDoorbells.clear();
|
|
715
|
+
node.activeDoorbellRequests.clear();
|
|
716
|
+
node.closeWebSocket();
|
|
717
|
+
node.stopDoorbellLogPolling();
|
|
718
|
+
} catch (error) {
|
|
719
|
+
} finally {
|
|
720
|
+
if (typeof done === "function") {
|
|
721
|
+
done();
|
|
722
|
+
}
|
|
712
723
|
}
|
|
713
724
|
});
|
|
714
725
|
}
|