homebridge-unifi-protect 6.5.1 → 6.7.0

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.
Files changed (48) hide show
  1. package/README.md +12 -12
  2. package/config.schema.json +24 -3
  3. package/dist/protect-camera.d.ts +1 -2
  4. package/dist/protect-camera.js +21 -8
  5. package/dist/protect-camera.js.map +1 -1
  6. package/dist/protect-device.d.ts +1 -0
  7. package/dist/protect-device.js +33 -2
  8. package/dist/protect-device.js.map +1 -1
  9. package/dist/protect-ffmpeg-codecs.d.ts +19 -0
  10. package/dist/protect-ffmpeg-codecs.js +141 -0
  11. package/dist/protect-ffmpeg-codecs.js.map +1 -0
  12. package/dist/protect-ffmpeg-options.d.ts +20 -0
  13. package/dist/protect-ffmpeg-options.js +468 -0
  14. package/dist/protect-ffmpeg-options.js.map +1 -0
  15. package/dist/protect-ffmpeg-record.js +21 -24
  16. package/dist/protect-ffmpeg-record.js.map +1 -1
  17. package/dist/protect-ffmpeg-stream.d.ts +5 -2
  18. package/dist/protect-ffmpeg-stream.js +8 -11
  19. package/dist/protect-ffmpeg-stream.js.map +1 -1
  20. package/dist/protect-ffmpeg.d.ts +1 -4
  21. package/dist/protect-ffmpeg.js +23 -10
  22. package/dist/protect-ffmpeg.js.map +1 -1
  23. package/dist/protect-nvr-events.d.ts +0 -2
  24. package/dist/protect-nvr-events.js +36 -6
  25. package/dist/protect-nvr-events.js.map +1 -1
  26. package/dist/protect-nvr.js +17 -3
  27. package/dist/protect-nvr.js.map +1 -1
  28. package/dist/protect-options.d.ts +2 -0
  29. package/dist/protect-options.js +2 -1
  30. package/dist/protect-options.js.map +1 -1
  31. package/dist/protect-platform.d.ts +2 -3
  32. package/dist/protect-platform.js +11 -50
  33. package/dist/protect-platform.js.map +1 -1
  34. package/dist/protect-record.js +1 -1
  35. package/dist/protect-record.js.map +1 -1
  36. package/dist/protect-rtp.js +3 -1
  37. package/dist/protect-rtp.js.map +1 -1
  38. package/dist/protect-stream.d.ts +3 -8
  39. package/dist/protect-stream.js +14 -248
  40. package/dist/protect-stream.js.map +1 -1
  41. package/dist/protect-types.d.ts +0 -23
  42. package/dist/protect-types.js.map +1 -1
  43. package/dist/settings.d.ts +2 -0
  44. package/dist/settings.js +4 -0
  45. package/dist/settings.js.map +1 -1
  46. package/homebridge-ui/public/index.html +45 -10
  47. package/homebridge-ui/server.js +2 -0
  48. package/package.json +7 -7
@@ -29,7 +29,7 @@
29
29
  <div id="deviceInfo">
30
30
  <table class="table table-sm table-borderless">
31
31
  <tr class="align-center">
32
- <td colspan="2" class="m-0 p-2 text-center font-weight-bold">Feature options are applied in prioritized order, from global to device-specific options:<br><i>Global options</i> (lowest priority) &rarr; <i>Protect controller options</i> &rarr; <i>Protect device options</i> (highest priority)</td>
32
+ <td id="headerInfo" colspan="2" class="m-0 p-2 text-center font-weight-bold"></td>
33
33
  </tr>
34
34
  <tr class="align-top">
35
35
  <td rowspan="3" class="w-25">
@@ -50,7 +50,7 @@
50
50
  </td>
51
51
  <td>
52
52
  <table class="table table-sm table-borderless border-bottom m-0 p-0" id="deviceStatsTable" style="display: none;">
53
- <tr>
53
+ <tr id="deviceStatsHeader">
54
54
  <th style="width: 30%;" class="m-0 p-0"><B>Model<B></th>
55
55
  <th style="width: 25%;" class="m-0 p-0"><B>IP Address</B></th>
56
56
  <th style="width: 20%;" class="m-0 p-0"><B>MAC Address</B></th>
@@ -234,6 +234,17 @@
234
234
  // Start with a clean slate.
235
235
  controllersTable.innerHTML = "";
236
236
 
237
+ // We haven't configured anything yet - we're done.
238
+ if(!currentConfig[0]?.controllers?.length) {
239
+
240
+ document.getElementById("headerInfo").innerHTML = "Please configure a UniFi Protect controller to access in the main settings tab before configuring feature options."
241
+ homebridge.hideSpinner();
242
+ return;
243
+ }
244
+
245
+ // Initialize our informational header.
246
+ document.getElementById("headerInfo").innerHTML = "Feature options are applied in prioritized order, from global to device-specific options:<br><i>Global options</i> (lowest priority) &rarr; <i>Protect controller options</i> &rarr; <i>Protect device options</i> (highest priority)"
247
+
237
248
  // Enumerate our global options.
238
249
  const trGlobal = document.createElement("tr");
239
250
 
@@ -342,7 +353,12 @@
342
353
 
343
354
  devicesTable.innerHTML = "";
344
355
 
345
- document.getElementById("device_model").innerHTML = "Unable to connect to the Protect controller. Check your settings for this controller in the settings tab."
356
+ document.getElementById("device_model").innerHTML = "Unable to connect to the Protect controller. Check your settings for this controller in the main settings tab to verify they are correct."
357
+ document.getElementById("device_model").colSpan = 3;
358
+ document.getElementById("device_model").style.fontWeight = "bold";
359
+ document.getElementById("device_model").classList.add("text-center");
360
+ document.getElementById("deviceStatsHeader").style.display = "none";
361
+
346
362
  document.getElementById("device_mac").innerHTML = "";
347
363
  document.getElementById("device_address").innerHTML = "";
348
364
  document.getElementById("device_online").innerHTML = "";
@@ -421,10 +437,21 @@
421
437
  }
422
438
 
423
439
  const configTable = document.getElementById("configTable");
424
- let configOptions = currentConfig[0].options || [];
440
+ let configOptions = [];
441
+ let optionsList = [];
442
+
443
+ // Update our configuration options.
444
+ const updateConfigOptions = (newConfig) => {
445
+
446
+ // Update our configuration.
447
+ configOptions = newConfig;
425
448
 
426
- // Show all the valid options configured by the user.
427
- optionsList = configOptions.filter(x => x.match(/^(Enable|Disable)\.*/gi)).map(x => x.toUpperCase());
449
+ // Show all the valid options configured by the user.
450
+ optionsList = configOptions.filter(x => x.match(/^(Enable|Disable)\.*/gi)).map(x => x.toUpperCase());
451
+ };
452
+
453
+ // Initialize our feature option configuration.
454
+ updateConfigOptions(currentConfig[0].options ?? [])
428
455
 
429
456
  // Is a feature option globally enabled?
430
457
  const isGlobalOptionEnabled = (featureOption, defaultValue) => {
@@ -435,7 +462,7 @@
435
462
  return optionsList.some(x => x === ("ENABLE." + featureOption)) ? true :
436
463
  (optionsList.some(x => x === ("DISABLE." + featureOption)) ? false : defaultValue
437
464
  );
438
- }
465
+ };
439
466
 
440
467
  // Is a feature option enabled at the device or controller level.
441
468
  const isDeviceOptionEnabled = (featureOption, mac, defaultValue) => {
@@ -447,7 +474,7 @@
447
474
  return optionsList.some(x => x === ("ENABLE." + featureOption + "." + mac)) ? true :
448
475
  (optionsList.some(x => x === ("DISABLE." + featureOption + "." + mac)) ? false : defaultValue
449
476
  );
450
- }
477
+ };
451
478
 
452
479
  // Show feature option information for a specific device, controller, or globally.
453
480
  const showDeviceInfo = async (deviceId) => {
@@ -463,6 +490,10 @@
463
490
  // Ensure we have a controller or device. The only time this won't be the case is when we're looking at global options.
464
491
  if(ufpDevice) {
465
492
 
493
+ document.getElementById("deviceStatsHeader").style.display = "";
494
+ document.getElementById("device_model").classList.remove("text-center");
495
+ document.getElementById("device_model").colSpan = 1;
496
+ document.getElementById("device_model").style.fontWeight = "normal";
466
497
  document.getElementById("device_model").innerHTML = ufpDevice.marketName ?? ufpDevice.type;
467
498
  document.getElementById("device_mac").innerHTML = ufpDevice.mac;
468
499
  document.getElementById("device_address").innerHTML = ufpDevice.host ?? (ufpDevice.modelKey === "sensor" ? "Bluetooth Device" : "None");
@@ -473,6 +504,10 @@
473
504
 
474
505
  document.getElementById("deviceStatsTable").style.display = "none";
475
506
 
507
+ document.getElementById("deviceStatsHeader").style.display = "";
508
+ document.getElementById("device_model").classList.remove("text-center");
509
+ document.getElementById("device_model").colSpan = 1;
510
+ document.getElementById("device_model").style.fontWeight = "normal";
476
511
  document.getElementById("device_model").innerHTML = "N/A"
477
512
  document.getElementById("device_mac").innerHTML = "N/A";
478
513
  document.getElementById("device_address").innerHTML = "N/A";
@@ -544,7 +579,7 @@
544
579
  checkbox.type = "checkbox";
545
580
  checkbox.id = featureOption;
546
581
  checkbox.name = featureOption;
547
- checkbox.value = featureOption + (!ufpDevice ? "" : ("." + ufpDevice.mac)); // LEFT OFF HERE
582
+ checkbox.value = featureOption + (!ufpDevice ? "" : ("." + ufpDevice.mac));
548
583
  checkbox.checked = !ufpDevice ? isGlobalOptionEnabled(featureOption, option.default) :
549
584
  isDeviceOptionEnabled(featureOption, ufpDevice.mac, option.default);
550
585
 
@@ -571,7 +606,7 @@
571
606
 
572
607
  // Update our configuration in Homebridge.
573
608
  currentConfig[0].options = newOptions;
574
- configOptions = newOptions;
609
+ updateConfigOptions(newOptions);
575
610
  await homebridge.updatePluginConfig(currentConfig);
576
611
  });
577
612
 
@@ -129,6 +129,7 @@ class PluginUiServer extends HomebridgePluginUiServer {
129
129
 
130
130
  // Compatibility for older versions of the Homebridge UI.
131
131
  this.onRequest("/getCachedAccessories", async () => {
132
+
132
133
  try {
133
134
 
134
135
  // Define the plugin and create the array to return.
@@ -159,6 +160,7 @@ class PluginUiServer extends HomebridgePluginUiServer {
159
160
  return [];
160
161
  }
161
162
  });
163
+
162
164
  this.ready();
163
165
  }
164
166
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-unifi-protect",
3
- "version": "6.5.1",
3
+ "version": "6.7.0",
4
4
  "displayName": "Homebridge UniFi Protect",
5
5
  "description": "Homebridge UniFi Protect plugin providing complete HomeKit integration for the UniFi Protect ecosystem with full support for most features including autoconfiguration, motion detection, multiple controllers, and realtime updates.",
6
6
  "author": {
@@ -68,18 +68,18 @@
68
68
  "@homebridge/plugin-ui-utils": "^0.0.19",
69
69
  "ffmpeg-for-homebridge": "^0.1.4",
70
70
  "mqtt": "4.3.7",
71
- "unifi-protect": "^4.2.2",
71
+ "unifi-protect": "^4.2.3",
72
72
  "ws": "^8.13.0"
73
73
  },
74
74
  "devDependencies": {
75
- "@types/node": "^18.16.3",
75
+ "@types/node": "^20.2.1",
76
76
  "@types/ws": "^8.5.4",
77
- "@typescript-eslint/eslint-plugin": "^5.59.2",
78
- "@typescript-eslint/parser": "^5.59.2",
79
- "eslint": "^8.39.0",
77
+ "@typescript-eslint/eslint-plugin": "^5.59.6",
78
+ "@typescript-eslint/parser": "^5.59.6",
79
+ "eslint": "^8.41.0",
80
80
  "homebridge": "=1.6.1",
81
81
  "nodemon": "^2.0.22",
82
- "rimraf": "^5.0.0",
82
+ "rimraf": "^5.0.1",
83
83
  "typescript": "^5.0.4"
84
84
  }
85
85
  }