homebridge-unifi-protect 5.5.4 → 6.0.1
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 +3 -3
- package/config.schema.json +17 -16
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/protect-camera.d.ts +58 -0
- package/dist/protect-camera.js +367 -246
- package/dist/protect-camera.js.map +1 -1
- package/dist/protect-device.d.ts +48 -0
- package/dist/protect-device.js +189 -0
- package/dist/protect-device.js.map +1 -0
- package/dist/protect-doorbell.d.ts +22 -0
- package/dist/protect-doorbell.js +75 -64
- package/dist/protect-doorbell.js.map +1 -1
- package/dist/protect-ffmpeg-record.d.ts +15 -0
- package/dist/protect-ffmpeg-record.js +48 -34
- package/dist/protect-ffmpeg-record.js.map +1 -1
- package/dist/protect-ffmpeg-stream.d.ts +15 -0
- package/dist/protect-ffmpeg-stream.js +22 -12
- package/dist/protect-ffmpeg-stream.js.map +1 -1
- package/dist/protect-ffmpeg.d.ts +42 -0
- package/dist/protect-ffmpeg.js +49 -58
- package/dist/protect-ffmpeg.js.map +1 -1
- package/dist/protect-light.d.ts +13 -0
- package/dist/protect-light.js +63 -40
- package/dist/protect-light.js.map +1 -1
- package/dist/protect-liveviews.d.ts +17 -0
- package/dist/protect-liveviews.js +117 -101
- package/dist/protect-liveviews.js.map +1 -1
- package/dist/protect-mqtt.d.ts +19 -0
- package/dist/protect-mqtt.js +26 -35
- package/dist/protect-mqtt.js.map +1 -1
- package/dist/protect-nvr-events.d.ts +30 -0
- package/dist/protect-nvr-events.js +168 -431
- package/dist/protect-nvr-events.js.map +1 -1
- package/dist/protect-nvr-systeminfo.d.ts +15 -0
- package/dist/protect-nvr-systeminfo.js +43 -49
- package/dist/protect-nvr-systeminfo.js.map +1 -1
- package/dist/protect-nvr.d.ts +48 -0
- package/dist/protect-nvr.js +327 -359
- package/dist/protect-nvr.js.map +1 -1
- package/dist/protect-options.d.ts +39 -0
- package/dist/protect-options.js +172 -6
- package/dist/protect-options.js.map +1 -1
- package/dist/protect-platform.d.ts +17 -0
- package/dist/protect-platform.js +17 -30
- package/dist/protect-platform.js.map +1 -1
- package/dist/protect-record.d.ts +33 -0
- package/dist/protect-record.js +130 -126
- package/dist/protect-record.js.map +1 -1
- package/dist/protect-rtp.d.ts +29 -0
- package/dist/protect-rtp.js +133 -16
- package/dist/protect-rtp.js.map +1 -1
- package/dist/protect-securitysystem.d.ts +18 -0
- package/dist/protect-securitysystem.js +105 -109
- package/dist/protect-securitysystem.js.map +1 -1
- package/dist/protect-sensor.d.ts +28 -0
- package/dist/protect-sensor.js +79 -97
- package/dist/protect-sensor.js.map +1 -1
- package/dist/protect-stream.d.ts +41 -0
- package/dist/protect-stream.js +298 -156
- package/dist/protect-stream.js.map +1 -1
- package/dist/protect-timeshift.d.ts +30 -0
- package/dist/protect-timeshift.js +65 -48
- package/dist/protect-timeshift.js.map +1 -1
- package/dist/protect-types.d.ts +50 -0
- package/dist/protect-types.js +22 -0
- package/dist/protect-types.js.map +1 -0
- package/dist/protect-viewer.d.ts +17 -0
- package/dist/protect-viewer.js +41 -47
- package/dist/protect-viewer.js.map +1 -1
- package/dist/settings.d.ts +22 -0
- package/dist/settings.js +30 -35
- package/dist/settings.js.map +1 -1
- package/homebridge-ui/public/index.html +715 -0
- package/homebridge-ui/server.js +156 -0
- package/package.json +15 -15
- package/dist/protect-accessory.js +0 -184
- package/dist/protect-accessory.js.map +0 -1
package/dist/protect-viewer.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ProtectDevice } from "./protect-device.js";
|
|
2
|
+
export class ProtectViewer extends ProtectDevice {
|
|
3
|
+
// Create an instance.
|
|
4
|
+
constructor(nvr, device, accessory) {
|
|
5
|
+
super(nvr, accessory);
|
|
6
|
+
this.ufp = device;
|
|
7
|
+
this.configureHints();
|
|
8
|
+
this.configureDevice();
|
|
9
|
+
}
|
|
6
10
|
// Initialize and configure the viewer accessory for HomeKit.
|
|
7
|
-
|
|
8
|
-
var _a;
|
|
9
|
-
// Save the device object before we wipeout the context.
|
|
10
|
-
const device = this.accessory.context.device;
|
|
11
|
+
configureDevice() {
|
|
11
12
|
// Clean out the context object in case it's been polluted somehow.
|
|
12
13
|
this.accessory.context = {};
|
|
13
|
-
this.accessory.context.
|
|
14
|
-
this.accessory.context.nvr =
|
|
14
|
+
this.accessory.context.mac = this.ufp.mac;
|
|
15
|
+
this.accessory.context.nvr = this.nvr.ufp.mac;
|
|
15
16
|
// Configure accessory information.
|
|
16
17
|
this.configureInfo();
|
|
17
18
|
// Configure accessory services.
|
|
@@ -20,24 +21,23 @@ class ProtectViewer extends protect_accessory_1.ProtectAccessory {
|
|
|
20
21
|
this.configureMqtt();
|
|
21
22
|
// Inform the user what we're enabling on startup.
|
|
22
23
|
if (enabledLiveviews.length) {
|
|
23
|
-
this.log.info("
|
|
24
|
+
this.log.info("Configured liveview%s: %s.", enabledLiveviews.length > 1 ? "s" : "", enabledLiveviews.join(", "));
|
|
24
25
|
}
|
|
25
26
|
else {
|
|
26
|
-
this.log.info("
|
|
27
|
+
this.log.info("No liveviews configured.");
|
|
27
28
|
}
|
|
28
|
-
return
|
|
29
|
+
return true;
|
|
29
30
|
}
|
|
30
31
|
// Update accessory services and characteristics.
|
|
31
32
|
updateDevice(configureHandlers = false) {
|
|
32
|
-
var _a, _b, _c, _d;
|
|
33
33
|
// Grab the current list of liveview switches we know about.
|
|
34
34
|
const currentLiveviewSwitches = this.accessory.services.filter(x => (x.UUID === this.hap.Service.Switch.UUID) && x.subtype);
|
|
35
35
|
// Grab the current list of liveview identifiers from Protect.
|
|
36
|
-
const nvrLiveviewIds =
|
|
36
|
+
const nvrLiveviewIds = this.ufpApi.bootstrap?.liveviews?.map(x => x.id);
|
|
37
37
|
// Identify what's been removed on the NVR and remove it from the accessory as well.
|
|
38
|
-
currentLiveviewSwitches.filter(x =>
|
|
38
|
+
currentLiveviewSwitches.filter(x => !nvrLiveviewIds?.includes(x.subtype ?? "")).map(x => this.accessory.removeService(x));
|
|
39
39
|
// Identify what needs to be added to HomeKit that isn't already there, and add them.
|
|
40
|
-
this.addLiveviewSwitch(
|
|
40
|
+
this.addLiveviewSwitch(nvrLiveviewIds?.filter(x => !currentLiveviewSwitches.filter(liveviewSwitch => liveviewSwitch.subtype === x).length) ?? []);
|
|
41
41
|
// Finally, reflect the state of the liveview that's currently enabled.
|
|
42
42
|
// Loop through the list of services on our viewer accessory and sync the liveview switches.
|
|
43
43
|
this.updateLiveviewSwitchState(configureHandlers);
|
|
@@ -62,24 +62,24 @@ class ProtectViewer extends protect_accessory_1.ProtectAccessory {
|
|
|
62
62
|
}
|
|
63
63
|
// Configure the state and handlers of a liveview switch.
|
|
64
64
|
configureLiveviewSwitch(switchService, configureHandlers = true) {
|
|
65
|
-
var _a;
|
|
66
65
|
// If we're configuring a switch for the first time, we add our respective handlers.
|
|
67
66
|
if (configureHandlers) {
|
|
68
67
|
// Turn the liveview switch on or off.
|
|
69
|
-
|
|
68
|
+
switchService.getCharacteristic(this.hap.Characteristic.On)
|
|
69
|
+
?.onGet(() => {
|
|
70
70
|
return this.getLiveviewSwitchState(switchService);
|
|
71
|
-
})
|
|
71
|
+
})
|
|
72
|
+
.onSet((value) => {
|
|
72
73
|
return this.setLiveviewSwitchState(switchService, value);
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
// Set the state to reflect Protect.
|
|
76
|
-
switchService.updateCharacteristic(this.hap.Characteristic.On, switchService.subtype === this.
|
|
77
|
+
switchService.updateCharacteristic(this.hap.Characteristic.On, switchService.subtype === this.ufp.liveview);
|
|
77
78
|
return true;
|
|
78
79
|
}
|
|
79
80
|
// Return the current state of the liveview switch.
|
|
80
81
|
getLiveviewSwitchState(switchService) {
|
|
81
|
-
return (this.
|
|
82
|
-
(this.accessory.context.device.liveview === switchService.subtype);
|
|
82
|
+
return (this.ufp.liveview !== null) && (this.ufp.liveview === switchService.subtype);
|
|
83
83
|
}
|
|
84
84
|
// Set the current state of the liveview switch.
|
|
85
85
|
async setLiveviewSwitchState(switchService, value) {
|
|
@@ -87,21 +87,20 @@ class ProtectViewer extends protect_accessory_1.ProtectAccessory {
|
|
|
87
87
|
const newDevice = await this.setViewer(viewState);
|
|
88
88
|
if (!newDevice) {
|
|
89
89
|
if (viewState) {
|
|
90
|
-
this.log.error("
|
|
90
|
+
this.log.error("Unable to set the liveview to: %s.", switchService.displayName);
|
|
91
91
|
}
|
|
92
92
|
else {
|
|
93
|
-
this.log.error("
|
|
93
|
+
this.log.error("Unable to clear the liveview.");
|
|
94
94
|
}
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
97
|
// Set the context to our updated device configuration.
|
|
98
|
-
this.
|
|
98
|
+
this.ufp = newDevice;
|
|
99
99
|
// Update all the other liveview switches.
|
|
100
100
|
this.updateLiveviewSwitchState();
|
|
101
101
|
}
|
|
102
102
|
// Add liveview switches to HomeKit for viewer devices.
|
|
103
103
|
addLiveviewSwitch(newLiveviewIds) {
|
|
104
|
-
var _a, _b, _c, _d;
|
|
105
104
|
// Loop through the list of liveview identifiers and add them to HomeKit as switches.
|
|
106
105
|
for (const liveviewId of newLiveviewIds) {
|
|
107
106
|
// Empty or invalid liveview identifier.
|
|
@@ -109,11 +108,11 @@ class ProtectViewer extends protect_accessory_1.ProtectAccessory {
|
|
|
109
108
|
continue;
|
|
110
109
|
}
|
|
111
110
|
// Retrieve the name assigned to this liveview.
|
|
112
|
-
const liveviewName =
|
|
111
|
+
const liveviewName = this.ufpApi.bootstrap?.liveviews?.find(x => x.id === liveviewId)?.name;
|
|
113
112
|
// Grab the switch service associated with this liveview.
|
|
114
113
|
const switchService = new this.hap.Service.Switch(liveviewName, liveviewId);
|
|
115
114
|
if (!switchService) {
|
|
116
|
-
this.log.error("
|
|
115
|
+
this.log.error("Unable to add liveview switch for %s.", liveviewName);
|
|
117
116
|
continue;
|
|
118
117
|
}
|
|
119
118
|
this.accessory.addService(switchService);
|
|
@@ -123,48 +122,43 @@ class ProtectViewer extends protect_accessory_1.ProtectAccessory {
|
|
|
123
122
|
}
|
|
124
123
|
// Set the liveview on a viewer device in UniFi Protect.
|
|
125
124
|
async setViewer(newLiveview) {
|
|
126
|
-
var _a, _b, _c, _d;
|
|
127
125
|
// Set the liveview.
|
|
128
|
-
const newDevice = (await this.nvr.
|
|
126
|
+
const newDevice = (await this.nvr.ufpApi.updateDevice(this.ufp, { liveview: newLiveview }));
|
|
129
127
|
// Find the liveview name for MQTT.
|
|
130
|
-
const liveview =
|
|
128
|
+
const liveview = this.ufpApi.bootstrap?.liveviews?.find(x => x.id === newLiveview);
|
|
131
129
|
// Publish an MQTT event.
|
|
132
130
|
if (liveview) {
|
|
133
|
-
|
|
131
|
+
this.nvr.mqtt?.publish(this.accessory, "liveview", liveview.name);
|
|
134
132
|
}
|
|
135
133
|
return newDevice;
|
|
136
134
|
}
|
|
137
135
|
// Configure MQTT capabilities of this viewer.
|
|
138
136
|
configureMqtt() {
|
|
139
|
-
var _a, _b;
|
|
140
137
|
// Trigger a motion event in MQTT, if requested to do so.
|
|
141
|
-
|
|
142
|
-
var _a, _b, _c;
|
|
138
|
+
this.nvr.mqtt?.subscribe(this.accessory, "liveview/set", (message) => {
|
|
143
139
|
const value = message.toString().toLowerCase();
|
|
144
|
-
const liveview =
|
|
140
|
+
const liveview = this.ufpApi.bootstrap?.liveviews?.find(x => x.name.toLowerCase() === value);
|
|
145
141
|
if (!liveview) {
|
|
146
|
-
this.log.error("
|
|
142
|
+
this.log.error("Unable to locate a liveview named %s.", message.toString());
|
|
147
143
|
return;
|
|
148
144
|
}
|
|
149
145
|
(async () => {
|
|
150
146
|
const newDevice = await this.setViewer(liveview.id);
|
|
151
147
|
if (newDevice) {
|
|
152
|
-
this.
|
|
153
|
-
this.log.info("
|
|
148
|
+
this.ufp = newDevice;
|
|
149
|
+
this.log.info("Liveview set via MQTT to %s.", liveview.name);
|
|
154
150
|
}
|
|
155
151
|
else {
|
|
156
|
-
this.log.error("
|
|
152
|
+
this.log.error("Unable to set liveview via MQTT to %s.", message.toString());
|
|
157
153
|
}
|
|
158
154
|
})();
|
|
159
155
|
});
|
|
160
156
|
// Trigger a motion event in MQTT, if requested to do so.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return (_d = liveview === null || liveview === void 0 ? void 0 : liveview.name) !== null && _d !== void 0 ? _d : "None";
|
|
157
|
+
this.nvr.mqtt?.subscribeGet(this.accessory, this.name, "liveview", "Liveview", () => {
|
|
158
|
+
const liveview = this.ufpApi.bootstrap?.liveviews?.find(x => x.id === this.ufp.liveview);
|
|
159
|
+
return liveview?.name ?? "None";
|
|
165
160
|
});
|
|
166
161
|
return true;
|
|
167
162
|
}
|
|
168
163
|
}
|
|
169
|
-
exports.ProtectViewer = ProtectViewer;
|
|
170
164
|
//# sourceMappingURL=protect-viewer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protect-viewer.js","sourceRoot":"","sources":["../src/protect-viewer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"protect-viewer.js","sourceRoot":"","sources":["../src/protect-viewer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,MAAM,OAAO,aAAc,SAAQ,aAAa;IAI9C,sBAAsB;IACtB,YAAY,GAAe,EAAE,MAA2B,EAAE,SAA4B;QAEpF,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAEtB,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC;QAElB,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAED,6DAA6D;IACrD,eAAe;QAErB,mEAAmE;QACnE,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,EAAE,CAAC;QAC5B,IAAI,CAA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AI,CAAC,GAAG,CAAC,KAAK,CAAC,wCAAwC,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;iBAC9E;YAEH,CAAC,CAAC,EAAE,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,yDAAyD;QACzD,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE;YAElF,MAAM,QAAQ,GAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAE1F,OAAO,QAAQ,EAAE,IAAI,IAAI,MAAM,CAAC;QAClC,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const PLUGIN_NAME = "homebridge-unifi-protect";
|
|
2
|
+
export declare const PLATFORM_NAME = "UniFi Protect";
|
|
3
|
+
export declare const PROTECT_API_ERROR_LIMIT = 10;
|
|
4
|
+
export declare const PROTECT_API_RETRY_INTERVAL = 300;
|
|
5
|
+
export declare const PROTECT_API_TIMEOUT = 3.5;
|
|
6
|
+
export declare const PROTECT_CONTROLLER_REFRESH_INTERVAL = 120;
|
|
7
|
+
export declare const PROTECT_FFMPEG_AUDIO_FILTER_FFTNR = 90;
|
|
8
|
+
export declare const PROTECT_FFMPEG_AUDIO_FILTER_HIGHPASS = 200;
|
|
9
|
+
export declare const PROTECT_FFMPEG_AUDIO_FILTER_LOWPASS = 1000;
|
|
10
|
+
export declare const PROTECT_FFMPEG_OPTIONS: never[];
|
|
11
|
+
export declare const PROTECT_HOMEKIT_IDR_INTERVAL = 4;
|
|
12
|
+
export declare const PROTECT_HKSV_SEGMENT_LENGTH = 4000;
|
|
13
|
+
export declare const PROTECT_HKSV_TIMESHIFT_BUFFER_MAXLENGTH: number;
|
|
14
|
+
export declare const PROTECT_HKSV_SEGMENT_RESOLUTION = 100;
|
|
15
|
+
export declare const PROTECT_LOGIN_REFRESH_INTERVAL = 1800;
|
|
16
|
+
export declare const PROTECT_MOTION_DURATION = 10;
|
|
17
|
+
export declare const PROTECT_MQTT_RECONNECT_INTERVAL = 60;
|
|
18
|
+
export declare const PROTECT_MQTT_TOPIC = "unifi/protect";
|
|
19
|
+
export declare const PROTECT_RING_DURATION = 3;
|
|
20
|
+
export declare const PROTECT_SNAPSHOT_CACHE_MAXAGE = 90;
|
|
21
|
+
export declare const PROTECT_SNAPSHOT_CACHE_REFRESH_INTERVAL = 59;
|
|
22
|
+
export declare const PROTECT_TWOWAY_HEARTBEAT_INTERVAL = 3;
|
package/dist/settings.js
CHANGED
|
@@ -1,54 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PROTECT_HKSV_BUFFER_LENGTH = exports.PROTECT_HKSV_SEGMENT_LENGTH = exports.PROTECT_HKSV_SEGMENT_RESOLUTION = exports.PROTECT_TWOWAY_HEARTBEAT_INTERVAL = exports.PROTECT_RING_DURATION = exports.PROTECT_NVR_UNIFIOS_REFRESH_INTERVAL = exports.PROTECT_MQTT_TOPIC = exports.PROTECT_MQTT_RECONNECT_INTERVAL = exports.PROTECT_MOTION_DURATION = exports.PROTECT_LOGIN_REFRESH_INTERVAL = exports.PROTECT_HOMEKIT_IDR_INTERVAL = exports.PROTECT_FFMPEG_OPTIONS = exports.PROTECT_FFMPEG_AUDIO_FILTER_LOWPASS = exports.PROTECT_FFMPEG_AUDIO_FILTER_HIGHPASS = exports.PROTECT_FFMPEG_AUDIO_FILTER_FFTNR = exports.PROTECT_EVENTS_HEARTBEAT_INTERVAL = exports.PROTECT_API_TIMEOUT = exports.PROTECT_API_RETRY_INTERVAL = exports.PROTECT_API_ERROR_LIMIT = exports.PLATFORM_NAME = exports.PLUGIN_NAME = void 0;
|
|
4
|
-
/* Copyright(C) 2017-2022, HJD (https://github.com/hjdhjd). All rights reserved.
|
|
1
|
+
/* Copyright(C) 2022-2023, HJD (https://github.com/hjdhjd). All rights reserved.
|
|
5
2
|
*
|
|
6
3
|
* settings.ts: Settings and constants for homebridge-unifi-protect.
|
|
7
4
|
*/
|
|
8
5
|
// The name of our plugin.
|
|
9
|
-
|
|
6
|
+
export const PLUGIN_NAME = "homebridge-unifi-protect";
|
|
10
7
|
// The platform the plugin creates.
|
|
11
|
-
|
|
8
|
+
export const PLATFORM_NAME = "UniFi Protect";
|
|
12
9
|
// Number of API errors to accept before we implement backoff so we don't slam a Protect controller.
|
|
13
|
-
|
|
10
|
+
export const PROTECT_API_ERROR_LIMIT = 10;
|
|
14
11
|
// Interval, in seconds, to wait before trying to access the API again once we've hit the PROTECT_API_ERROR_LIMIT threshold.
|
|
15
|
-
|
|
12
|
+
export const PROTECT_API_RETRY_INTERVAL = 300;
|
|
16
13
|
// Protect API response timeout, in seconds. This should never be greater than 5 seconds.
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
exports.PROTECT_EVENTS_HEARTBEAT_INTERVAL = 10;
|
|
14
|
+
export const PROTECT_API_TIMEOUT = 3.5;
|
|
15
|
+
// How often, in seconds, should we check Protect controllers for new or removed devices.
|
|
16
|
+
export const PROTECT_CONTROLLER_REFRESH_INTERVAL = 120;
|
|
21
17
|
// FFmpeg afftdn audio filter defaults - this setting uses FFTs to reduce noise in an audio signal by the number of decibels below.
|
|
22
|
-
|
|
18
|
+
export const PROTECT_FFMPEG_AUDIO_FILTER_FFTNR = 90;
|
|
23
19
|
// FFmpeg highpass audio filter defaults - this setting attenuates (eliminates) frequencies below the value.
|
|
24
|
-
|
|
20
|
+
export const PROTECT_FFMPEG_AUDIO_FILTER_HIGHPASS = 200;
|
|
25
21
|
// FFmpeg lowpass audio filter defaults - this setting attenuates (eliminates) frequencies above the value.
|
|
26
|
-
|
|
22
|
+
export const PROTECT_FFMPEG_AUDIO_FILTER_LOWPASS = 1000;
|
|
27
23
|
// Magic incantantion to further streamline FFmpeg for Protect.
|
|
28
|
-
|
|
24
|
+
export const PROTECT_FFMPEG_OPTIONS = [];
|
|
29
25
|
// HomeKit prefers a video streaming I-frame interval of 4 seconds.
|
|
30
|
-
|
|
26
|
+
export const PROTECT_HOMEKIT_IDR_INTERVAL = 4;
|
|
27
|
+
// HomeKit Secure Video segment length, in milliseconds. HomeKit only supports this value currently.
|
|
28
|
+
export const PROTECT_HKSV_SEGMENT_LENGTH = 4000;
|
|
29
|
+
// HomeKit Secure Video timeshift buffer default length, in milliseconds. This defines how far back in time we can look when we see a motion event.
|
|
30
|
+
export const PROTECT_HKSV_TIMESHIFT_BUFFER_MAXLENGTH = PROTECT_HKSV_SEGMENT_LENGTH * 2;
|
|
31
|
+
// HomeKit Secure Video segment resolution, in milliseconds. This defines the resolution of our buffer. It should never be less than 100ms or greater than 1500ms.
|
|
32
|
+
export const PROTECT_HKSV_SEGMENT_RESOLUTION = 100;
|
|
31
33
|
// How often, in seconds, should we refresh our Protect login credentials.
|
|
32
|
-
|
|
34
|
+
export const PROTECT_LOGIN_REFRESH_INTERVAL = 1800;
|
|
33
35
|
// Default duration, in seconds, of motion events. Setting this too low will potentially cause a lot of notification spam.
|
|
34
|
-
|
|
36
|
+
export const PROTECT_MOTION_DURATION = 10;
|
|
35
37
|
// How often, in seconds, should we try to reconnect with an MQTT broker, if we have one configured.
|
|
36
|
-
|
|
38
|
+
export const PROTECT_MQTT_RECONNECT_INTERVAL = 60;
|
|
37
39
|
// Default MQTT topic to use when publishing events. This is in the form of: unifi/protect/camera/event
|
|
38
|
-
|
|
39
|
-
// How often, in seconds, should we check Protect controllers for new or removed devices.
|
|
40
|
-
// This will NOT impact motion or doorbell event detection on UniFi OS devices.
|
|
41
|
-
exports.PROTECT_NVR_UNIFIOS_REFRESH_INTERVAL = 10;
|
|
40
|
+
export const PROTECT_MQTT_TOPIC = "unifi/protect";
|
|
42
41
|
// Default duration, in seconds, of ring events.
|
|
43
|
-
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// less than
|
|
49
|
-
|
|
50
|
-
// HomeKit Secure Video segment length, in milliseconds. HomeKit only supports this value currently.
|
|
51
|
-
exports.PROTECT_HKSV_SEGMENT_LENGTH = 4000;
|
|
52
|
-
// HomeKit Secure Video buffer length, in milliseconds. This defines how far back in time we can look when we see a motion event.
|
|
53
|
-
exports.PROTECT_HKSV_BUFFER_LENGTH = exports.PROTECT_HKSV_SEGMENT_LENGTH * 2;
|
|
42
|
+
export const PROTECT_RING_DURATION = 3;
|
|
43
|
+
// Maximum age of a snapshot in seconds.
|
|
44
|
+
export const PROTECT_SNAPSHOT_CACHE_MAXAGE = 90;
|
|
45
|
+
// Snapshot cache refresh interval in seconds.
|
|
46
|
+
export const PROTECT_SNAPSHOT_CACHE_REFRESH_INTERVAL = 59;
|
|
47
|
+
// How often, in seconds, should we heartbeat FFmpeg in two-way audio sessions. This should be less than 5 seconds, which is FFmpeg's input timeout interval.
|
|
48
|
+
export const PROTECT_TWOWAY_HEARTBEAT_INTERVAL = 3;
|
|
54
49
|
//# sourceMappingURL=settings.js.map
|
package/dist/settings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,0BAA0B;AAC1B,MAAM,CAAC,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAEtD,mCAAmC;AACnC,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC;AAE7C,oGAAoG;AACpG,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C,4HAA4H;AAC5H,MAAM,CAAC,MAAM,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