@camstack/addon-provider-reolink 1.2.250 → 1.2.252
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 +387 -173
- package/dist/addon.mjs +387 -173
- package/i18n/en.json +16 -1
- package/i18n/it.json +16 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.2.252] - 2026-11-20
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Battery cameras get a Power source section: read whether the camera runs on the adapter or the battery, and switch between wired and battery power (dry-run first, read back after; only switch to wired power when the adapter meets the camera's spec).
|
|
15
|
+
|
|
16
|
+
## [1.2.251] - 2026-11-20
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Reverted the 'sleep push ignored while streaming' change: a camera that really slept kept a dead stream open and live view could not start.
|
|
21
|
+
|
|
10
22
|
## [1.2.250] - 2026-11-20
|
|
11
23
|
|
|
12
24
|
### Changed
|
package/dist/addon.js
CHANGED
|
@@ -129610,6 +129610,16 @@ var RecordingBandTriggersSchema = RecordingTriggersSchema;
|
|
|
129610
129610
|
* question to answer as a continuous one.
|
|
129611
129611
|
*/
|
|
129612
129612
|
var RecordingBandAudioSchema = _enum(["on", "muted"]);
|
|
129613
|
+
/**
|
|
129614
|
+
* A battery condition on a band: the band covers a charge level only when
|
|
129615
|
+
* `min <= level < max` (half-open; a missing bound is unbounded). OPTIONAL —
|
|
129616
|
+
* an absent key means "any charge", which is what every config written before
|
|
129617
|
+
* it meant. A band WITH a condition is never met while the charge is unknown.
|
|
129618
|
+
*/
|
|
129619
|
+
var RecordingBandBatterySchema = object({
|
|
129620
|
+
min: number$1().min(0).max(100).optional(),
|
|
129621
|
+
max: number$1().min(0).max(100).optional()
|
|
129622
|
+
});
|
|
129613
129623
|
var RecordingBandSchema = object({
|
|
129614
129624
|
days: array(RecordingWeekdaySchema),
|
|
129615
129625
|
start: string().regex(HHMM),
|
|
@@ -129621,6 +129631,7 @@ var RecordingBandSchema = object({
|
|
|
129621
129631
|
* missing must keep meaning what it meant. See {@link RecordingBandAudioSchema}.
|
|
129622
129632
|
*/
|
|
129623
129633
|
audio: RecordingBandAudioSchema.optional(),
|
|
129634
|
+
battery: RecordingBandBatterySchema.optional(),
|
|
129624
129635
|
triggers: RecordingBandTriggersSchema.optional(),
|
|
129625
129636
|
/**
|
|
129626
129637
|
* RETIRED (D381). A band no longer carries a pre-buffer of its own.
|
|
@@ -162525,7 +162536,7 @@ var HISTORY_PRIMARY = {
|
|
|
162525
162536
|
}
|
|
162526
162537
|
};
|
|
162527
162538
|
DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
|
|
162528
|
-
var PowerSourceRefusalReasonSchema = _enum([
|
|
162539
|
+
var PowerSourceRefusalReasonSchema$1 = _enum([
|
|
162529
162540
|
"no-power-source",
|
|
162530
162541
|
"switch-missing",
|
|
162531
162542
|
"switch-offline",
|
|
@@ -162540,7 +162551,7 @@ var PowerSourceRefusalReasonSchema = _enum([
|
|
|
162540
162551
|
]);
|
|
162541
162552
|
var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
|
|
162542
162553
|
accepted: literal(false),
|
|
162543
|
-
reason: PowerSourceRefusalReasonSchema,
|
|
162554
|
+
reason: PowerSourceRefusalReasonSchema$1,
|
|
162544
162555
|
/** One line for the operator, naming the switch. */
|
|
162545
162556
|
message: string()
|
|
162546
162557
|
})]);
|
|
@@ -228571,46 +228582,6 @@ var IntercomFailureReport = class {
|
|
|
228571
228582
|
/** The process-wide instance every camera in this addon notes into. */
|
|
228572
228583
|
var intercomFailureReport = new IntercomFailureReport();
|
|
228573
228584
|
//#endregion
|
|
228574
|
-
//#region src/clips/clip-time-zone.ts
|
|
228575
|
-
function isUsableTimeZone(timeZone) {
|
|
228576
|
-
try {
|
|
228577
|
-
new Intl.DateTimeFormat("en-US", { timeZone });
|
|
228578
|
-
return true;
|
|
228579
|
-
} catch {
|
|
228580
|
-
return false;
|
|
228581
|
-
}
|
|
228582
|
-
}
|
|
228583
|
-
/**
|
|
228584
|
-
* @param candidate the zone the process reports
|
|
228585
|
-
* @param cameraZone a zone derived from the camera's reported UTC offset, if any
|
|
228586
|
-
*/
|
|
228587
|
-
function resolveClipTimeZone(candidate, cameraZone) {
|
|
228588
|
-
if (isUsableTimeZone(candidate)) return { timeZone: candidate };
|
|
228589
|
-
if (cameraZone !== void 0 && isUsableTimeZone(cameraZone)) return {
|
|
228590
|
-
timeZone: cameraZone,
|
|
228591
|
-
rejected: candidate
|
|
228592
|
-
};
|
|
228593
|
-
return {
|
|
228594
|
-
timeZone: "UTC",
|
|
228595
|
-
rejected: candidate
|
|
228596
|
-
};
|
|
228597
|
-
}
|
|
228598
|
-
/** Resolve and, when the candidate was refused, warn ONCE per `warned` holder. */
|
|
228599
|
-
function resolveClipTimeZoneOnce(candidate, cameraZone, logger, deviceId, warned) {
|
|
228600
|
-
const res = resolveClipTimeZone(candidate, cameraZone);
|
|
228601
|
-
if (res.rejected !== void 0 && !warned.done) {
|
|
228602
|
-
warned.done = true;
|
|
228603
|
-
logger.warn("clip catalog: the process time zone is not usable, using a fallback", {
|
|
228604
|
-
tags: { deviceId },
|
|
228605
|
-
meta: {
|
|
228606
|
-
rejectedTimeZone: res.rejected,
|
|
228607
|
-
fallbackTimeZone: res.timeZone
|
|
228608
|
-
}
|
|
228609
|
-
});
|
|
228610
|
-
}
|
|
228611
|
-
return res.timeZone;
|
|
228612
|
-
}
|
|
228613
|
-
//#endregion
|
|
228614
228585
|
//#region src/baichuan-webhook-shared.ts
|
|
228615
228586
|
/** The data-plane prefix this addon serves the camera push on: `/addon/<addonId>/webhook/<stableId>`. */
|
|
228616
228587
|
var BAICHUAN_WEBHOOK_PREFIX = "webhook";
|
|
@@ -229010,6 +228981,46 @@ async function refreshSnapshotCacheOnce(input) {
|
|
|
229010
228981
|
return true;
|
|
229011
228982
|
}
|
|
229012
228983
|
//#endregion
|
|
228984
|
+
//#region src/clips/clip-time-zone.ts
|
|
228985
|
+
function isUsableTimeZone(timeZone) {
|
|
228986
|
+
try {
|
|
228987
|
+
new Intl.DateTimeFormat("en-US", { timeZone });
|
|
228988
|
+
return true;
|
|
228989
|
+
} catch {
|
|
228990
|
+
return false;
|
|
228991
|
+
}
|
|
228992
|
+
}
|
|
228993
|
+
/**
|
|
228994
|
+
* @param candidate the zone the process reports
|
|
228995
|
+
* @param cameraZone a zone derived from the camera's reported UTC offset, if any
|
|
228996
|
+
*/
|
|
228997
|
+
function resolveClipTimeZone(candidate, cameraZone) {
|
|
228998
|
+
if (isUsableTimeZone(candidate)) return { timeZone: candidate };
|
|
228999
|
+
if (cameraZone !== void 0 && isUsableTimeZone(cameraZone)) return {
|
|
229000
|
+
timeZone: cameraZone,
|
|
229001
|
+
rejected: candidate
|
|
229002
|
+
};
|
|
229003
|
+
return {
|
|
229004
|
+
timeZone: "UTC",
|
|
229005
|
+
rejected: candidate
|
|
229006
|
+
};
|
|
229007
|
+
}
|
|
229008
|
+
/** Resolve and, when the candidate was refused, warn ONCE per `warned` holder. */
|
|
229009
|
+
function resolveClipTimeZoneOnce(candidate, cameraZone, logger, deviceId, warned) {
|
|
229010
|
+
const res = resolveClipTimeZone(candidate, cameraZone);
|
|
229011
|
+
if (res.rejected !== void 0 && !warned.done) {
|
|
229012
|
+
warned.done = true;
|
|
229013
|
+
logger.warn("clip catalog: the process time zone is not usable, using a fallback", {
|
|
229014
|
+
tags: { deviceId },
|
|
229015
|
+
meta: {
|
|
229016
|
+
rejectedTimeZone: res.rejected,
|
|
229017
|
+
fallbackTimeZone: res.timeZone
|
|
229018
|
+
}
|
|
229019
|
+
});
|
|
229020
|
+
}
|
|
229021
|
+
return res.timeZone;
|
|
229022
|
+
}
|
|
229023
|
+
//#endregion
|
|
229013
229024
|
//#region src/day-night-mapping.ts
|
|
229014
229025
|
/**
|
|
229015
229026
|
* Maps between the vendor-neutral `day-night` cap's `DayNightMode` and
|
|
@@ -229112,6 +229123,114 @@ function deriveReolinkCameraFeatures(inputs) {
|
|
|
229112
229123
|
return out;
|
|
229113
229124
|
}
|
|
229114
229125
|
//#endregion
|
|
229126
|
+
//#region src/hub-child-settings.ts
|
|
229127
|
+
/**
|
|
229128
|
+
* A camera adopted under an NVR / Home Hub dials through the integration's session: the address
|
|
229129
|
+
* and the credentials belong to the integration, never to the camera. These are the per-camera
|
|
229130
|
+
* keys a hub child must refuse to change.
|
|
229131
|
+
*/
|
|
229132
|
+
var HUB_CHILD_CONNECTION_KEYS = [
|
|
229133
|
+
"host",
|
|
229134
|
+
"port",
|
|
229135
|
+
"username",
|
|
229136
|
+
"password"
|
|
229137
|
+
];
|
|
229138
|
+
/**
|
|
229139
|
+
* Sections that act on the hub itself (no channel in the call) or on the per-camera connection,
|
|
229140
|
+
* hidden for a hub child:
|
|
229141
|
+
* - `connection`: the per-camera address and credentials (the integration owns them);
|
|
229142
|
+
* - `network-ports`: `setPortConfig` rewrites the NVR's own service ports;
|
|
229143
|
+
* - `time-ntp`: `setNtp` / `setSystemGeneral` / `setDst` rewrite the NVR's clock.
|
|
229144
|
+
*/
|
|
229145
|
+
var HUB_CHILD_HIDDEN_SECTION_IDS = [
|
|
229146
|
+
"connection",
|
|
229147
|
+
"network-ports",
|
|
229148
|
+
"time-ntp"
|
|
229149
|
+
];
|
|
229150
|
+
/** Thrown by `applySettingsPatch` for a refused hub-child patch; carries the typed reason. */
|
|
229151
|
+
var HubChildPatchRefusedError = class extends Error {
|
|
229152
|
+
refusal;
|
|
229153
|
+
constructor(refusal) {
|
|
229154
|
+
super(describeRefusal(refusal));
|
|
229155
|
+
this.refusal = refusal;
|
|
229156
|
+
this.name = "HubChildPatchRefusedError";
|
|
229157
|
+
}
|
|
229158
|
+
};
|
|
229159
|
+
function describeRefusal(refusal) {
|
|
229160
|
+
switch (refusal.reason) {
|
|
229161
|
+
case "connection-owned-by-integration": return `This camera is connected through its NVR / Home Hub integration: ${refusal.keys.join(", ")} can only be changed on the integration`;
|
|
229162
|
+
case "channel-not-an-integer": return `The hub channel must be a whole number, got ${String(refusal.value)}`;
|
|
229163
|
+
case "channel-out-of-range": return `Channel ${refusal.value} is not one of the hub's channels (${refusal.channels.join(", ")})`;
|
|
229164
|
+
}
|
|
229165
|
+
}
|
|
229166
|
+
/**
|
|
229167
|
+
* Judge a settings patch against the hub-child rules. `channels` is the hub's last good channel
|
|
229168
|
+
* list (empty when unknown — then only the integer rule applies).
|
|
229169
|
+
*/
|
|
229170
|
+
function judgeHubChildPatch(patch, channels) {
|
|
229171
|
+
const touched = HUB_CHILD_CONNECTION_KEYS.filter((k) => patch[k] !== void 0);
|
|
229172
|
+
if (touched.length > 0) return {
|
|
229173
|
+
reason: "connection-owned-by-integration",
|
|
229174
|
+
keys: touched
|
|
229175
|
+
};
|
|
229176
|
+
if (patch["channel"] === void 0) return null;
|
|
229177
|
+
const value = patch["channel"];
|
|
229178
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) return {
|
|
229179
|
+
reason: "channel-not-an-integer",
|
|
229180
|
+
value
|
|
229181
|
+
};
|
|
229182
|
+
if (channels.length > 0 && !channels.includes(value)) return {
|
|
229183
|
+
reason: "channel-out-of-range",
|
|
229184
|
+
value,
|
|
229185
|
+
channels
|
|
229186
|
+
};
|
|
229187
|
+
return null;
|
|
229188
|
+
}
|
|
229189
|
+
/** What a hub child shows before its session has read the hub's channel list. */
|
|
229190
|
+
var EMPTY_HUB_CHANNEL_SNAPSHOT = {
|
|
229191
|
+
channels: [],
|
|
229192
|
+
lastRefreshAt: null,
|
|
229193
|
+
lastError: null
|
|
229194
|
+
};
|
|
229195
|
+
/** The hub-child "Hub" section: which hub, and the one editable connection field, the channel. */
|
|
229196
|
+
function buildHubChildSection(snapshot) {
|
|
229197
|
+
return {
|
|
229198
|
+
id: "hub",
|
|
229199
|
+
tab: "general",
|
|
229200
|
+
title: "Hub",
|
|
229201
|
+
titleKey: "provider-reolink:schema.s_hub.title",
|
|
229202
|
+
description: "This camera is connected through its NVR / Home Hub. Address and credentials belong to that integration; the channel is kept in line with the hub automatically.",
|
|
229203
|
+
descriptionKey: "provider-reolink:schema.s_hub.description",
|
|
229204
|
+
columns: 2,
|
|
229205
|
+
fields: [{
|
|
229206
|
+
type: "text",
|
|
229207
|
+
key: "hubName",
|
|
229208
|
+
label: "Connected to",
|
|
229209
|
+
labelKey: "provider-reolink:schema.s_hub.hubName.label",
|
|
229210
|
+
disabled: true
|
|
229211
|
+
}, {
|
|
229212
|
+
type: "number",
|
|
229213
|
+
key: "channel",
|
|
229214
|
+
label: "Hub channel",
|
|
229215
|
+
labelKey: "provider-reolink:schema.s_hub.channel.label",
|
|
229216
|
+
min: 0,
|
|
229217
|
+
...snapshot.channels.length > 0 ? { max: Math.max(...snapshot.channels.map((c) => c.channel)) } : {},
|
|
229218
|
+
step: 1
|
|
229219
|
+
}]
|
|
229220
|
+
};
|
|
229221
|
+
}
|
|
229222
|
+
/** Replace the connection/hub-acting sections of a standalone schema with the Hub section. */
|
|
229223
|
+
function applyHubChildSections(sections, snapshot) {
|
|
229224
|
+
const kept = sections.filter((s) => !HUB_CHILD_HIDDEN_SECTION_IDS.includes(s.id));
|
|
229225
|
+
const at = kept.findIndex((s) => s.id === "driver-refresh");
|
|
229226
|
+
const hub = buildHubChildSection(snapshot);
|
|
229227
|
+
return at < 0 ? [hub, ...kept] : [
|
|
229228
|
+
...kept.slice(0, at + 1),
|
|
229229
|
+
hub,
|
|
229230
|
+
...kept.slice(at + 1)
|
|
229231
|
+
];
|
|
229232
|
+
}
|
|
229233
|
+
//#endregion
|
|
229115
229234
|
//#region src/image-settings-mapping.ts
|
|
229116
229235
|
/**
|
|
229117
229236
|
* Reolink's `InputAdvanceCfg.Exposure.mode` (Baichuan cmdId 25/26, via
|
|
@@ -230898,114 +231017,6 @@ function registerHubChildStateRefresh(target) {
|
|
|
230898
231017
|
}, { stateRefresh: hubChildRefreshPolicy(integrationId) });
|
|
230899
231018
|
}
|
|
230900
231019
|
//#endregion
|
|
230901
|
-
//#region src/hub-child-settings.ts
|
|
230902
|
-
/**
|
|
230903
|
-
* A camera adopted under an NVR / Home Hub dials through the integration's session: the address
|
|
230904
|
-
* and the credentials belong to the integration, never to the camera. These are the per-camera
|
|
230905
|
-
* keys a hub child must refuse to change.
|
|
230906
|
-
*/
|
|
230907
|
-
var HUB_CHILD_CONNECTION_KEYS = [
|
|
230908
|
-
"host",
|
|
230909
|
-
"port",
|
|
230910
|
-
"username",
|
|
230911
|
-
"password"
|
|
230912
|
-
];
|
|
230913
|
-
/**
|
|
230914
|
-
* Sections that act on the hub itself (no channel in the call) or on the per-camera connection,
|
|
230915
|
-
* hidden for a hub child:
|
|
230916
|
-
* - `connection`: the per-camera address and credentials (the integration owns them);
|
|
230917
|
-
* - `network-ports`: `setPortConfig` rewrites the NVR's own service ports;
|
|
230918
|
-
* - `time-ntp`: `setNtp` / `setSystemGeneral` / `setDst` rewrite the NVR's clock.
|
|
230919
|
-
*/
|
|
230920
|
-
var HUB_CHILD_HIDDEN_SECTION_IDS = [
|
|
230921
|
-
"connection",
|
|
230922
|
-
"network-ports",
|
|
230923
|
-
"time-ntp"
|
|
230924
|
-
];
|
|
230925
|
-
/** Thrown by `applySettingsPatch` for a refused hub-child patch; carries the typed reason. */
|
|
230926
|
-
var HubChildPatchRefusedError = class extends Error {
|
|
230927
|
-
refusal;
|
|
230928
|
-
constructor(refusal) {
|
|
230929
|
-
super(describeRefusal(refusal));
|
|
230930
|
-
this.refusal = refusal;
|
|
230931
|
-
this.name = "HubChildPatchRefusedError";
|
|
230932
|
-
}
|
|
230933
|
-
};
|
|
230934
|
-
function describeRefusal(refusal) {
|
|
230935
|
-
switch (refusal.reason) {
|
|
230936
|
-
case "connection-owned-by-integration": return `This camera is connected through its NVR / Home Hub integration: ${refusal.keys.join(", ")} can only be changed on the integration`;
|
|
230937
|
-
case "channel-not-an-integer": return `The hub channel must be a whole number, got ${String(refusal.value)}`;
|
|
230938
|
-
case "channel-out-of-range": return `Channel ${refusal.value} is not one of the hub's channels (${refusal.channels.join(", ")})`;
|
|
230939
|
-
}
|
|
230940
|
-
}
|
|
230941
|
-
/**
|
|
230942
|
-
* Judge a settings patch against the hub-child rules. `channels` is the hub's last good channel
|
|
230943
|
-
* list (empty when unknown — then only the integer rule applies).
|
|
230944
|
-
*/
|
|
230945
|
-
function judgeHubChildPatch(patch, channels) {
|
|
230946
|
-
const touched = HUB_CHILD_CONNECTION_KEYS.filter((k) => patch[k] !== void 0);
|
|
230947
|
-
if (touched.length > 0) return {
|
|
230948
|
-
reason: "connection-owned-by-integration",
|
|
230949
|
-
keys: touched
|
|
230950
|
-
};
|
|
230951
|
-
if (patch["channel"] === void 0) return null;
|
|
230952
|
-
const value = patch["channel"];
|
|
230953
|
-
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) return {
|
|
230954
|
-
reason: "channel-not-an-integer",
|
|
230955
|
-
value
|
|
230956
|
-
};
|
|
230957
|
-
if (channels.length > 0 && !channels.includes(value)) return {
|
|
230958
|
-
reason: "channel-out-of-range",
|
|
230959
|
-
value,
|
|
230960
|
-
channels
|
|
230961
|
-
};
|
|
230962
|
-
return null;
|
|
230963
|
-
}
|
|
230964
|
-
/** What a hub child shows before its session has read the hub's channel list. */
|
|
230965
|
-
var EMPTY_HUB_CHANNEL_SNAPSHOT = {
|
|
230966
|
-
channels: [],
|
|
230967
|
-
lastRefreshAt: null,
|
|
230968
|
-
lastError: null
|
|
230969
|
-
};
|
|
230970
|
-
/** The hub-child "Hub" section: which hub, and the one editable connection field, the channel. */
|
|
230971
|
-
function buildHubChildSection(snapshot) {
|
|
230972
|
-
return {
|
|
230973
|
-
id: "hub",
|
|
230974
|
-
tab: "general",
|
|
230975
|
-
title: "Hub",
|
|
230976
|
-
titleKey: "provider-reolink:schema.s_hub.title",
|
|
230977
|
-
description: "This camera is connected through its NVR / Home Hub. Address and credentials belong to that integration; the channel is kept in line with the hub automatically.",
|
|
230978
|
-
descriptionKey: "provider-reolink:schema.s_hub.description",
|
|
230979
|
-
columns: 2,
|
|
230980
|
-
fields: [{
|
|
230981
|
-
type: "text",
|
|
230982
|
-
key: "hubName",
|
|
230983
|
-
label: "Connected to",
|
|
230984
|
-
labelKey: "provider-reolink:schema.s_hub.hubName.label",
|
|
230985
|
-
disabled: true
|
|
230986
|
-
}, {
|
|
230987
|
-
type: "number",
|
|
230988
|
-
key: "channel",
|
|
230989
|
-
label: "Hub channel",
|
|
230990
|
-
labelKey: "provider-reolink:schema.s_hub.channel.label",
|
|
230991
|
-
min: 0,
|
|
230992
|
-
...snapshot.channels.length > 0 ? { max: Math.max(...snapshot.channels.map((c) => c.channel)) } : {},
|
|
230993
|
-
step: 1
|
|
230994
|
-
}]
|
|
230995
|
-
};
|
|
230996
|
-
}
|
|
230997
|
-
/** Replace the connection/hub-acting sections of a standalone schema with the Hub section. */
|
|
230998
|
-
function applyHubChildSections(sections, snapshot) {
|
|
230999
|
-
const kept = sections.filter((s) => !HUB_CHILD_HIDDEN_SECTION_IDS.includes(s.id));
|
|
231000
|
-
const at = kept.findIndex((s) => s.id === "driver-refresh");
|
|
231001
|
-
const hub = buildHubChildSection(snapshot);
|
|
231002
|
-
return at < 0 ? [hub, ...kept] : [
|
|
231003
|
-
...kept.slice(0, at + 1),
|
|
231004
|
-
hub,
|
|
231005
|
-
...kept.slice(at + 1)
|
|
231006
|
-
];
|
|
231007
|
-
}
|
|
231008
|
-
//#endregion
|
|
231009
231020
|
//#region src/sleep-state-decision.ts
|
|
231010
231021
|
/**
|
|
231011
231022
|
* Hysteresis is ASYMMETRIC, because the two directions have very different
|
|
@@ -231081,16 +231092,6 @@ function decideSleepCommit(input) {
|
|
|
231081
231092
|
stampFirstHand: source !== "hub-reconcile"
|
|
231082
231093
|
};
|
|
231083
231094
|
}
|
|
231084
|
-
/**
|
|
231085
|
-
* A firmware `sleeping` push is ignored while a consumer (the recorder,
|
|
231086
|
-
* a live view) holds an RFC 4571 server on the camera. Teardown on that
|
|
231087
|
-
* push is what cut a recorded battery camera into 40–110 s gaps: the
|
|
231088
|
-
* broker only re-dialled ~20 s after we closed the stream. With no
|
|
231089
|
-
* consumer the push is acted on exactly as before.
|
|
231090
|
-
*/
|
|
231091
|
-
function shouldIgnoreSleepPush(input) {
|
|
231092
|
-
return input.activeStreams > 0;
|
|
231093
|
-
}
|
|
231094
231095
|
//#endregion
|
|
231095
231096
|
//#region src/snapshot-wake-gate.ts
|
|
231096
231097
|
/**
|
|
@@ -233643,6 +233644,160 @@ function buildSupportedNativeClasses(aiDetectTypes, isSupportedClass) {
|
|
|
233643
233644
|
}
|
|
233644
233645
|
return classes;
|
|
233645
233646
|
}
|
|
233647
|
+
var PowerSourceModeSchema = _enum(["adapter", "battery"]);
|
|
233648
|
+
/** What a read says: a mode, or `unknown` when the read failed or the firmware is silent. */
|
|
233649
|
+
var PowerSourceReadingSchema = _enum([
|
|
233650
|
+
"adapter",
|
|
233651
|
+
"battery",
|
|
233652
|
+
"unknown"
|
|
233653
|
+
]);
|
|
233654
|
+
var ReadPowerSourceResultSchema = object({ source: PowerSourceReadingSchema });
|
|
233655
|
+
/** The device (or this code) declined before any real write was sent. */
|
|
233656
|
+
var PowerSourceRefusalReasonSchema = _enum(["dry-run-refused", "dry-run-failed"]);
|
|
233657
|
+
var SwitchPowerSourceResultSchema = discriminatedUnion("outcome", [
|
|
233658
|
+
object({
|
|
233659
|
+
outcome: literal("refused"),
|
|
233660
|
+
mode: PowerSourceModeSchema,
|
|
233661
|
+
reason: PowerSourceRefusalReasonSchema,
|
|
233662
|
+
before: PowerSourceReadingSchema
|
|
233663
|
+
}),
|
|
233664
|
+
object({
|
|
233665
|
+
outcome: literal("sent"),
|
|
233666
|
+
mode: PowerSourceModeSchema,
|
|
233667
|
+
/** The firmware accepted the command. NOT proof it took effect. */
|
|
233668
|
+
accepted: boolean(),
|
|
233669
|
+
before: PowerSourceReadingSchema,
|
|
233670
|
+
after: PowerSourceReadingSchema,
|
|
233671
|
+
/** True only when the read-back after the write equals the requested mode. */
|
|
233672
|
+
applied: boolean()
|
|
233673
|
+
}),
|
|
233674
|
+
object({
|
|
233675
|
+
outcome: literal("failed"),
|
|
233676
|
+
mode: PowerSourceModeSchema,
|
|
233677
|
+
/** The real write threw. It was sent once and is not retried. */
|
|
233678
|
+
error: string(),
|
|
233679
|
+
before: PowerSourceReadingSchema
|
|
233680
|
+
})
|
|
233681
|
+
]);
|
|
233682
|
+
function errorMessage(error) {
|
|
233683
|
+
return error instanceof Error ? error.message : String(error);
|
|
233684
|
+
}
|
|
233685
|
+
/** Read the power source; a failed or silent read is `unknown`. */
|
|
233686
|
+
async function readPowerSource(target) {
|
|
233687
|
+
const { api, channel, deviceId, logger } = target;
|
|
233688
|
+
try {
|
|
233689
|
+
const mode = await api.getPowerSource(channel);
|
|
233690
|
+
if (mode === void 0) {
|
|
233691
|
+
logger.info("power source: the firmware does not report it", {
|
|
233692
|
+
tags: { deviceId },
|
|
233693
|
+
meta: { channel }
|
|
233694
|
+
});
|
|
233695
|
+
return "unknown";
|
|
233696
|
+
}
|
|
233697
|
+
return mode;
|
|
233698
|
+
} catch (error) {
|
|
233699
|
+
logger.warn("power source: read failed, reporting unknown", {
|
|
233700
|
+
tags: { deviceId },
|
|
233701
|
+
meta: {
|
|
233702
|
+
channel,
|
|
233703
|
+
error: errorMessage(error)
|
|
233704
|
+
}
|
|
233705
|
+
});
|
|
233706
|
+
return "unknown";
|
|
233707
|
+
}
|
|
233708
|
+
}
|
|
233709
|
+
/**
|
|
233710
|
+
* Switch the power source: read, dry run, one real write, read back.
|
|
233711
|
+
* The write is sent at most once and never retried.
|
|
233712
|
+
*/
|
|
233713
|
+
async function switchPowerSourceTo(target, mode) {
|
|
233714
|
+
const { api, channel, deviceId, logger } = target;
|
|
233715
|
+
const before = await readPowerSource(target);
|
|
233716
|
+
logger.info("power source: switch requested", {
|
|
233717
|
+
tags: { deviceId },
|
|
233718
|
+
meta: {
|
|
233719
|
+
mode,
|
|
233720
|
+
before,
|
|
233721
|
+
channel
|
|
233722
|
+
}
|
|
233723
|
+
});
|
|
233724
|
+
let supported;
|
|
233725
|
+
try {
|
|
233726
|
+
supported = await api.probePowerSourceSwitchSupport(mode, { channel });
|
|
233727
|
+
} catch (error) {
|
|
233728
|
+
logger.warn("power source: dry run failed, no switch sent", {
|
|
233729
|
+
tags: { deviceId },
|
|
233730
|
+
meta: {
|
|
233731
|
+
mode,
|
|
233732
|
+
error: errorMessage(error)
|
|
233733
|
+
}
|
|
233734
|
+
});
|
|
233735
|
+
return {
|
|
233736
|
+
outcome: "refused",
|
|
233737
|
+
mode,
|
|
233738
|
+
reason: "dry-run-failed",
|
|
233739
|
+
before
|
|
233740
|
+
};
|
|
233741
|
+
}
|
|
233742
|
+
if (!supported) {
|
|
233743
|
+
logger.warn("power source: the device refused the dry run, no switch sent", {
|
|
233744
|
+
tags: { deviceId },
|
|
233745
|
+
meta: {
|
|
233746
|
+
mode,
|
|
233747
|
+
before
|
|
233748
|
+
}
|
|
233749
|
+
});
|
|
233750
|
+
return {
|
|
233751
|
+
outcome: "refused",
|
|
233752
|
+
mode,
|
|
233753
|
+
reason: "dry-run-refused",
|
|
233754
|
+
before
|
|
233755
|
+
};
|
|
233756
|
+
}
|
|
233757
|
+
let result;
|
|
233758
|
+
try {
|
|
233759
|
+
result = await api.switchPowerSource(mode, { channel });
|
|
233760
|
+
} catch (error) {
|
|
233761
|
+
logger.error("power source: the switch threw; it is not retried", {
|
|
233762
|
+
tags: { deviceId },
|
|
233763
|
+
meta: {
|
|
233764
|
+
mode,
|
|
233765
|
+
error: errorMessage(error)
|
|
233766
|
+
}
|
|
233767
|
+
});
|
|
233768
|
+
return {
|
|
233769
|
+
outcome: "failed",
|
|
233770
|
+
mode,
|
|
233771
|
+
error: errorMessage(error),
|
|
233772
|
+
before
|
|
233773
|
+
};
|
|
233774
|
+
}
|
|
233775
|
+
const after = await readPowerSource(target);
|
|
233776
|
+
const applied = result.accepted && after === mode;
|
|
233777
|
+
const meta = {
|
|
233778
|
+
mode,
|
|
233779
|
+
before,
|
|
233780
|
+
after,
|
|
233781
|
+
accepted: result.accepted,
|
|
233782
|
+
rspCode: result.rspCode
|
|
233783
|
+
};
|
|
233784
|
+
if (applied) logger.info("power source: switched", {
|
|
233785
|
+
tags: { deviceId },
|
|
233786
|
+
meta
|
|
233787
|
+
});
|
|
233788
|
+
else logger.warn("power source: the switch was sent but the read-back does not show it", {
|
|
233789
|
+
tags: { deviceId },
|
|
233790
|
+
meta
|
|
233791
|
+
});
|
|
233792
|
+
return {
|
|
233793
|
+
outcome: "sent",
|
|
233794
|
+
mode,
|
|
233795
|
+
accepted: result.accepted,
|
|
233796
|
+
before,
|
|
233797
|
+
after,
|
|
233798
|
+
applied
|
|
233799
|
+
};
|
|
233800
|
+
}
|
|
233646
233801
|
//#endregion
|
|
233647
233802
|
//#region src/ptz-zoom.ts
|
|
233648
233803
|
/**
|
|
@@ -234632,6 +234787,8 @@ var RefreshSettingsResultSchema = object({
|
|
|
234632
234787
|
capsWarmed: number$1(),
|
|
234633
234788
|
capsTotal: number$1()
|
|
234634
234789
|
});
|
|
234790
|
+
/** The two switch actions, one implementation each way. */
|
|
234791
|
+
var POWER_SWITCH_ACTIONS = [["switch-to-wired-power", "adapter"], ["switch-to-battery-power", "battery"]];
|
|
234635
234792
|
/** The uid out of a device's metadata bag, or nothing. Never a cast. */
|
|
234636
234793
|
function metaUid(metadata) {
|
|
234637
234794
|
if (metadata === null) return void 0;
|
|
@@ -234804,8 +234961,6 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
234804
234961
|
* `sleep-state-decision.ts` for the measurement (D603).
|
|
234805
234962
|
*/
|
|
234806
234963
|
sleepStateChangedAt = 0;
|
|
234807
|
-
/** True once the 'sleep push ignored' line was logged for the current consumer-attached stretch. */
|
|
234808
|
-
sleepPushIgnoreLogged = false;
|
|
234809
234964
|
/**
|
|
234810
234965
|
* Wall-clock ms of the last PROACTIVE wake — one we issued on our own
|
|
234811
234966
|
* initiative (background snapshot refresh), not because the operator
|
|
@@ -236019,6 +236174,16 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
236019
236174
|
capsTotal
|
|
236020
236175
|
};
|
|
236021
236176
|
});
|
|
236177
|
+
if (this.isBattery) {
|
|
236178
|
+
this.registerDeviceAction("read-power-source", deviceCustomAction(unknown(), ReadPowerSourceResultSchema, { kind: "mutation" }), async () => {
|
|
236179
|
+
await this.wakeIfSleeping();
|
|
236180
|
+
return { source: await readPowerSource(await this.powerSourceTarget()) };
|
|
236181
|
+
});
|
|
236182
|
+
for (const [action, mode] of POWER_SWITCH_ACTIONS) this.registerDeviceAction(action, deviceCustomAction(unknown(), SwitchPowerSourceResultSchema, { kind: "mutation" }), async () => {
|
|
236183
|
+
await this.wakeIfSleeping();
|
|
236184
|
+
return switchPowerSourceTo(await this.powerSourceTarget(), mode);
|
|
236185
|
+
});
|
|
236186
|
+
}
|
|
236022
236187
|
this.registerDeviceAction("refresh-sessions", deviceCustomAction(unknown(), _void(), { kind: "mutation" }), async () => {
|
|
236023
236188
|
await this.refreshSessionsSnapshot();
|
|
236024
236189
|
});
|
|
@@ -236558,6 +236723,65 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
236558
236723
|
autoRefreshes: !this.isBattery
|
|
236559
236724
|
});
|
|
236560
236725
|
}
|
|
236726
|
+
/** The hub API for a child, the camera's own otherwise, plus the channel to address. */
|
|
236727
|
+
async powerSourceTarget() {
|
|
236728
|
+
return {
|
|
236729
|
+
api: await this.ensureApi(),
|
|
236730
|
+
channel: this.getChannel(),
|
|
236731
|
+
deviceId: this.id,
|
|
236732
|
+
logger: this.ctx.logger
|
|
236733
|
+
};
|
|
236734
|
+
}
|
|
236735
|
+
/**
|
|
236736
|
+
* Battery-cam power-source section (General tab): read the source, switch to
|
|
236737
|
+
* wired or back to battery. Returns `[]` for a wired-only camera. The buttons
|
|
236738
|
+
* dispatch the `read-power-source` / `switch-to-*-power` device actions.
|
|
236739
|
+
*/
|
|
236740
|
+
buildPowerSourceSection() {
|
|
236741
|
+
if (!this.isBattery) return [];
|
|
236742
|
+
const switchMessage = "Switch {outcome} · before: {before} · after: {after} · applied: {applied}";
|
|
236743
|
+
return [{
|
|
236744
|
+
id: "power-source",
|
|
236745
|
+
tab: "general",
|
|
236746
|
+
title: "Power source",
|
|
236747
|
+
titleKey: "provider-reolink:schema.s_power-source.title",
|
|
236748
|
+
description: "Only switch to wired power when the adapter meets the camera's spec.",
|
|
236749
|
+
descriptionKey: "provider-reolink:schema.s_power-source.description",
|
|
236750
|
+
columns: 1,
|
|
236751
|
+
fields: [
|
|
236752
|
+
{
|
|
236753
|
+
type: "device-action-button",
|
|
236754
|
+
key: "_readPowerSource",
|
|
236755
|
+
label: "Power source",
|
|
236756
|
+
labelKey: "provider-reolink:schema.s_power-source._readPowerSource.label",
|
|
236757
|
+
buttonLabel: "Read power source",
|
|
236758
|
+
action: "read-power-source",
|
|
236759
|
+
variant: "default",
|
|
236760
|
+
successMessage: "Power source: {source}"
|
|
236761
|
+
},
|
|
236762
|
+
{
|
|
236763
|
+
type: "device-action-button",
|
|
236764
|
+
key: "_switchToWiredPower",
|
|
236765
|
+
label: "Wired power",
|
|
236766
|
+
labelKey: "provider-reolink:schema.s_power-source._switchToWiredPower.label",
|
|
236767
|
+
buttonLabel: "Switch to wired power",
|
|
236768
|
+
action: "switch-to-wired-power",
|
|
236769
|
+
variant: "default",
|
|
236770
|
+
successMessage: switchMessage
|
|
236771
|
+
},
|
|
236772
|
+
{
|
|
236773
|
+
type: "device-action-button",
|
|
236774
|
+
key: "_switchToBatteryPower",
|
|
236775
|
+
label: "Battery power",
|
|
236776
|
+
labelKey: "provider-reolink:schema.s_power-source._switchToBatteryPower.label",
|
|
236777
|
+
buttonLabel: "Switch to battery power",
|
|
236778
|
+
action: "switch-to-battery-power",
|
|
236779
|
+
variant: "default",
|
|
236780
|
+
successMessage: switchMessage
|
|
236781
|
+
}
|
|
236782
|
+
]
|
|
236783
|
+
}];
|
|
236784
|
+
}
|
|
236561
236785
|
/**
|
|
236562
236786
|
* Battery-cam Email Push auto-configure section. Returns `[]` for any
|
|
236563
236787
|
* camera that wouldn't benefit (wired cams keep a live socket for
|
|
@@ -241470,6 +241694,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
241470
241694
|
}),
|
|
241471
241695
|
...this.buildSessionsTabSections(),
|
|
241472
241696
|
...this.buildEmailPushSection(),
|
|
241697
|
+
...this.buildPowerSourceSection(),
|
|
241473
241698
|
...this.buildEmailTabSections(),
|
|
241474
241699
|
...buildClipRefreshDeviceSection({
|
|
241475
241700
|
isHubChild: this.isHubChild(),
|
|
@@ -242325,17 +242550,6 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
242325
242550
|
return;
|
|
242326
242551
|
}
|
|
242327
242552
|
if (event.type === "sleeping") {
|
|
242328
|
-
if (this.isBattery && shouldIgnoreSleepPush({ activeStreams: this.active.size })) {
|
|
242329
|
-
if (!this.sleepPushIgnoreLogged) {
|
|
242330
|
-
this.sleepPushIgnoreLogged = true;
|
|
242331
|
-
this.ctx.logger.info(`sleep push ignored: ${this.active.size} active stream consumer(s)`, {
|
|
242332
|
-
tags: { deviceId: this.id },
|
|
242333
|
-
meta: { activeStreams: this.active.size }
|
|
242334
|
-
});
|
|
242335
|
-
}
|
|
242336
|
-
return;
|
|
242337
|
-
}
|
|
242338
|
-
this.sleepPushIgnoreLogged = false;
|
|
242339
242553
|
const wasSleeping = this.sleeping;
|
|
242340
242554
|
if (!this.commitSleepState(true, "simple-event")) return;
|
|
242341
242555
|
if (!wasSleeping) this.ctx.eventBus.emit(createEvent(EventCategory.DeviceSleeping, eventSource, {
|