@camstack/addon-provider-reolink 1.2.253 → 1.2.254
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/CHANGELOG.md +12 -0
- package/dist/addon.js +380 -161
- package/dist/addon.mjs +380 -161
- package/i18n/en.json +6 -3
- package/i18n/it.json +6 -3
- package/package.json +2 -2
package/dist/addon.mjs
CHANGED
|
@@ -162705,7 +162705,7 @@ var mediaPlayerCapability = {
|
|
|
162705
162705
|
]
|
|
162706
162706
|
}
|
|
162707
162707
|
};
|
|
162708
|
-
DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Climate, DeviceType.EventEmitter, DeviceType.Climate, DeviceType.Climate, DeviceType.Camera, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.WeatherStation, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Workload, DeviceType.Camera, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Gateway, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.PetFeeder, DeviceType.MediaPlayer, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation;
|
|
162708
|
+
DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Climate, DeviceType.EventEmitter, DeviceType.Climate, DeviceType.Climate, DeviceType.Camera, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.WeatherStation, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Workload, DeviceType.Camera, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.HeatPump, DeviceType.HeatPump, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Gateway, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.PetFeeder, DeviceType.MediaPlayer, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation;
|
|
162709
162709
|
var NUMBER = {
|
|
162710
162710
|
kind: "fixed",
|
|
162711
162711
|
result: ["number"]
|
|
@@ -171128,6 +171128,43 @@ function heatPumpInstantCop(power) {
|
|
|
171128
171128
|
if (thermalW === null || electricalW === null || electricalW <= 0) return null;
|
|
171129
171129
|
return thermalW / electricalW;
|
|
171130
171130
|
}
|
|
171131
|
+
var HEAT_PUMP_CUSTOMIZE_DEVICE_TYPES = [DeviceType.HeatPump];
|
|
171132
|
+
/** One electrical reading the operator may take from a device they pick, unit checked. */
|
|
171133
|
+
function electricalTarget(id, path, unit) {
|
|
171134
|
+
return {
|
|
171135
|
+
id,
|
|
171136
|
+
cardinality: "scalar",
|
|
171137
|
+
vocabulary: { cap: "heat-pump-status" },
|
|
171138
|
+
deviceTypes: HEAT_PUMP_CUSTOMIZE_DEVICE_TYPES,
|
|
171139
|
+
apply: "replace",
|
|
171140
|
+
path,
|
|
171141
|
+
sources: [{
|
|
171142
|
+
kind: "numeric",
|
|
171143
|
+
requiredUnit: unit,
|
|
171144
|
+
transforms: [{ kind: "identity" }]
|
|
171145
|
+
}],
|
|
171146
|
+
sourceReport: { status: "assignment-status" }
|
|
171147
|
+
};
|
|
171148
|
+
}
|
|
171149
|
+
var HEAT_PUMP_TARGETS = [electricalTarget("electrical-power", "power.electricalW", "W"), electricalTarget("electrical-energy", "energy.electricalKwh", "kWh")];
|
|
171150
|
+
/**
|
|
171151
|
+
* Customize (D984, #476): a gateway that reports no instantaneous electrical
|
|
171152
|
+
* power (the cloud ones) or whose energy meter the operator trusts less than a
|
|
171153
|
+
* dedicated one lets the OPERATOR pick a device for `power.electricalW` and
|
|
171154
|
+
* `energy.electricalKwh` — a `replace` over a field listed in `overridable`,
|
|
171155
|
+
* nothing else. The replaced value IS the cap field, so the instant COP, the
|
|
171156
|
+
* hero pills and the history use it; nothing is linked by itself (D356), the
|
|
171157
|
+
* unit is checked, and a source that does not answer releases the field back to
|
|
171158
|
+
* the native reading (never a 0, D393).
|
|
171159
|
+
*/
|
|
171160
|
+
var heatPumpStatusCustomize = {
|
|
171161
|
+
version: 1,
|
|
171162
|
+
overridable: HEAT_PUMP_TARGETS.map((target) => ({
|
|
171163
|
+
path: target.path,
|
|
171164
|
+
by: target.id
|
|
171165
|
+
})),
|
|
171166
|
+
targets: HEAT_PUMP_TARGETS
|
|
171167
|
+
};
|
|
171131
171168
|
var heatPumpStatusCapability = {
|
|
171132
171169
|
name: "heat-pump-status",
|
|
171133
171170
|
scope: "device",
|
|
@@ -171146,6 +171183,7 @@ var heatPumpStatusCapability = {
|
|
|
171146
171183
|
* (the series are recorded). See `RuntimeStateDurability`.
|
|
171147
171184
|
*/
|
|
171148
171185
|
durability: "session",
|
|
171186
|
+
customize: heatPumpStatusCustomize,
|
|
171149
171187
|
/**
|
|
171150
171188
|
* History (D850, D917): `circuits[]` is a keyed array — one series per circuit and
|
|
171151
171189
|
* field, named by the circuit's label. The mode is a state (D896); the energy
|
|
@@ -172937,6 +172975,8 @@ var IntegrationInstanceKindSchema = object({
|
|
|
172937
172975
|
role: IntegrationInstanceRoleSchema.optional(),
|
|
172938
172976
|
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
172939
172977
|
canTest: boolean().optional(),
|
|
172978
|
+
/** `false`: Add never offers this kind (the system creates its one instance, e.g. a default integration). Absent = creatable. */
|
|
172979
|
+
creatable: boolean().optional(),
|
|
172940
172980
|
/** The kind signs in through a server-held interactive session. */
|
|
172941
172981
|
signIn: object({
|
|
172942
172982
|
basePath: string().min(1),
|
|
@@ -222670,6 +222710,19 @@ object({
|
|
|
222670
222710
|
delay: number$1().nonnegative().optional(),
|
|
222671
222711
|
commands: record(string(), unknown())
|
|
222672
222712
|
});
|
|
222713
|
+
/** The `instance-select` field of a link, keyed like the body field it fills. */
|
|
222714
|
+
function linkFieldDescriptor(key, target, labels) {
|
|
222715
|
+
return {
|
|
222716
|
+
type: "instance-select",
|
|
222717
|
+
key,
|
|
222718
|
+
label: labels.label,
|
|
222719
|
+
...labels.description !== void 0 ? { description: labels.description } : {},
|
|
222720
|
+
required: labels.required ?? true,
|
|
222721
|
+
...labels.noneLabel !== void 0 ? { noneLabel: labels.noneLabel } : {},
|
|
222722
|
+
functionCap: target.cap,
|
|
222723
|
+
...target.kind !== void 0 ? { kind: target.kind } : {}
|
|
222724
|
+
};
|
|
222725
|
+
}
|
|
222673
222726
|
//#endregion
|
|
222674
222727
|
//#region src/clips/clip-prefetch.ts
|
|
222675
222728
|
/** The longest a device may stay quiet after refusals, whatever its interval. */
|
|
@@ -223169,6 +223222,11 @@ var reolinkCameraSchema = object({
|
|
|
223169
223222
|
/** Empty for a camera adopted from an NVR / Home Hub: it borrows its integration's session. */
|
|
223170
223223
|
password: string().default("").describe("Password").meta({ secret: true }),
|
|
223171
223224
|
/**
|
|
223225
|
+
* The SMTP password last written to the camera on the Email tab (or by Auto-configure email
|
|
223226
|
+
* push). A keychain secret: the form shows set / not set, never the value.
|
|
223227
|
+
*/
|
|
223228
|
+
emailPassword: string().default("").describe("Camera SMTP password").meta({ secret: true }),
|
|
223229
|
+
/**
|
|
223172
223230
|
* Transport mode resolved at creation time by autodetect (Slice 15).
|
|
223173
223231
|
* - `tcp` : standard TCP-based Baichuan (regular cameras, NVR/Hub)
|
|
223174
223232
|
* - `udp` : BCUDP-based Baichuan (battery cams, UDP-only models like
|
|
@@ -223496,6 +223554,17 @@ var reolinkCameraSchema = object({
|
|
|
223496
223554
|
supported: boolean().optional()
|
|
223497
223555
|
}).optional(),
|
|
223498
223556
|
/**
|
|
223557
|
+
* The power source of a battery camera (`getPowerSource`): `adapter`,
|
|
223558
|
+
* `battery`, or `unknown` when the read failed or the firmware is
|
|
223559
|
+
* silent. Drives the Advanced tab's "Power source" setting; `unknown`
|
|
223560
|
+
* hides it.
|
|
223561
|
+
*/
|
|
223562
|
+
powerSourceSnapshot: object({ source: _enum([
|
|
223563
|
+
"adapter",
|
|
223564
|
+
"battery",
|
|
223565
|
+
"unknown"
|
|
223566
|
+
]) }).optional(),
|
|
223567
|
+
/**
|
|
223499
223568
|
* Snapshot of the camera's auto-reboot schedule from
|
|
223500
223569
|
* `getAutoReboot` (cmd_id 101). Drives the "Auto reboot" section
|
|
223501
223570
|
* defaults on the Advanced tab. `weekDay` is the lib's `DayOfWeek`
|
|
@@ -229777,6 +229846,17 @@ function deriveReolinkCameraFeatures(inputs) {
|
|
|
229777
229846
|
return out;
|
|
229778
229847
|
}
|
|
229779
229848
|
//#endregion
|
|
229849
|
+
//#region src/email-smtp-password.ts
|
|
229850
|
+
/**
|
|
229851
|
+
* The camera SMTP password an operator wrote on the Email tab, when it is a real value to push
|
|
229852
|
+
* to the camera and keep: a non-empty string that is not a keychain marker. Blank means "keep
|
|
229853
|
+
* the stored one" and a marker is the form echoing back what it was shown; neither is a write.
|
|
229854
|
+
*/
|
|
229855
|
+
function smtpPasswordToWrite(value) {
|
|
229856
|
+
if (typeof value !== "string" || value.length === 0) return null;
|
|
229857
|
+
return isSecretMarker(value) ? null : value;
|
|
229858
|
+
}
|
|
229859
|
+
//#endregion
|
|
229780
229860
|
//#region src/hub-child-settings.ts
|
|
229781
229861
|
/**
|
|
229782
229862
|
* A camera adopted under an NVR / Home Hub dials through the integration's session: the address
|
|
@@ -232410,6 +232490,13 @@ var PirAccessory = class extends BaseDevice {
|
|
|
232410
232490
|
* inverse `101 - userValue` (lower raw = more sensitive).
|
|
232411
232491
|
* Mirrors `refreshSwitchFromExternal`'s reverse transform. */
|
|
232412
232492
|
async pushConfigToFirmware(enable) {
|
|
232493
|
+
if (this.parent.wakeForWrite && !await this.parent.wakeForWrite()) {
|
|
232494
|
+
this.ctx.logger.warn("pir write not sent — the battery camera could not be woken", {
|
|
232495
|
+
tags: { deviceId: this.id },
|
|
232496
|
+
meta: { channel: this.channel }
|
|
232497
|
+
});
|
|
232498
|
+
throw new Error("The camera is asleep and could not be woken; try again in a moment.");
|
|
232499
|
+
}
|
|
232413
232500
|
const api = await this.api;
|
|
232414
232501
|
const sensitive = this.config.get("pirSensitive");
|
|
232415
232502
|
const reduceAlarm = this.config.get("pirReduceAlarm");
|
|
@@ -234305,10 +234392,9 @@ var PowerSourceReadingSchema = _enum([
|
|
|
234305
234392
|
"battery",
|
|
234306
234393
|
"unknown"
|
|
234307
234394
|
]);
|
|
234308
|
-
var ReadPowerSourceResultSchema = object({ source: PowerSourceReadingSchema });
|
|
234309
234395
|
/** The device (or this code) declined before any real write was sent. */
|
|
234310
234396
|
var PowerSourceRefusalReasonSchema = _enum(["dry-run-refused", "dry-run-failed"]);
|
|
234311
|
-
|
|
234397
|
+
discriminatedUnion("outcome", [
|
|
234312
234398
|
object({
|
|
234313
234399
|
outcome: literal("refused"),
|
|
234314
234400
|
mode: PowerSourceModeSchema,
|
|
@@ -234452,6 +234538,54 @@ async function switchPowerSourceTo(target, mode) {
|
|
|
234452
234538
|
applied
|
|
234453
234539
|
};
|
|
234454
234540
|
}
|
|
234541
|
+
/** The settings key of the power source: an ordinary select, owned by the camera (never stored). */
|
|
234542
|
+
var POWER_SOURCE_SETTING_KEY = "powerSource";
|
|
234543
|
+
/**
|
|
234544
|
+
* The power source as a setting, in its own section of the Advanced tab.
|
|
234545
|
+
* Only a battery camera whose read ANSWERED with a mode has one: a camera that
|
|
234546
|
+
* was never asked, or that did not answer, shows nothing rather than a guess.
|
|
234547
|
+
*/
|
|
234548
|
+
function buildPowerSourceSettingsSection(input) {
|
|
234549
|
+
const { isBattery, source } = input;
|
|
234550
|
+
if (!isBattery || source === void 0 || source === "unknown") return [];
|
|
234551
|
+
return [{
|
|
234552
|
+
id: "power-source",
|
|
234553
|
+
tab: "advanced",
|
|
234554
|
+
title: "Power source",
|
|
234555
|
+
titleKey: "provider-reolink:schema.s_power-source.title",
|
|
234556
|
+
description: "Only switch to wired power when the adapter meets the camera's spec.",
|
|
234557
|
+
descriptionKey: "provider-reolink:schema.s_power-source.description",
|
|
234558
|
+
columns: 1,
|
|
234559
|
+
fields: [{
|
|
234560
|
+
type: "select",
|
|
234561
|
+
key: POWER_SOURCE_SETTING_KEY,
|
|
234562
|
+
label: "Power source",
|
|
234563
|
+
labelKey: "provider-reolink:schema.s_power-source.powerSource.label",
|
|
234564
|
+
default: source,
|
|
234565
|
+
options: [{
|
|
234566
|
+
value: "adapter",
|
|
234567
|
+
label: "Wired power",
|
|
234568
|
+
labelKey: "provider-reolink:schema.s_power-source.powerSource.o_adapter.label"
|
|
234569
|
+
}, {
|
|
234570
|
+
value: "battery",
|
|
234571
|
+
label: "Battery power",
|
|
234572
|
+
labelKey: "provider-reolink:schema.s_power-source.powerSource.o_battery.label"
|
|
234573
|
+
}]
|
|
234574
|
+
}]
|
|
234575
|
+
}];
|
|
234576
|
+
}
|
|
234577
|
+
/**
|
|
234578
|
+
* Apply the setting: switch the camera and REFUSE to call a switch that did not
|
|
234579
|
+
* land a success — the settings form keeps the operator's edit, marked unsaved.
|
|
234580
|
+
*/
|
|
234581
|
+
async function applyPowerSourceSetting(target, value) {
|
|
234582
|
+
const mode = PowerSourceModeSchema.safeParse(value);
|
|
234583
|
+
if (!mode.success) throw new Error(`Not a power source: ${String(value)}`);
|
|
234584
|
+
const outcome = await switchPowerSourceTo(target, mode.data);
|
|
234585
|
+
if (outcome.outcome === "refused") throw new Error(`The camera refused the power source switch (${outcome.reason})`);
|
|
234586
|
+
if (outcome.outcome === "failed") throw new Error(`The power source switch failed: ${outcome.error}`);
|
|
234587
|
+
if (!outcome.applied) throw new Error(`The camera did not take the power source switch (it reports ${outcome.after})`);
|
|
234588
|
+
}
|
|
234455
234589
|
//#endregion
|
|
234456
234590
|
//#region src/ptz-zoom.ts
|
|
234457
234591
|
/**
|
|
@@ -235425,6 +235559,7 @@ function slicesForPatch(patch) {
|
|
|
235425
235559
|
if (has("pirReduceFalseAlarm")) out.add("pir");
|
|
235426
235560
|
if (has("autoRebootEnabled", "autoRebootWeekDay", "autoRebootHour", "autoRebootMinute")) out.add("autoReboot");
|
|
235427
235561
|
if (has("timeZoneId")) out.add("systemGeneral");
|
|
235562
|
+
if (has("powerSource")) out.add("powerSource");
|
|
235428
235563
|
return out;
|
|
235429
235564
|
}
|
|
235430
235565
|
/**
|
|
@@ -235441,8 +235576,6 @@ var RefreshSettingsResultSchema = object({
|
|
|
235441
235576
|
capsWarmed: number$1(),
|
|
235442
235577
|
capsTotal: number$1()
|
|
235443
235578
|
});
|
|
235444
|
-
/** The two switch actions, one implementation each way. */
|
|
235445
|
-
var POWER_SWITCH_ACTIONS = [["switch-to-wired-power", "adapter"], ["switch-to-battery-power", "battery"]];
|
|
235446
235579
|
/** The uid out of a device's metadata bag, or nothing. Never a cast. */
|
|
235447
235580
|
function metaUid(metadata) {
|
|
235448
235581
|
if (metadata === null) return void 0;
|
|
@@ -236250,6 +236383,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
236250
236383
|
} catch (err) {
|
|
236251
236384
|
this.ctx.logger.debug("reolink getPirInfo probe failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
236252
236385
|
}
|
|
236386
|
+
if (want("powerSource") && this.isBattery) cacheUpdate.powerSourceSnapshot = { source: await readPowerSource(await this.powerSourceTarget()) };
|
|
236253
236387
|
if (want("autoReboot")) try {
|
|
236254
236388
|
const reboot = await api.getAutoReboot();
|
|
236255
236389
|
cacheUpdate.autoRebootSnapshot = {
|
|
@@ -236602,6 +236736,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
236602
236736
|
runTest: false
|
|
236603
236737
|
}, this.getChannel());
|
|
236604
236738
|
this.ctx.logger.info("email-push: camera auto-configure applied", { tags: { deviceId: this.id } });
|
|
236739
|
+
if (params.authPassword !== void 0) await this.config.setAll({ emailPassword: params.authPassword });
|
|
236605
236740
|
await this.refreshCameraEmailConfig().catch(() => {});
|
|
236606
236741
|
}
|
|
236607
236742
|
/**
|
|
@@ -236828,16 +236963,6 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
236828
236963
|
capsTotal
|
|
236829
236964
|
};
|
|
236830
236965
|
});
|
|
236831
|
-
if (this.isBattery) {
|
|
236832
|
-
this.registerDeviceAction("read-power-source", deviceCustomAction(unknown(), ReadPowerSourceResultSchema, { kind: "mutation" }), async () => {
|
|
236833
|
-
await this.wakeIfSleeping();
|
|
236834
|
-
return { source: await readPowerSource(await this.powerSourceTarget()) };
|
|
236835
|
-
});
|
|
236836
|
-
for (const [action, mode] of POWER_SWITCH_ACTIONS) this.registerDeviceAction(action, deviceCustomAction(unknown(), SwitchPowerSourceResultSchema, { kind: "mutation" }), async () => {
|
|
236837
|
-
await this.wakeIfSleeping();
|
|
236838
|
-
return switchPowerSourceTo(await this.powerSourceTarget(), mode);
|
|
236839
|
-
});
|
|
236840
|
-
}
|
|
236841
236966
|
this.registerDeviceAction("refresh-sessions", deviceCustomAction(unknown(), _void(), { kind: "mutation" }), async () => {
|
|
236842
236967
|
await this.refreshSessionsSnapshot();
|
|
236843
236968
|
});
|
|
@@ -237387,56 +237512,6 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
237387
237512
|
};
|
|
237388
237513
|
}
|
|
237389
237514
|
/**
|
|
237390
|
-
* Battery-cam power-source section (General tab): read the source, switch to
|
|
237391
|
-
* wired or back to battery. Returns `[]` for a wired-only camera. The buttons
|
|
237392
|
-
* dispatch the `read-power-source` / `switch-to-*-power` device actions.
|
|
237393
|
-
*/
|
|
237394
|
-
buildPowerSourceSection() {
|
|
237395
|
-
if (!this.isBattery) return [];
|
|
237396
|
-
const switchMessage = "Switch {outcome} · before: {before} · after: {after} · applied: {applied}";
|
|
237397
|
-
return [{
|
|
237398
|
-
id: "power-source",
|
|
237399
|
-
tab: "general",
|
|
237400
|
-
title: "Power source",
|
|
237401
|
-
titleKey: "provider-reolink:schema.s_power-source.title",
|
|
237402
|
-
description: "Only switch to wired power when the adapter meets the camera's spec.",
|
|
237403
|
-
descriptionKey: "provider-reolink:schema.s_power-source.description",
|
|
237404
|
-
columns: 1,
|
|
237405
|
-
fields: [
|
|
237406
|
-
{
|
|
237407
|
-
type: "device-action-button",
|
|
237408
|
-
key: "_readPowerSource",
|
|
237409
|
-
label: "Power source",
|
|
237410
|
-
labelKey: "provider-reolink:schema.s_power-source._readPowerSource.label",
|
|
237411
|
-
buttonLabel: "Read power source",
|
|
237412
|
-
action: "read-power-source",
|
|
237413
|
-
variant: "default",
|
|
237414
|
-
successMessage: "Power source: {source}"
|
|
237415
|
-
},
|
|
237416
|
-
{
|
|
237417
|
-
type: "device-action-button",
|
|
237418
|
-
key: "_switchToWiredPower",
|
|
237419
|
-
label: "Wired power",
|
|
237420
|
-
labelKey: "provider-reolink:schema.s_power-source._switchToWiredPower.label",
|
|
237421
|
-
buttonLabel: "Switch to wired power",
|
|
237422
|
-
action: "switch-to-wired-power",
|
|
237423
|
-
variant: "default",
|
|
237424
|
-
successMessage: switchMessage
|
|
237425
|
-
},
|
|
237426
|
-
{
|
|
237427
|
-
type: "device-action-button",
|
|
237428
|
-
key: "_switchToBatteryPower",
|
|
237429
|
-
label: "Battery power",
|
|
237430
|
-
labelKey: "provider-reolink:schema.s_power-source._switchToBatteryPower.label",
|
|
237431
|
-
buttonLabel: "Switch to battery power",
|
|
237432
|
-
action: "switch-to-battery-power",
|
|
237433
|
-
variant: "default",
|
|
237434
|
-
successMessage: switchMessage
|
|
237435
|
-
}
|
|
237436
|
-
]
|
|
237437
|
-
}];
|
|
237438
|
-
}
|
|
237439
|
-
/**
|
|
237440
237515
|
* Battery-cam Email Push auto-configure section. Returns `[]` for any
|
|
237441
237516
|
* camera that wouldn't benefit (wired cams keep a live socket for
|
|
237442
237517
|
* native push; hub children have no independent email path). The
|
|
@@ -237627,7 +237702,8 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
237627
237702
|
if (typeof fields.emailSmtpServer === "string") patch.smtpServer = fields.emailSmtpServer;
|
|
237628
237703
|
if (typeof fields.emailSmtpPort === "number") patch.smtpPort = fields.emailSmtpPort;
|
|
237629
237704
|
if (typeof fields.emailUserName === "string") patch.userName = fields.emailUserName;
|
|
237630
|
-
|
|
237705
|
+
const smtpPassword = smtpPasswordToWrite(fields.emailPassword);
|
|
237706
|
+
if (smtpPassword !== null) patch.password = smtpPassword;
|
|
237631
237707
|
if (typeof fields.emailSsl === "boolean") patch.ssl = fields.emailSsl ? 1 : 0;
|
|
237632
237708
|
if (typeof fields.emailRecipient1 === "string") patch.address1 = fields.emailRecipient1;
|
|
237633
237709
|
if (typeof fields.emailRecipient2 === "string") patch.address2 = fields.emailRecipient2;
|
|
@@ -242348,7 +242424,10 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
242348
242424
|
}),
|
|
242349
242425
|
...this.buildSessionsTabSections(),
|
|
242350
242426
|
...this.buildEmailPushSection(),
|
|
242351
|
-
...
|
|
242427
|
+
...buildPowerSourceSettingsSection({
|
|
242428
|
+
isBattery: this.isBattery,
|
|
242429
|
+
source: cache?.powerSourceSnapshot?.source
|
|
242430
|
+
}),
|
|
242352
242431
|
...this.buildEmailTabSections(),
|
|
242353
242432
|
...buildClipRefreshDeviceSection({
|
|
242354
242433
|
isHubChild: this.isHubChild(),
|
|
@@ -242377,7 +242456,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
242377
242456
|
emailSmtpServer: emailSnap?.smtpServer ?? "",
|
|
242378
242457
|
emailSmtpPort: emailSnap?.smtpPort ?? 587,
|
|
242379
242458
|
emailUserName: emailSnap?.userName ?? "",
|
|
242380
|
-
emailPassword: "",
|
|
242459
|
+
emailPassword: this.config.get("emailPassword"),
|
|
242381
242460
|
emailSsl: emailSnap?.ssl ?? false,
|
|
242382
242461
|
emailRecipient1: emailSnap?.recipients?.[0] ?? "",
|
|
242383
242462
|
emailRecipient2: emailSnap?.recipients?.[1] ?? "",
|
|
@@ -242444,6 +242523,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
242444
242523
|
audioNoiseLevel: this.config.get("audioNoiseLevel") ?? (cache?.audioNoiseSnapshot?.enabled ? cache.audioNoiseSnapshot?.level ?? 1 : 0),
|
|
242445
242524
|
autoFocusEnabled: this.config.get("autoFocusEnabled") ?? cache?.autoFocusSnapshot?.enabled ?? true,
|
|
242446
242525
|
pirReduceFalseAlarm: this.config.get("pirReduceFalseAlarm") ?? cache?.pirSnapshot?.reduceFalseAlarm ?? false,
|
|
242526
|
+
...cache?.powerSourceSnapshot !== void 0 ? { [POWER_SOURCE_SETTING_KEY]: cache.powerSourceSnapshot.source } : {},
|
|
242447
242527
|
gop: this.config.get("gop") ?? cache?.encSnapshot?.mainStream?.gop ?? 4,
|
|
242448
242528
|
autoRebootEnabled: this.config.get("autoRebootEnabled") ?? cache?.autoRebootSnapshot?.enabled ?? false,
|
|
242449
242529
|
autoRebootWeekDay: this.config.get("autoRebootWeekDay") ?? cache?.autoRebootSnapshot?.weekDay ?? "everyday",
|
|
@@ -242473,8 +242553,8 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
242473
242553
|
}
|
|
242474
242554
|
async applySettingsPatch(patch) {
|
|
242475
242555
|
if (this.isHubChild()) this.refuseHubChildPatch(patch);
|
|
242476
|
-
const { emailSmtpServer, emailSmtpPort, emailUserName, emailPassword, emailSsl, emailRecipient1, emailRecipient2, emailRecipient3, emailSendNickname, emailScheduleEnabled, osdChannelEnabled, osdChannelName, osdChannelPosition, osdTimeEnabled, osdTimePosition, osdWatermark, hubName: _hubName, ...rest } = patch;
|
|
242477
|
-
if ((osdChannelEnabled !== void 0 || osdChannelName !== void 0 || osdChannelPosition !== void 0 || osdTimeEnabled !== void 0 || osdTimePosition !== void 0 || osdWatermark !== void 0 || emailSmtpServer !== void 0 || emailRecipient1 !== void 0) && !await this.wakeIfSleeping()) this.ctx.logger.warn("settings write: battery cam did not wake — writing anyway", { tags: { deviceId: this.id } });
|
|
242556
|
+
const { emailSmtpServer, emailSmtpPort, emailUserName, emailPassword, emailSsl, emailRecipient1, emailRecipient2, emailRecipient3, emailSendNickname, emailScheduleEnabled, osdChannelEnabled, osdChannelName, osdChannelPosition, osdTimeEnabled, osdTimePosition, osdWatermark, hubName: _hubName, [POWER_SOURCE_SETTING_KEY]: powerSource, ...rest } = patch;
|
|
242557
|
+
if ((osdChannelEnabled !== void 0 || osdChannelName !== void 0 || osdChannelPosition !== void 0 || osdTimeEnabled !== void 0 || osdTimePosition !== void 0 || osdWatermark !== void 0 || emailSmtpServer !== void 0 || emailRecipient1 !== void 0 || powerSource !== void 0) && !await this.wakeIfSleeping()) this.ctx.logger.warn("settings write: battery cam did not wake — writing anyway", { tags: { deviceId: this.id } });
|
|
242478
242558
|
const emailFields = {
|
|
242479
242559
|
emailSmtpServer,
|
|
242480
242560
|
emailSmtpPort,
|
|
@@ -242487,12 +242567,18 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
242487
242567
|
emailSendNickname,
|
|
242488
242568
|
emailScheduleEnabled
|
|
242489
242569
|
};
|
|
242490
|
-
if (Object.values(emailFields).some((v) => v !== void 0))
|
|
242491
|
-
|
|
242492
|
-
|
|
242493
|
-
|
|
242570
|
+
if (Object.values(emailFields).some((v) => v !== void 0)) {
|
|
242571
|
+
let written = true;
|
|
242572
|
+
await this.applyEmailConfigPatch(emailFields).catch((err) => {
|
|
242573
|
+
written = false;
|
|
242574
|
+
this.ctx.logger.warn("email config write failed", {
|
|
242575
|
+
tags: { deviceId: this.id },
|
|
242576
|
+
meta: { error: err instanceof Error ? err.message : String(err) }
|
|
242577
|
+
});
|
|
242494
242578
|
});
|
|
242495
|
-
|
|
242579
|
+
const stored = smtpPasswordToWrite(emailPassword);
|
|
242580
|
+
if (written && stored !== null) await this.config.setAll({ emailPassword: stored });
|
|
242581
|
+
}
|
|
242496
242582
|
const osdPatch = buildOsdPatch({
|
|
242497
242583
|
osdChannelEnabled,
|
|
242498
242584
|
osdChannelName,
|
|
@@ -242509,6 +242595,10 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
242509
242595
|
osdTimePosition,
|
|
242510
242596
|
osdWatermark
|
|
242511
242597
|
].some((v) => v !== void 0);
|
|
242598
|
+
if (powerSource !== void 0) {
|
|
242599
|
+
await applyPowerSourceSetting(await this.powerSourceTarget(), powerSource);
|
|
242600
|
+
await this.refreshParentSettingsSnapshot(new Set(["powerSource"]), "post-write");
|
|
242601
|
+
}
|
|
242512
242602
|
if (Object.keys(rest).length === 0 && !hasOsdPatch) return;
|
|
242513
242603
|
if (Object.keys(rest).length > 0) await this.config.setAll(rest);
|
|
242514
242604
|
const typedPatch = patch;
|
|
@@ -242943,6 +243033,11 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
242943
243033
|
isSleeping() {
|
|
242944
243034
|
return this.sleeping;
|
|
242945
243035
|
}
|
|
243036
|
+
/** Implements `ReolinkAccessoryHost.wakeForWrite`: an accessory's operator
|
|
243037
|
+
* write (PIR, ...) wakes a sleeping battery camera first. */
|
|
243038
|
+
wakeForWrite() {
|
|
243039
|
+
return this.wakeIfSleeping();
|
|
243040
|
+
}
|
|
242946
243041
|
async ensureApi() {
|
|
242947
243042
|
if (this.isHubChild()) {
|
|
242948
243043
|
const session = this.hubSession();
|
|
@@ -243967,6 +244062,8 @@ var EmailPushBridge = class {
|
|
|
243967
244062
|
/** The last failure that was reported, so a mailbox provider that stays away is said once. */
|
|
243968
244063
|
lastFailure = null;
|
|
243969
244064
|
chain = Promise.resolve();
|
|
244065
|
+
/** The integrations whose empty link this process filled (only those are released). */
|
|
244066
|
+
filled = /* @__PURE__ */ new Set();
|
|
243970
244067
|
constructor(deps) {
|
|
243971
244068
|
this.deps = deps;
|
|
243972
244069
|
}
|
|
@@ -244037,43 +244134,104 @@ var EmailPushBridge = class {
|
|
|
244037
244134
|
const recipients = this.recipients();
|
|
244038
244135
|
if (recipients.length === 0) {
|
|
244039
244136
|
if (this.brokerId !== null && this.subscriptionId !== null) await this.deps.port.unsubscribe(this.brokerId, this.subscriptionId);
|
|
244040
|
-
if (this.brokerId !== null) await this.syncLinks(this.brokerId,
|
|
244137
|
+
if (this.brokerId !== null) await this.syncLinks(this.brokerId, await this.tryDefaultId(), false);
|
|
244041
244138
|
this.subscriptionId = null;
|
|
244042
244139
|
this.declared = null;
|
|
244043
244140
|
return;
|
|
244044
244141
|
}
|
|
244045
|
-
const
|
|
244046
|
-
const
|
|
244142
|
+
const { defaultId, complete } = await this.resolveDefault();
|
|
244143
|
+
const picked = await this.pickedMailbox(defaultId);
|
|
244144
|
+
const key = `${recipients.join(",")}|${defaultId ?? ""}|${picked ?? this.brokerId ?? ""}`;
|
|
244047
244145
|
if (!force && this.declared === key && this.subscriptionId !== null) return;
|
|
244048
|
-
const brokerId = await this.ensureMailbox();
|
|
244146
|
+
const brokerId = picked ?? await this.ensureMailbox();
|
|
244147
|
+
if (this.brokerId !== null && this.brokerId !== brokerId && this.subscriptionId !== null) {
|
|
244148
|
+
await this.deps.port.unsubscribe(this.brokerId, this.subscriptionId);
|
|
244149
|
+
this.subscriptionId = null;
|
|
244150
|
+
}
|
|
244049
244151
|
await this.seedBaseline(brokerId);
|
|
244050
244152
|
const { subscriptionId } = await this.deps.port.subscribe(brokerId, recipients);
|
|
244051
244153
|
this.brokerId = brokerId;
|
|
244052
244154
|
this.subscriptionId = subscriptionId;
|
|
244053
|
-
|
|
244155
|
+
const linked = await this.syncLinks(brokerId, defaultId, true);
|
|
244156
|
+
this.declared = linked && complete ? `${recipients.join(",")}|${defaultId ?? ""}|${brokerId}` : null;
|
|
244054
244157
|
await this.reconcile();
|
|
244055
244158
|
}
|
|
244056
|
-
/**
|
|
244057
|
-
|
|
244058
|
-
|
|
244059
|
-
|
|
244060
|
-
|
|
244159
|
+
/**
|
|
244160
|
+
* The default integration holds the mailbox link for every email-push camera (a hub child's
|
|
244161
|
+
* integration carries none). `complete` is false when it could not be resolved: the caller
|
|
244162
|
+
* retries at the next sync.
|
|
244163
|
+
*/
|
|
244164
|
+
async resolveDefault() {
|
|
244165
|
+
const cam = this.deps.listCameras().find((c) => c.isEmailPushEligible);
|
|
244166
|
+
const tags = cam === void 0 ? {} : { tags: { deviceId: cam.id } };
|
|
244167
|
+
let defaultId = null;
|
|
244168
|
+
try {
|
|
244169
|
+
defaultId = await this.deps.defaultIntegrationId();
|
|
244170
|
+
} catch (err) {
|
|
244171
|
+
this.deps.logger.warn("email-push: the default integration could not be read", {
|
|
244172
|
+
...tags,
|
|
244173
|
+
meta: { error: errMsg(err) }
|
|
244174
|
+
});
|
|
244175
|
+
return {
|
|
244176
|
+
defaultId: null,
|
|
244177
|
+
complete: false
|
|
244178
|
+
};
|
|
244179
|
+
}
|
|
244180
|
+
if (defaultId === null) {
|
|
244181
|
+
this.deps.logger.warn("email-push: a camera uses the mailbox but the default integration is not resolved yet; retrying at the next sync", tags);
|
|
244182
|
+
return {
|
|
244183
|
+
defaultId: null,
|
|
244184
|
+
complete: false
|
|
244185
|
+
};
|
|
244186
|
+
}
|
|
244187
|
+
return {
|
|
244188
|
+
defaultId,
|
|
244189
|
+
complete: true
|
|
244190
|
+
};
|
|
244191
|
+
}
|
|
244192
|
+
async tryDefaultId() {
|
|
244193
|
+
try {
|
|
244194
|
+
return await this.deps.defaultIntegrationId();
|
|
244195
|
+
} catch {
|
|
244196
|
+
return null;
|
|
244197
|
+
}
|
|
244198
|
+
}
|
|
244199
|
+
/**
|
|
244200
|
+
* The mailbox the operator picked on the default integration, or null while none is picked.
|
|
244201
|
+
* A pick that no mailbox answers to throws: the bridge never swaps it for another one.
|
|
244202
|
+
*/
|
|
244203
|
+
async pickedMailbox(defaultId) {
|
|
244204
|
+
if (defaultId === null) return null;
|
|
244205
|
+
const row = (await this.deps.links.list()).find((r) => r.id === defaultId);
|
|
244206
|
+
if (row === void 0 || row.mailboxId === "") return null;
|
|
244207
|
+
if (!(await this.deps.port.list()).some((m) => m.id === row.mailboxId)) throw new Error(`the camera mailbox picked on the default integration (${row.mailboxId}) does not exist`);
|
|
244208
|
+
return row.mailboxId;
|
|
244209
|
+
}
|
|
244210
|
+
/** The mailbox a camera is pointed at: the operator's pick, else the one this addon adopts or creates. */
|
|
244211
|
+
async resolveMailbox() {
|
|
244212
|
+
return await this.pickedMailbox(await this.tryDefaultId()) ?? await this.ensureMailbox();
|
|
244061
244213
|
}
|
|
244062
244214
|
/**
|
|
244063
|
-
* Make the `mailboxId`
|
|
244064
|
-
*
|
|
244065
|
-
*
|
|
244066
|
-
*
|
|
244215
|
+
* Make the `mailboxId` link of the DEFAULT integration say it uses the mailbox. It is filled only
|
|
244216
|
+
* while empty (a pick of the operator is never overwritten) and released only if this process
|
|
244217
|
+
* filled it. A hub integration carries no link: a stale one is cleared. With no default
|
|
244218
|
+
* resolved nothing is touched. False when the links could not be written.
|
|
244067
244219
|
*/
|
|
244068
|
-
async syncLinks(brokerId,
|
|
244220
|
+
async syncLinks(brokerId, defaultId, inUse) {
|
|
244221
|
+
if (defaultId === null) return true;
|
|
244069
244222
|
try {
|
|
244070
244223
|
const rows = await this.deps.links.list();
|
|
244071
|
-
for (const row of rows) {
|
|
244072
|
-
|
|
244073
|
-
|
|
244074
|
-
|
|
244075
|
-
|
|
244076
|
-
|
|
244224
|
+
for (const row of rows) if (row.id !== defaultId) {
|
|
244225
|
+
if (row.mailboxId !== "") await this.deps.links.set(row.id, "");
|
|
244226
|
+
} else if (inUse && row.mailboxId === "") {
|
|
244227
|
+
await this.deps.links.set(row.id, brokerId);
|
|
244228
|
+
this.filled.add(row.id);
|
|
244229
|
+
} else if (!inUse && this.filled.has(row.id) && row.mailboxId === brokerId) {
|
|
244230
|
+
await this.deps.links.set(row.id, "");
|
|
244231
|
+
this.filled.delete(row.id);
|
|
244232
|
+
}
|
|
244233
|
+
if (inUse && !rows.some((row) => row.id === defaultId)) this.deps.logger.warn("email-push: the default integration has no record to link the mailbox from", { meta: {
|
|
244234
|
+
integrationId: defaultId,
|
|
244077
244235
|
brokerId
|
|
244078
244236
|
} });
|
|
244079
244237
|
return true;
|
|
@@ -244212,7 +244370,7 @@ var EmailPushBridge = class {
|
|
|
244212
244370
|
*/
|
|
244213
244371
|
async buildCameraSetupParams(cam) {
|
|
244214
244372
|
if (!cam.isEmailPushEligible) return null;
|
|
244215
|
-
const brokerId = await this.
|
|
244373
|
+
const brokerId = await this.resolveMailbox();
|
|
244216
244374
|
const parsed = SmtpInboundConfigSchema.safeParse(await this.deps.port.getBrokerConfig(brokerId));
|
|
244217
244375
|
if (!parsed.success) throw new Error("The camera mailbox answered a configuration this build cannot read");
|
|
244218
244376
|
const config = parsed.data;
|
|
@@ -244234,6 +244392,60 @@ function pickMailbox(list) {
|
|
|
244234
244392
|
return list.find((b) => b.id === "smtp-inbound-default")?.id ?? list[0]?.id ?? null;
|
|
244235
244393
|
}
|
|
244236
244394
|
//#endregion
|
|
244395
|
+
//#region src/email-push-removal-hook.ts
|
|
244396
|
+
/**
|
|
244397
|
+
* A removed camera leaves its `cam-<stableId>` recipient in the mailbox (D865). The addon holds
|
|
244398
|
+
* no per-device DATA for the intake (the mailbox is owned by the mail addon), so removal only
|
|
244399
|
+
* redeclares the recipient set without the camera. Driven by the tombstone, never by absence.
|
|
244400
|
+
*/
|
|
244401
|
+
function createEmailPushRemovalHook(deps) {
|
|
244402
|
+
return {
|
|
244403
|
+
onDeviceRemoved: async () => {
|
|
244404
|
+
await deps.resync();
|
|
244405
|
+
return { counts: { "mailbox-recipients": 0 } };
|
|
244406
|
+
},
|
|
244407
|
+
listDeviceData: async () => []
|
|
244408
|
+
};
|
|
244409
|
+
}
|
|
244410
|
+
var LEGACY_PREFIX = "/webhook/";
|
|
244411
|
+
async function startLegacyWebhookIntake(deps) {
|
|
244412
|
+
const warned = /* @__PURE__ */ new Set();
|
|
244413
|
+
const server = createServer((req, res) => {
|
|
244414
|
+
const url = req.url ?? "";
|
|
244415
|
+
if (!url.startsWith(LEGACY_PREFIX)) {
|
|
244416
|
+
res.writeHead(404).end();
|
|
244417
|
+
return;
|
|
244418
|
+
}
|
|
244419
|
+
const rest = url.slice(8);
|
|
244420
|
+
req.url = rest;
|
|
244421
|
+
const id = decodeURIComponent(rest.replace(/^\//, "").split("?")[0] ?? "");
|
|
244422
|
+
const camera = deps.listCameras().find((c) => c.stableId === id);
|
|
244423
|
+
if (camera !== void 0 && !warned.has(id)) {
|
|
244424
|
+
warned.add(id);
|
|
244425
|
+
deps.logger.warn("legacy webhook port used — camera will be re-pointed", {
|
|
244426
|
+
tags: { deviceId: camera.id },
|
|
244427
|
+
meta: { port: deps.port ?? 9081 }
|
|
244428
|
+
});
|
|
244429
|
+
}
|
|
244430
|
+
Promise.resolve(deps.handler(req, res)).catch((err) => {
|
|
244431
|
+
deps.logger.error("legacy webhook intake failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
244432
|
+
if (!res.headersSent) res.writeHead(500);
|
|
244433
|
+
res.end();
|
|
244434
|
+
});
|
|
244435
|
+
});
|
|
244436
|
+
await new Promise((resolve, reject) => {
|
|
244437
|
+
server.once("error", reject);
|
|
244438
|
+
server.listen(deps.port ?? 9081, "0.0.0.0", () => {
|
|
244439
|
+
server.off("error", reject);
|
|
244440
|
+
resolve();
|
|
244441
|
+
});
|
|
244442
|
+
});
|
|
244443
|
+
return {
|
|
244444
|
+
server,
|
|
244445
|
+
close: () => new Promise((resolve) => server.close(() => resolve()))
|
|
244446
|
+
};
|
|
244447
|
+
}
|
|
244448
|
+
//#endregion
|
|
244237
244449
|
//#region src/reolink-connection-test.ts
|
|
244238
244450
|
/**
|
|
244239
244451
|
* The Reolink NVR / Home Hub connection test (planning#581): log in over Baichuan with the
|
|
@@ -244341,6 +244553,28 @@ var reolinkConnectionsEntryKind = defineEntryKind("connections", {
|
|
|
244341
244553
|
}),
|
|
244342
244554
|
writeTrigger: "an operator adds, edits or removes a Reolink integration"
|
|
244343
244555
|
});
|
|
244556
|
+
/** The kind of the default integration (standalone cameras): a name and the mailbox link, no Test. */
|
|
244557
|
+
var REOLINK_DEFAULT_KIND = "default";
|
|
244558
|
+
/** The kind of an NVR / Home Hub integration: its connection, with a Test. */
|
|
244559
|
+
var REOLINK_HUB_KIND = "connection";
|
|
244560
|
+
/** The form of the default integration: which camera mailbox its standalone cameras use. */
|
|
244561
|
+
function buildDefaultInstanceSchema() {
|
|
244562
|
+
return { sections: [{
|
|
244563
|
+
id: "mailbox",
|
|
244564
|
+
title: "Camera mailbox",
|
|
244565
|
+
titleKey: "provider-reolink:connection.s_mailbox.title",
|
|
244566
|
+
description: "The mailbox the standalone cameras send their email push to.",
|
|
244567
|
+
descriptionKey: "provider-reolink:connection.s_mailbox.description",
|
|
244568
|
+
columns: 1,
|
|
244569
|
+
fields: [{
|
|
244570
|
+
...linkFieldDescriptor(MAILBOX_LINK_FIELD, SMTP_MAILBOX_LINK, {
|
|
244571
|
+
label: "Camera mailbox",
|
|
244572
|
+
required: false
|
|
244573
|
+
}),
|
|
244574
|
+
labelKey: "provider-reolink:connection.s_mailbox.mailboxId.label"
|
|
244575
|
+
}]
|
|
244576
|
+
}] };
|
|
244577
|
+
}
|
|
244344
244578
|
/** Every kind this addon declares, keyed by its name. */
|
|
244345
244579
|
var reolinkRecordKinds = { connections: reolinkConnectionsEntryKind };
|
|
244346
244580
|
/**
|
|
@@ -244447,12 +244681,26 @@ function buildReolinkInstances(records, deps) {
|
|
|
244447
244681
|
kind: "connection",
|
|
244448
244682
|
canTest: true,
|
|
244449
244683
|
kinds: [{
|
|
244450
|
-
id:
|
|
244451
|
-
label: "Reolink",
|
|
244684
|
+
id: REOLINK_DEFAULT_KIND,
|
|
244685
|
+
label: "Reolink standalone cameras",
|
|
244686
|
+
functionCap: "device-provider",
|
|
244687
|
+
role: "devices",
|
|
244688
|
+
canTest: false,
|
|
244689
|
+
creatable: false
|
|
244690
|
+
}, {
|
|
244691
|
+
id: REOLINK_HUB_KIND,
|
|
244692
|
+
label: "Reolink NVR / Home Hub",
|
|
244452
244693
|
functionCap: "device-provider",
|
|
244453
|
-
role: "devices"
|
|
244694
|
+
role: "devices",
|
|
244695
|
+
canTest: true
|
|
244696
|
+
}],
|
|
244697
|
+
links: [{
|
|
244698
|
+
kind: REOLINK_DEFAULT_KIND,
|
|
244699
|
+
field: MAILBOX_LINK_FIELD,
|
|
244700
|
+
to: SMTP_MAILBOX_LINK
|
|
244454
244701
|
}]
|
|
244455
244702
|
},
|
|
244703
|
+
kindOf: () => REOLINK_HUB_KIND,
|
|
244456
244704
|
formSchema: () => buildHubInstanceSchema(),
|
|
244457
244705
|
initialBody: (name) => ({ name }),
|
|
244458
244706
|
configured: (body) => (body.host ?? "").length === 0 || (body.password ?? "").length > 0,
|
|
@@ -244466,10 +244714,15 @@ function buildReolinkInstances(records, deps) {
|
|
|
244466
244714
|
*/
|
|
244467
244715
|
function reolinkInstancesProvider(instances, deps) {
|
|
244468
244716
|
const base = instances.toProvider();
|
|
244469
|
-
const withAddDevice = async (instance) =>
|
|
244470
|
-
|
|
244471
|
-
|
|
244472
|
-
|
|
244717
|
+
const withAddDevice = async (instance) => {
|
|
244718
|
+
const isHub = await integrationIsHubCached(instances, deps.evidenceCache, instance.id);
|
|
244719
|
+
const known = deps.evidenceCache.get(instance.id) !== null;
|
|
244720
|
+
return {
|
|
244721
|
+
...instance,
|
|
244722
|
+
kind: known && !isHub ? REOLINK_DEFAULT_KIND : REOLINK_HUB_KIND,
|
|
244723
|
+
addDevice: isHub ? "children" : "scan"
|
|
244724
|
+
};
|
|
244725
|
+
};
|
|
244473
244726
|
return {
|
|
244474
244727
|
...base,
|
|
244475
244728
|
listInstances: async (input) => Promise.all((await base.listInstances(input)).map(withAddDevice)),
|
|
@@ -244485,7 +244738,7 @@ function reolinkInstancesProvider(instances, deps) {
|
|
|
244485
244738
|
originStableId: evidence.originStableId,
|
|
244486
244739
|
info: evidence.info,
|
|
244487
244740
|
settings: body === null ? {} : hubSettingsOf(body)
|
|
244488
|
-
}) || body === null ? buildHubInstanceSchema() :
|
|
244741
|
+
}) || body === null ? buildHubInstanceSchema() : buildDefaultInstanceSchema();
|
|
244489
244742
|
}
|
|
244490
244743
|
};
|
|
244491
244744
|
}
|
|
@@ -244537,60 +244790,6 @@ function mailboxLinkStoreOver(records) {
|
|
|
244537
244790
|
};
|
|
244538
244791
|
}
|
|
244539
244792
|
//#endregion
|
|
244540
|
-
//#region src/email-push-removal-hook.ts
|
|
244541
|
-
/**
|
|
244542
|
-
* A removed camera leaves its `cam-<stableId>` recipient in the mailbox (D865). The addon holds
|
|
244543
|
-
* no per-device DATA for the intake (the mailbox is owned by the mail addon), so removal only
|
|
244544
|
-
* redeclares the recipient set without the camera. Driven by the tombstone, never by absence.
|
|
244545
|
-
*/
|
|
244546
|
-
function createEmailPushRemovalHook(deps) {
|
|
244547
|
-
return {
|
|
244548
|
-
onDeviceRemoved: async () => {
|
|
244549
|
-
await deps.resync();
|
|
244550
|
-
return { counts: { "mailbox-recipients": 0 } };
|
|
244551
|
-
},
|
|
244552
|
-
listDeviceData: async () => []
|
|
244553
|
-
};
|
|
244554
|
-
}
|
|
244555
|
-
var LEGACY_PREFIX = "/webhook/";
|
|
244556
|
-
async function startLegacyWebhookIntake(deps) {
|
|
244557
|
-
const warned = /* @__PURE__ */ new Set();
|
|
244558
|
-
const server = createServer((req, res) => {
|
|
244559
|
-
const url = req.url ?? "";
|
|
244560
|
-
if (!url.startsWith(LEGACY_PREFIX)) {
|
|
244561
|
-
res.writeHead(404).end();
|
|
244562
|
-
return;
|
|
244563
|
-
}
|
|
244564
|
-
const rest = url.slice(8);
|
|
244565
|
-
req.url = rest;
|
|
244566
|
-
const id = decodeURIComponent(rest.replace(/^\//, "").split("?")[0] ?? "");
|
|
244567
|
-
const camera = deps.listCameras().find((c) => c.stableId === id);
|
|
244568
|
-
if (camera !== void 0 && !warned.has(id)) {
|
|
244569
|
-
warned.add(id);
|
|
244570
|
-
deps.logger.warn("legacy webhook port used — camera will be re-pointed", {
|
|
244571
|
-
tags: { deviceId: camera.id },
|
|
244572
|
-
meta: { port: deps.port ?? 9081 }
|
|
244573
|
-
});
|
|
244574
|
-
}
|
|
244575
|
-
Promise.resolve(deps.handler(req, res)).catch((err) => {
|
|
244576
|
-
deps.logger.error("legacy webhook intake failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
244577
|
-
if (!res.headersSent) res.writeHead(500);
|
|
244578
|
-
res.end();
|
|
244579
|
-
});
|
|
244580
|
-
});
|
|
244581
|
-
await new Promise((resolve, reject) => {
|
|
244582
|
-
server.once("error", reject);
|
|
244583
|
-
server.listen(deps.port ?? 9081, "0.0.0.0", () => {
|
|
244584
|
-
server.off("error", reject);
|
|
244585
|
-
resolve();
|
|
244586
|
-
});
|
|
244587
|
-
});
|
|
244588
|
-
return {
|
|
244589
|
-
server,
|
|
244590
|
-
close: () => new Promise((resolve) => server.close(() => resolve()))
|
|
244591
|
-
};
|
|
244592
|
-
}
|
|
244593
|
-
//#endregion
|
|
244594
244793
|
//#region src/migrations/drop-webhook-intake-settings.ts
|
|
244595
244794
|
/**
|
|
244596
244795
|
* The camera webhook is a plane of the addon's HTTP data plane, not a private listener
|
|
@@ -244811,6 +245010,14 @@ var REOLINK_MIGRATIONS = [{
|
|
|
244811
245010
|
},
|
|
244812
245011
|
plan: planDropWebhookIntakeSettings
|
|
244813
245012
|
}];
|
|
245013
|
+
/** The date of the device claim (D1007). */
|
|
245014
|
+
var CLAIM_DEVICES_DATE = "2026-11-04";
|
|
245015
|
+
/**
|
|
245016
|
+
* Every persisted camera that names no integration is claimed to the addon's default one. The
|
|
245017
|
+
* integration a hub migration created is never the default, so it is not eligible. The integration
|
|
245018
|
+
* settings themselves stay where they are until this addon's own wave moves them.
|
|
245019
|
+
*/
|
|
245020
|
+
var REOLINK_CLAIM_ELIGIBLE = (integration) => integration.info[MIGRATED_FROM_HUB_KEY] === void 0;
|
|
244814
245021
|
/**
|
|
244815
245022
|
* The integration wave (D1007) in declaration order, which must follow `seq`: the device claim
|
|
244816
245023
|
* shipped first (seq 3) and the rows move follows it (seq 4). The engine refuses the whole
|
|
@@ -244818,10 +245025,10 @@ var REOLINK_MIGRATIONS = [{
|
|
|
244818
245025
|
*/
|
|
244819
245026
|
var REOLINK_INTEGRATION_MIGRATIONS = [claimDevicesMigration({
|
|
244820
245027
|
addonId: "provider-reolink",
|
|
244821
|
-
date:
|
|
245028
|
+
date: CLAIM_DEVICES_DATE,
|
|
244822
245029
|
seq: 3,
|
|
244823
245030
|
dependsOn: [],
|
|
244824
|
-
eligible:
|
|
245031
|
+
eligible: REOLINK_CLAIM_ELIGIBLE
|
|
244825
245032
|
}), REOLINK_ROWS_TO_RECORD_MIGRATION];
|
|
244826
245033
|
//#endregion
|
|
244827
245034
|
//#region src/reolink-adoption-provider.ts
|
|
@@ -245673,12 +245880,24 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
|
245673
245880
|
if (records === void 0) throw new Error("provider-reolink: ctx.records is required (hub-only addon)");
|
|
245674
245881
|
return records;
|
|
245675
245882
|
}
|
|
245883
|
+
/**
|
|
245884
|
+
* The registry id of the default integration (standalone cameras): the lowest-numbered one this
|
|
245885
|
+
* addon owns that no hub migration created, the same rule as the device claim (D1007).
|
|
245886
|
+
*/
|
|
245887
|
+
async resolveDefaultIntegrationId() {
|
|
245888
|
+
return defaultIntegrationOf((await this.ctx.api.integrations.list.query()).filter((i) => i.addonId === this.ctx.id).map((i) => ({
|
|
245889
|
+
id: i.id,
|
|
245890
|
+
name: i.name,
|
|
245891
|
+
info: { ...i.info }
|
|
245892
|
+
})), REOLINK_CLAIM_ELIGIBLE)?.id ?? null;
|
|
245893
|
+
}
|
|
245676
245894
|
/** The camera mailbox bridge, built once. */
|
|
245677
245895
|
ensureEmailBridge() {
|
|
245678
245896
|
this.emailBridge ??= new EmailPushBridge({
|
|
245679
245897
|
port: createBrokerPort(this.ctx.api),
|
|
245680
245898
|
links: mailboxLinkStoreOver(this.requireRecords()),
|
|
245681
245899
|
listCameras: () => this.listReolinkCameras(),
|
|
245900
|
+
defaultIntegrationId: () => this.resolveDefaultIntegrationId(),
|
|
245682
245901
|
logger: this.ctx.logger.child("email-push"),
|
|
245683
245902
|
pending: {
|
|
245684
245903
|
read: () => this.readPendingMailbox(),
|