homebridge-unifi-protect 6.18.1 → 6.20.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 (111) hide show
  1. package/dist/devices/index.d.ts +11 -0
  2. package/dist/devices/index.js +16 -0
  3. package/dist/devices/index.js.map +1 -0
  4. package/dist/{protect-camera-package.js → devices/protect-camera-package.js} +2 -4
  5. package/dist/devices/protect-camera-package.js.map +1 -0
  6. package/dist/{protect-camera.d.ts → devices/protect-camera.d.ts} +2 -5
  7. package/dist/{protect-camera.js → devices/protect-camera.js} +119 -210
  8. package/dist/devices/protect-camera.js.map +1 -0
  9. package/dist/{protect-chime.d.ts → devices/protect-chime.d.ts} +4 -1
  10. package/dist/devices/protect-chime.js +180 -0
  11. package/dist/devices/protect-chime.js.map +1 -0
  12. package/dist/{protect-device.d.ts → devices/protect-device.d.ts} +12 -5
  13. package/dist/{protect-device.js → devices/protect-device.js} +159 -109
  14. package/dist/devices/protect-device.js.map +1 -0
  15. package/dist/{protect-doorbell.d.ts → devices/protect-doorbell.d.ts} +1 -1
  16. package/dist/{protect-doorbell.js → devices/protect-doorbell.js} +50 -83
  17. package/dist/devices/protect-doorbell.js.map +1 -0
  18. package/dist/{protect-light.d.ts → devices/protect-light.d.ts} +1 -1
  19. package/dist/{protect-light.js → devices/protect-light.js} +34 -44
  20. package/dist/devices/protect-light.js.map +1 -0
  21. package/dist/{protect-liveviews.d.ts → devices/protect-liveviews.d.ts} +1 -1
  22. package/dist/{protect-liveviews.js → devices/protect-liveviews.js} +11 -21
  23. package/dist/devices/protect-liveviews.js.map +1 -0
  24. package/dist/{protect-nvr-systeminfo.d.ts → devices/protect-nvr-systeminfo.d.ts} +1 -1
  25. package/dist/{protect-nvr-systeminfo.js → devices/protect-nvr-systeminfo.js} +3 -9
  26. package/dist/devices/protect-nvr-systeminfo.js.map +1 -0
  27. package/dist/{protect-securitysystem.d.ts → devices/protect-securitysystem.d.ts} +2 -3
  28. package/dist/{protect-securitysystem.js → devices/protect-securitysystem.js} +32 -59
  29. package/dist/devices/protect-securitysystem.js.map +1 -0
  30. package/dist/{protect-sensor.d.ts → devices/protect-sensor.d.ts} +3 -2
  31. package/dist/devices/protect-sensor.js +402 -0
  32. package/dist/devices/protect-sensor.js.map +1 -0
  33. package/dist/{protect-viewer.d.ts → devices/protect-viewer.d.ts} +1 -1
  34. package/dist/{protect-viewer.js → devices/protect-viewer.js} +21 -28
  35. package/dist/devices/protect-viewer.js.map +1 -0
  36. package/dist/ffmpeg/index.d.ts +6 -0
  37. package/dist/ffmpeg/index.js +11 -0
  38. package/dist/ffmpeg/index.js.map +1 -0
  39. package/dist/{protect-ffmpeg-codecs.d.ts → ffmpeg/protect-ffmpeg-codecs.d.ts} +1 -1
  40. package/dist/ffmpeg/protect-ffmpeg-codecs.js.map +1 -0
  41. package/dist/{protect-ffmpeg-exec.d.ts → ffmpeg/protect-ffmpeg-exec.d.ts} +5 -2
  42. package/dist/{protect-ffmpeg-exec.js → ffmpeg/protect-ffmpeg-exec.js} +13 -1
  43. package/dist/ffmpeg/protect-ffmpeg-exec.js.map +1 -0
  44. package/dist/{protect-ffmpeg-options.d.ts → ffmpeg/protect-ffmpeg-options.d.ts} +1 -1
  45. package/dist/{protect-ffmpeg-options.js → ffmpeg/protect-ffmpeg-options.js} +1 -1
  46. package/dist/ffmpeg/protect-ffmpeg-options.js.map +1 -0
  47. package/dist/{protect-ffmpeg-record.d.ts → ffmpeg/protect-ffmpeg-record.d.ts} +1 -1
  48. package/dist/{protect-ffmpeg-record.js → ffmpeg/protect-ffmpeg-record.js} +7 -3
  49. package/dist/ffmpeg/protect-ffmpeg-record.js.map +1 -0
  50. package/dist/{protect-ffmpeg-stream.d.ts → ffmpeg/protect-ffmpeg-stream.d.ts} +1 -1
  51. package/dist/ffmpeg/protect-ffmpeg-stream.js.map +1 -0
  52. package/dist/{protect-ffmpeg.d.ts → ffmpeg/protect-ffmpeg.d.ts} +3 -3
  53. package/dist/ffmpeg/protect-ffmpeg.js.map +1 -0
  54. package/dist/{protect-nvr-events.d.ts → protect-events.d.ts} +3 -4
  55. package/dist/{protect-nvr-events.js → protect-events.js} +4 -4
  56. package/dist/protect-events.js.map +1 -0
  57. package/dist/protect-mqtt.d.ts +3 -2
  58. package/dist/protect-mqtt.js +30 -6
  59. package/dist/protect-mqtt.js.map +1 -1
  60. package/dist/protect-nvr.d.ts +4 -8
  61. package/dist/protect-nvr.js +82 -129
  62. package/dist/protect-nvr.js.map +1 -1
  63. package/dist/protect-options.js +7 -5
  64. package/dist/protect-options.js.map +1 -1
  65. package/dist/protect-platform.d.ts +1 -1
  66. package/dist/protect-platform.js +1 -1
  67. package/dist/protect-platform.js.map +1 -1
  68. package/dist/protect-record.d.ts +4 -2
  69. package/dist/protect-record.js +37 -34
  70. package/dist/protect-record.js.map +1 -1
  71. package/dist/protect-snapshot.d.ts +21 -0
  72. package/dist/protect-snapshot.js +200 -0
  73. package/dist/protect-snapshot.js.map +1 -0
  74. package/dist/protect-stream.d.ts +3 -7
  75. package/dist/protect-stream.js +7 -86
  76. package/dist/protect-stream.js.map +1 -1
  77. package/dist/protect-timeshift.d.ts +3 -2
  78. package/dist/protect-timeshift.js +31 -30
  79. package/dist/protect-timeshift.js.map +1 -1
  80. package/dist/protect-types.d.ts +5 -6
  81. package/dist/protect-types.js +8 -0
  82. package/dist/protect-types.js.map +1 -1
  83. package/dist/settings.d.ts +3 -6
  84. package/dist/settings.js +6 -12
  85. package/dist/settings.js.map +1 -1
  86. package/homebridge-ui/public/index.html +2 -0
  87. package/package.json +12 -12
  88. package/dist/protect-camera-package.js.map +0 -1
  89. package/dist/protect-camera.js.map +0 -1
  90. package/dist/protect-chime.js +0 -108
  91. package/dist/protect-chime.js.map +0 -1
  92. package/dist/protect-device.js.map +0 -1
  93. package/dist/protect-doorbell.js.map +0 -1
  94. package/dist/protect-ffmpeg-codecs.js.map +0 -1
  95. package/dist/protect-ffmpeg-exec.js.map +0 -1
  96. package/dist/protect-ffmpeg-options.js.map +0 -1
  97. package/dist/protect-ffmpeg-record.js.map +0 -1
  98. package/dist/protect-ffmpeg-stream.js.map +0 -1
  99. package/dist/protect-ffmpeg.js.map +0 -1
  100. package/dist/protect-light.js.map +0 -1
  101. package/dist/protect-liveviews.js.map +0 -1
  102. package/dist/protect-nvr-events.js.map +0 -1
  103. package/dist/protect-nvr-systeminfo.js.map +0 -1
  104. package/dist/protect-securitysystem.js.map +0 -1
  105. package/dist/protect-sensor.js +0 -449
  106. package/dist/protect-sensor.js.map +0 -1
  107. package/dist/protect-viewer.js.map +0 -1
  108. /package/dist/{protect-camera-package.d.ts → devices/protect-camera-package.d.ts} +0 -0
  109. /package/dist/{protect-ffmpeg-codecs.js → ffmpeg/protect-ffmpeg-codecs.js} +0 -0
  110. /package/dist/{protect-ffmpeg-stream.js → ffmpeg/protect-ffmpeg-stream.js} +0 -0
  111. /package/dist/{protect-ffmpeg.js → ffmpeg/protect-ffmpeg.js} +0 -0
@@ -1,6 +1,6 @@
1
- import { PROTECT_MOTION_DURATION, PROTECT_OCCUPANCY_DURATION } from "./settings.js";
2
- import { ProtectReservedNames } from "./protect-types.js";
3
- import { getOptionFloat, getOptionNumber, getOptionValue, isOptionEnabled } from "./protect-options.js";
1
+ import { PROTECT_MOTION_DURATION, PROTECT_OCCUPANCY_DURATION } from "../settings.js";
2
+ import { ProtectReservedNames } from "../protect-types.js";
3
+ import { getOptionFloat, getOptionNumber, getOptionValue, isOptionEnabled } from "../protect-options.js";
4
4
  import util from "node:util";
5
5
  export class ProtectBase {
6
6
  api;
@@ -25,14 +25,14 @@ export class ProtectBase {
25
25
  warn: (message, ...parameters) => nvr.platform.log.warn(util.format(this.name + ": " + message, ...parameters))
26
26
  };
27
27
  }
28
- // Configure the device device information for HomeKit.
28
+ // Configure the device information for HomeKit.
29
29
  setInfo(accessory, device) {
30
30
  // If we don't have a device, we're done.
31
31
  if (!device) {
32
32
  return false;
33
33
  }
34
34
  // Update the manufacturer information for this device.
35
- accessory.getService(this.hap.Service.AccessoryInformation)?.updateCharacteristic(this.hap.Characteristic.Manufacturer, "Ubiquiti Networks");
35
+ accessory.getService(this.hap.Service.AccessoryInformation)?.updateCharacteristic(this.hap.Characteristic.Manufacturer, "Ubiquiti Inc.");
36
36
  // Update the model information for this device.
37
37
  let deviceModel = device.type;
38
38
  if ("marketName" in device) {
@@ -55,7 +55,7 @@ export class ProtectBase {
55
55
  }
56
56
  return true;
57
57
  }
58
- // Utility function to return the fully enumerated name of this camera.
58
+ // Utility function to return the fully enumerated name of this device.
59
59
  get name() {
60
60
  return this.nvr.ufpApi.name;
61
61
  }
@@ -75,12 +75,68 @@ export class ProtectDevice extends ProtectBase {
75
75
  this.accessory = accessory;
76
76
  }
77
77
  }
78
+ // Retrieve an existing service from an accessory, creating it if necessary.
79
+ acquireService(serviceType, name = this.accessoryName, subtype, onServiceCreate) {
80
+ // Services that need the ConfiguredName characteristic added and maintained.
81
+ const configuredNameServices = [this.hap.Service.ContactSensor, this.hap.Service.Lightbulb, this.hap.Service.MotionSensor, this.hap.Service.OccupancySensor,
82
+ this.hap.Service.Switch];
83
+ // Services that need the Name characteristic maintained.
84
+ const nameServices = [this.hap.Service.Battery, this.hap.Service.ContactSensor, this.hap.Service.HumiditySensor, this.hap.Service.LeakSensor,
85
+ this.hap.Service.Lightbulb, this.hap.Service.LightSensor, this.hap.Service.MotionSensor, this.hap.Service.TemperatureSensor];
86
+ // Find the service, if it exists.
87
+ let service = subtype ? this.accessory.getServiceById(serviceType, subtype) : this.accessory.getService(serviceType);
88
+ // Add the service to the accessory, if needed.
89
+ if (!service) {
90
+ // @ts-expect-error TypeScript tries to associate this with an overloaded version of the addService method. However, Homebridge/HAP-NodeJS isn't exporting
91
+ // a version of the method that implements the unexposed interface that's been defined for each service class (e.g. Lightbulb). The constructor on the
92
+ // service-type-specific version of the service takes the following arguments: constructor(displayName?: string, subtype?: string). We're safe, but because
93
+ // the type definitions are missing, we need to override it here.
94
+ service = new serviceType(name, subtype);
95
+ if (!service) {
96
+ return null;
97
+ }
98
+ this.accessory.addService(service);
99
+ if (onServiceCreate) {
100
+ onServiceCreate();
101
+ }
102
+ }
103
+ // Update our name.
104
+ service.displayName = name;
105
+ if (configuredNameServices.includes(serviceType)) {
106
+ // Add the characteristic if we don't already have it. We do this here instead of at service creation to ensure we catch legacy situations where we may have
107
+ // already created the service previously without adding the optional characteristics we want.
108
+ if (!service.optionalCharacteristics.some(x => (x.UUID === this.hap.Characteristic.ConfiguredName.UUID))) {
109
+ service.addOptionalCharacteristic(this.hap.Characteristic.ConfiguredName);
110
+ }
111
+ service.updateCharacteristic(this.hap.Characteristic.ConfiguredName, name);
112
+ }
113
+ if (nameServices.includes(serviceType)) {
114
+ service.updateCharacteristic(this.hap.Characteristic.Name, name);
115
+ }
116
+ return service;
117
+ }
118
+ // Validate whether a service should exist, removing it if necessary.
119
+ validService(serviceType, validate, subtype) {
120
+ // Find the switch service, if it exists.
121
+ const service = subtype ? this.accessory.getServiceById(serviceType, subtype) : this.accessory.getService(serviceType);
122
+ // Validate whether we should have the service. If not, remove it.
123
+ if (!validate()) {
124
+ if (service) {
125
+ this.accessory.removeService(service);
126
+ }
127
+ return false;
128
+ }
129
+ // We have a valid service.
130
+ return true;
131
+ }
78
132
  // Configure device-specific settings.
79
133
  configureHints() {
134
+ this.hints.enabled = this.hasFeature("Device");
80
135
  this.hints.logMotion = this.hasFeature("Log.Motion");
81
136
  this.hints.motionDuration = this.getFeatureNumber("Motion.Duration") ?? PROTECT_MOTION_DURATION;
82
137
  this.hints.occupancyDuration = this.getFeatureNumber("Motion.OccupancySensor.Duration") ?? PROTECT_OCCUPANCY_DURATION;
83
138
  this.hints.smartOccupancy = [];
139
+ this.hints.standalone = this.hasFeature("Device.Standalone");
84
140
  this.hints.syncName = this.hasFeature("Device.SyncName");
85
141
  // Sanity check motion detection duration. Make sure it's never less than 2 seconds so we can actually alert the user.
86
142
  if (this.hints.motionDuration < 2) {
@@ -117,46 +173,63 @@ export class ProtectDevice extends ProtectBase {
117
173
  delete this.listeners[eventName];
118
174
  }
119
175
  }
176
+ // Utility to ease publishing of MQTT events.
177
+ publish(topic, message) {
178
+ this.nvr.mqtt?.publish(this.accessory, topic, message);
179
+ }
180
+ // Configure our MQTT get subscriptions.
181
+ subscribeGet(topic, type, getValue) {
182
+ this.nvr.mqtt?.subscribeGet(this.accessory, topic, type, getValue);
183
+ }
184
+ // Configure our MQTT set subscriptions.
185
+ subscribeSet(topic, type, setValue) {
186
+ this.nvr.mqtt?.subscribeSet(this.accessory, topic, type, setValue);
187
+ }
120
188
  // Configure the Protect motion sensor for HomeKit.
121
189
  configureMotionSensor(isEnabled = true, isInitialized = false) {
122
- // Find the motion sensor service, if it exists.
123
- let motionService = this.accessory.getService(this.hap.Service.MotionSensor);
124
- // Have we disabled the motion sensor?
125
- if (!isEnabled) {
126
- if (motionService) {
127
- this.accessory.removeService(motionService);
128
- this.nvr.mqtt?.unsubscribe(this.id, "motion/trigger");
129
- this.log.info("Disabling motion sensor.");
190
+ // Validate whether we should have this service enabled.
191
+ if (!this.validService(this.hap.Service.MotionSensor, () => {
192
+ // Have we disabled the motion sensor?
193
+ if (!isEnabled) {
194
+ this.nvr.mqtt?.unsubscribe(this.accessory, "motion/get");
195
+ this.nvr.mqtt?.unsubscribe(this.accessory, "motion/set");
196
+ this.configureMotionSwitch(isEnabled);
197
+ this.configureMotionTrigger(isEnabled);
198
+ return false;
130
199
  }
131
- this.configureMotionSwitch(isEnabled);
132
- this.configureMotionTrigger(isEnabled);
200
+ return true;
201
+ })) {
133
202
  return false;
134
203
  }
135
- // We don't have a motion sensor, let's add it to the device.
136
- if (!motionService) {
137
- // We don't have it, add the motion sensor to the device.
138
- motionService = new this.hap.Service.MotionSensor(this.accessoryName);
139
- if (!motionService) {
140
- this.log.error("Unable to add motion sensor.");
141
- return false;
142
- }
143
- this.accessory.addService(motionService);
204
+ // Acquire the service.
205
+ const service = this.acquireService(this.hap.Service.MotionSensor, undefined, undefined, () => {
144
206
  isInitialized = false;
145
- this.log.info("Enabling motion sensor.");
207
+ });
208
+ if (!service) {
209
+ this.log.error("Unable to add motion sensor.");
210
+ return false;
146
211
  }
147
212
  // Have we previously initialized this sensor? We assume not by default, but this allows for scenarios where you may be dynamically reconfiguring a sensor at
148
213
  // runtime (e.g. UniFi sensors can be reconfigured for various sensor modes in realtime).
149
214
  if (!isInitialized) {
150
215
  // Initialize the state of the motion sensor.
151
- motionService.displayName = this.accessoryName;
152
- motionService.updateCharacteristic(this.hap.Characteristic.Name, this.accessoryName);
153
- motionService.updateCharacteristic(this.hap.Characteristic.MotionDetected, false);
154
- motionService.updateCharacteristic(this.hap.Characteristic.StatusActive, this.isOnline);
155
- motionService.getCharacteristic(this.hap.Characteristic.StatusActive).onGet(() => {
216
+ service.updateCharacteristic(this.hap.Characteristic.MotionDetected, false);
217
+ service.updateCharacteristic(this.hap.Characteristic.StatusActive, this.isOnline);
218
+ service.getCharacteristic(this.hap.Characteristic.StatusActive).onGet(() => {
156
219
  return this.isOnline;
157
220
  });
158
221
  // Configure our MQTT support.
159
- this.configureMqttMotionTrigger();
222
+ this.subscribeGet("motion", "motion", () => {
223
+ return service.getCharacteristic(this.hap.Characteristic.MotionDetected).value === true ? "true" : "false";
224
+ });
225
+ this.subscribeSet("motion", "motion event trigger", (value) => {
226
+ // When we get the right message, we trigger the motion event.
227
+ if (value !== "true") {
228
+ return;
229
+ }
230
+ // Trigger the motion event.
231
+ this.nvr.events.motionEventHandler(this);
232
+ });
160
233
  // Configure any motion switches or triggers the user may have enabled or disabled.
161
234
  this.configureMotionSwitch(isEnabled);
162
235
  this.configureMotionTrigger(isEnabled);
@@ -165,36 +238,31 @@ export class ProtectDevice extends ProtectBase {
165
238
  }
166
239
  // Configure a switch to easily activate or deactivate motion sensor detection for HomeKit.
167
240
  configureMotionSwitch(isEnabled = true) {
168
- // Find the switch service, if it exists.
169
- let switchService = this.accessory.getServiceById(this.hap.Service.Switch, ProtectReservedNames.SWITCH_MOTION_SENSOR);
170
- // Motion switches are disabled by default unless the user enables them.
171
- if (!isEnabled || !this.hasFeature("Motion.Switch")) {
172
- if (switchService) {
173
- this.accessory.removeService(switchService);
241
+ // Validate whether we should have this service enabled.
242
+ if (!this.validService(this.hap.Service.Switch, () => {
243
+ // Motion switches are disabled by default unless the user enables them.
244
+ if (!isEnabled || !this.hasFeature("Motion.Switch")) {
245
+ return false;
174
246
  }
175
- // If we disable the switch, make sure we fully reset it's state. Otherwise, we can end up in a situation (e.g. liveview switches) where we have
176
- // disabled motion detection with no meaningful way to enable it again.
247
+ return true;
248
+ }, ProtectReservedNames.SWITCH_MOTION_SENSOR)) {
249
+ // If we disable the switch, make sure we fully reset it's state. Otherwise, we can end up in a situation (e.g. liveview switches) where we have disabled motion
250
+ // detection with no meaningful way to enable it again.
177
251
  this.accessory.context.detectMotion = true;
178
252
  return false;
179
253
  }
180
- this.log.info("Enabling motion sensor switch.");
181
- const switchName = this.accessoryName + " Motion Events";
182
- // Add the switch to the camera, if needed.
183
- if (!switchService) {
184
- switchService = new this.hap.Service.Switch(switchName, ProtectReservedNames.SWITCH_MOTION_SENSOR);
185
- if (!switchService) {
186
- this.log.error("Unable to add motion sensor switch.");
187
- return false;
188
- }
189
- switchService.addOptionalCharacteristic(this.hap.Characteristic.ConfiguredName);
190
- this.accessory.addService(switchService);
254
+ // Acquire the service.
255
+ const service = this.acquireService(this.hap.Service.Switch, this.accessoryName + " Motion Events", ProtectReservedNames.SWITCH_MOTION_SENSOR);
256
+ // Fail gracefully.
257
+ if (!service) {
258
+ this.log.error("Unable to add motion sensor switch.");
259
+ return false;
191
260
  }
192
261
  // Activate or deactivate motion detection.
193
- switchService.getCharacteristic(this.hap.Characteristic.On)
194
- ?.onGet(() => {
262
+ service.getCharacteristic(this.hap.Characteristic.On)?.onGet(() => {
195
263
  return this.accessory.context.detectMotion === true;
196
- })
197
- .onSet((value) => {
264
+ });
265
+ service.getCharacteristic(this.hap.Characteristic.On)?.onSet((value) => {
198
266
  if (this.accessory.context.detectMotion !== value) {
199
267
  this.log.info("Motion detection %s.", (value === true) ? "enabled" : "disabled");
200
268
  }
@@ -204,31 +272,28 @@ export class ProtectDevice extends ProtectBase {
204
272
  if (!("detectMotion" in this.accessory.context)) {
205
273
  this.accessory.context.detectMotion = true;
206
274
  }
207
- switchService.updateCharacteristic(this.hap.Characteristic.ConfiguredName, switchName);
208
- switchService.updateCharacteristic(this.hap.Characteristic.On, this.accessory.context.detectMotion);
275
+ service.updateCharacteristic(this.hap.Characteristic.On, this.accessory.context.detectMotion);
276
+ this.log.info("Enabling motion sensor switch.");
209
277
  return true;
210
278
  }
211
279
  // Configure a switch to manually trigger a motion sensor event for HomeKit.
212
280
  configureMotionTrigger(isEnabled = true) {
213
- // Find the switch service, if it exists.
214
- let triggerService = this.accessory.getServiceById(this.hap.Service.Switch, ProtectReservedNames.SWITCH_MOTION_TRIGGER);
215
- // Motion triggers are disabled by default and primarily exist for automation purposes.
216
- if (!isEnabled || !this.hasFeature("Motion.Trigger")) {
217
- if (triggerService) {
218
- this.accessory.removeService(triggerService);
281
+ // Validate whether we should have this service enabled.
282
+ if (!this.validService(this.hap.Service.Switch, () => {
283
+ // Motion triggers are disabled by default and primarily exist for automation purposes.
284
+ if (!isEnabled || !this.hasFeature("Motion.Trigger")) {
285
+ return false;
219
286
  }
287
+ return true;
288
+ }, ProtectReservedNames.SWITCH_MOTION_TRIGGER)) {
220
289
  return false;
221
290
  }
222
- const triggerName = this.accessoryName + " Motion Trigger";
223
- // Add the switch to the camera, if needed.
291
+ // Acquire the service.
292
+ const triggerService = this.acquireService(this.hap.Service.Switch, this.accessoryName + " Motion Trigger", ProtectReservedNames.SWITCH_MOTION_TRIGGER);
293
+ // Fail gracefully.
224
294
  if (!triggerService) {
225
- triggerService = new this.hap.Service.Switch(triggerName, ProtectReservedNames.SWITCH_MOTION_TRIGGER);
226
- if (!triggerService) {
227
- this.log.error("Unable to add motion sensor trigger.");
228
- return false;
229
- }
230
- triggerService.addOptionalCharacteristic(this.hap.Characteristic.ConfiguredName);
231
- this.accessory.addService(triggerService);
295
+ this.log.error("Unable to add motion sensor trigger.");
296
+ return false;
232
297
  }
233
298
  const motionService = this.accessory.getService(this.hap.Service.MotionSensor);
234
299
  const switchService = this.accessory.getServiceById(this.hap.Service.Switch, ProtectReservedNames.SWITCH_MOTION_SENSOR);
@@ -246,7 +311,7 @@ export class ProtectDevice extends ProtectBase {
246
311
  }
247
312
  else {
248
313
  // Trigger the motion event.
249
- this.nvr.events.motionEventHandler(this, Date.now());
314
+ this.nvr.events.motionEventHandler(this);
250
315
  // Inform the user.
251
316
  this.log.info("Motion event triggered.");
252
317
  }
@@ -260,55 +325,36 @@ export class ProtectDevice extends ProtectBase {
260
325
  }
261
326
  });
262
327
  // Initialize the switch.
263
- triggerService.updateCharacteristic(this.hap.Characteristic.ConfiguredName, triggerName);
264
328
  triggerService.updateCharacteristic(this.hap.Characteristic.On, false);
265
329
  this.log.info("Enabling motion sensor automation trigger.");
266
330
  return true;
267
331
  }
268
- // Configure MQTT motion triggers.
269
- configureMqttMotionTrigger() {
270
- // Trigger a motion event in MQTT, if requested to do so.
271
- this.nvr.mqtt?.subscribe(this.id, "motion/trigger", (message) => {
272
- const value = message.toString();
273
- // When we get the right message, we trigger the motion event.
274
- if (value?.toLowerCase() !== "true") {
275
- return;
276
- }
277
- // Trigger the motion event.
278
- this.nvr.events.motionEventHandler(this, Date.now());
279
- this.log.info("Motion event triggered via MQTT.");
280
- });
281
- return true;
282
- }
283
332
  // Configure the Protect occupancy sensor for HomeKit.
284
333
  configureOccupancySensor(isEnabled = true, isInitialized = false) {
285
- // Find the occupancy sensor service, if it exists.
286
- let occupancyService = this.accessory.getService(this.hap.Service.OccupancySensor);
287
- // Occupancy sensors are disabled by default and primarily exist for automation purposes.
288
- if (!isEnabled || !this.hasFeature("Motion.OccupancySensor")) {
289
- if (occupancyService) {
290
- this.accessory.removeService(occupancyService);
291
- this.log.info("Disabling occupancy sensor.");
334
+ // Validate whether we should have this service enabled.
335
+ if (!this.validService(this.hap.Service.OccupancySensor, () => {
336
+ // Occupancy sensors are disabled by default and primarily exist for automation purposes.
337
+ if (!isEnabled || !this.hasFeature("Motion.OccupancySensor")) {
338
+ this.nvr.mqtt?.unsubscribe(this.accessory, "occupancy/get");
339
+ return false;
292
340
  }
341
+ return true;
342
+ })) {
293
343
  return false;
294
344
  }
295
- // We don't have an occupancy sensor, let's add it to the device.
296
- if (!occupancyService) {
297
- // We don't have it, add the occupancy sensor to the device.
298
- occupancyService = new this.hap.Service.OccupancySensor(this.accessoryName);
299
- if (!occupancyService) {
300
- this.log.error("Unable to add occupancy sensor.");
301
- return false;
302
- }
303
- this.accessory.addService(occupancyService);
345
+ // Acquire the service.
346
+ const service = this.acquireService(this.hap.Service.OccupancySensor);
347
+ if (!service) {
348
+ this.log.error("Unable to add occupancy sensor.");
349
+ return false;
304
350
  }
305
351
  // Have we previously initialized this sensor? We assume not by default, but this allows for scenarios where you may be dynamically reconfiguring a sensor at
306
352
  // runtime (e.g. UniFi sensors can be reconfigured for various sensor modes in realtime).
307
353
  if (!isInitialized) {
308
354
  // Initialize the state of the occupancy sensor.
309
- occupancyService.updateCharacteristic(this.hap.Characteristic.OccupancyDetected, false);
310
- occupancyService.updateCharacteristic(this.hap.Characteristic.StatusActive, this.isOnline);
311
- occupancyService.getCharacteristic(this.hap.Characteristic.StatusActive).onGet(() => {
355
+ service.updateCharacteristic(this.hap.Characteristic.OccupancyDetected, false);
356
+ service.updateCharacteristic(this.hap.Characteristic.StatusActive, this.isOnline);
357
+ service.getCharacteristic(this.hap.Characteristic.StatusActive).onGet(() => {
312
358
  return this.isOnline;
313
359
  });
314
360
  // If we have smart motion detection, allow users to choose which object types determine occupancy.
@@ -324,6 +370,10 @@ export class ProtectDevice extends ProtectBase {
324
370
  this.hints.smartOccupancy.push("no smart motion detection object type configured");
325
371
  }
326
372
  }
373
+ // Configure our MQTT support.
374
+ this.subscribeGet("occupancy", "occupancy", () => {
375
+ return service.getCharacteristic(this.hap.Characteristic.OccupancyDetected).value === true ? "true" : "false";
376
+ });
327
377
  this.log.info("Enabling occupancy sensor%s.", this.hints.smartDetect ? " using smart motion detection: " + this.hints.smartOccupancy.join(", ") : "");
328
378
  }
329
379
  return true;
@@ -358,7 +408,7 @@ export class ProtectDevice extends ProtectBase {
358
408
  }
359
409
  // Utility function to return the fully enumerated name of this device.
360
410
  get name() {
361
- return this.nvr.ufpApi.getFullName(this.ufp);
411
+ return this.nvr.ufpApi.getDeviceName(this.ufp);
362
412
  }
363
413
  // Utility function to return the current accessory name of this device.
364
414
  get accessoryName() {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protect-device.js","sourceRoot":"","sources":["../../src/devices/protect-device.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAC,MAAM,gBAAgB,CAAC;AAEpF,OAAO,EAA4C,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGzG,OAAO,IAAI,MAAM,WAAW,CAAC;AA0C7B,MAAM,OAAgB,WAAW;IAEf,GAAG,CAAM;IACjB,KAAK,CAAsD;IAChD,GAAG,CAAM;IACZ,GAAG,CAAiB;IACpB,GAAG,CAAa;IACzB,MAAM,CAAa;IACV,QAAQ,CAAkB;IAE1C,yEAAyE;IACzE,YAAY,GAAe;QAEzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,GAAG,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AE;QAEX,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,uEAAuE;IACvE,IAAW,IAAI;QAEb,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC;IAED,wEAAwE;IACxE,IAAW,aAAa;QAEtB,OAAQ,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,KAAgB;YACxI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,SAAS,CAAC,CAAC;IAClC,CAAC;IAED,qEAAqE;IACrE,IAAW,aAAa,CAAC,IAAY;QAEnC,oFAAoF;QACpF,IAAI,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC;QAClC,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,WAAW,GAAG,IAAI,CAAC;QAE1D,qCAAqC;QACrC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7H,CAAC;CACF"}
@@ -2,7 +2,7 @@ import { PlatformAccessory } from "homebridge";
2
2
  import { ProtectCameraConfig, ProtectEventPacket } from "unifi-protect";
3
3
  import { ProtectCamera } from "./protect-camera.js";
4
4
  import { ProtectCameraPackage } from "./protect-camera-package.js";
5
- import { ProtectNvr } from "./protect-nvr.js";
5
+ import { ProtectNvr } from "../protect-nvr.js";
6
6
  export declare class ProtectDoorbell extends ProtectCamera {
7
7
  private chimeDigitalDuration;
8
8
  private defaultMessageDuration;