node-red-contrib-unifi-ultimate 1.1.7 → 1.1.9
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
CHANGED
|
@@ -124,6 +124,7 @@ Things you can do:
|
|
|
124
124
|
- Switch a viewer to a different live feed.
|
|
125
125
|
- Monitor bridges, Link Stations, alarm hubs, key fobs, sirens, relays, and speakers.
|
|
126
126
|
- Play or stop a siren, control relay outputs, and test speaker or siren sound.
|
|
127
|
+
- Read and select Protect Arm Profiles, then arm or disarm the local Alarm Manager from the NVR control.
|
|
127
128
|
|
|
128
129
|
### Automatic KNX AI camera adapter
|
|
129
130
|
|
|
@@ -194,6 +194,20 @@ module.exports = function(RED) {
|
|
|
194
194
|
: [];
|
|
195
195
|
};
|
|
196
196
|
|
|
197
|
+
node.fetchArmProfiles = async () => {
|
|
198
|
+
const response = await node.apiRequest({
|
|
199
|
+
path: "/v1/arm-profiles",
|
|
200
|
+
method: "GET"
|
|
201
|
+
});
|
|
202
|
+
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
203
|
+
throw new Error(`Failed to load Protect arm profiles (${response.statusCode})`);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return Array.isArray(response.payload)
|
|
207
|
+
? response.payload
|
|
208
|
+
: [];
|
|
209
|
+
};
|
|
210
|
+
|
|
197
211
|
node.fetchCapabilityOptions = async (deviceType, deviceId, capabilityId, capabilityConfig) => {
|
|
198
212
|
const selectedDevice = deviceId
|
|
199
213
|
? await node.fetchDeviceByTypeAndId(deviceType, deviceId)
|
|
@@ -205,7 +219,8 @@ module.exports = function(RED) {
|
|
|
205
219
|
capabilityConfig,
|
|
206
220
|
fetchDevice: node.fetchDeviceByTypeAndId,
|
|
207
221
|
fetchDevices: node.fetchDevices,
|
|
208
|
-
fetchAssetFiles: node.fetchAssetFiles
|
|
222
|
+
fetchAssetFiles: node.fetchAssetFiles,
|
|
223
|
+
fetchArmProfiles: node.fetchArmProfiles
|
|
209
224
|
});
|
|
210
225
|
};
|
|
211
226
|
|
|
@@ -1163,9 +1163,10 @@
|
|
|
1163
1163
|
<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. A saved selection that is temporarily unavailable is preserved instead of being cleared.</p>
|
|
1164
1164
|
<p><b>Action</b> only shows actions supported by the selected device.</p>
|
|
1165
1165
|
<p>Additional fields appear only when the selected action needs extra input. For example, events, PTZ presets, live views, or discovered properties.</p>
|
|
1166
|
-
<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
|
|
1166
|
+
<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>
|
|
1167
1167
|
<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>
|
|
1168
1168
|
<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>
|
|
1169
|
+
<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>
|
|
1169
1170
|
<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>
|
|
1170
1171
|
<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>
|
|
1171
1172
|
<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>
|
|
@@ -567,6 +567,62 @@ const TYPE_CAPABILITIES = {
|
|
|
567
567
|
method: "GET",
|
|
568
568
|
path: "/v1/meta/info",
|
|
569
569
|
mode: "request"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
id: "getArmProfiles",
|
|
573
|
+
label: "Read Arm Profiles",
|
|
574
|
+
description: "Fetch the arm profiles configured in Protect's local Alarm Manager.",
|
|
575
|
+
method: "GET",
|
|
576
|
+
path: "/v1/arm-profiles",
|
|
577
|
+
mode: "request"
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
id: "setCurrentArmProfile",
|
|
581
|
+
label: "Select Arm Profile",
|
|
582
|
+
description: "Select the arm profile Protect will use the next time the alarm is armed.",
|
|
583
|
+
method: "PATCH",
|
|
584
|
+
path: "/v1/arm-profiles/settings",
|
|
585
|
+
mode: "request",
|
|
586
|
+
ignoreInputPayload: true,
|
|
587
|
+
useConfiguredPayload: true,
|
|
588
|
+
editor: {
|
|
589
|
+
fields: [
|
|
590
|
+
{
|
|
591
|
+
id: "armProfileId",
|
|
592
|
+
label: "Arm profile",
|
|
593
|
+
type: "select",
|
|
594
|
+
placeholder: "Select an arm profile"
|
|
595
|
+
}
|
|
596
|
+
]
|
|
597
|
+
},
|
|
598
|
+
requestComposer: ({ capabilityConfig }) => {
|
|
599
|
+
const armProfileId = String(capabilityConfig.armProfileId || "").trim();
|
|
600
|
+
if (!armProfileId) {
|
|
601
|
+
throw new Error("Select an arm profile before using this action.");
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
return {
|
|
605
|
+
payload: { armProfileId }
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
id: "enableArmAlarm",
|
|
611
|
+
label: "Arm Alarm",
|
|
612
|
+
description: "Arm Protect using the currently selected arm profile.",
|
|
613
|
+
method: "POST",
|
|
614
|
+
path: "/v1/arm-profiles/enable",
|
|
615
|
+
mode: "request",
|
|
616
|
+
ignoreInputPayload: true
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
id: "disableArmAlarm",
|
|
620
|
+
label: "Disarm Alarm",
|
|
621
|
+
description: "Disarm Protect's local Alarm Manager.",
|
|
622
|
+
method: "POST",
|
|
623
|
+
path: "/v1/arm-profiles/disable",
|
|
624
|
+
mode: "request",
|
|
625
|
+
ignoreInputPayload: true
|
|
570
626
|
}
|
|
571
627
|
],
|
|
572
628
|
bridge: [],
|
|
@@ -907,6 +963,24 @@ async function getCapabilityOptions(deviceType, capabilityId, context) {
|
|
|
907
963
|
};
|
|
908
964
|
}
|
|
909
965
|
|
|
966
|
+
if (deviceType === "nvr" && capabilityId === "setCurrentArmProfile") {
|
|
967
|
+
const armProfiles = context && typeof context.fetchArmProfiles === "function"
|
|
968
|
+
? await context.fetchArmProfiles()
|
|
969
|
+
: [];
|
|
970
|
+
const currentArmProfileId = firstDefinedValue(context && context.device, [
|
|
971
|
+
"armMode.armProfileId"
|
|
972
|
+
]);
|
|
973
|
+
return {
|
|
974
|
+
capabilityId,
|
|
975
|
+
fields: [buildArmProfileField(
|
|
976
|
+
armProfiles,
|
|
977
|
+
capability.editor.fields[0],
|
|
978
|
+
context && context.capabilityConfig,
|
|
979
|
+
currentArmProfileId
|
|
980
|
+
)]
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
|
|
910
984
|
if (deviceType === "camera" && capabilityId === "setDoorbellMessage") {
|
|
911
985
|
return buildDoorbellMessageFields(context, capability);
|
|
912
986
|
}
|
|
@@ -1025,6 +1099,36 @@ function buildLiveviewOptions(liveviews, allowEmpty, emptyLabel) {
|
|
|
1025
1099
|
return options;
|
|
1026
1100
|
}
|
|
1027
1101
|
|
|
1102
|
+
function buildArmProfileField(armProfiles, baseField, capabilityConfig, currentArmProfileId) {
|
|
1103
|
+
const profiles = Array.isArray(armProfiles) ? armProfiles : [];
|
|
1104
|
+
const options = profiles.map((profile) => ({
|
|
1105
|
+
value: String(profile && profile.id ? profile.id : ""),
|
|
1106
|
+
label: String((profile && profile.name) || (profile && profile.id) || "Arm profile")
|
|
1107
|
+
})).filter((option) => option.value);
|
|
1108
|
+
const discoveredProfileCount = options.length;
|
|
1109
|
+
const configuredId = String(
|
|
1110
|
+
normalizeObject(capabilityConfig).armProfileId
|
|
1111
|
+
|| currentArmProfileId
|
|
1112
|
+
|| ""
|
|
1113
|
+
).trim();
|
|
1114
|
+
|
|
1115
|
+
if (configuredId && !options.some((option) => option.value === configuredId)) {
|
|
1116
|
+
options.push({
|
|
1117
|
+
value: configuredId,
|
|
1118
|
+
label: `${configuredId} (saved; currently unavailable)`
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
return {
|
|
1123
|
+
...baseField,
|
|
1124
|
+
options,
|
|
1125
|
+
defaultValue: configuredId,
|
|
1126
|
+
helpText: discoveredProfileCount > 0
|
|
1127
|
+
? "The selected profile is stored in Protect and will be used by Arm Alarm."
|
|
1128
|
+
: "No arm profiles were returned. Arm profiles require Protect's local Alarm Manager."
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1028
1132
|
function isCapabilitySupportedForDevice(deviceType, capability, device) {
|
|
1029
1133
|
// Protect exposes one broad family of camera APIs, but not every camera
|
|
1030
1134
|
// model supports every feature. Filter those actions in the editor.
|
package/package.json
CHANGED