node-red-contrib-unifi-ultimate 1.1.1 → 1.1.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 +12 -0
- package/nodes/unifi-access-config.js +20 -4
- package/nodes/unifi-access-device.html +5 -3
- package/nodes/unifi-network-device.html +3 -2
- package/nodes/unifi-protect-device.html +4 -2
- package/nodes/utils/unifi-access-device-registry.js +100 -4
- package/nodes/utils/unifi-network-device-registry.js +48 -0
- package/nodes/utils/unifi-protect-device-registry.js +225 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -80,6 +80,9 @@ Things you can do:
|
|
|
80
80
|
- Check whether a device or phone is connected to your network.
|
|
81
81
|
- Re-send the current presence state at a fixed interval with the Presence node's **Resend** field (e.g. to keep a dashboard or home-automation system in sync).
|
|
82
82
|
- Count how many clients are currently online.
|
|
83
|
+
- List the site's configured networks, Wi-Fi broadcasts, and WAN interfaces.
|
|
84
|
+
- List VPN servers and site-to-site VPN tunnels.
|
|
85
|
+
- List existing guest Wi-Fi vouchers.
|
|
83
86
|
- Create guest Wi-Fi vouchers.
|
|
84
87
|
- Read CPU usage, memory, and uptime from a switch or access point.
|
|
85
88
|
- Read the temperature of a switch (where supported).
|
|
@@ -105,6 +108,9 @@ Use **Protect** nodes to work with:
|
|
|
105
108
|
- lights
|
|
106
109
|
- chimes
|
|
107
110
|
- viewers
|
|
111
|
+
- bridges and Link Stations
|
|
112
|
+
- alarm hubs and key fobs
|
|
113
|
+
- sirens, relays, and speakers
|
|
108
114
|
- NVR
|
|
109
115
|
|
|
110
116
|
Things you can do:
|
|
@@ -115,6 +121,8 @@ Things you can do:
|
|
|
115
121
|
- Control PTZ cameras (move to preset, start/stop patrol).
|
|
116
122
|
- Display a custom message on a doorbell screen.
|
|
117
123
|
- Switch a viewer to a different live feed.
|
|
124
|
+
- Monitor bridges, Link Stations, alarm hubs, key fobs, sirens, relays, and speakers.
|
|
125
|
+
- Play or stop a siren, control relay outputs, and test speaker or siren sound.
|
|
118
126
|
|
|
119
127
|
<br/>
|
|
120
128
|
<br/>
|
|
@@ -130,6 +138,8 @@ Use **Access** nodes to work with:
|
|
|
130
138
|
- Access devices (hubs, intercoms)
|
|
131
139
|
- door events (unlock, ring, DPS, emergency)
|
|
132
140
|
- lock rules and schedules
|
|
141
|
+
- visitors, access policies, holiday groups, and door groups
|
|
142
|
+
- recent system logs
|
|
133
143
|
- doorbell actions
|
|
134
144
|
|
|
135
145
|
Things you can do:
|
|
@@ -139,6 +149,8 @@ Things you can do:
|
|
|
139
149
|
- Enable lockdown or evacuation mode.
|
|
140
150
|
- Receive door events in real time.
|
|
141
151
|
- Trigger or cancel an intercom doorbell.
|
|
152
|
+
- Read visitors, access policies, schedules, holiday groups, and door groups.
|
|
153
|
+
- Inspect recent Access system-log entries and the door-group topology.
|
|
142
154
|
|
|
143
155
|
## Outputs
|
|
144
156
|
|
|
@@ -133,19 +133,35 @@ module.exports = function(RED) {
|
|
|
133
133
|
throw new Error(`Unsupported device type: ${deviceType}`);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
const listMethod = String(definition.listMethod || "GET").toUpperCase();
|
|
137
|
+
const listPayload = typeof definition.listPayload === "function"
|
|
138
|
+
? definition.listPayload()
|
|
139
|
+
: definition.listPayload;
|
|
136
140
|
const response = await node.apiRequest({
|
|
137
141
|
path: definition.listPath,
|
|
138
|
-
method:
|
|
142
|
+
method: listMethod,
|
|
139
143
|
// Some Access device inventories only refresh reliably when this
|
|
140
144
|
// query flag is present.
|
|
141
|
-
query:
|
|
145
|
+
query: {
|
|
146
|
+
...(definition.listQuery && typeof definition.listQuery === "object" ? definition.listQuery : {}),
|
|
147
|
+
...(deviceType === "device" ? { refresh: "true" } : {})
|
|
148
|
+
},
|
|
149
|
+
payload: listMethod === "GET" || listMethod === "HEAD" ? undefined : listPayload
|
|
142
150
|
});
|
|
143
151
|
|
|
144
152
|
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
145
153
|
throw new Error(`Failed to load ${deviceType} entries (${response.statusCode})`);
|
|
146
154
|
}
|
|
147
155
|
|
|
148
|
-
|
|
156
|
+
let collectionPayload = extractAccessData(response.payload);
|
|
157
|
+
if (definition.collectionPath) {
|
|
158
|
+
collectionPayload = String(definition.collectionPath)
|
|
159
|
+
.split(".")
|
|
160
|
+
.filter(Boolean)
|
|
161
|
+
.reduce((current, key) => current && typeof current === "object" ? current[key] : undefined, collectionPayload);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return normalizeAccessCollection(collectionPayload);
|
|
149
165
|
};
|
|
150
166
|
|
|
151
167
|
node.fetchDeviceByTypeAndId = async (deviceType, deviceId) => {
|
|
@@ -170,7 +186,7 @@ module.exports = function(RED) {
|
|
|
170
186
|
}
|
|
171
187
|
|
|
172
188
|
const items = await node.fetchDevices(deviceType);
|
|
173
|
-
return items.find((entry) => String(entry.id || "").trim() === String(deviceId || "").trim()) || null;
|
|
189
|
+
return items.find((entry) => String(entry.id || entry._id || "").trim() === String(deviceId || "").trim()) || null;
|
|
174
190
|
};
|
|
175
191
|
|
|
176
192
|
node.fetchCapabilityOptions = async (deviceType, deviceId, capabilityId, capabilityConfig) => {
|
|
@@ -1135,13 +1135,15 @@
|
|
|
1135
1135
|
|
|
1136
1136
|
<h3>Configuration</h3>
|
|
1137
1137
|
<p><b>Connection</b> selects the shared UniFi Access config node.</p>
|
|
1138
|
-
<p><b>Control</b> chooses the Access category. <b>Device</b> chooses the specific door or
|
|
1138
|
+
<p><b>Control</b> chooses the Access category. <b>Device</b> chooses the specific door, device, visitor, policy, schedule, holiday group, door group, or recent system-log entry. Selectors are searchable and open with the complete list before filtering.</p>
|
|
1139
1139
|
<p><b>Action</b> only shows actions supported by the selected item.</p>
|
|
1140
1140
|
<p>Additional fields appear only when the selected action needs extra input, such as a temporary lock rule or a room name for doorbell actions.</p>
|
|
1141
1141
|
<p>For <code>Set Temporary Lock Rule</code>, choose <code>Custom Duration</code> to reveal the minutes field. Legacy <code>ended_time</code> is still available only as fallback compatibility.</p>
|
|
1142
1142
|
<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>
|
|
1143
1143
|
<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>
|
|
1144
1144
|
<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>
|
|
1145
|
+
<p>Visitors support state reads and the official visitor-status event. Access policies, schedules, holiday groups, and door groups are read-only. <code>Read Door Group Topology</code> returns the complete hierarchy documented by Access.</p>
|
|
1146
|
+
<p><code>Recent System Log</code> lists entries from the previous 24 hours, up to the first 200 results. It is read-only and requires the token's <code>view:system_log</code> permission.</p>
|
|
1145
1147
|
<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>
|
|
1146
1148
|
<p>Request timeout is handled automatically by the node.</p>
|
|
1147
1149
|
<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>
|
|
@@ -1156,7 +1158,7 @@
|
|
|
1156
1158
|
<h3>Outputs</h3>
|
|
1157
1159
|
<dl class="message-properties">
|
|
1158
1160
|
<dt>Output 1 — result</dt>
|
|
1159
|
-
<dd>Emits state and live event messages for the selected
|
|
1161
|
+
<dd>Emits state and live event messages for the selected Access resource. When <code>Receive Events</code> is active, both state and event messages use this pin.</dd>
|
|
1160
1162
|
<dt class="optional">msg.topic</dt>
|
|
1161
1163
|
<dd>Node name from the editor.</dd>
|
|
1162
1164
|
<dt class="optional">msg.deviceName</dt>
|
|
@@ -1202,4 +1204,4 @@
|
|
|
1202
1204
|
"payload": null,
|
|
1203
1205
|
"error": { "message": "Request timed out" }
|
|
1204
1206
|
}</code></pre>
|
|
1205
|
-
</script>
|
|
1207
|
+
</script>
|
|
@@ -1267,8 +1267,9 @@
|
|
|
1267
1267
|
<p><b>Resource</b> chooses what you want to work with: Site, UniFi Device, or Client.</p>
|
|
1268
1268
|
<p><b>Item</b> chooses the specific site, device, or client. Device and client selectors are searchable and open with the complete list before filtering.</p>
|
|
1269
1269
|
<p><b>Action</b> only shows actions supported by the selected resource. Additional fields appear only when the selected action needs extra input.</p>
|
|
1270
|
-
<p>Action highlights include <code>Count Online Clients</code>, <code>Create Guest Voucher</code>, <code>Read CPU</code>, <code>Read Memory</code>, <code>Read Uptime</code>, <code>Read Temperatures</code>, <code>Is Client Online</code>, <code>Restart Device</code>, and <code>Power Cycle Port</code>.</p>
|
|
1270
|
+
<p>Action highlights include <code>Count Online Clients</code>, <code>List Networks</code>, <code>List Wi-Fi Broadcasts</code>, <code>List WAN Interfaces</code>, <code>List VPN Servers</code>, <code>List Site-to-Site VPN Tunnels</code>, <code>List Guest Vouchers</code>, <code>Create Guest Voucher</code>, <code>Read CPU</code>, <code>Read Memory</code>, <code>Read Uptime</code>, <code>Read Temperatures</code>, <code>Is Client Online</code>, <code>Restart Device</code>, and <code>Power Cycle Port</code>.</p>
|
|
1271
1271
|
<p><code>Read Application Info</code> is available on the <code>Site</code> resource type and returns Network application metadata.</p>
|
|
1272
|
+
<p>The site list actions return the full API collection in <code>msg.payload</code> for networks, Wi-Fi broadcasts, WAN interfaces, VPN servers, site-to-site VPN tunnels, or guest vouchers. These actions are read-only and can be repeated periodically.</p>
|
|
1272
1273
|
<p><code>Count Online Clients</code> emits the number of online clients as <code>msg.payload</code>. Full client details are available in <code>msg.details.clients</code> and <code>msg.details.onlineClients</code>.</p>
|
|
1273
1274
|
<p><code>Create Guest Voucher</code> emits the voucher code as <code>msg.payload</code> when one voucher is created, or an array of codes when more than one is created. Full voucher details are available in <code>msg.details.vouchers</code>.</p>
|
|
1274
1275
|
<p><code>Read CPU</code>, <code>Read Memory</code>, and <code>Read Uptime</code> emit a single number as <code>msg.payload</code>. Full statistics are available in <code>msg.details.statistics</code>.</p>
|
|
@@ -1338,4 +1339,4 @@
|
|
|
1338
1339
|
"payload": null,
|
|
1339
1340
|
"error": { "message": "Request timed out" }
|
|
1340
1341
|
}</code></pre>
|
|
1341
|
-
</script>
|
|
1342
|
+
</script>
|
|
@@ -1149,7 +1149,9 @@
|
|
|
1149
1149
|
<p><b>Control</b> chooses the Protect device category. <b>Device</b> chooses the specific item. Device selectors are searchable and open with the complete list before filtering.</p>
|
|
1150
1150
|
<p><b>Action</b> only shows actions supported by the selected device.</p>
|
|
1151
1151
|
<p>Additional fields appear only when the selected action needs extra input. For example, events, PTZ presets, live views, or discovered properties.</p>
|
|
1152
|
-
<p>Action highlights: <code>Receive Events</code>, <code>Read Device State</code>, <code>Take Snapshot</code>, <code>Show Doorbell Message</code>, and <code>Read Application Info</code> on <code>NVR</code>.</p>
|
|
1152
|
+
<p>Action highlights: <code>Receive Events</code>, <code>Read Device State</code>, <code>Take Snapshot</code>, <code>Show Doorbell Message</code>, siren play/stop/test, relay output control, speaker sound test, and <code>Read Application Info</code> on <code>NVR</code>.</p>
|
|
1153
|
+
<p>Protect resources include cameras, sensors, lights, chimes, viewers, live views, NVRs, bridges, Link Stations, alarm hubs, key fobs, relays, sirens, and speakers. The newer device families expose read state and events without the generic raw-update action.</p>
|
|
1154
|
+
<p><code>Play Siren</code> uses a duration in seconds. <code>Control Relay Output</code> requires an explicit output and on/off state; auto-off applies only when turning an output on. Sound-test actions use a configured volume and never read control values from the incoming message.</p>
|
|
1153
1155
|
<p><code>Receive Events</code> performs an initial fetch and then subscribes to streams managed by the shared Protect config node. The config node keeps websocket channels and forwards matching updates to runtime nodes. In this mode, the input pin is hidden and listening starts automatically after deploy/restart.</p>
|
|
1154
1156
|
<p>For <code>Sensor</code>, <code>Camera</code>, and <code>Light</code> observables, <code>All</code> emits every event for the selected device. Choosing a specific observable normalizes the main output to a derived value and keeps the original context in <code>msg.details.raw</code>. Event observables emit <code>true/false</code>; sensor metrics such as <code>Temperature</code>, <code>Humidity</code>, <code>Light Level</code>, and <code>Battery Level</code> emit numeric values.</p>
|
|
1155
1157
|
<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>
|
|
@@ -1217,4 +1219,4 @@
|
|
|
1217
1219
|
"payload": null,
|
|
1218
1220
|
"error": { "message": "Request timed out" }
|
|
1219
1221
|
}</code></pre>
|
|
1220
|
-
</script>
|
|
1222
|
+
</script>
|
|
@@ -12,6 +12,60 @@ const DEVICE_TYPE_DEFINITIONS = {
|
|
|
12
12
|
type: "device",
|
|
13
13
|
label: "Access Device",
|
|
14
14
|
listPath: "/api/v1/developer/devices"
|
|
15
|
+
},
|
|
16
|
+
visitor: {
|
|
17
|
+
type: "visitor",
|
|
18
|
+
label: "Visitor",
|
|
19
|
+
listPath: "/api/v1/developer/visitors",
|
|
20
|
+
detailPath: "/api/v1/developer/visitors/:id"
|
|
21
|
+
},
|
|
22
|
+
accessPolicy: {
|
|
23
|
+
type: "accessPolicy",
|
|
24
|
+
label: "Access Policy",
|
|
25
|
+
listPath: "/api/v1/developer/access_policies",
|
|
26
|
+
detailPath: "/api/v1/developer/access_policies/:id",
|
|
27
|
+
supportsEvents: false
|
|
28
|
+
},
|
|
29
|
+
schedule: {
|
|
30
|
+
type: "schedule",
|
|
31
|
+
label: "Schedule",
|
|
32
|
+
listPath: "/api/v1/developer/access_policies/schedules",
|
|
33
|
+
detailPath: "/api/v1/developer/access_policies/schedules/:id",
|
|
34
|
+
supportsEvents: false
|
|
35
|
+
},
|
|
36
|
+
holidayGroup: {
|
|
37
|
+
type: "holidayGroup",
|
|
38
|
+
label: "Holiday Group",
|
|
39
|
+
listPath: "/api/v1/developer/access_policies/holiday_groups",
|
|
40
|
+
detailPath: "/api/v1/developer/access_policies/holiday_groups/:id",
|
|
41
|
+
supportsEvents: false
|
|
42
|
+
},
|
|
43
|
+
doorGroup: {
|
|
44
|
+
type: "doorGroup",
|
|
45
|
+
label: "Door Group",
|
|
46
|
+
listPath: "/api/v1/developer/door_groups",
|
|
47
|
+
detailPath: "/api/v1/developer/door_groups/:id",
|
|
48
|
+
supportsEvents: false
|
|
49
|
+
},
|
|
50
|
+
systemLog: {
|
|
51
|
+
type: "systemLog",
|
|
52
|
+
label: "Recent System Log",
|
|
53
|
+
listPath: "/api/v1/developer/system/logs",
|
|
54
|
+
listMethod: "POST",
|
|
55
|
+
listQuery: {
|
|
56
|
+
page_size: 200,
|
|
57
|
+
page_num: 1
|
|
58
|
+
},
|
|
59
|
+
listPayload: () => {
|
|
60
|
+
const until = Math.floor(Date.now() / 1000);
|
|
61
|
+
return {
|
|
62
|
+
topic: "all",
|
|
63
|
+
since: Math.max(0, until - 86400),
|
|
64
|
+
until
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
collectionPath: "hits",
|
|
68
|
+
supportsEvents: false
|
|
15
69
|
}
|
|
16
70
|
};
|
|
17
71
|
|
|
@@ -309,7 +363,22 @@ const TYPE_CAPABILITIES = {
|
|
|
309
363
|
return { payload };
|
|
310
364
|
}
|
|
311
365
|
}
|
|
312
|
-
]
|
|
366
|
+
],
|
|
367
|
+
visitor: [],
|
|
368
|
+
accessPolicy: [],
|
|
369
|
+
schedule: [],
|
|
370
|
+
holidayGroup: [],
|
|
371
|
+
doorGroup: [
|
|
372
|
+
{
|
|
373
|
+
id: "readDoorGroupTopology",
|
|
374
|
+
label: "Read Door Group Topology",
|
|
375
|
+
description: "Fetch the complete building and door-group topology.",
|
|
376
|
+
method: "GET",
|
|
377
|
+
path: "/api/v1/developer/door_groups/topology",
|
|
378
|
+
mode: "request"
|
|
379
|
+
}
|
|
380
|
+
],
|
|
381
|
+
systemLog: []
|
|
313
382
|
};
|
|
314
383
|
|
|
315
384
|
function getDeviceTypes() {
|
|
@@ -329,6 +398,7 @@ function getCapabilitiesForType(deviceType, device) {
|
|
|
329
398
|
// Device-aware filtering keeps the editor clean, for example by only
|
|
330
399
|
// showing doorbell actions on hardware that can actually ring.
|
|
331
400
|
return COMMON_CAPABILITIES
|
|
401
|
+
.filter((capability) => capability.id !== "observe" || definition.supportsEvents !== false)
|
|
332
402
|
.concat(TYPE_CAPABILITIES[definition.type] || [])
|
|
333
403
|
.filter((capability) => isCapabilitySupportedForDevice(definition.type, capability, device))
|
|
334
404
|
.map((capability) => ({
|
|
@@ -527,7 +597,7 @@ function summarizeDevice(deviceType, device) {
|
|
|
527
597
|
// summary shape for the editor.
|
|
528
598
|
const normalizedType = String(deviceType || "").trim();
|
|
529
599
|
const item = device && typeof device === "object" ? device : {};
|
|
530
|
-
const id = String(item.id || "").trim();
|
|
600
|
+
const id = String(item.id || item._id || "").trim();
|
|
531
601
|
|
|
532
602
|
if (normalizedType === "door") {
|
|
533
603
|
const stateParts = [];
|
|
@@ -546,10 +616,36 @@ function summarizeDevice(deviceType, device) {
|
|
|
546
616
|
};
|
|
547
617
|
}
|
|
548
618
|
|
|
619
|
+
if (normalizedType === "visitor") {
|
|
620
|
+
const fullName = String(
|
|
621
|
+
item.full_name
|
|
622
|
+
|| [item.first_name, item.last_name].filter(Boolean).join(" ")
|
|
623
|
+
|| item.name
|
|
624
|
+
|| id
|
|
625
|
+
|| "Visitor"
|
|
626
|
+
).trim();
|
|
627
|
+
|
|
628
|
+
return {
|
|
629
|
+
id,
|
|
630
|
+
name: fullName,
|
|
631
|
+
state: String(item.status || item.visitor_status || item.end_time || "").trim(),
|
|
632
|
+
raw: item
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
if (normalizedType === "systemLog") {
|
|
637
|
+
return {
|
|
638
|
+
id,
|
|
639
|
+
name: String(item.event || item.topic || item.type || item.message || id || "System Log"),
|
|
640
|
+
state: String(item.created_at || item.create_time || item.timestamp || "").trim(),
|
|
641
|
+
raw: item
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
|
|
549
645
|
return {
|
|
550
646
|
id,
|
|
551
|
-
name: String(item.alias || item.name || id || "
|
|
552
|
-
state: String(item.type || "").trim(),
|
|
647
|
+
name: String(item.alias || item.name || item.full_name || id || "Access Item"),
|
|
648
|
+
state: String(item.type || item.status || item.is_default || "").trim(),
|
|
553
649
|
raw: item
|
|
554
650
|
};
|
|
555
651
|
}
|
|
@@ -94,6 +94,54 @@ const TYPE_CAPABILITIES = {
|
|
|
94
94
|
path: "/v1/sites/{siteId}/clients",
|
|
95
95
|
mode: "request"
|
|
96
96
|
},
|
|
97
|
+
{
|
|
98
|
+
id: "listSiteNetworks",
|
|
99
|
+
label: "List Networks",
|
|
100
|
+
description: "Fetch the networks configured for the selected site.",
|
|
101
|
+
method: "GET",
|
|
102
|
+
path: "/v1/sites/{siteId}/networks",
|
|
103
|
+
mode: "request"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: "listWifiBroadcasts",
|
|
107
|
+
label: "List Wi-Fi Broadcasts",
|
|
108
|
+
description: "Fetch the Wi-Fi broadcasts configured for the selected site.",
|
|
109
|
+
method: "GET",
|
|
110
|
+
path: "/v1/sites/{siteId}/wifi/broadcasts",
|
|
111
|
+
mode: "request"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: "listWanInterfaces",
|
|
115
|
+
label: "List WAN Interfaces",
|
|
116
|
+
description: "Fetch the WAN interfaces configured for the selected site.",
|
|
117
|
+
method: "GET",
|
|
118
|
+
path: "/v1/sites/{siteId}/wans",
|
|
119
|
+
mode: "request"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: "listVpnServers",
|
|
123
|
+
label: "List VPN Servers",
|
|
124
|
+
description: "Fetch the VPN servers configured for the selected site.",
|
|
125
|
+
method: "GET",
|
|
126
|
+
path: "/v1/sites/{siteId}/vpn/servers",
|
|
127
|
+
mode: "request"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
id: "listSiteToSiteVpnTunnels",
|
|
131
|
+
label: "List Site-to-Site VPN Tunnels",
|
|
132
|
+
description: "Fetch the site-to-site VPN tunnels configured for the selected site.",
|
|
133
|
+
method: "GET",
|
|
134
|
+
path: "/v1/sites/{siteId}/vpn/site-to-site-tunnels",
|
|
135
|
+
mode: "request"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: "listGuestVouchers",
|
|
139
|
+
label: "List Guest Vouchers",
|
|
140
|
+
description: "Fetch the Hotspot guest vouchers for the selected site.",
|
|
141
|
+
method: "GET",
|
|
142
|
+
path: "/v1/sites/{siteId}/hotspot/vouchers",
|
|
143
|
+
mode: "request"
|
|
144
|
+
},
|
|
97
145
|
{
|
|
98
146
|
id: "countOnlineClients",
|
|
99
147
|
label: "Count Online Clients",
|
|
@@ -61,6 +61,62 @@ const DEVICE_TYPE_DEFINITIONS = {
|
|
|
61
61
|
modelKey: "nvr",
|
|
62
62
|
listPath: "/v1/nvrs",
|
|
63
63
|
detailPath: "/v1/nvrs"
|
|
64
|
+
},
|
|
65
|
+
bridge: {
|
|
66
|
+
type: "bridge",
|
|
67
|
+
label: "Bridge",
|
|
68
|
+
modelKey: "bridge",
|
|
69
|
+
listPath: "/v1/bridges",
|
|
70
|
+
detailPath: "/v1/bridges/:id",
|
|
71
|
+
supportsRawUpdate: false
|
|
72
|
+
},
|
|
73
|
+
linkStation: {
|
|
74
|
+
type: "linkStation",
|
|
75
|
+
label: "Link Station",
|
|
76
|
+
modelKey: "linkstation",
|
|
77
|
+
listPath: "/v1/link-stations",
|
|
78
|
+
detailPath: "/v1/link-stations/:id",
|
|
79
|
+
supportsRawUpdate: false
|
|
80
|
+
},
|
|
81
|
+
alarmHub: {
|
|
82
|
+
type: "alarmHub",
|
|
83
|
+
label: "Alarm Hub",
|
|
84
|
+
modelKey: "linkstation",
|
|
85
|
+
listPath: "/v1/alarm-hubs",
|
|
86
|
+
detailPath: "/v1/alarm-hubs/:id",
|
|
87
|
+
supportsRawUpdate: false
|
|
88
|
+
},
|
|
89
|
+
fob: {
|
|
90
|
+
type: "fob",
|
|
91
|
+
label: "Key Fob",
|
|
92
|
+
modelKey: "fob",
|
|
93
|
+
listPath: "/v1/fobs",
|
|
94
|
+
detailPath: "/v1/fobs/:id",
|
|
95
|
+
supportsRawUpdate: false
|
|
96
|
+
},
|
|
97
|
+
relay: {
|
|
98
|
+
type: "relay",
|
|
99
|
+
label: "Relay",
|
|
100
|
+
modelKey: "relay",
|
|
101
|
+
listPath: "/v1/relays",
|
|
102
|
+
detailPath: "/v1/relays/:id",
|
|
103
|
+
supportsRawUpdate: false
|
|
104
|
+
},
|
|
105
|
+
siren: {
|
|
106
|
+
type: "siren",
|
|
107
|
+
label: "Siren",
|
|
108
|
+
modelKey: "siren",
|
|
109
|
+
listPath: "/v1/sirens",
|
|
110
|
+
detailPath: "/v1/sirens/:id",
|
|
111
|
+
supportsRawUpdate: false
|
|
112
|
+
},
|
|
113
|
+
speaker: {
|
|
114
|
+
type: "speaker",
|
|
115
|
+
label: "Speaker",
|
|
116
|
+
modelKey: "speaker",
|
|
117
|
+
listPath: "/v1/speakers",
|
|
118
|
+
detailPath: "/v1/speakers/:id",
|
|
119
|
+
supportsRawUpdate: false
|
|
64
120
|
}
|
|
65
121
|
};
|
|
66
122
|
|
|
@@ -512,6 +568,160 @@ const TYPE_CAPABILITIES = {
|
|
|
512
568
|
path: "/v1/meta/info",
|
|
513
569
|
mode: "request"
|
|
514
570
|
}
|
|
571
|
+
],
|
|
572
|
+
bridge: [],
|
|
573
|
+
linkStation: [],
|
|
574
|
+
alarmHub: [],
|
|
575
|
+
fob: [],
|
|
576
|
+
relay: [
|
|
577
|
+
{
|
|
578
|
+
id: "activateRelayOutput",
|
|
579
|
+
label: "Control Relay Output",
|
|
580
|
+
description: "Turn a relay output on or off, optionally with an automatic off pulse.",
|
|
581
|
+
method: "POST",
|
|
582
|
+
path: "/v1/relays/:id/outputs/:outputId/activate",
|
|
583
|
+
mode: "request",
|
|
584
|
+
ignoreInputPayload: true,
|
|
585
|
+
useConfiguredPayload: true,
|
|
586
|
+
editor: {
|
|
587
|
+
fields: [
|
|
588
|
+
{
|
|
589
|
+
id: "outputId",
|
|
590
|
+
label: "Output",
|
|
591
|
+
type: "select",
|
|
592
|
+
options: [
|
|
593
|
+
{ value: "0", label: "Output 0" },
|
|
594
|
+
{ value: "1", label: "Output 1" }
|
|
595
|
+
],
|
|
596
|
+
defaultValue: "0"
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
id: "state",
|
|
600
|
+
label: "State",
|
|
601
|
+
type: "select",
|
|
602
|
+
options: [
|
|
603
|
+
{ value: "on", label: "On" },
|
|
604
|
+
{ value: "off", label: "Off" }
|
|
605
|
+
],
|
|
606
|
+
defaultValue: "on"
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
id: "pulseDuration",
|
|
610
|
+
label: "Auto-off (ms)",
|
|
611
|
+
type: "number",
|
|
612
|
+
placeholder: "0",
|
|
613
|
+
defaultValue: 0,
|
|
614
|
+
helpText: "0 keeps the selected state until another command."
|
|
615
|
+
}
|
|
616
|
+
]
|
|
617
|
+
},
|
|
618
|
+
requestComposer: ({ capabilityConfig }) => {
|
|
619
|
+
const outputId = parseConfiguredInteger(capabilityConfig.outputId, 0, 1, 0);
|
|
620
|
+
const state = String(capabilityConfig.state || "on").trim().toLowerCase() === "off" ? "off" : "on";
|
|
621
|
+
const pulseDuration = parseConfiguredInteger(capabilityConfig.pulseDuration, 0, Number.MAX_SAFE_INTEGER, 0);
|
|
622
|
+
const payload = { state };
|
|
623
|
+
|
|
624
|
+
if (state === "on") {
|
|
625
|
+
payload.pulseDuration = pulseDuration;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
return {
|
|
629
|
+
params: { outputId },
|
|
630
|
+
payload
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
],
|
|
635
|
+
siren: [
|
|
636
|
+
{
|
|
637
|
+
id: "playSiren",
|
|
638
|
+
label: "Play Siren",
|
|
639
|
+
description: "Activate the siren for the configured duration.",
|
|
640
|
+
method: "POST",
|
|
641
|
+
path: "/v1/sirens/:id/play",
|
|
642
|
+
mode: "request",
|
|
643
|
+
ignoreInputPayload: true,
|
|
644
|
+
useConfiguredPayload: true,
|
|
645
|
+
editor: {
|
|
646
|
+
fields: [
|
|
647
|
+
{
|
|
648
|
+
id: "duration",
|
|
649
|
+
label: "Duration (seconds)",
|
|
650
|
+
type: "number",
|
|
651
|
+
placeholder: "5",
|
|
652
|
+
defaultValue: 5
|
|
653
|
+
}
|
|
654
|
+
]
|
|
655
|
+
},
|
|
656
|
+
requestComposer: ({ capabilityConfig }) => ({
|
|
657
|
+
payload: {
|
|
658
|
+
duration: parseConfiguredInteger(capabilityConfig.duration, 0, Number.MAX_SAFE_INTEGER, 5)
|
|
659
|
+
}
|
|
660
|
+
})
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
id: "stopSiren",
|
|
664
|
+
label: "Stop Siren",
|
|
665
|
+
description: "Stop an active siren.",
|
|
666
|
+
method: "POST",
|
|
667
|
+
path: "/v1/sirens/:id/stop",
|
|
668
|
+
mode: "request",
|
|
669
|
+
ignoreInputPayload: true
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
id: "testSirenSound",
|
|
673
|
+
label: "Test Siren Sound",
|
|
674
|
+
description: "Play the siren test sound at the configured volume.",
|
|
675
|
+
method: "POST",
|
|
676
|
+
path: "/v1/sirens/:id/test-sound",
|
|
677
|
+
mode: "request",
|
|
678
|
+
ignoreInputPayload: true,
|
|
679
|
+
useConfiguredPayload: true,
|
|
680
|
+
editor: {
|
|
681
|
+
fields: [
|
|
682
|
+
{
|
|
683
|
+
id: "volume",
|
|
684
|
+
label: "Volume",
|
|
685
|
+
type: "number",
|
|
686
|
+
placeholder: "1-100",
|
|
687
|
+
defaultValue: 50
|
|
688
|
+
}
|
|
689
|
+
]
|
|
690
|
+
},
|
|
691
|
+
requestComposer: ({ capabilityConfig }) => ({
|
|
692
|
+
payload: {
|
|
693
|
+
volume: parseConfiguredInteger(capabilityConfig.volume, 1, 100, 50)
|
|
694
|
+
}
|
|
695
|
+
})
|
|
696
|
+
}
|
|
697
|
+
],
|
|
698
|
+
speaker: [
|
|
699
|
+
{
|
|
700
|
+
id: "testSpeakerSound",
|
|
701
|
+
label: "Test Speaker Sound",
|
|
702
|
+
description: "Play the speaker test sound at the configured volume.",
|
|
703
|
+
method: "POST",
|
|
704
|
+
path: "/v1/speakers/:id/test-sound",
|
|
705
|
+
mode: "request",
|
|
706
|
+
ignoreInputPayload: true,
|
|
707
|
+
useConfiguredPayload: true,
|
|
708
|
+
editor: {
|
|
709
|
+
fields: [
|
|
710
|
+
{
|
|
711
|
+
id: "volume",
|
|
712
|
+
label: "Volume",
|
|
713
|
+
type: "number",
|
|
714
|
+
placeholder: "0-100",
|
|
715
|
+
defaultValue: 50
|
|
716
|
+
}
|
|
717
|
+
]
|
|
718
|
+
},
|
|
719
|
+
requestComposer: ({ capabilityConfig }) => ({
|
|
720
|
+
payload: {
|
|
721
|
+
volume: parseConfiguredInteger(capabilityConfig.volume, 0, 100, 50)
|
|
722
|
+
}
|
|
723
|
+
})
|
|
724
|
+
}
|
|
515
725
|
]
|
|
516
726
|
};
|
|
517
727
|
|
|
@@ -533,6 +743,7 @@ function getCapabilitiesForType(deviceType, device) {
|
|
|
533
743
|
// support, such as PTZ actions on non-PTZ cameras.
|
|
534
744
|
return COMMON_CAPABILITIES
|
|
535
745
|
.concat(TYPE_CAPABILITIES[definition.type] || [])
|
|
746
|
+
.filter((capability) => capability.id !== "patchSettings" || definition.supportsRawUpdate !== false)
|
|
536
747
|
.filter((capability) => isCapabilitySupportedForDevice(definition.type, capability, device))
|
|
537
748
|
.map((capability) => ({
|
|
538
749
|
...capability,
|
|
@@ -1319,6 +1530,20 @@ function parseConfiguredPropertyValue(value, valueType) {
|
|
|
1319
1530
|
return value;
|
|
1320
1531
|
}
|
|
1321
1532
|
|
|
1533
|
+
function parseConfiguredInteger(value, minimum, maximum, fallback) {
|
|
1534
|
+
const numeric = Number(value);
|
|
1535
|
+
if (!Number.isFinite(numeric)) {
|
|
1536
|
+
return fallback;
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
const integer = Math.trunc(numeric);
|
|
1540
|
+
if (integer < minimum || integer > maximum) {
|
|
1541
|
+
return fallback;
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
return integer;
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1322
1547
|
function buildDoorbellMessagePayload(capabilityConfig) {
|
|
1323
1548
|
const messageType = String(capabilityConfig.messageType || "").trim();
|
|
1324
1549
|
const payload = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-unifi-ultimate",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Node-RED nodes for Ubiquiti UniFi integrations, including UniFi Protect, UniFi Access, and UniFi Network.",
|
|
5
5
|
"files": [
|
|
6
6
|
"nodes/",
|
|
@@ -38,7 +38,11 @@
|
|
|
38
38
|
"ws": "8.20.0"
|
|
39
39
|
},
|
|
40
40
|
"license": "MIT",
|
|
41
|
-
"author":
|
|
41
|
+
"author": {
|
|
42
|
+
"name": "Massimo Saccani",
|
|
43
|
+
"email": "maxsupergiovane@icloud.com",
|
|
44
|
+
"url": "https://youtube.com/@maxsupervibe"
|
|
45
|
+
},
|
|
42
46
|
"homepage": "https://github.com/Supergiovane/node-red-contrib-unifi-ultimate",
|
|
43
47
|
"repository": {
|
|
44
48
|
"type": "git",
|