node-red-contrib-unifi-ultimate 1.0.1 → 1.0.3
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 +59 -208
- package/nodes/unifi-access-config.html +4 -3
- package/nodes/unifi-access-device.html +77 -17
- package/nodes/unifi-access-device.js +79 -68
- package/nodes/unifi-network-config.html +15 -5
- package/nodes/unifi-network-config.js +288 -0
- package/nodes/unifi-network-control-poe.html +40 -22
- package/nodes/unifi-network-control-poe.js +13 -68
- package/nodes/unifi-network-device.html +113 -19
- package/nodes/unifi-network-device.js +437 -82
- package/nodes/unifi-network-presence.html +40 -21
- package/nodes/unifi-network-presence.js +18 -55
- package/nodes/unifi-protect-config.html +4 -3
- package/nodes/unifi-protect-device.html +77 -17
- package/nodes/unifi-protect-device.js +79 -68
- package/nodes/utils/common-utils.js +104 -0
- package/nodes/utils/unifi-network-device-registry.js +95 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
# node-red-contrib-unifi-ultimate
|
|
15
15
|
|
|
16
|
-
Control and monitor
|
|
16
|
+
Control and monitor your **UniFi Network**, **UniFi Protect**, and **UniFi Access** devices directly from Node-RED — no technical knowledge required.
|
|
17
17
|
|
|
18
18
|
[View Changelog](CHANGELOG.md)
|
|
19
19
|
|
|
@@ -41,16 +41,16 @@ In Node-RED:
|
|
|
41
41
|
|
|
42
42
|
## Quick Start
|
|
43
43
|
|
|
44
|
-
1. Add
|
|
45
|
-
2. Enter
|
|
46
|
-
3. Add the matching
|
|
47
|
-
4. Select the
|
|
44
|
+
1. Add a config node for your UniFi product: **Unifi Network Config**, **Unifi Protect Config**, or **Unifi Access Config**.
|
|
45
|
+
2. Enter your UniFi controller address and login credentials.
|
|
46
|
+
3. Add the matching node to your flow.
|
|
47
|
+
4. Select the device you want to control or monitor.
|
|
48
48
|
5. Select the action.
|
|
49
|
-
6. Deploy
|
|
50
|
-
7. Send any message into the node to run the
|
|
49
|
+
6. Click **Deploy**.
|
|
50
|
+
7. Send any message into the node to run the action.
|
|
51
51
|
|
|
52
|
-
For most actions, the incoming message is
|
|
53
|
-
|
|
52
|
+
> **Tip:** For most actions, the incoming message is just a trigger — the node uses the device and action you configured in the editor.
|
|
53
|
+
> The only exception is **Control POE** with the *POE controlled by incoming message* action: send `true` to turn PoE on and `false` to turn it off.
|
|
54
54
|
|
|
55
55
|
<br/>
|
|
56
56
|
<br/>
|
|
@@ -60,28 +60,24 @@ Exception: in `Unifi Network Control POE`, action `POE controlled by msg.payload
|
|
|
60
60
|
</a>
|
|
61
61
|
</p>
|
|
62
62
|
|
|
63
|
-
Use Network nodes to work with:
|
|
63
|
+
Use **Network** nodes to work with:
|
|
64
64
|
|
|
65
65
|
- sites
|
|
66
66
|
- UniFi devices such as switches and access points
|
|
67
|
-
- clients such as phones, computers, and IoT devices
|
|
68
|
-
- switch ports
|
|
69
|
-
-
|
|
70
|
-
- client presence
|
|
67
|
+
- connected clients such as phones, computers, and IoT devices
|
|
68
|
+
- switch ports and PoE control
|
|
69
|
+
- client presence detection
|
|
71
70
|
|
|
72
|
-
|
|
71
|
+
Things you can do:
|
|
73
72
|
|
|
74
|
-
- Check whether a
|
|
73
|
+
- Check whether a device or phone is connected to your network.
|
|
74
|
+
- Count how many clients are currently online.
|
|
75
|
+
- Create guest Wi-Fi vouchers.
|
|
76
|
+
- Read CPU usage, memory, and uptime from a switch or access point.
|
|
77
|
+
- Read the temperature of a switch (where supported).
|
|
75
78
|
- Restart a UniFi device.
|
|
76
|
-
- Power-cycle a PoE port.
|
|
77
|
-
-
|
|
78
|
-
- Select a client and let the PoE node find the connected switch and port when the information is available.
|
|
79
|
-
|
|
80
|
-
Editor conveniences:
|
|
81
|
-
|
|
82
|
-
- Device and client fields are searchable.
|
|
83
|
-
- Port lists show port status and connected clients when UniFi exposes that information.
|
|
84
|
-
- Selecting an item updates the node `Name` automatically.
|
|
79
|
+
- Power-cycle or turn on/off a PoE port.
|
|
80
|
+
- Let the PoE node automatically find which port a client is connected to.
|
|
85
81
|
|
|
86
82
|
<br/>
|
|
87
83
|
<br/>
|
|
@@ -91,27 +87,23 @@ Editor conveniences:
|
|
|
91
87
|
</a>
|
|
92
88
|
</p>
|
|
93
89
|
|
|
94
|
-
Use Protect nodes to work with:
|
|
90
|
+
Use **Protect** nodes to work with:
|
|
95
91
|
|
|
96
92
|
- cameras
|
|
97
|
-
- sensors
|
|
93
|
+
- sensors (motion, contact, temperature, humidity, leak)
|
|
98
94
|
- lights
|
|
99
95
|
- chimes
|
|
100
96
|
- viewers
|
|
101
|
-
-
|
|
102
|
-
- NVR information
|
|
97
|
+
- NVR
|
|
103
98
|
|
|
104
|
-
|
|
99
|
+
Things you can do:
|
|
105
100
|
|
|
106
|
-
- Receive motion, ring, contact, tamper, leak, and battery
|
|
101
|
+
- Receive motion, ring, contact, tamper, leak, and low-battery alerts.
|
|
107
102
|
- Read the current state of a camera or sensor.
|
|
108
|
-
- Take camera
|
|
109
|
-
- Control PTZ cameras.
|
|
110
|
-
-
|
|
111
|
-
- Switch viewer live
|
|
112
|
-
- Update supported device properties.
|
|
113
|
-
|
|
114
|
-
For supported observables, the node can output normalized values while still keeping the raw UniFi event details available (`true/false` for event states, numeric values for sensor metrics like temperature and humidity).
|
|
103
|
+
- Take a camera snapshot.
|
|
104
|
+
- Control PTZ cameras (move to preset, start/stop patrol).
|
|
105
|
+
- Display a custom message on a doorbell screen.
|
|
106
|
+
- Switch a viewer to a different live feed.
|
|
115
107
|
|
|
116
108
|
<br/>
|
|
117
109
|
<br/>
|
|
@@ -121,193 +113,52 @@ For supported observables, the node can output normalized values while still kee
|
|
|
121
113
|
</a>
|
|
122
114
|
</p>
|
|
123
115
|
|
|
124
|
-
Use Access nodes to work with:
|
|
116
|
+
Use **Access** nodes to work with:
|
|
125
117
|
|
|
126
118
|
- doors
|
|
127
|
-
- Access devices
|
|
128
|
-
- door events
|
|
129
|
-
- lock rules
|
|
130
|
-
- emergency mode
|
|
119
|
+
- Access devices (hubs, intercoms)
|
|
120
|
+
- door events (unlock, ring, DPS, emergency)
|
|
121
|
+
- lock rules and schedules
|
|
131
122
|
- doorbell actions
|
|
132
123
|
|
|
133
|
-
|
|
124
|
+
Things you can do:
|
|
134
125
|
|
|
135
|
-
- Unlock a door.
|
|
136
|
-
-
|
|
126
|
+
- Unlock a door remotely.
|
|
127
|
+
- Set a temporary unlock window with a custom duration.
|
|
137
128
|
- Enable lockdown or evacuation mode.
|
|
138
|
-
- Receive
|
|
139
|
-
- Trigger or cancel an intercom doorbell
|
|
129
|
+
- Receive door events in real time.
|
|
130
|
+
- Trigger or cancel an intercom doorbell.
|
|
140
131
|
|
|
141
132
|
## Outputs
|
|
142
133
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
- `msg.details.unifiNetwork`
|
|
154
|
-
- `msg.details.unifiNetworkPresence`
|
|
155
|
-
- `msg.details.unifiNetworkPoe`
|
|
156
|
-
- `msg.details.unifiProtect`
|
|
157
|
-
- `msg.details.unifiAccess`
|
|
158
|
-
|
|
159
|
-
When `msg.payload` is an object, it also includes `payload.deviceName` with the same value.
|
|
160
|
-
|
|
161
|
-
## Output Examples
|
|
162
|
-
|
|
163
|
-
### Unifi Network Device
|
|
164
|
-
|
|
165
|
-
```json
|
|
166
|
-
{
|
|
167
|
-
"topic": "Switch Soffitta",
|
|
168
|
-
"deviceName": "Soffitta",
|
|
169
|
-
"eventName": "request:readState",
|
|
170
|
-
"payload": {
|
|
171
|
-
"id": "8c072de0-d71d-37bd-a6f5-eac67c95a314",
|
|
172
|
-
"name": "Soffitta",
|
|
173
|
-
"state": "READY",
|
|
174
|
-
"deviceName": "Soffitta"
|
|
175
|
-
},
|
|
176
|
-
"details": {
|
|
177
|
-
"unifiNetwork": {
|
|
178
|
-
"nodeType": "device",
|
|
179
|
-
"deviceType": "device",
|
|
180
|
-
"capability": "readState",
|
|
181
|
-
"source": "request"
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### Unifi Network Presence
|
|
188
|
-
|
|
189
|
-
```json
|
|
190
|
-
{
|
|
191
|
-
"topic": "iPhone Massimo Presence",
|
|
192
|
-
"deviceName": "iPhone-Massimo",
|
|
193
|
-
"eventName": "connected",
|
|
194
|
-
"payload": true,
|
|
195
|
-
"present": true,
|
|
196
|
-
"details": {
|
|
197
|
-
"unifiNetworkPresence": {
|
|
198
|
-
"nodeType": "presence",
|
|
199
|
-
"source": "poll",
|
|
200
|
-
"reason": "connected"
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### Unifi Network Control POE
|
|
207
|
-
|
|
208
|
-
```json
|
|
209
|
-
{
|
|
210
|
-
"topic": "POE Soffitta Port 2",
|
|
211
|
-
"deviceName": "Soffitta",
|
|
212
|
-
"eventName": "request:enable",
|
|
213
|
-
"payload": {
|
|
214
|
-
"status": "ok",
|
|
215
|
-
"deviceName": "Soffitta",
|
|
216
|
-
"portIdx": 2,
|
|
217
|
-
"portName": "Port 2",
|
|
218
|
-
"portPowerW": 2.6,
|
|
219
|
-
"powerConsumptionSwitchTotal": 36.4
|
|
220
|
-
},
|
|
221
|
-
"details": {
|
|
222
|
-
"unifiNetworkPoe": {
|
|
223
|
-
"nodeType": "poe-control",
|
|
224
|
-
"action": "enable",
|
|
225
|
-
"portIdx": 2,
|
|
226
|
-
"portPowerW": 2.6,
|
|
227
|
-
"powerConsumptionSwitchTotal": 36.4
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
Power fields for `Unifi Network Control POE`:
|
|
234
|
-
|
|
235
|
-
| Field | Type | Guaranteed | Notes |
|
|
236
|
-
| --------------------------------------------------------- | ------ | ---------- | ------------------------------------------------------------------------ |
|
|
237
|
-
| `msg.payload.portIdx` | number | yes | Selected port index. |
|
|
238
|
-
| `msg.payload.portName` | string | yes | Selected port display name. |
|
|
239
|
-
| `msg.payload.portPowerW` | number | no | Current PoE power draw for the selected port (W), when UniFi exposes it. |
|
|
240
|
-
| `msg.payload.powerConsumptionSwitchTotal` | number | no | Sum of all port PoE consumptions on the switch (W), when available. |
|
|
241
|
-
| `msg.details.unifiNetworkPoe.portPowerW` | number | no | Same value as `msg.payload.portPowerW`. |
|
|
242
|
-
| `msg.details.unifiNetworkPoe.powerConsumptionSwitchTotal` | number | no | Same value as `msg.payload.powerConsumptionSwitchTotal`. |
|
|
243
|
-
|
|
244
|
-
### Unifi Protect Device
|
|
245
|
-
|
|
246
|
-
```json
|
|
247
|
-
{
|
|
248
|
-
"topic": "Front Door Camera",
|
|
249
|
-
"deviceName": "Front Door Camera",
|
|
250
|
-
"eventName": "smartDetectZone",
|
|
251
|
-
"payload": {
|
|
252
|
-
"device": {
|
|
253
|
-
"id": "camera-id"
|
|
254
|
-
},
|
|
255
|
-
"event": {
|
|
256
|
-
"type": "smartDetectZone"
|
|
257
|
-
},
|
|
258
|
-
"deviceName": "Front Door Camera"
|
|
259
|
-
},
|
|
260
|
-
"details": {
|
|
261
|
-
"unifiProtect": {
|
|
262
|
-
"nodeType": "device",
|
|
263
|
-
"deviceType": "camera",
|
|
264
|
-
"capability": "observe",
|
|
265
|
-
"source": "events"
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
### Unifi Access Device
|
|
272
|
-
|
|
273
|
-
```json
|
|
274
|
-
{
|
|
275
|
-
"topic": "Main Door",
|
|
276
|
-
"deviceName": "Main Door",
|
|
277
|
-
"eventName": "door.unlock",
|
|
278
|
-
"payload": {
|
|
279
|
-
"event": "door.unlock",
|
|
280
|
-
"deviceName": "Main Door"
|
|
281
|
-
},
|
|
282
|
-
"details": {
|
|
283
|
-
"unifiAccess": {
|
|
284
|
-
"nodeType": "device",
|
|
285
|
-
"deviceType": "door",
|
|
286
|
-
"capability": "observe",
|
|
287
|
-
"source": "events"
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
```
|
|
134
|
+
Every node has **two outputs**:
|
|
135
|
+
|
|
136
|
+
| Output | When it fires |
|
|
137
|
+
| ------ | ------------- |
|
|
138
|
+
| **1 — result** | The action completed successfully. The result is available in `msg.payload`. |
|
|
139
|
+
| **2 — error** | Something went wrong (connection problem, timeout, unsupported action). |
|
|
140
|
+
|
|
141
|
+
When an error occurs, the node status turns red and the error message comes out of the second output. Connect it to a **debug** node to see what happened, or wire it to any notification logic in your flow.
|
|
142
|
+
|
|
143
|
+
**Repeat periodically** — for read actions, you can tick *Emit periodically* in the node editor to have the node send the result automatically at a fixed interval, without needing an Inject node.
|
|
292
144
|
|
|
293
145
|
## Example Flows
|
|
294
146
|
|
|
295
147
|
Import from `examples/`:
|
|
296
148
|
|
|
297
|
-
| Flow file
|
|
298
|
-
|
|
|
299
|
-
| [examples/unifi-protect-info.json](examples/unifi-protect-info.json)
|
|
300
|
-
| [examples/unifi-protect-sensor-observe.json](examples/unifi-protect-sensor-observe.json)
|
|
301
|
-
| [examples/unifi-protect-camera-actions.json](examples/unifi-protect-camera-actions.json)
|
|
302
|
-
| [examples/unifi-access-door-control.json](examples/unifi-access-door-control.json)
|
|
303
|
-
| [examples/unifi-access-intercom-doorbell.json](examples/unifi-access-intercom-doorbell.json) | Intercom
|
|
149
|
+
| Flow file | What it demonstrates |
|
|
150
|
+
| --------- | -------------------- |
|
|
151
|
+
| [examples/unifi-protect-info.json](examples/unifi-protect-info.json) | Read the state of a Protect camera |
|
|
152
|
+
| [examples/unifi-protect-sensor-observe.json](examples/unifi-protect-sensor-observe.json) | Receive sensor events (motion, temperature, humidity, …) |
|
|
153
|
+
| [examples/unifi-protect-camera-actions.json](examples/unifi-protect-camera-actions.json) | Take snapshots, move PTZ, show doorbell messages |
|
|
154
|
+
| [examples/unifi-access-door-control.json](examples/unifi-access-door-control.json) | Door state, remote unlock, temporary lock rule |
|
|
155
|
+
| [examples/unifi-access-intercom-doorbell.json](examples/unifi-access-intercom-doorbell.json) | Intercom — receive ring, trigger and cancel doorbell |
|
|
304
156
|
|
|
305
157
|
## Notes
|
|
306
158
|
|
|
307
|
-
- You need valid
|
|
308
|
-
- Some actions
|
|
309
|
-
- UniFi
|
|
310
|
-
- For safety, actions exposed by the nodes are intentionally limited to known supported operations.
|
|
159
|
+
- You need valid login credentials for the UniFi application you want to use.
|
|
160
|
+
- Some actions are only available on specific device models.
|
|
161
|
+
- UniFi behavior can vary between application versions.
|
|
311
162
|
|
|
312
163
|
[npm-version-image]: https://img.shields.io/npm/v/node-red-contrib-unifi-ultimate.svg
|
|
313
164
|
[npm-url]: https://www.npmjs.com/package/node-red-contrib-unifi-ultimate
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
return this.name || this.host || "Unifi Access Config";
|
|
16
16
|
},
|
|
17
17
|
oneditprepare: function () {
|
|
18
|
-
const
|
|
18
|
+
const node = this;
|
|
19
|
+
const $hostInput = $("#node-config-input-host");
|
|
19
20
|
const $apiToken = $("#node-config-input-apiToken");
|
|
20
21
|
const $rejectUnauthorized = $("#node-config-input-rejectUnauthorized");
|
|
21
22
|
const $apiTokenRow = $apiToken.closest(".form-row");
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
const $advancedRow = $("#node-config-row-advanced");
|
|
24
25
|
|
|
25
26
|
function syncProgressiveRows() {
|
|
26
|
-
const hasHost = String($
|
|
27
|
+
const hasHost = String($hostInput.val() || node.host || "").trim() !== "";
|
|
27
28
|
$apiTokenRow.toggle(hasHost);
|
|
28
29
|
$securityRow.toggle(hasHost);
|
|
29
30
|
$advancedRow.toggle(hasHost);
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
|
|
39
40
|
syncProgressiveRows();
|
|
40
41
|
|
|
41
|
-
$
|
|
42
|
+
$hostInput.on("change input", function () {
|
|
42
43
|
syncProgressiveRows();
|
|
43
44
|
});
|
|
44
45
|
}
|
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
inputs: { value: 1 },
|
|
15
15
|
capability: { value: "observe", required: true },
|
|
16
16
|
capabilityConfig: { value: "{}" },
|
|
17
|
-
|
|
17
|
+
autoEmit: { value: false },
|
|
18
|
+
autoEmitInterval: { value: 60, validate: RED.validators.number() }
|
|
18
19
|
},
|
|
19
20
|
inputs: 1,
|
|
20
|
-
outputs:
|
|
21
|
+
outputs: 2,
|
|
21
22
|
icon: "unifi-u-logo-light-access.svg",
|
|
22
23
|
paletteLabel: "ACCESS",
|
|
23
|
-
outputLabels: ["result"],
|
|
24
|
+
outputLabels: ["result", "error"],
|
|
24
25
|
label: function () {
|
|
25
26
|
return this.name || this.deviceId || "Unifi Access";
|
|
26
27
|
},
|
|
@@ -28,8 +29,11 @@
|
|
|
28
29
|
const selectedCapabilityId = String($("#node-input-capability").val() || this.capability || "observe").trim();
|
|
29
30
|
const selectedCapabilityOpensStream = $("#node-input-capability option:selected").data("opens-stream") === true
|
|
30
31
|
|| $("#node-input-capability option:selected").attr("data-opens-stream") === "true";
|
|
32
|
+
const selectedCapabilityMethod = String($("#node-input-capability option:selected").data("method") || $("#node-input-capability option:selected").attr("data-method") || "").trim().toUpperCase();
|
|
33
|
+
const supportsPeriodicEmit = !selectedCapabilityOpensStream && (!selectedCapabilityMethod || selectedCapabilityMethod === "GET");
|
|
31
34
|
// Hide the input pin only when the selected action starts an event stream.
|
|
32
35
|
this.inputs = (selectedCapabilityOpensStream || selectedCapabilityId === "observe") ? 0 : 1;
|
|
36
|
+
this.autoEmit = supportsPeriodicEmit ? $("#node-input-autoEmit").is(":checked") : false;
|
|
33
37
|
|
|
34
38
|
const $capabilityConfig = $("#node-input-capabilityConfig");
|
|
35
39
|
const capabilityConfig = {};
|
|
@@ -85,6 +89,9 @@
|
|
|
85
89
|
const $capabilityConfig = $("#node-input-capabilityConfig");
|
|
86
90
|
const $capabilityConfigRow = $("#node-row-capabilityConfig");
|
|
87
91
|
const $capabilityConfigContainer = $("#node-input-capabilityConfigContainer");
|
|
92
|
+
const $autoEmit = $("#node-input-autoEmit");
|
|
93
|
+
const $autoEmitRow = $("#node-row-autoEmit");
|
|
94
|
+
const $autoEmitIntervalRow = $("#node-row-autoEmitInterval");
|
|
88
95
|
const $refresh = $("#node-input-refreshDevices");
|
|
89
96
|
const $deviceTypeRow = $deviceType.closest(".form-row");
|
|
90
97
|
const $deviceIdRow = $deviceId.closest(".form-row");
|
|
@@ -95,6 +102,7 @@
|
|
|
95
102
|
let capabilityOptionsRequestId = 0;
|
|
96
103
|
let suspendChangeHandling = false;
|
|
97
104
|
let isInitializingEditor = true;
|
|
105
|
+
let restoredPersistedAutoEmit = false;
|
|
98
106
|
let deviceTypeDefinitions = [];
|
|
99
107
|
let capabilityDefinitions = [];
|
|
100
108
|
|
|
@@ -109,12 +117,30 @@
|
|
|
109
117
|
const hasDevice = hasSelection($deviceId);
|
|
110
118
|
const hasCapability = hasSelection($capability);
|
|
111
119
|
const hasCapabilityFields = $capabilityConfigRow.data("has-fields") === true;
|
|
120
|
+
const capabilityDefinition = getSelectedCapabilityDefinition();
|
|
121
|
+
const capabilityMethod = String(capabilityDefinition && capabilityDefinition.method || "").trim().toUpperCase();
|
|
122
|
+
const supportsPeriodicEmit = capabilityDefinition
|
|
123
|
+
&& capabilityDefinition.opensEventStream !== true
|
|
124
|
+
&& (!capabilityMethod || capabilityMethod === "GET");
|
|
125
|
+
const showPeriodicEmit = Boolean(hasServer && hasDeviceType && hasDevice && hasCapability && supportsPeriodicEmit);
|
|
112
126
|
|
|
113
127
|
$deviceTypeRow.toggle(hasServer);
|
|
114
128
|
$deviceIdRow.toggle(hasServer && hasDeviceType);
|
|
115
129
|
$capabilityRow.toggle(hasServer && hasDeviceType && hasDevice);
|
|
116
130
|
$capabilityConfigRow.toggle(hasServer && hasDeviceType && hasDevice && hasCapability && hasCapabilityFields);
|
|
117
131
|
$advancedRow.toggle(hasServer && hasDeviceType && hasDevice && hasCapability);
|
|
132
|
+
$autoEmitRow.toggle(showPeriodicEmit);
|
|
133
|
+
$autoEmitIntervalRow.toggle(showPeriodicEmit && $autoEmit.is(":checked"));
|
|
134
|
+
|
|
135
|
+
if (showPeriodicEmit && !restoredPersistedAutoEmit) {
|
|
136
|
+
$autoEmit.prop("checked", node.autoEmit === true || node.autoEmit === "true");
|
|
137
|
+
restoredPersistedAutoEmit = true;
|
|
138
|
+
$autoEmitIntervalRow.toggle($autoEmit.is(":checked"));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (!showPeriodicEmit && !isInitializingEditor) {
|
|
142
|
+
$autoEmit.prop("checked", false);
|
|
143
|
+
}
|
|
118
144
|
}
|
|
119
145
|
|
|
120
146
|
function parseCapabilityConfig(rawValue) {
|
|
@@ -575,6 +601,7 @@
|
|
|
575
601
|
$capability.append(
|
|
576
602
|
$("<option></option>")
|
|
577
603
|
.val(item.id)
|
|
604
|
+
.attr("data-method", String(item.method || "").trim())
|
|
578
605
|
.attr("data-opens-stream", item.opensEventStream === true ? "true" : "false")
|
|
579
606
|
.text(item.label)
|
|
580
607
|
);
|
|
@@ -1032,6 +1059,9 @@
|
|
|
1032
1059
|
writeCapabilityConfig();
|
|
1033
1060
|
refreshAfterCapabilityChange();
|
|
1034
1061
|
});
|
|
1062
|
+
$autoEmit.on("change", function () {
|
|
1063
|
+
syncProgressiveRows();
|
|
1064
|
+
});
|
|
1035
1065
|
$refresh.on("click", function (event) {
|
|
1036
1066
|
event.preventDefault();
|
|
1037
1067
|
refreshAfterServerChange();
|
|
@@ -1084,9 +1114,15 @@
|
|
|
1084
1114
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
1085
1115
|
<input type="text" id="node-input-name" placeholder="Node name">
|
|
1086
1116
|
</div>
|
|
1087
|
-
<div class="form-row">
|
|
1088
|
-
<label for="node-input-
|
|
1089
|
-
<input type="
|
|
1117
|
+
<div class="form-row" id="node-row-autoEmit">
|
|
1118
|
+
<label for="node-input-autoEmit"><i class="fa fa-repeat"></i> Repeat</label>
|
|
1119
|
+
<input type="checkbox" id="node-input-autoEmit" style="display:inline-block; width:auto; vertical-align:top;">
|
|
1120
|
+
<span style="margin-left:8px;">Emit periodically</span>
|
|
1121
|
+
</div>
|
|
1122
|
+
<div class="form-row" id="node-row-autoEmitInterval">
|
|
1123
|
+
<label for="node-input-autoEmitInterval"><i class="fa fa-clock-o"></i> Every</label>
|
|
1124
|
+
<input type="number" id="node-input-autoEmitInterval" min="5" step="1" placeholder="60" style="width:120px;">
|
|
1125
|
+
<span style="margin-left:8px;">seconds</span>
|
|
1090
1126
|
</div>
|
|
1091
1127
|
</div>
|
|
1092
1128
|
</script>
|
|
@@ -1105,7 +1141,9 @@
|
|
|
1105
1141
|
<p><code>Receive Events</code> fetches the current state once and then subscribes to events provided by the shared UniFi Access config node. The config node maintains the official notifications WebSocket and fans out events to runtime nodes. In this mode, <code>All</code> emits every event for the selected device/door, while specific <code>Event</code> choices filter to official UniFi Access event families (for example doorbell, door unlock, DPS, emergency, schedule, and temporary unlock events). The input pin is hidden and listening starts automatically after deploy/restart.</p>
|
|
1106
1142
|
<p><code>Trigger Doorbell</code> and <code>Cancel Doorbell</code> use a manual <code>Room Name</code> field when needed. The node does not currently discover Intercom directory names automatically.</p>
|
|
1107
1143
|
<p><code>Cancel Doorbell</code> uses a shared safe-cancel guard in the UniFi Access config node with a 3 minute tracking window. Tracking is updated by websocket events and a fallback system-log poller.</p>
|
|
1108
|
-
<p><b>
|
|
1144
|
+
<p><b>Emit periodically</b> repeats read-only actions at the selected interval and sends each result to the flow. It is hidden for <code>Receive Events</code> and write actions.</p>
|
|
1145
|
+
<p>Request timeout is handled automatically by the node.</p>
|
|
1146
|
+
<p><b>Name</b> is the node name shown in the editor and is updated only when you manually select a different item from the list.</p>
|
|
1109
1147
|
|
|
1110
1148
|
<h3>Input</h3>
|
|
1111
1149
|
<ul>
|
|
@@ -1114,16 +1152,32 @@
|
|
|
1114
1152
|
<li>Input message properties are ignored by this node.</li>
|
|
1115
1153
|
</ul>
|
|
1116
1154
|
|
|
1117
|
-
<h3>
|
|
1118
|
-
<
|
|
1119
|
-
<
|
|
1120
|
-
<
|
|
1121
|
-
<
|
|
1122
|
-
<
|
|
1123
|
-
<
|
|
1124
|
-
<
|
|
1125
|
-
|
|
1126
|
-
|
|
1155
|
+
<h3>Outputs</h3>
|
|
1156
|
+
<dl class="message-properties">
|
|
1157
|
+
<dt>Output 1 — result</dt>
|
|
1158
|
+
<dd>Emits state and live event messages for the selected door or Access device. When <code>Receive Events</code> is active, both state and event messages use this pin.</dd>
|
|
1159
|
+
<dt class="optional">msg.topic</dt>
|
|
1160
|
+
<dd>Node name from the editor.</dd>
|
|
1161
|
+
<dt class="optional">msg.deviceName</dt>
|
|
1162
|
+
<dd>Remembered/observed name of the selected device.</dd>
|
|
1163
|
+
<dt class="optional">msg.eventName</dt>
|
|
1164
|
+
<dd>Trigger or event that produced the message.</dd>
|
|
1165
|
+
<dt class="optional">msg.details.unifiAccess</dt>
|
|
1166
|
+
<dd>Standardized metadata for the device and selected capability.</dd>
|
|
1167
|
+
<dt class="optional">msg.payload.skipped</dt>
|
|
1168
|
+
<dd><code>true</code> when <code>Cancel Doorbell</code> is blocked because no active ring is currently tracked.</dd>
|
|
1169
|
+
</dl>
|
|
1170
|
+
<dl class="message-properties">
|
|
1171
|
+
<dt>Output 2 — error</dt>
|
|
1172
|
+
<dd>Emitted when the action fails (API error, timeout, or configuration problem). The node status also turns red. Errors are additionally forwarded to any connected <code>catch</code> node.</dd>
|
|
1173
|
+
<dt class="optional">msg.payload</dt>
|
|
1174
|
+
<dd><code>null</code></dd>
|
|
1175
|
+
<dt class="optional">msg.topic</dt>
|
|
1176
|
+
<dd>Node name from the editor.</dd>
|
|
1177
|
+
<dt class="optional">msg.error.message</dt>
|
|
1178
|
+
<dd>Human-readable error description.</dd>
|
|
1179
|
+
</dl>
|
|
1180
|
+
<p>Example output (pin 1):</p>
|
|
1127
1181
|
<pre><code>{
|
|
1128
1182
|
"topic": "Main Door",
|
|
1129
1183
|
"deviceName": "Main Door",
|
|
@@ -1140,5 +1194,11 @@
|
|
|
1140
1194
|
"source": "events"
|
|
1141
1195
|
}
|
|
1142
1196
|
}
|
|
1197
|
+
}</code></pre>
|
|
1198
|
+
<p>Example output (pin 2 — error):</p>
|
|
1199
|
+
<pre><code>{
|
|
1200
|
+
"topic": "Main Door",
|
|
1201
|
+
"payload": null,
|
|
1202
|
+
"error": { "message": "Request timed out" }
|
|
1143
1203
|
}</code></pre>
|
|
1144
1204
|
</script>
|