node-red-contrib-unifi-ultimate 1.1.15 → 1.1.16
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.
|
@@ -99,11 +99,13 @@
|
|
|
99
99
|
const $capabilityRow = $capability.closest(".form-row");
|
|
100
100
|
const $advancedRow = $("#node-row-advanced");
|
|
101
101
|
let capabilityConfig = parseCapabilityConfig(node.capabilityConfig);
|
|
102
|
+
let deviceListRequestId = 0;
|
|
102
103
|
let capabilityListRequestId = 0;
|
|
103
104
|
let capabilityOptionsRequestId = 0;
|
|
104
105
|
let suspendChangeHandling = false;
|
|
105
106
|
let isInitializingEditor = true;
|
|
106
107
|
let restoredPersistedAutoEmit = false;
|
|
108
|
+
let preserveSavedDeviceSelection = true;
|
|
107
109
|
let deviceTypeDefinitions = [];
|
|
108
110
|
let capabilityDefinitions = [];
|
|
109
111
|
|
|
@@ -568,6 +570,17 @@
|
|
|
568
570
|
$deviceName.val(selectedDeviceName);
|
|
569
571
|
}
|
|
570
572
|
|
|
573
|
+
function clearDeviceSelection() {
|
|
574
|
+
preserveSavedDeviceSelection = false;
|
|
575
|
+
deviceListRequestId += 1;
|
|
576
|
+
capabilityListRequestId += 1;
|
|
577
|
+
capabilityOptionsRequestId += 1;
|
|
578
|
+
$deviceName.val("");
|
|
579
|
+
renderDevices([]);
|
|
580
|
+
renderCapabilities([]);
|
|
581
|
+
renderCapabilityOptions({ fields: [] }, { clearStoredConfig: false });
|
|
582
|
+
}
|
|
583
|
+
|
|
571
584
|
function renderDeviceTypes(items) {
|
|
572
585
|
deviceTypeDefinitions = Array.isArray(items) ? items.slice() : [];
|
|
573
586
|
const currentValue = getCurrentOrNodeValue($deviceType, node.deviceType, "");
|
|
@@ -840,7 +853,8 @@
|
|
|
840
853
|
}
|
|
841
854
|
|
|
842
855
|
function renderDevices(items) {
|
|
843
|
-
const
|
|
856
|
+
const savedDeviceId = preserveSavedDeviceSelection ? node.deviceId : "";
|
|
857
|
+
const currentValue = getCurrentOrNodeValue($deviceId, savedDeviceId, "");
|
|
844
858
|
withSuppressedChanges(function () {
|
|
845
859
|
$deviceId.empty();
|
|
846
860
|
$deviceId.append($("<option></option>").val("").text("Choose a device"));
|
|
@@ -950,6 +964,7 @@
|
|
|
950
964
|
}
|
|
951
965
|
|
|
952
966
|
function loadDevices() {
|
|
967
|
+
const requestId = ++deviceListRequestId;
|
|
953
968
|
const serverId = $server.val();
|
|
954
969
|
const selectedType = getCurrentOrNodeValue($deviceType, node.deviceType, "");
|
|
955
970
|
if (!serverId || serverId === "_ADD_" || !selectedType) {
|
|
@@ -962,14 +977,22 @@
|
|
|
962
977
|
return requestJson(
|
|
963
978
|
"unifiAccess/devices?serverId=" + encodeURIComponent(serverId) + "&deviceType=" + encodeURIComponent(selectedType)
|
|
964
979
|
).then(function (data) {
|
|
980
|
+
if (requestId !== deviceListRequestId) {
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
965
983
|
renderDevices(Array.isArray(data) ? data : []);
|
|
966
984
|
}).catch(function (xhr) {
|
|
985
|
+
if (requestId !== deviceListRequestId) {
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
967
988
|
renderDevices([]);
|
|
968
989
|
renderCapabilityOptions({ fields: [] }, { clearStoredConfig: false });
|
|
969
990
|
const errorText = xhr && xhr.responseJSON && xhr.responseJSON.error ? xhr.responseJSON.error : "Unable to load devices";
|
|
970
991
|
RED.notify(errorText, "error");
|
|
971
992
|
}).finally(function () {
|
|
972
|
-
|
|
993
|
+
if (requestId === deviceListRequestId) {
|
|
994
|
+
$refresh.find("i").removeClass("fa-spin");
|
|
995
|
+
}
|
|
973
996
|
});
|
|
974
997
|
}
|
|
975
998
|
|
|
@@ -1049,12 +1072,16 @@
|
|
|
1049
1072
|
if (suspendChangeHandling || isInitializingEditor) {
|
|
1050
1073
|
return;
|
|
1051
1074
|
}
|
|
1075
|
+
clearDeviceSelection();
|
|
1076
|
+
capabilityConfig = {};
|
|
1077
|
+
writeCapabilityConfig();
|
|
1052
1078
|
refreshAfterServerChange();
|
|
1053
1079
|
});
|
|
1054
1080
|
$deviceType.on("change", function () {
|
|
1055
1081
|
if (suspendChangeHandling || isInitializingEditor) {
|
|
1056
1082
|
return;
|
|
1057
1083
|
}
|
|
1084
|
+
clearDeviceSelection();
|
|
1058
1085
|
capabilityConfig = {};
|
|
1059
1086
|
writeCapabilityConfig();
|
|
1060
1087
|
refreshAfterTypeChange();
|
|
@@ -1158,12 +1185,12 @@
|
|
|
1158
1185
|
|
|
1159
1186
|
<h3>Configuration</h3>
|
|
1160
1187
|
<p><b>Connection</b> selects the shared UniFi Access config node.</p>
|
|
1161
|
-
<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. A saved selection that is temporarily unavailable is preserved
|
|
1188
|
+
<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. A saved selection that is temporarily unavailable is preserved until <b>Connection</b> or <b>Control</b> changes.</p>
|
|
1162
1189
|
<p><b>Action</b> only shows actions supported by the selected item.</p>
|
|
1163
1190
|
<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>
|
|
1164
1191
|
<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>
|
|
1165
1192
|
<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>
|
|
1166
|
-
<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>
|
|
1193
|
+
<p><code>Trigger Doorbell</code> and <code>Cancel Doorbell</code> are shown only for Intercom and Reader Pro devices supported by the official Access API. They use a manual <code>Room Name</code> field when needed. The node does not currently discover Intercom directory names automatically.</p>
|
|
1167
1194
|
<p><code>Cancel Doorbell</code> only runs while the selected device has a tracked active ring. WebSocket events and <code>Trigger Doorbell</code> requests are tracked for up to 3 minutes, or until the call ends. A fallback system-log poller requires <code>view:system_log</code> permission and uses a shorter 25 second window when no live call is tracked; it does not shorten live tracking. Delayed logs cannot reactivate a completed call or clear a newer one.</p>
|
|
1168
1195
|
<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>
|
|
1169
1196
|
<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>
|
|
@@ -99,11 +99,13 @@
|
|
|
99
99
|
const $capabilityRow = $capability.closest(".form-row");
|
|
100
100
|
const $advancedRow = $("#node-row-advanced");
|
|
101
101
|
let capabilityConfig = parseCapabilityConfig(node.capabilityConfig);
|
|
102
|
+
let deviceListRequestId = 0;
|
|
102
103
|
let capabilityListRequestId = 0;
|
|
103
104
|
let capabilityOptionsRequestId = 0;
|
|
104
105
|
let suspendChangeHandling = false;
|
|
105
106
|
let isInitializingEditor = true;
|
|
106
107
|
let restoredPersistedAutoEmit = false;
|
|
108
|
+
let preserveSavedDeviceSelection = true;
|
|
107
109
|
let deviceTypeDefinitions = [];
|
|
108
110
|
let capabilityDefinitions = [];
|
|
109
111
|
|
|
@@ -557,6 +559,17 @@
|
|
|
557
559
|
$deviceName.val(selectedDeviceName);
|
|
558
560
|
}
|
|
559
561
|
|
|
562
|
+
function clearDeviceSelection() {
|
|
563
|
+
preserveSavedDeviceSelection = false;
|
|
564
|
+
deviceListRequestId += 1;
|
|
565
|
+
capabilityListRequestId += 1;
|
|
566
|
+
capabilityOptionsRequestId += 1;
|
|
567
|
+
$deviceName.val("");
|
|
568
|
+
renderDevices([]);
|
|
569
|
+
renderCapabilities([]);
|
|
570
|
+
renderCapabilityOptions({ fields: [] }, { clearStoredConfig: false });
|
|
571
|
+
}
|
|
572
|
+
|
|
560
573
|
function renderDeviceTypes(items) {
|
|
561
574
|
deviceTypeDefinitions = Array.isArray(items) ? items.slice() : [];
|
|
562
575
|
const currentValue = getCurrentOrNodeValue($deviceType, node.deviceType, "");
|
|
@@ -851,7 +864,8 @@
|
|
|
851
864
|
}
|
|
852
865
|
|
|
853
866
|
function renderDevices(items) {
|
|
854
|
-
const
|
|
867
|
+
const savedDeviceId = preserveSavedDeviceSelection ? node.deviceId : "";
|
|
868
|
+
const currentValue = getCurrentOrNodeValue($deviceId, savedDeviceId, "");
|
|
855
869
|
withSuppressedChanges(function () {
|
|
856
870
|
$deviceId.empty();
|
|
857
871
|
$deviceId.append($("<option></option>").val("").text("Choose a device"));
|
|
@@ -961,6 +975,7 @@
|
|
|
961
975
|
}
|
|
962
976
|
|
|
963
977
|
function loadDevices() {
|
|
978
|
+
const requestId = ++deviceListRequestId;
|
|
964
979
|
const serverId = $server.val();
|
|
965
980
|
const selectedType = getCurrentOrNodeValue($deviceType, node.deviceType, "");
|
|
966
981
|
if (!serverId || serverId === "_ADD_" || !selectedType) {
|
|
@@ -973,14 +988,22 @@
|
|
|
973
988
|
return requestJson(
|
|
974
989
|
"unifiProtect/devices?serverId=" + encodeURIComponent(serverId) + "&deviceType=" + encodeURIComponent(selectedType)
|
|
975
990
|
).then(function (data) {
|
|
991
|
+
if (requestId !== deviceListRequestId) {
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
976
994
|
renderDevices(Array.isArray(data) ? data : []);
|
|
977
995
|
}).catch(function (xhr) {
|
|
996
|
+
if (requestId !== deviceListRequestId) {
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
978
999
|
renderDevices([]);
|
|
979
1000
|
renderCapabilityOptions({ fields: [] }, { clearStoredConfig: false });
|
|
980
1001
|
const errorText = xhr && xhr.responseJSON && xhr.responseJSON.error ? xhr.responseJSON.error : "Unable to load devices";
|
|
981
1002
|
RED.notify(errorText, "error");
|
|
982
1003
|
}).finally(function () {
|
|
983
|
-
|
|
1004
|
+
if (requestId === deviceListRequestId) {
|
|
1005
|
+
$refresh.find("i").removeClass("fa-spin");
|
|
1006
|
+
}
|
|
984
1007
|
});
|
|
985
1008
|
}
|
|
986
1009
|
|
|
@@ -1066,6 +1089,7 @@
|
|
|
1066
1089
|
if (suspendChangeHandling || isInitializingEditor) {
|
|
1067
1090
|
return;
|
|
1068
1091
|
}
|
|
1092
|
+
clearDeviceSelection();
|
|
1069
1093
|
capabilityConfig = {};
|
|
1070
1094
|
writeCapabilityConfig();
|
|
1071
1095
|
refreshAfterTypeChange();
|
|
@@ -1174,10 +1198,12 @@
|
|
|
1174
1198
|
<p>Additional fields appear only when the selected action needs extra input. For example, events, PTZ presets, live views, or discovered properties.</p>
|
|
1175
1199
|
<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 application/alarm actions on <code>NVR</code>.</p>
|
|
1176
1200
|
<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>
|
|
1177
|
-
<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>
|
|
1201
|
+
<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. <code>Trigger Alarm Hub Output</code> can toggle an output or set it on/off, with an optional delay and duration. Sound-test actions use a configured volume and never read control values from the incoming message.</p>
|
|
1178
1202
|
<p>Protect alarm arming is application-wide, so its actions are available under <code>NVR</code>, not on an individual Alarm Hub. Use <code>Read Arm Profiles</code>, <code>Select Arm Profile</code>, <code>Arm Alarm</code>, and <code>Disarm Alarm</code>. These endpoints require Protect's local Alarm Manager.</p>
|
|
1179
1203
|
<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>
|
|
1180
|
-
<p>For <code>Sensor</code>, <code>Camera</code>, and <code>
|
|
1204
|
+
<p>For <code>Sensor</code>, <code>Camera</code>, <code>Light</code>, <code>Key Fob</code>, <code>Relay</code>, and <code>Alarm Hub</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. <code>License Plate (LPR)</code> emits recognized plate text.</p>
|
|
1205
|
+
<p>For <code>Key Fob</code>, the event list includes <code>Arm (1)</code>, <code>Night (2)</code>, <code>Disarm (3)</code>, <code>Panic (4)</code>, <code>Left</code>, and <code>Right</code>. The two side buttons have no printed number. Selecting one emits <code>true</code> only for that button; the original <code>sensorButtonPressed</code> event remains available in <code>msg.details.raw</code>.</p>
|
|
1206
|
+
<p>The event list also covers the official Protect event families for NFC and fingerprint scans on supported cameras; vape, smoke/CO health, and button events on sensors; relay input changes; and Alarm Hub motion, entry, smoke, glass-break, emergency-button, tamper, relay, and battery events. Resource families without a granular official event type retain only <code>All</code>.</p>
|
|
1181
1207
|
<p>To read plates, select <code>Camera</code> → <code>Receive Events</code> → <code>License Plate (LPR)</code>. Use an LPR-capable camera and enable license plate recognition in Protect. Open the shared <b>Connection</b> and enter its optional <b>Local User</b> and <b>Local Password</b> for a local UniFi OS account that can view the camera's recordings. All Protect nodes using that connection share this account. The official event stream identifies license plate detections but does not include OCR text in its documented schema, so the node retrieves the matching event's metadata through Protect's local, unofficial events API. Compatibility of this lookup depends on the Protect version.</p>
|
|
1182
1208
|
<p>LPR emits the first available reading immediately, including low-confidence text, as a string such as <code>"AB123CD"</code> in <code>msg.payload</code>, with <code>msg.eventName = "licensePlate"</code>. Text already present in a live event bypasses any outstanding HTTP lookup. Otherwise the node starts looking for OCR as soon as a vehicle is detected, using a prepared local session without waiting for the live LPR classification or for the event to end. Only actual plate metadata is emitted.</p>
|
|
1183
1209
|
<p>After a detection/update, up to five follow-up reads look for missing or improved OCR, with delays of 150, 350, 750, 1500 and 3000 milliseconds between requests. Corrected text, additional plates and higher confidence for the same text produce another message. Identical readings and lower confidence for previously emitted text are suppressed. The first text still depends on when Protect makes OCR available; a later reading is not a guarantee of accuracy.</p>
|
|
@@ -591,7 +591,9 @@ function isDoorbellCapableAccessDevice(device) {
|
|
|
591
591
|
return true;
|
|
592
592
|
}
|
|
593
593
|
|
|
594
|
-
return /READER[^A-Z0-9]*PRO/.test(joined)
|
|
594
|
+
return /READER[^A-Z0-9]*PRO/.test(joined)
|
|
595
|
+
|| /UA[-_ ]?(?:G2|G3)[-_ ]?PRO/.test(joined)
|
|
596
|
+
|| /(?:^|\s)UA[-_ ]?PRO(?:\s|$)/.test(joined);
|
|
595
597
|
}
|
|
596
598
|
|
|
597
599
|
function normalizeObjectArray(value) {
|
|
@@ -197,6 +197,42 @@ const SENSOR_OBSERVABLE_DEFINITIONS = [
|
|
|
197
197
|
label: "Extreme values",
|
|
198
198
|
eventTypes: ["sensorExtremeValues"]
|
|
199
199
|
},
|
|
200
|
+
{
|
|
201
|
+
id: "vape",
|
|
202
|
+
label: "Vape detected",
|
|
203
|
+
eventTypes: ["sensorVape"]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
id: "button",
|
|
207
|
+
label: "Button pressed",
|
|
208
|
+
eventTypes: ["sensorButtonPressed"],
|
|
209
|
+
occurrence: true
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
id: "smokeBatteryLow",
|
|
213
|
+
label: "Smoke detector battery low",
|
|
214
|
+
eventTypes: ["sensorSmokeBatteryLow"]
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
id: "smokeNeedsCleaning",
|
|
218
|
+
label: "Smoke detector needs cleaning",
|
|
219
|
+
eventTypes: ["sensorSmokeNeedsCleaning"]
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
id: "smokeFault",
|
|
223
|
+
label: "Smoke detector fault",
|
|
224
|
+
eventTypes: ["sensorSmokeFault"]
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
id: "coFault",
|
|
228
|
+
label: "CO detector fault",
|
|
229
|
+
eventTypes: ["sensorCoFault"]
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
id: "smokeEndOfLife",
|
|
233
|
+
label: "Smoke detector end of life",
|
|
234
|
+
eventTypes: ["sensorSmokeEndOfLife"]
|
|
235
|
+
},
|
|
200
236
|
{
|
|
201
237
|
id: "temperature",
|
|
202
238
|
label: "Temperature",
|
|
@@ -254,6 +290,18 @@ const CAMERA_OBSERVABLE_DEFINITIONS = [
|
|
|
254
290
|
id: "smartDetectLoiterZone",
|
|
255
291
|
label: "Smart detect loiter",
|
|
256
292
|
eventTypes: ["smartDetectLoiterZone"]
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
id: "nfcCardScanned",
|
|
296
|
+
label: "NFC card scanned",
|
|
297
|
+
eventTypes: ["nfcCardScanned"],
|
|
298
|
+
occurrence: true
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
id: "fingerprintIdentified",
|
|
302
|
+
label: "Fingerprint identified",
|
|
303
|
+
eventTypes: ["fingerprintIdentified"],
|
|
304
|
+
occurrence: true
|
|
257
305
|
}
|
|
258
306
|
];
|
|
259
307
|
|
|
@@ -270,6 +318,98 @@ const LIGHT_OBSERVABLE_DEFINITIONS = [
|
|
|
270
318
|
}
|
|
271
319
|
];
|
|
272
320
|
|
|
321
|
+
const FOB_OBSERVABLE_DEFINITIONS = [
|
|
322
|
+
{
|
|
323
|
+
id: "arm",
|
|
324
|
+
label: "Arm (1)",
|
|
325
|
+
eventTypes: ["sensorButtonPressed"]
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
id: "night",
|
|
329
|
+
label: "Night (2)",
|
|
330
|
+
eventTypes: ["sensorButtonPressed"]
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
id: "disarm",
|
|
334
|
+
label: "Disarm (3)",
|
|
335
|
+
eventTypes: ["sensorButtonPressed"]
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
id: "panic",
|
|
339
|
+
label: "Panic (4)",
|
|
340
|
+
eventTypes: ["sensorButtonPressed"]
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
id: "left",
|
|
344
|
+
label: "Left",
|
|
345
|
+
eventTypes: ["sensorButtonPressed"]
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
id: "right",
|
|
349
|
+
label: "Right",
|
|
350
|
+
eventTypes: ["sensorButtonPressed"]
|
|
351
|
+
}
|
|
352
|
+
];
|
|
353
|
+
|
|
354
|
+
const RELAY_OBSERVABLE_DEFINITIONS = [
|
|
355
|
+
{
|
|
356
|
+
id: "inputChanged",
|
|
357
|
+
label: "Input changed",
|
|
358
|
+
eventTypes: ["relayInputChanged"]
|
|
359
|
+
}
|
|
360
|
+
];
|
|
361
|
+
|
|
362
|
+
const ALARM_HUB_OBSERVABLE_DEFINITIONS = [
|
|
363
|
+
{
|
|
364
|
+
id: "motion",
|
|
365
|
+
label: "Motion input",
|
|
366
|
+
eventTypes: ["alarmHubMotion"]
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
id: "entry",
|
|
370
|
+
label: "Entry open/closed",
|
|
371
|
+
eventTypes: ["alarmHubEntryOpened", "alarmHubEntryClosed"]
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
id: "smoke",
|
|
375
|
+
label: "Smoke input",
|
|
376
|
+
eventTypes: ["alarmHubSmoke"]
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
id: "glassBreak",
|
|
380
|
+
label: "Glass break input",
|
|
381
|
+
eventTypes: ["alarmHubGlassBreak"]
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
id: "emergencyButton",
|
|
385
|
+
label: "Emergency button",
|
|
386
|
+
eventTypes: ["alarmHubButtonPress"],
|
|
387
|
+
occurrence: true
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
id: "tamper",
|
|
391
|
+
label: "Tamper",
|
|
392
|
+
eventTypes: ["alarmHubTamper"]
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
id: "relaySwitched",
|
|
396
|
+
label: "Relay switched",
|
|
397
|
+
eventTypes: ["alarmHubRelaySwitched"],
|
|
398
|
+
occurrence: true
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
id: "batteryLow",
|
|
402
|
+
label: "Battery low",
|
|
403
|
+
eventTypes: ["alarmHubBatteryLow"]
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
id: "batteryConnected",
|
|
407
|
+
label: "Battery connected",
|
|
408
|
+
eventTypes: ["alarmHubBatteryConnected"],
|
|
409
|
+
occurrence: true
|
|
410
|
+
}
|
|
411
|
+
];
|
|
412
|
+
|
|
273
413
|
const ALL_OBSERVABLE_VALUE = "all";
|
|
274
414
|
const ALL_OBSERVABLE_OPTION = {
|
|
275
415
|
value: ALL_OBSERVABLE_VALUE,
|
|
@@ -651,7 +791,74 @@ const TYPE_CAPABILITIES = {
|
|
|
651
791
|
],
|
|
652
792
|
bridge: [],
|
|
653
793
|
linkStation: [],
|
|
654
|
-
alarmHub: [
|
|
794
|
+
alarmHub: [
|
|
795
|
+
{
|
|
796
|
+
id: "triggerAlarmHubOutput",
|
|
797
|
+
label: "Trigger Alarm Hub Output",
|
|
798
|
+
description: "Turn, toggle, or pulse an Alarm Hub output.",
|
|
799
|
+
method: "POST",
|
|
800
|
+
path: "/v1/alarm-hubs/:id/outputs/:outputId/trigger",
|
|
801
|
+
mode: "request",
|
|
802
|
+
ignoreInputPayload: true,
|
|
803
|
+
useConfiguredPayload: true,
|
|
804
|
+
editor: {
|
|
805
|
+
fields: [
|
|
806
|
+
{
|
|
807
|
+
id: "outputId",
|
|
808
|
+
label: "Output",
|
|
809
|
+
type: "select",
|
|
810
|
+
options: [
|
|
811
|
+
{ value: "0", label: "Output 0" },
|
|
812
|
+
{ value: "1", label: "Output 1" }
|
|
813
|
+
],
|
|
814
|
+
defaultValue: "0"
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
id: "state",
|
|
818
|
+
label: "State",
|
|
819
|
+
type: "select",
|
|
820
|
+
options: [
|
|
821
|
+
{ value: "toggle", label: "Toggle" },
|
|
822
|
+
{ value: "on", label: "On" },
|
|
823
|
+
{ value: "off", label: "Off" }
|
|
824
|
+
],
|
|
825
|
+
defaultValue: "toggle"
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
id: "delay",
|
|
829
|
+
label: "Delay (ms)",
|
|
830
|
+
type: "number",
|
|
831
|
+
defaultValue: 0,
|
|
832
|
+
min: 0
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
id: "duration",
|
|
836
|
+
label: "Duration (ms)",
|
|
837
|
+
type: "number",
|
|
838
|
+
defaultValue: 0,
|
|
839
|
+
min: 0
|
|
840
|
+
}
|
|
841
|
+
]
|
|
842
|
+
},
|
|
843
|
+
requestComposer: ({ capabilityConfig }) => {
|
|
844
|
+
const state = String(capabilityConfig.state || "toggle").trim().toLowerCase();
|
|
845
|
+
const payload = {
|
|
846
|
+
delay: parseConfiguredInteger(capabilityConfig.delay, 0, Number.MAX_SAFE_INTEGER, 0),
|
|
847
|
+
duration: parseConfiguredInteger(capabilityConfig.duration, 0, Number.MAX_SAFE_INTEGER, 0)
|
|
848
|
+
};
|
|
849
|
+
if (state === "on" || state === "off") {
|
|
850
|
+
payload.enable = state === "on";
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return {
|
|
854
|
+
params: {
|
|
855
|
+
outputId: parseConfiguredInteger(capabilityConfig.outputId, 0, 1, 0)
|
|
856
|
+
},
|
|
857
|
+
payload
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
],
|
|
655
862
|
fob: [],
|
|
656
863
|
relay: [
|
|
657
864
|
{
|
|
@@ -1713,7 +1920,10 @@ function getObservableDefinitions(deviceType) {
|
|
|
1713
1920
|
const definitionsByDeviceType = {
|
|
1714
1921
|
sensor: SENSOR_OBSERVABLE_DEFINITIONS,
|
|
1715
1922
|
camera: CAMERA_OBSERVABLE_DEFINITIONS,
|
|
1716
|
-
light: LIGHT_OBSERVABLE_DEFINITIONS
|
|
1923
|
+
light: LIGHT_OBSERVABLE_DEFINITIONS,
|
|
1924
|
+
fob: FOB_OBSERVABLE_DEFINITIONS,
|
|
1925
|
+
relay: RELAY_OBSERVABLE_DEFINITIONS,
|
|
1926
|
+
alarmHub: ALARM_HUB_OBSERVABLE_DEFINITIONS
|
|
1717
1927
|
};
|
|
1718
1928
|
|
|
1719
1929
|
return definitionsByDeviceType[String(deviceType || "").trim()] || [];
|
|
@@ -1942,6 +2152,18 @@ function resolveObservableEventValue(deviceType, event, observable, observableSc
|
|
|
1942
2152
|
return resolveLightObservableEventValue(event, observable);
|
|
1943
2153
|
}
|
|
1944
2154
|
|
|
2155
|
+
if (deviceType === "fob") {
|
|
2156
|
+
return resolveFobObservableEventValue(event, observable);
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
if (deviceType === "relay") {
|
|
2160
|
+
return resolveRelayObservableEventValue(event, observable);
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
if (deviceType === "alarmHub") {
|
|
2164
|
+
return resolveAlarmHubObservableEventValue(event, observable);
|
|
2165
|
+
}
|
|
2166
|
+
|
|
1945
2167
|
return { matched: false };
|
|
1946
2168
|
}
|
|
1947
2169
|
|
|
@@ -1970,6 +2192,13 @@ function resolveSensorObservableEventValue(event, observable) {
|
|
|
1970
2192
|
return { matched: false };
|
|
1971
2193
|
}
|
|
1972
2194
|
|
|
2195
|
+
if (definition.occurrence) {
|
|
2196
|
+
return {
|
|
2197
|
+
matched: true,
|
|
2198
|
+
value: true
|
|
2199
|
+
};
|
|
2200
|
+
}
|
|
2201
|
+
|
|
1973
2202
|
return {
|
|
1974
2203
|
matched: true,
|
|
1975
2204
|
value: event.end === null || event.end === undefined
|
|
@@ -1997,6 +2226,14 @@ function resolveCameraObservableEventValue(event, observable, observableScopeId)
|
|
|
1997
2226
|
};
|
|
1998
2227
|
}
|
|
1999
2228
|
|
|
2229
|
+
if (definition.occurrence) {
|
|
2230
|
+
return {
|
|
2231
|
+
matched: true,
|
|
2232
|
+
eventTypeMatched: true,
|
|
2233
|
+
value: true
|
|
2234
|
+
};
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2000
2237
|
const scopeDefinition = CAMERA_OBSERVABLE_SCOPE_DEFINITIONS[String(observable || "").trim()];
|
|
2001
2238
|
if (scopeDefinition) {
|
|
2002
2239
|
const configuredScopeId = normalizeScopeIdentifier(observableScopeId);
|
|
@@ -2035,6 +2272,84 @@ function resolveLightObservableEventValue(event, observable) {
|
|
|
2035
2272
|
return { matched: false };
|
|
2036
2273
|
}
|
|
2037
2274
|
|
|
2275
|
+
function resolveFobObservableEventValue(event, observable) {
|
|
2276
|
+
if (!event || typeof event !== "object") {
|
|
2277
|
+
return { matched: false };
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
const eventType = String(event.type || "").trim();
|
|
2281
|
+
if (eventType !== "sensorButtonPressed") {
|
|
2282
|
+
return { matched: false };
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
const button = String(firstDefinedValue(event, [
|
|
2286
|
+
"metadata.button.text",
|
|
2287
|
+
"metadata.button.value",
|
|
2288
|
+
"metadata.button.name",
|
|
2289
|
+
"button"
|
|
2290
|
+
]) || "").trim().toLowerCase();
|
|
2291
|
+
const selectedButton = String(observable || "").trim().toLowerCase();
|
|
2292
|
+
|
|
2293
|
+
if (!button || !selectedButton || button !== selectedButton) {
|
|
2294
|
+
return {
|
|
2295
|
+
matched: false,
|
|
2296
|
+
eventTypeMatched: true
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
return {
|
|
2301
|
+
matched: true,
|
|
2302
|
+
eventTypeMatched: true,
|
|
2303
|
+
value: true
|
|
2304
|
+
};
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
function resolveRelayObservableEventValue(event, observable) {
|
|
2308
|
+
if (!event || typeof event !== "object" || observable !== "inputChanged" || event.type !== "relayInputChanged") {
|
|
2309
|
+
return { matched: false };
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
const inputState = String(firstDefinedValue(event, [
|
|
2313
|
+
"metadata.inputState.text",
|
|
2314
|
+
"metadata.inputState.value",
|
|
2315
|
+
"inputState"
|
|
2316
|
+
]) || "").trim();
|
|
2317
|
+
|
|
2318
|
+
return {
|
|
2319
|
+
matched: true,
|
|
2320
|
+
eventTypeMatched: true,
|
|
2321
|
+
value: inputState === "circuitClosed"
|
|
2322
|
+
};
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
function resolveAlarmHubObservableEventValue(event, observable) {
|
|
2326
|
+
if (!event || typeof event !== "object") {
|
|
2327
|
+
return { matched: false };
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
const eventType = String(event.type || "").trim();
|
|
2331
|
+
if (observable === "entry") {
|
|
2332
|
+
if (eventType === "alarmHubEntryOpened") {
|
|
2333
|
+
return { matched: true, eventTypeMatched: true, value: true };
|
|
2334
|
+
}
|
|
2335
|
+
if (eventType === "alarmHubEntryClosed") {
|
|
2336
|
+
return { matched: true, eventTypeMatched: true, value: false };
|
|
2337
|
+
}
|
|
2338
|
+
return { matched: false };
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2341
|
+
const definition = ALARM_HUB_OBSERVABLE_DEFINITIONS.find((entry) => entry.id === observable);
|
|
2342
|
+
if (!definition || !definition.eventTypes.includes(eventType)) {
|
|
2343
|
+
return { matched: false };
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
return {
|
|
2347
|
+
matched: true,
|
|
2348
|
+
eventTypeMatched: true,
|
|
2349
|
+
value: definition.occurrence === true || event.end === null || event.end === undefined
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2038
2353
|
function normalizeBooleanState(value, fallbackValue) {
|
|
2039
2354
|
if (typeof value === "boolean") {
|
|
2040
2355
|
return value;
|
|
@@ -205,6 +205,16 @@ const OBSERVABLE_METADATA = {
|
|
|
205
205
|
label: "Smart Detect Loiter",
|
|
206
206
|
description: "True while a smart loitering detection event is active.",
|
|
207
207
|
source: "inferred"
|
|
208
|
+
},
|
|
209
|
+
nfcCardScanned: {
|
|
210
|
+
label: "NFC Card Scanned",
|
|
211
|
+
description: "Emits true when an NFC card is scanned at the camera device.",
|
|
212
|
+
source: "official"
|
|
213
|
+
},
|
|
214
|
+
fingerprintIdentified: {
|
|
215
|
+
label: "Fingerprint Identified",
|
|
216
|
+
description: "Emits true when a fingerprint is scanned at the camera device.",
|
|
217
|
+
source: "official"
|
|
208
218
|
}
|
|
209
219
|
},
|
|
210
220
|
sensor: {
|
|
@@ -248,6 +258,41 @@ const OBSERVABLE_METADATA = {
|
|
|
248
258
|
description: "True while the sensor is reporting an active extreme-values event.",
|
|
249
259
|
source: "official"
|
|
250
260
|
},
|
|
261
|
+
vape: {
|
|
262
|
+
label: "Vape Detected",
|
|
263
|
+
description: "True while the sensor is reporting a vape detection.",
|
|
264
|
+
source: "official"
|
|
265
|
+
},
|
|
266
|
+
button: {
|
|
267
|
+
label: "Button Pressed",
|
|
268
|
+
description: "Emits true when the sensor reports a button press.",
|
|
269
|
+
source: "official"
|
|
270
|
+
},
|
|
271
|
+
smokeBatteryLow: {
|
|
272
|
+
label: "Smoke Detector Battery Low",
|
|
273
|
+
description: "True while the smoke or CO detector reports that its internal battery needs replacement.",
|
|
274
|
+
source: "official"
|
|
275
|
+
},
|
|
276
|
+
smokeNeedsCleaning: {
|
|
277
|
+
label: "Smoke Detector Needs Cleaning",
|
|
278
|
+
description: "True while the smoke detector reports that cleaning is required.",
|
|
279
|
+
source: "official"
|
|
280
|
+
},
|
|
281
|
+
smokeFault: {
|
|
282
|
+
label: "Smoke Detector Fault",
|
|
283
|
+
description: "True while the smoke detector reports a fault.",
|
|
284
|
+
source: "official"
|
|
285
|
+
},
|
|
286
|
+
coFault: {
|
|
287
|
+
label: "CO Detector Fault",
|
|
288
|
+
description: "True while the carbon-monoxide detector reports a fault.",
|
|
289
|
+
source: "official"
|
|
290
|
+
},
|
|
291
|
+
smokeEndOfLife: {
|
|
292
|
+
label: "Smoke Detector End of Life",
|
|
293
|
+
description: "True when the smoke or CO detector reports the end of its service life.",
|
|
294
|
+
source: "official"
|
|
295
|
+
},
|
|
251
296
|
temperature: {
|
|
252
297
|
label: "Temperature",
|
|
253
298
|
description: "Current ambient temperature reported by the sensor.",
|
|
@@ -280,6 +325,92 @@ const OBSERVABLE_METADATA = {
|
|
|
280
325
|
description: "True when the light output is currently on.",
|
|
281
326
|
source: "inferred"
|
|
282
327
|
}
|
|
328
|
+
},
|
|
329
|
+
fob: {
|
|
330
|
+
arm: {
|
|
331
|
+
label: "Arm (1)",
|
|
332
|
+
description: "Emits true when the Key Fob Arm button is pressed.",
|
|
333
|
+
source: "official"
|
|
334
|
+
},
|
|
335
|
+
night: {
|
|
336
|
+
label: "Night (2)",
|
|
337
|
+
description: "Emits true when the Key Fob Night button is pressed.",
|
|
338
|
+
source: "official"
|
|
339
|
+
},
|
|
340
|
+
disarm: {
|
|
341
|
+
label: "Disarm (3)",
|
|
342
|
+
description: "Emits true when the Key Fob Disarm button is pressed.",
|
|
343
|
+
source: "official"
|
|
344
|
+
},
|
|
345
|
+
panic: {
|
|
346
|
+
label: "Panic (4)",
|
|
347
|
+
description: "Emits true when the Key Fob Panic button is pressed.",
|
|
348
|
+
source: "official"
|
|
349
|
+
},
|
|
350
|
+
left: {
|
|
351
|
+
label: "Left",
|
|
352
|
+
description: "Emits true when the Key Fob left side button is pressed.",
|
|
353
|
+
source: "official"
|
|
354
|
+
},
|
|
355
|
+
right: {
|
|
356
|
+
label: "Right",
|
|
357
|
+
description: "Emits true when the Key Fob right side button is pressed.",
|
|
358
|
+
source: "official"
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
relay: {
|
|
362
|
+
inputChanged: {
|
|
363
|
+
label: "Input Changed",
|
|
364
|
+
description: "Emits true when the relay input circuit closes and false when it opens.",
|
|
365
|
+
source: "official"
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
alarmHub: {
|
|
369
|
+
motion: {
|
|
370
|
+
label: "Motion Input",
|
|
371
|
+
description: "True while an Alarm Hub motion input is active.",
|
|
372
|
+
source: "official"
|
|
373
|
+
},
|
|
374
|
+
entry: {
|
|
375
|
+
label: "Entry Open/Closed",
|
|
376
|
+
description: "True when an Alarm Hub entry input opens and false when it closes.",
|
|
377
|
+
source: "official"
|
|
378
|
+
},
|
|
379
|
+
smoke: {
|
|
380
|
+
label: "Smoke Input",
|
|
381
|
+
description: "True while an Alarm Hub smoke input is active.",
|
|
382
|
+
source: "official"
|
|
383
|
+
},
|
|
384
|
+
glassBreak: {
|
|
385
|
+
label: "Glass Break Input",
|
|
386
|
+
description: "True while an Alarm Hub glass-break input is active.",
|
|
387
|
+
source: "official"
|
|
388
|
+
},
|
|
389
|
+
emergencyButton: {
|
|
390
|
+
label: "Emergency Button",
|
|
391
|
+
description: "Emits true when an Alarm Hub emergency button is pressed.",
|
|
392
|
+
source: "official"
|
|
393
|
+
},
|
|
394
|
+
tamper: {
|
|
395
|
+
label: "Tamper",
|
|
396
|
+
description: "True while an Alarm Hub input reports tampering.",
|
|
397
|
+
source: "official"
|
|
398
|
+
},
|
|
399
|
+
relaySwitched: {
|
|
400
|
+
label: "Relay Switched",
|
|
401
|
+
description: "Emits true when an Alarm Hub relay output is switched.",
|
|
402
|
+
source: "official"
|
|
403
|
+
},
|
|
404
|
+
batteryLow: {
|
|
405
|
+
label: "Battery Low",
|
|
406
|
+
description: "True while the Alarm Hub reports a low battery condition.",
|
|
407
|
+
source: "official"
|
|
408
|
+
},
|
|
409
|
+
batteryConnected: {
|
|
410
|
+
label: "Battery Connected",
|
|
411
|
+
description: "Emits true when an Alarm Hub battery is connected.",
|
|
412
|
+
source: "official"
|
|
413
|
+
}
|
|
283
414
|
}
|
|
284
415
|
};
|
|
285
416
|
|
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.16",
|
|
4
4
|
"description": "Node-RED nodes for Ubiquiti UniFi integrations, including UniFi Protect, UniFi Access, and UniFi Network.",
|
|
5
5
|
"files": [
|
|
6
6
|
"nodes/",
|
|
@@ -82,4 +82,4 @@
|
|
|
82
82
|
"bugs": {
|
|
83
83
|
"url": "https://github.com/Supergiovane/node-red-contrib-unifi-ultimate/issues"
|
|
84
84
|
}
|
|
85
|
-
}
|
|
85
|
+
}
|