node-red-contrib-unifi-ultimate 1.0.0 → 1.0.2
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 +39 -8
- package/nodes/unifi-access-config.html +4 -3
- package/nodes/unifi-access-device.html +44 -6
- package/nodes/unifi-access-device.js +94 -6
- package/nodes/unifi-network-config.html +15 -5
- package/nodes/unifi-network-config.js +288 -0
- package/nodes/unifi-network-control-poe.html +2 -7
- package/nodes/unifi-network-control-poe.js +2 -1
- package/nodes/unifi-network-device.html +79 -7
- package/nodes/unifi-network-device.js +439 -19
- package/nodes/unifi-network-presence.html +2 -7
- package/nodes/unifi-network-presence.js +2 -1
- package/nodes/unifi-protect-config.html +4 -3
- package/nodes/unifi-protect-device.html +44 -6
- package/nodes/unifi-protect-device.js +82 -9
- package/nodes/utils/unifi-access-device-registry.js +142 -5
- package/nodes/utils/unifi-network-device-registry.js +95 -0
- package/nodes/utils/unifi-protect-device-registry.js +107 -3
- package/nodes/utils/unifi-protect-field-metadata.js +21 -1
- package/package.json +2 -2
|
@@ -138,6 +138,26 @@ const SENSOR_OBSERVABLE_DEFINITIONS = [
|
|
|
138
138
|
id: "extremeValues",
|
|
139
139
|
label: "Extreme values",
|
|
140
140
|
eventTypes: ["sensorExtremeValues"]
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: "temperature",
|
|
144
|
+
label: "Temperature",
|
|
145
|
+
eventTypes: []
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
id: "humidity",
|
|
149
|
+
label: "Humidity",
|
|
150
|
+
eventTypes: []
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
id: "lightLevel",
|
|
154
|
+
label: "Light level",
|
|
155
|
+
eventTypes: []
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
id: "batteryLevel",
|
|
159
|
+
label: "Battery level",
|
|
160
|
+
eventTypes: []
|
|
141
161
|
}
|
|
142
162
|
];
|
|
143
163
|
|
|
@@ -948,8 +968,8 @@ function buildAssetFileOptions(files) {
|
|
|
948
968
|
}
|
|
949
969
|
|
|
950
970
|
async function buildObservableFields(deviceType, context) {
|
|
951
|
-
// Observables let the generic "Receive Events" capability expose a
|
|
952
|
-
// boolean
|
|
971
|
+
// Observables let the generic "Receive Events" capability expose a typed
|
|
972
|
+
// value (boolean or number) tailored to the selected Protect device family.
|
|
953
973
|
const capabilityConfig = normalizeObject(context && context.capabilityConfig);
|
|
954
974
|
const observableOptions = getObservableOptions(deviceType);
|
|
955
975
|
const selectedObservable = resolveSelectedObservable(observableOptions, capabilityConfig.observable);
|
|
@@ -965,7 +985,7 @@ async function buildObservableFields(deviceType, context) {
|
|
|
965
985
|
? "Emit all events for the selected Protect device."
|
|
966
986
|
: selectedObservable
|
|
967
987
|
? buildObservableHelpText(deviceType, selectedObservable)
|
|
968
|
-
: "Select which
|
|
988
|
+
: "Select which observable value should be exposed on msg.payload."
|
|
969
989
|
}
|
|
970
990
|
];
|
|
971
991
|
|
|
@@ -1445,6 +1465,49 @@ function resolveSensorObservableState(sensor, observable, fallbackValue) {
|
|
|
1445
1465
|
"isExtremeValueDetected",
|
|
1446
1466
|
"extremeValueDetected",
|
|
1447
1467
|
"status.extremeValueDetected"
|
|
1468
|
+
]),
|
|
1469
|
+
temperature: () => firstDefinedValue(sensor, [
|
|
1470
|
+
"temperature",
|
|
1471
|
+
"status.temperature.value",
|
|
1472
|
+
"status.temperature",
|
|
1473
|
+
"stats.temperature.value",
|
|
1474
|
+
"stats.temperature",
|
|
1475
|
+
"environment.temperature",
|
|
1476
|
+
"sensorTemperature"
|
|
1477
|
+
]),
|
|
1478
|
+
humidity: () => firstDefinedValue(sensor, [
|
|
1479
|
+
"humidity",
|
|
1480
|
+
"status.humidity.value",
|
|
1481
|
+
"status.humidity",
|
|
1482
|
+
"stats.humidity.value",
|
|
1483
|
+
"stats.humidity",
|
|
1484
|
+
"environment.humidity",
|
|
1485
|
+
"sensorHumidity"
|
|
1486
|
+
]),
|
|
1487
|
+
lightLevel: () => firstDefinedValue(sensor, [
|
|
1488
|
+
"lightLevel",
|
|
1489
|
+
"light",
|
|
1490
|
+
"lux",
|
|
1491
|
+
"status.lightLevel",
|
|
1492
|
+
"status.light",
|
|
1493
|
+
"status.illuminance",
|
|
1494
|
+
"stats.lightLevel",
|
|
1495
|
+
"stats.light.value",
|
|
1496
|
+
"stats.light",
|
|
1497
|
+
"stats.illuminance.value",
|
|
1498
|
+
"stats.illuminance",
|
|
1499
|
+
"ambientLight"
|
|
1500
|
+
]),
|
|
1501
|
+
batteryLevel: () => firstDefinedValue(sensor, [
|
|
1502
|
+
"batteryLevel",
|
|
1503
|
+
"batteryPercentage",
|
|
1504
|
+
"batteryPercent",
|
|
1505
|
+
"battery.percentage",
|
|
1506
|
+
"batteryStatus.percentage",
|
|
1507
|
+
"status.batteryLevel",
|
|
1508
|
+
"status.batteryPercentage",
|
|
1509
|
+
"stats.battery.percentage",
|
|
1510
|
+
"stats.batteryLevel"
|
|
1448
1511
|
])
|
|
1449
1512
|
};
|
|
1450
1513
|
|
|
@@ -1456,6 +1519,10 @@ function resolveSensorObservableState(sensor, observable, fallbackValue) {
|
|
|
1456
1519
|
return fallbackValue;
|
|
1457
1520
|
}
|
|
1458
1521
|
|
|
1522
|
+
if (["temperature", "humidity", "lightLevel", "batteryLevel"].includes(observable)) {
|
|
1523
|
+
return normalizeNumericState(rawValue, fallbackValue);
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1459
1526
|
return normalizeBooleanState(rawValue, fallbackValue);
|
|
1460
1527
|
}
|
|
1461
1528
|
|
|
@@ -1623,6 +1690,43 @@ function normalizeBooleanState(value, fallbackValue) {
|
|
|
1623
1690
|
return fallbackValue;
|
|
1624
1691
|
}
|
|
1625
1692
|
|
|
1693
|
+
function normalizeNumericState(value, fallbackValue) {
|
|
1694
|
+
if (typeof value === "number") {
|
|
1695
|
+
return Number.isFinite(value)
|
|
1696
|
+
? value
|
|
1697
|
+
: fallbackValue;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
if (typeof value === "string") {
|
|
1701
|
+
const normalized = value.trim().replace(",", ".");
|
|
1702
|
+
const match = normalized.match(/-?\d+(\.\d+)?/);
|
|
1703
|
+
if (match) {
|
|
1704
|
+
const parsed = Number.parseFloat(match[0]);
|
|
1705
|
+
if (Number.isFinite(parsed)) {
|
|
1706
|
+
return parsed;
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
return fallbackValue;
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
1713
|
+
const nested = firstDefinedValue(value, [
|
|
1714
|
+
"value",
|
|
1715
|
+
"current",
|
|
1716
|
+
"reading",
|
|
1717
|
+
"level",
|
|
1718
|
+
"amount",
|
|
1719
|
+
"percent",
|
|
1720
|
+
"percentage"
|
|
1721
|
+
]);
|
|
1722
|
+
if (nested !== undefined) {
|
|
1723
|
+
return normalizeNumericState(nested, fallbackValue);
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
return fallbackValue;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1626
1730
|
async function buildCameraObservableScopeField(context, selectedObservable, capabilityConfig) {
|
|
1627
1731
|
const scopeDefinition = CAMERA_OBSERVABLE_SCOPE_DEFINITIONS[String(selectedObservable || "").trim()];
|
|
1628
1732
|
if (!scopeDefinition) {
|
|
@@ -168,7 +168,7 @@ const TYPE_FIELD_METADATA = {
|
|
|
168
168
|
};
|
|
169
169
|
|
|
170
170
|
// Observable metadata powers the "Receive Events" helper text shown in the
|
|
171
|
-
// editor when the user chooses which
|
|
171
|
+
// editor when the user chooses which state/metric to expose.
|
|
172
172
|
const OBSERVABLE_METADATA = {
|
|
173
173
|
camera: {
|
|
174
174
|
ring: {
|
|
@@ -242,6 +242,26 @@ const OBSERVABLE_METADATA = {
|
|
|
242
242
|
label: "Extreme Values",
|
|
243
243
|
description: "True while the sensor is reporting an active extreme-values event.",
|
|
244
244
|
source: "official"
|
|
245
|
+
},
|
|
246
|
+
temperature: {
|
|
247
|
+
label: "Temperature",
|
|
248
|
+
description: "Current ambient temperature reported by the sensor.",
|
|
249
|
+
source: "official"
|
|
250
|
+
},
|
|
251
|
+
humidity: {
|
|
252
|
+
label: "Humidity",
|
|
253
|
+
description: "Current relative humidity reported by the sensor.",
|
|
254
|
+
source: "official"
|
|
255
|
+
},
|
|
256
|
+
lightLevel: {
|
|
257
|
+
label: "Light Level",
|
|
258
|
+
description: "Current ambient light level reported by the sensor.",
|
|
259
|
+
source: "inferred"
|
|
260
|
+
},
|
|
261
|
+
batteryLevel: {
|
|
262
|
+
label: "Battery Level",
|
|
263
|
+
description: "Current battery percentage reported by the sensor.",
|
|
264
|
+
source: "inferred"
|
|
245
265
|
}
|
|
246
266
|
},
|
|
247
267
|
light: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-unifi-ultimate",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Node-RED nodes for Ubiquiti UniFi integrations, including UniFi Protect, UniFi Access, and UniFi Network.",
|
|
5
5
|
"files": [
|
|
6
6
|
"nodes/",
|
|
@@ -60,4 +60,4 @@
|
|
|
60
60
|
"bugs": {
|
|
61
61
|
"url": "https://github.com/Supergiovane/node-red-contrib-unifi-ultimate/issues"
|
|
62
62
|
}
|
|
63
|
-
}
|
|
63
|
+
}
|