homebridge-unifi-protect 7.21.0 → 7.23.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 (58) hide show
  1. package/dist/devices/protect-camera-package.js +3 -3
  2. package/dist/devices/protect-camera-package.js.map +1 -1
  3. package/dist/devices/protect-camera.d.ts +2 -1
  4. package/dist/devices/protect-camera.js +78 -49
  5. package/dist/devices/protect-camera.js.map +1 -1
  6. package/dist/devices/protect-chime.js +3 -2
  7. package/dist/devices/protect-chime.js.map +1 -1
  8. package/dist/devices/protect-device.js +19 -22
  9. package/dist/devices/protect-device.js.map +1 -1
  10. package/dist/devices/protect-doorbell.d.ts +4 -2
  11. package/dist/devices/protect-doorbell.js +37 -22
  12. package/dist/devices/protect-doorbell.js.map +1 -1
  13. package/dist/devices/protect-light.js +6 -6
  14. package/dist/devices/protect-light.js.map +1 -1
  15. package/dist/devices/protect-liveviews.js +8 -26
  16. package/dist/devices/protect-liveviews.js.map +1 -1
  17. package/dist/devices/protect-nvr-systeminfo.d.ts +0 -2
  18. package/dist/devices/protect-nvr-systeminfo.js +13 -47
  19. package/dist/devices/protect-nvr-systeminfo.js.map +1 -1
  20. package/dist/devices/protect-securitysystem.js +17 -36
  21. package/dist/devices/protect-securitysystem.js.map +1 -1
  22. package/dist/devices/protect-sensor.d.ts +4 -4
  23. package/dist/devices/protect-sensor.js +56 -44
  24. package/dist/devices/protect-sensor.js.map +1 -1
  25. package/dist/devices/protect-viewer.js +8 -8
  26. package/dist/devices/protect-viewer.js.map +1 -1
  27. package/dist/protect-events.js +12 -18
  28. package/dist/protect-events.js.map +1 -1
  29. package/dist/protect-livestream.js +10 -4
  30. package/dist/protect-livestream.js.map +1 -1
  31. package/dist/protect-nvr.d.ts +5 -5
  32. package/dist/protect-nvr.js +36 -34
  33. package/dist/protect-nvr.js.map +1 -1
  34. package/dist/protect-options.d.ts +4 -4
  35. package/dist/protect-options.js +3 -2
  36. package/dist/protect-options.js.map +1 -1
  37. package/dist/protect-platform.d.ts +1 -1
  38. package/dist/protect-platform.js +8 -14
  39. package/dist/protect-platform.js.map +1 -1
  40. package/dist/protect-record.d.ts +1 -2
  41. package/dist/protect-record.js +9 -14
  42. package/dist/protect-record.js.map +1 -1
  43. package/dist/protect-stream.js +39 -59
  44. package/dist/protect-stream.js.map +1 -1
  45. package/dist/protect-timeshift.d.ts +0 -2
  46. package/dist/protect-timeshift.js +7 -15
  47. package/dist/protect-timeshift.js.map +1 -1
  48. package/dist/protect-types.d.ts +2 -0
  49. package/dist/protect-types.js +3 -0
  50. package/dist/protect-types.js.map +1 -1
  51. package/dist/settings.d.ts +4 -4
  52. package/dist/settings.js +5 -5
  53. package/dist/settings.js.map +1 -1
  54. package/homebridge-ui/public/lib/featureoptions.js +7 -8
  55. package/homebridge-ui/public/lib/featureoptions.js.map +1 -1
  56. package/homebridge-ui/public/lib/webUi-featureoptions.mjs +488 -213
  57. package/homebridge-ui/public/ui.mjs +1 -1
  58. package/package.json +9 -9
@@ -111,8 +111,8 @@ export class ProtectCameraPackage extends ProtectCamera {
111
111
  return false;
112
112
  }
113
113
  // Activate or deactivate the package camera flashlight.
114
- service.getCharacteristic(this.hap.Characteristic.On)?.onGet(() => !!this.flashlightState);
115
- service.getCharacteristic(this.hap.Characteristic.On)?.onSet(async (value) => {
114
+ service.getCharacteristic(this.hap.Characteristic.On).onGet(() => !!this.flashlightState);
115
+ service.getCharacteristic(this.hap.Characteristic.On).onSet(async (value) => {
116
116
  // Stop heartbeating the flashlight to allow it to turn off.
117
117
  if (!value) {
118
118
  clearInterval(this.flashlightTimer);
@@ -146,7 +146,7 @@ export class ProtectCameraPackage extends ProtectCamera {
146
146
  clearInterval(this.flashlightTimer);
147
147
  // If it's dark, we're done.
148
148
  if (!this.ufp.isDark) {
149
- setTimeout(() => service?.updateCharacteristic(this.hap.Characteristic.On, false), 50);
149
+ setTimeout(() => service.updateCharacteristic(this.hap.Characteristic.On, false), 50);
150
150
  return;
151
151
  }
152
152
  // Activate the flashlight.
@@ -1 +1 @@
1
- {"version":3,"file":"protect-camera-package.js","sourceRoot":"","sources":["../../src/devices/protect-camera-package.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,KAAK,EAAC,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAkB,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,gKAAgK;AAChK,MAAM,OAAO,oBAAqB,SAAQ,aAAa;IAE7C,eAAe,CAAW;IAC1B,eAAe,CAAkB;IAEzC,gCAAgC;IACtB,eAAe;QAEvB,yBAAyB;QACzB,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAEzD,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;QAE7B,oCAAoC;QACpC,IAAG,YAAY,EAAE,CAAC;YAEhB,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,YAAY,CAAC;YAC1D,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,YAAY,CAAC,KAAK,CAAC,gBAAgB,CAAC;YAClE,IAAI,CAAC,KAAK,CAAC,mBAAmB,GAAG,YAAY,CAAC,KAAK,CAAC,mBAAmB,CAAC;YACxE,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,YAAY,CAAC,KAAK,CAAC,gBAAgB,CAAC;YAClE,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC;YAChD,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC;YACpD,IAAI,CAAC,KAAK,CAAC,g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,MAAM,EAAE,OAAO,CAAC,GAAG,CAAE,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,KAAK;gBACpG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG;YACnE,UAAU,EAAE,CAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAE;YAC1D,GAAG,EAAG,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,OAAO,CAAC,SAAS,GAAG,aAAa;SACjI,CAAC;IACJ,CAAC;IAED,kDAAkD;IAC3C,iBAAiB;QAEtB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -29,7 +29,7 @@ export declare class ProtectCamera extends ProtectDevice {
29
29
  detectLicensePlate: string[];
30
30
  readonly livestream: LivestreamManager;
31
31
  messageSwitches: {
32
- [index: string]: MessageSwitchInterface;
32
+ [index: string]: MessageSwitchInterface | undefined;
33
33
  };
34
34
  packageCamera?: Nullable<ProtectCameraPackage>;
35
35
  private rtspEntries;
@@ -64,5 +64,6 @@ export declare class ProtectCamera extends ProtectDevice {
64
64
  get isHksvCapable(): boolean;
65
65
  private get nightVision();
66
66
  private get nightVisionBrightness();
67
+ get audioFilters(): string[];
67
68
  }
68
69
  export {};
@@ -1,5 +1,6 @@
1
1
  import { ProtectReservedNames, toCamelCase } from "../protect-types.js";
2
2
  import { LivestreamManager } from "../protect-livestream.js";
3
+ import { PROTECT_FFMPEG_AUDIO_FILTER_FFTNR } from "../settings.js";
3
4
  import { ProtectDevice } from "./protect-device.js";
4
5
  import { ProtectStreamingDelegate } from "../protect-stream.js";
5
6
  export class ProtectCamera extends ProtectDevice {
@@ -53,10 +54,10 @@ export class ProtectCamera extends ProtectDevice {
53
54
  this.hints.twoWayAudio = this.ufp.featureFlags.hasSpeaker && this.hasFeature("Audio") && this.hasFeature("Audio.TwoWay");
54
55
  this.hints.twoWayAudioDirect = this.ufp.featureFlags.hasSpeaker && this.hasFeature("Audio") && this.hasFeature("Audio.TwoWay.Direct");
55
56
  // Sanity check our target transcoding bitrates, if defined.
56
- if ((this.hints.transcodeBitrate === null) || (this.hints.transcodeBitrate === undefined) || (this.hints.transcodeBitrate <= 0)) {
57
+ if (!this.hints.transcodeBitrate || (this.hints.transcodeBitrate <= 0)) {
57
58
  this.hints.transcodeBitrate = -1;
58
59
  }
59
- if ((this.hints.transcodeHighLatencyBitrate === null) || (this.hints.transcodeHighLatencyBitrate === undefined) || (this.hints.transcodeHighLatencyBitrate <= 0)) {
60
+ if (!this.hints.transcodeHighLatencyBitrate || (this.hints.transcodeHighLatencyBitrate <= 0)) {
60
61
  this.hints.transcodeHighLatencyBitrate = -1;
61
62
  }
62
63
  return true;
@@ -136,15 +137,13 @@ export class ProtectCamera extends ProtectDevice {
136
137
  // Cleanup after ourselves if we're being deleted.
137
138
  cleanup() {
138
139
  // If we've got HomeKit Secure Video enabled and recording, disable it.
139
- if (this.stream?.hksv?.isRecording) {
140
+ if (this.stream.hksv?.isRecording) {
140
141
  void this.stream.hksv.updateRecordingActive(false);
141
142
  }
142
143
  // Cleanup our livestream manager.
143
144
  this.livestream.shutdown();
144
145
  // Unregister our controller.
145
- if (this.stream?.controller) {
146
- this.accessory.removeController(this.stream.controller);
147
- }
146
+ this.accessory.removeController(this.stream.controller);
148
147
  super.cleanup();
149
148
  this.isDeleted = true;
150
149
  }
@@ -163,7 +162,7 @@ export class ProtectCamera extends ProtectDevice {
163
162
  // - HKSV recording enabled.
164
163
  // - No enabled smart motion detection capabilities on the Protect device.
165
164
  // - Smart detection disabled.
166
- if (this.stream?.hksv?.isRecording ||
165
+ if (this.stream.hksv?.isRecording ||
167
166
  !(this.ufp.featureFlags.smartDetectAudioTypes.length || this.ufp.featureFlags.smartDetectTypes.length) || !this.hints.smartDetect) {
168
167
  this.nvr.events.motionEventHandler(this);
169
168
  }
@@ -175,8 +174,9 @@ export class ProtectCamera extends ProtectDevice {
175
174
  // If smart detection is enabled, we need to filter out any events tagged as "motion". When users enable the "Create motion events" setting on a camera, Protect will
176
175
  // create motion-specific thumbnail events. We're only interested in true smart detection events.
177
176
  if (this.hints.smartDetect) {
178
- if (payload.metadata) {
179
- payload.metadata.detectedThumbnails = payload.metadata.detectedThumbnails?.filter(({ type }) => type !== "motion");
177
+ const event = payload;
178
+ if (event.metadata?.detectedThumbnails) {
179
+ event.metadata.detectedThumbnails = event.metadata.detectedThumbnails.filter(({ type }) => type !== "motion");
180
180
  }
181
181
  }
182
182
  // Process smart detection events that have occurred on a non-realtime basis. Generally, this includes audio and video events that require more analysis by Protect.
@@ -197,7 +197,7 @@ export class ProtectCamera extends ProtectDevice {
197
197
  addEventHandler(packet) {
198
198
  const payload = packet.payload;
199
199
  // Detect UniFi Access unlock events surfaced in Protect.
200
- if ((packet.header.modelKey === "event") && (payload.metadata?.action === "open_door") && payload.metadata?.openSuccess) {
200
+ if ((packet.header.modelKey === "event") && (payload.metadata?.action === "open_door") && payload.metadata.openSuccess) {
201
201
  const lockService = this.accessory.getServiceById(this.hap.Service.LockMechanism, ProtectReservedNames.LOCK_ACCESS);
202
202
  if (!lockService) {
203
203
  return;
@@ -209,8 +209,8 @@ export class ProtectCamera extends ProtectDevice {
209
209
  clearTimeout(this.accessUnlockTimer);
210
210
  }
211
211
  this.accessUnlockTimer = setTimeout(() => {
212
- lockService?.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
213
- lockService?.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED);
212
+ lockService.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
213
+ lockService.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED);
214
214
  this.accessUnlockTimer = undefined;
215
215
  }, 2000);
216
216
  return;
@@ -222,7 +222,7 @@ export class ProtectCamera extends ProtectDevice {
222
222
  // - We explicitly filter out events tagged as "motion". When users enable the "Create motion events" setting on a camera, Protect will create motion-specific
223
223
  // thumbnail events. We're only interested in true smart detection events.
224
224
  if (!this.hints.smartDetect || !((packet.header.modelKey === "smartDetectObject") || ((packet.header.modelKey === "event") &&
225
- ["smartDetectLine", "smartDetectZone"].includes(payload.type) && (payload.type !== "motion") && payload.smartDetectTypes.length))) {
225
+ ["smartDetectLine", "smartDetectZone"].includes(payload.type) && (payload.type !== "motion") && payload.smartDetectTypes?.length))) {
226
226
  return;
227
227
  }
228
228
  // Process the motion event.
@@ -252,11 +252,9 @@ export class ProtectCamera extends ProtectDevice {
252
252
  return -1;
253
253
  }
254
254
  try {
255
- let lux = (await response?.body.json()).illuminance ?? -1;
255
+ let lux = (await response?.body.json()).illuminance ?? 0;
256
256
  // The minimum value for ambient light in HomeKit is 0.0001. I have no idea why...but it is. Honor it.
257
- if (!lux) {
258
- lux = 0.0001;
259
- }
257
+ lux ||= 0.0001;
260
258
  return lux;
261
259
  // eslint-disable-next-line @stylistic/keyword-spacing
262
260
  }
@@ -284,14 +282,14 @@ export class ProtectCamera extends ProtectDevice {
284
282
  this.publish("ambientlight", this.ambientLight.toString());
285
283
  }, 60 * 1000);
286
284
  // Retrieve the active state when requested.
287
- service.getCharacteristic(this.hap.Characteristic.StatusActive)?.onGet(() => this.isOnline);
285
+ service.getCharacteristic(this.hap.Characteristic.StatusActive).onGet(() => this.isOnline);
288
286
  // Initialize the sensor.
289
287
  this.ambientLight = await getLux();
290
288
  if (this.ambientLight === -1) {
291
289
  this.ambientLight = 0.0001;
292
290
  }
293
291
  // Retrieve the current light level when requested.
294
- service.getCharacteristic(this.hap.Characteristic.CurrentAmbientLightLevel)?.onGet(() => this.ambientLight);
292
+ service.getCharacteristic(this.hap.Characteristic.CurrentAmbientLightLevel).onGet(() => this.ambientLight);
295
293
  service.updateCharacteristic(this.hap.Characteristic.CurrentAmbientLightLevel, this.ambientLight);
296
294
  service.updateCharacteristic(this.hap.Characteristic.StatusActive, this.isOnline);
297
295
  return true;
@@ -299,7 +297,7 @@ export class ProtectCamera extends ProtectDevice {
299
297
  // Configure UniFi Access specific features for devices that are made available in Protect.
300
298
  configureAccessFeatures() {
301
299
  // If the Access device doesn't have unlock capabilities, we're done.
302
- if (!this.ufp.accessDeviceMetadata?.featureFlags?.supportUnlock) {
300
+ if (!this.ufp.accessDeviceMetadata?.featureFlags.supportUnlock) {
303
301
  return false;
304
302
  }
305
303
  // Validate whether we should have this service enabled.
@@ -319,8 +317,8 @@ export class ProtectCamera extends ProtectDevice {
319
317
  if (value === this.hap.Characteristic.LockTargetState.SECURED) {
320
318
  // Let's make sure we revert the lock to it's prior state.
321
319
  setTimeout(() => {
322
- service?.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.UNSECURED);
323
- service?.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.UNSECURED);
320
+ service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.UNSECURED);
321
+ service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.UNSECURED);
324
322
  }, 50);
325
323
  return;
326
324
  }
@@ -329,8 +327,8 @@ export class ProtectCamera extends ProtectDevice {
329
327
  if (this.nvr.ufpApi.responseOk(response?.statusCode)) {
330
328
  // Something went wrong, revert to our prior state.
331
329
  setTimeout(() => {
332
- service?.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.UNSECURED);
333
- service?.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.UNSECURED);
330
+ service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.UNSECURED);
331
+ service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.UNSECURED);
334
332
  }, 50);
335
333
  return;
336
334
  }
@@ -352,7 +350,7 @@ export class ProtectCamera extends ProtectDevice {
352
350
  }
353
351
  // We don't have this contact sensor enabled, remove it.
354
352
  this.accessory.removeService(objectService);
355
- this.log.info("Disabling smart motion license plate contact sensor: %s.", objectService.subtype?.slice(objectService.subtype?.indexOf(".") + 1));
353
+ this.log.info("Disabling smart motion license plate contact sensor: %s.", objectService.subtype?.slice(objectService.subtype.indexOf(".") + 1));
356
354
  }
357
355
  // If we don't have smart motion detection available or we have smart motion object contact sensors disabled, let's remove them.
358
356
  if (!this.hints.smartDetectSensors) {
@@ -360,7 +358,7 @@ export class ProtectCamera extends ProtectDevice {
360
358
  for (const objectService of this.accessory.services.filter(x => x.subtype?.startsWith(ProtectReservedNames.CONTACT_MOTION_SMARTDETECT + "."))) {
361
359
  // We don't have this contact sensor enabled, remove it.
362
360
  this.accessory.removeService(objectService);
363
- this.log.info("Disabling smart motion contact sensor: %s.", objectService.subtype?.slice(objectService.subtype?.indexOf(".") + 1));
361
+ this.log.info("Disabling smart motion contact sensor: %s.", objectService.subtype?.slice(objectService.subtype.indexOf(".") + 1));
364
362
  }
365
363
  }
366
364
  // If we don't have smart motion detection, we're done.
@@ -421,8 +419,8 @@ export class ProtectCamera extends ProtectDevice {
421
419
  return false;
422
420
  }
423
421
  // Configure the switch.
424
- service.getCharacteristic(this.hap.Characteristic.On)?.onGet(() => this.accessory.context.doorbellMuted);
425
- service.getCharacteristic(this.hap.Characteristic.On)?.onSet((value) => {
422
+ service.getCharacteristic(this.hap.Characteristic.On).onGet(() => this.accessory.context.doorbellMuted);
423
+ service.getCharacteristic(this.hap.Characteristic.On).onSet((value) => {
426
424
  this.accessory.context.doorbellMuted = !!value;
427
425
  this.log.info("Doorbell chime %s.", value ? "disabled" : "enabled");
428
426
  });
@@ -463,8 +461,8 @@ export class ProtectCamera extends ProtectDevice {
463
461
  return false;
464
462
  }
465
463
  // Trigger the doorbell.
466
- triggerService.getCharacteristic(this.hap.Characteristic.On)?.onGet(() => this.isRinging);
467
- triggerService.getCharacteristic(this.hap.Characteristic.On)?.onSet((value) => {
464
+ triggerService.getCharacteristic(this.hap.Characteristic.On).onGet(() => this.isRinging);
465
+ triggerService.getCharacteristic(this.hap.Characteristic.On).onSet((value) => {
468
466
  if (value) {
469
467
  // Trigger the ring event.
470
468
  this.nvr.events.doorbellEventHandler(this, Date.now());
@@ -473,7 +471,7 @@ export class ProtectCamera extends ProtectDevice {
473
471
  else {
474
472
  // If the doorbell ring event is still going, we should be as well.
475
473
  if (this.isRinging) {
476
- setTimeout(() => triggerService?.updateCharacteristic(this.hap.Characteristic.On, true), 50);
474
+ setTimeout(() => triggerService.updateCharacteristic(this.hap.Characteristic.On, true), 50);
477
475
  }
478
476
  }
479
477
  });
@@ -527,7 +525,7 @@ export class ProtectCamera extends ProtectDevice {
527
525
  const newUfp = await this.nvr.ufpApi.updateDevice(this.ufp, { ispSettings: { irLedMode: value ? "auto" : "off" } });
528
526
  if (!newUfp) {
529
527
  this.log.error("Unable to set night vision to %s. Please ensure this username has the Administrator role in UniFi Protect.", value ? "auto" : "off");
530
- setTimeout(() => service?.updateCharacteristic(this.hap.Characteristic.NightVision, !value), 50);
528
+ setTimeout(() => service.updateCharacteristic(this.hap.Characteristic.NightVision, !value), 50);
531
529
  return;
532
530
  }
533
531
  // Update our internal view of the device configuration.
@@ -577,7 +575,7 @@ export class ProtectCamera extends ProtectDevice {
577
575
  async configureVideoStream() {
578
576
  const rtspEntries = [];
579
577
  // No channels exist on this camera or we don't have access to the bootstrap configuration.
580
- if (!this.ufp.channels) {
578
+ if (!this.ufp.channels.length) {
581
579
  return false;
582
580
  }
583
581
  // Enable RTSP on the camera if needed and get the list of RTSP streams we have ultimately configured.
@@ -585,7 +583,7 @@ export class ProtectCamera extends ProtectDevice {
585
583
  // Figure out which camera channels are RTSP-enabled, and user-enabled. We also filter out any package camera entries. We deal with those independently elsewhere.
586
584
  const cameraChannels = this.ufp.channels.filter(channel => channel.isRtspEnabled && (channel.name !== "Package Camera"));
587
585
  // Set the camera and shapshot URLs.
588
- const cameraUrl = "rtsps://" + (this.nvr.config.overrideAddress ?? this.ufp.connectionHost ?? this.nvr.ufp.host) + ":" + this.nvr.ufp.ports.rtsps.toString() + "/";
586
+ const cameraUrl = "rtsps://" + (this.nvr.config.overrideAddress ?? this.ufp.connectionHost) + ":" + this.nvr.ufp.ports.rtsps.toString() + "/";
589
587
  // No RTSP streams are available that meet our criteria - we're done.
590
588
  if (!cameraChannels.length) {
591
589
  this.log.info("No RTSP profiles found for this camera. " +
@@ -678,6 +676,7 @@ export class ProtectCamera extends ProtectDevice {
678
676
  // Publish our updated list of supported resolutions and their URLs.
679
677
  this.rtspEntries = rtspEntries;
680
678
  // If we've already configured the HomeKit video streaming delegate, we're done here.
679
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
681
680
  if (this.stream) {
682
681
  return true;
683
682
  }
@@ -761,8 +760,8 @@ export class ProtectCamera extends ProtectDevice {
761
760
  return false;
762
761
  }
763
762
  // Activate or deactivate HKSV recording.
764
- service.getCharacteristic(this.hap.Characteristic.On)?.onGet(() => !this.accessory.context.hksvRecordingDisabled);
765
- service.getCharacteristic(this.hap.Characteristic.On)?.onSet((value) => {
763
+ service.getCharacteristic(this.hap.Characteristic.On).onGet(() => !this.accessory.context.hksvRecordingDisabled);
764
+ service.getCharacteristic(this.hap.Characteristic.On).onSet((value) => {
766
765
  if (this.accessory.context.hksvRecordingDisabled !== !value) {
767
766
  this.log.info("HKSV event recording %s.", value ? "enabled" : "disabled");
768
767
  }
@@ -788,8 +787,8 @@ export class ProtectCamera extends ProtectDevice {
788
787
  return false;
789
788
  }
790
789
  // Adjust night vision capabilities.
791
- service.getCharacteristic(this.hap.Characteristic.On)?.onGet(() => this.nightVision);
792
- service.getCharacteristic(this.hap.Characteristic.On)?.onSet(async (value) => {
790
+ service.getCharacteristic(this.hap.Characteristic.On).onGet(() => this.nightVision);
791
+ service.getCharacteristic(this.hap.Characteristic.On).onSet(async (value) => {
793
792
  if (this.nightVision !== value) {
794
793
  this.log.info("Night vision %s.", value ? "enabled" : "disabled");
795
794
  }
@@ -798,15 +797,15 @@ export class ProtectCamera extends ProtectDevice {
798
797
  const newUfp = await this.nvr.ufpApi.updateDevice(this.ufp, { ispSettings: { irLedMode: value ? mode : "off" } });
799
798
  if (!newUfp) {
800
799
  this.log.error("Unable to set night vision to %s. Please ensure this username has the Administrator role in UniFi Protect.", value ? "custom" : "off");
801
- setTimeout(() => service?.updateCharacteristic(this.hap.Characteristic.On, !value), 50);
800
+ setTimeout(() => service.updateCharacteristic(this.hap.Characteristic.On, !value), 50);
802
801
  return;
803
802
  }
804
803
  // Update our internal view of the device configuration.
805
804
  this.ufp = newUfp;
806
805
  });
807
806
  // Adjust the sensitivity of night vision.
808
- service.getCharacteristic(this.hap.Characteristic.Brightness)?.onGet(() => this.nightVisionBrightness);
809
- service.getCharacteristic(this.hap.Characteristic.Brightness)?.onSet(async (value) => {
807
+ service.getCharacteristic(this.hap.Characteristic.Brightness).onGet(() => this.nightVisionBrightness);
808
+ service.getCharacteristic(this.hap.Characteristic.Brightness).onSet(async (value) => {
810
809
  let level = value;
811
810
  let nightvision = {};
812
811
  // If we're less than 10% in brightness, assume we want to disable night vision.
@@ -846,7 +845,7 @@ export class ProtectCamera extends ProtectDevice {
846
845
  // Set the context to our updated device configuration.
847
846
  this.ufp = newUfp;
848
847
  // Make sure we properly reflect what brightness we're actually at, given the differences in setting granularity between Protect and HomeKit.
849
- setTimeout(() => service?.updateCharacteristic(this.hap.Characteristic.Brightness, level), 50);
848
+ setTimeout(() => service.updateCharacteristic(this.hap.Characteristic.Brightness, level), 50);
850
849
  });
851
850
  // Initialize the dimmer state.
852
851
  service.updateCharacteristic(this.hap.Characteristic.On, this.nightVision);
@@ -873,8 +872,8 @@ export class ProtectCamera extends ProtectDevice {
873
872
  continue;
874
873
  }
875
874
  // Activate or deactivate the appropriate recording mode on the Protect controller.
876
- service.getCharacteristic(this.hap.Characteristic.On)?.onGet(() => this.ufp.recordingSettings.mode === ufpRecordingSetting);
877
- service.getCharacteristic(this.hap.Characteristic.On)?.onSet(async (value) => {
875
+ service.getCharacteristic(this.hap.Characteristic.On).onGet(() => this.ufp.recordingSettings.mode === ufpRecordingSetting);
876
+ service.getCharacteristic(this.hap.Characteristic.On).onSet(async (value) => {
878
877
  // We only want to do something if we're being activated. Turning off the switch would really be an undefined state given that there are three different
879
878
  // settings one can choose from. Instead, we do nothing and leave it to the user to choose what state they really want to set.
880
879
  if (!value) {
@@ -918,7 +917,7 @@ export class ProtectCamera extends ProtectDevice {
918
917
  this.subscribeGet("rtsp", "RTSP information", () => {
919
918
  // Grab all the available RTSP channels and return them as a JSON.
920
919
  return JSON.stringify(Object.assign({}, ...this.ufp.channels.filter(channel => channel.isRtspEnabled)
921
- .map(channel => ({ [channel.name]: "rtsps://" + (this.nvr.config.overrideAddress ?? this.ufp.connectionHost ?? this.nvr.ufp.host) + ":" +
920
+ .map(channel => ({ [channel.name]: "rtsps://" + (this.nvr.config.overrideAddress ?? this.ufp.connectionHost) + ":" +
922
921
  this.nvr.ufp.ports.rtsp + "/" + channel.rtspAlias + "?enableSrtp" }))));
923
922
  });
924
923
  // Trigger snapshots when requested.
@@ -927,6 +926,7 @@ export class ProtectCamera extends ProtectDevice {
927
926
  if (value !== "true") {
928
927
  return;
929
928
  }
929
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
930
930
  void this.stream?.handleSnapshotRequest();
931
931
  });
932
932
  // Enable doorbell-specific MQTT capabilities only when we have a Protect doorbell or a doorbell trigger enabled.
@@ -982,7 +982,7 @@ export class ProtectCamera extends ProtectDevice {
982
982
  findRtspEntry(width, height, options) {
983
983
  const rtspEntries = options?.rtspEntries ?? this.rtspEntries;
984
984
  // No RTSP entries to choose from, we're done.
985
- if (!rtspEntries || !rtspEntries.length) {
985
+ if (!rtspEntries.length) {
986
986
  return null;
987
987
  }
988
988
  // Second, we check to see if we've set an explicit preference for stream quality.
@@ -1006,11 +1006,11 @@ export class ProtectCamera extends ProtectDevice {
1006
1006
  // Find a streaming RTSP configuration for a given target resolution.
1007
1007
  findRtsp(width, height, options) {
1008
1008
  // Create our options JSON if needed.
1009
- options = options ?? {};
1009
+ options ??= {};
1010
1010
  // Set our default stream, if we've configured one.
1011
1011
  options.default = this.hints.streamingDefault;
1012
1012
  // See if we've been given RTSP entries or whether we should default to our own.
1013
- options.rtspEntries = options.rtspEntries ?? this.rtspEntries;
1013
+ options.rtspEntries ??= this.rtspEntries;
1014
1014
  // If we've imposed a constraint on the maximum dimensions of what we want due to a hardware limitation, filter out those entries.
1015
1015
  if (options.maxPixels !== undefined) {
1016
1016
  options.rtspEntries = options.rtspEntries.filter(x => (x.channel.width * x.channel.height) <= (options.maxPixels ?? Infinity));
@@ -1056,7 +1056,7 @@ export class ProtectCamera extends ProtectDevice {
1056
1056
  }
1057
1057
  // Utility property to return the current night vision state of a camera. It's a blunt instrument due to HomeKit constraints.
1058
1058
  get nightVision() {
1059
- return this.ufp?.ispSettings?.irLedMode !== "off";
1059
+ return this.ufp.ispSettings.irLedMode !== "off";
1060
1060
  }
1061
1061
  // Utility property to return the current night vision state of a camera, mapped to a brightness characteristic.
1062
1062
  get nightVisionBrightness() {
@@ -1075,5 +1075,34 @@ export class ProtectCamera extends ProtectDevice {
1075
1075
  return 0;
1076
1076
  }
1077
1077
  }
1078
+ // Utility to return our audio filter pipeline for this camera.
1079
+ get audioFilters() {
1080
+ // If we don't have audio filtering enabled, we're done.
1081
+ if (!this.hasFeature("Audio.Filter.Noise")) {
1082
+ return [];
1083
+ }
1084
+ const afOptions = [];
1085
+ // See what the user has set for the afftdn filter for this camera.
1086
+ let fftNr = this.getFeatureFloat("Audio.Filter.Noise.FftNr") ?? PROTECT_FFMPEG_AUDIO_FILTER_FFTNR;
1087
+ // If we have an invalid setting, use the defaults.
1088
+ fftNr = Math.max(0.01, Math.min(97, fftNr));
1089
+ const highpass = this.getFeatureNumber("Audio.Filter.Noise.HighPass");
1090
+ const lowpass = this.getFeatureNumber("Audio.Filter.Noise.LowPass");
1091
+ // We use the following order of operations for our filter: highpass, then lowpass, and finally afftdn.
1092
+ // Only set the highpass and lowpass filters if the user has explicitly enabled them.
1093
+ if (typeof highpass === "number") {
1094
+ afOptions.push("highpass=p=2:f=" + highpass.toString());
1095
+ }
1096
+ if (typeof lowpass === "number") {
1097
+ afOptions.push("lowpass=p=2:f=" + lowpass.toString());
1098
+ }
1099
+ // The afftdn filter options we use are:
1100
+ //
1101
+ // nt=c Use the custom noise profile that we've measured for two seconds at the beginning of our session.
1102
+ // tn=1 Enable noise tracking.
1103
+ // nr=X Noise reduction value in decibels.
1104
+ afOptions.push("asendcmd=c='1.0 afftdn sn start ; 3.0 afftdn sn stop', afftdn=nt=c:tn=1:nr=" + fftNr.toString());
1105
+ return afOptions;
1106
+ }
1078
1107
  }
1079
1108
  //# sourceMappingURL=protect-camera.js.map