@camstack/addon-provider-reolink 1.2.237 → 1.2.238
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 +6 -0
- package/dist/addon.js +140 -4
- package/dist/addon.mjs +140 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.2.238] - 2026-11-11
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- A battery camera asleep or on its adapter no longer reports a 0% level from the hub, which raised low/normal battery notification pairs; the last real level is kept.
|
|
15
|
+
|
|
10
16
|
## [1.2.237] - 2026-11-11
|
|
11
17
|
|
|
12
18
|
### Changed
|
package/dist/addon.js
CHANGED
|
@@ -145619,6 +145619,13 @@ var AutomationConditionOperatorSchema = _enum([
|
|
|
145619
145619
|
"in"
|
|
145620
145620
|
]);
|
|
145621
145621
|
/**
|
|
145622
|
+
* The stable name of an event leaf. A path (`when.0.1`) moves when a row is
|
|
145623
|
+
* reordered; the id does not, so a `triggered-by` leaf keeps pointing at the
|
|
145624
|
+
* same row. Optional: a leaf nothing refers to needs none.
|
|
145625
|
+
*/
|
|
145626
|
+
var EVENT_LEAF_ID_RE = /^[A-Za-z0-9_-]{1,40}$/;
|
|
145627
|
+
var eventLeafId = { id: string().regex(EVENT_LEAF_ID_RE).optional() };
|
|
145628
|
+
/**
|
|
145622
145629
|
* D8 compliance, and it is the reason a "becomes" leaf is not merely an event
|
|
145623
145630
|
* subscription: it evaluates against the **state mirror**, which is reconciled,
|
|
145624
145631
|
* and an event only WAKES the evaluation. A dropped event therefore DELAYS a
|
|
@@ -145626,6 +145633,7 @@ var AutomationConditionOperatorSchema = _enum([
|
|
|
145626
145633
|
*/
|
|
145627
145634
|
var DeviceBecomesLeafSchema = object({
|
|
145628
145635
|
kind: literal("device-becomes"),
|
|
145636
|
+
...eventLeafId,
|
|
145629
145637
|
deviceId: number$1().int().nonnegative(),
|
|
145630
145638
|
cap: string().min(1),
|
|
145631
145639
|
fieldPath: string().min(1),
|
|
@@ -145678,6 +145686,7 @@ var DeviceBecomesLeafSchema = object({
|
|
|
145678
145686
|
});
|
|
145679
145687
|
var DeviceEventLeafSchema = object({
|
|
145680
145688
|
kind: literal("device-event"),
|
|
145689
|
+
...eventLeafId,
|
|
145681
145690
|
/** An `EventCategory` value. */
|
|
145682
145691
|
category: string().min(1),
|
|
145683
145692
|
deviceId: number$1().int().nonnegative().optional()
|
|
@@ -145690,18 +145699,24 @@ var DeviceEventLeafSchema = object({
|
|
|
145690
145699
|
*/
|
|
145691
145700
|
var ScheduleLeafSchema = object({
|
|
145692
145701
|
kind: literal("schedule"),
|
|
145702
|
+
...eventLeafId,
|
|
145693
145703
|
at: TimeSpecSchema.optional(),
|
|
145694
145704
|
days: array(WeekdayKeySchema).min(1).max(7).optional(),
|
|
145695
145705
|
/** @deprecated legacy cron — new schedules use `at`. */
|
|
145696
145706
|
cron: string().min(1).max(120).optional()
|
|
145697
145707
|
}).refine((leaf) => leaf.at === void 0 !== (leaf.cron === void 0), { message: "a schedule names exactly one of `at` (a time spec) and `cron` (legacy)" }).refine((leaf) => leaf.days === void 0 || leaf.at !== void 0, { message: "`days` goes with `at`; a cron expression carries its own days" });
|
|
145698
|
-
var ManualLeafSchema = object({
|
|
145708
|
+
var ManualLeafSchema = object({
|
|
145709
|
+
kind: literal("manual"),
|
|
145710
|
+
...eventLeafId
|
|
145711
|
+
});
|
|
145699
145712
|
var IntervalLeafSchema = object({
|
|
145700
145713
|
kind: literal("interval"),
|
|
145714
|
+
...eventLeafId,
|
|
145701
145715
|
minutes: number$1().int().min(1).max(1440)
|
|
145702
145716
|
});
|
|
145703
145717
|
var DetectionLeafSchema = object({
|
|
145704
145718
|
kind: literal("detection"),
|
|
145719
|
+
...eventLeafId,
|
|
145705
145720
|
/** One macro class each, optionally narrowed by a label; a track of any listed subject fires. */
|
|
145706
145721
|
subjects: array(DetectionSubjectSchema).min(1),
|
|
145707
145722
|
deviceIds: array(number$1().int().nonnegative()).min(1),
|
|
@@ -145712,6 +145727,7 @@ var DetectionLeafSchema = object({
|
|
|
145712
145727
|
});
|
|
145713
145728
|
var StationaryLeafSchema = object({
|
|
145714
145729
|
kind: literal("stationary"),
|
|
145730
|
+
...eventLeafId,
|
|
145715
145731
|
deviceIds: array(number$1().int().nonnegative()).min(1),
|
|
145716
145732
|
subjects: array(StationarySubjectSchema).min(1).optional(),
|
|
145717
145733
|
zones: array(string().min(1)).min(1).optional(),
|
|
@@ -145757,6 +145773,41 @@ var StationaryPresentLeafSchema = object({
|
|
|
145757
145773
|
minCount: number$1().int().positive().optional()
|
|
145758
145774
|
});
|
|
145759
145775
|
/**
|
|
145776
|
+
* True while the site-local clock is inside a daily window and/or on one of
|
|
145777
|
+
* the named days. `days` names the local day a window STARTS on, so
|
|
145778
|
+
* 22:00-06:00 on weekdays is still inside at 01:00 Saturday. A one-date spec
|
|
145779
|
+
* (`kind: 'date'`) is refused: only a clock time or a sun event makes a window
|
|
145780
|
+
* that repeats every day.
|
|
145781
|
+
*/
|
|
145782
|
+
var TimeIsLeafSchema = object({
|
|
145783
|
+
kind: literal("time-is"),
|
|
145784
|
+
between: object({
|
|
145785
|
+
from: TimeSpecSchema,
|
|
145786
|
+
to: TimeSpecSchema
|
|
145787
|
+
}).optional(),
|
|
145788
|
+
days: array(WeekdayKeySchema).min(1).max(7).optional()
|
|
145789
|
+
}).superRefine((leaf, ctx) => {
|
|
145790
|
+
if (leaf.between === void 0 && leaf.days === void 0) ctx.addIssue({
|
|
145791
|
+
code: "custom",
|
|
145792
|
+
message: "a time-is leaf needs a between window, days, or both"
|
|
145793
|
+
});
|
|
145794
|
+
for (const end of ["from", "to"]) if (leaf.between?.[end].kind === "date") ctx.addIssue({
|
|
145795
|
+
code: "custom",
|
|
145796
|
+
message: "a one-date time cannot bound a daily window: use a clock time or a sun event",
|
|
145797
|
+
path: ["between", end]
|
|
145798
|
+
});
|
|
145799
|
+
});
|
|
145800
|
+
/**
|
|
145801
|
+
* True for the run that one of the named event leaves started. It reads the
|
|
145802
|
+
* run, not a device: in the tree it is judged against the leaf that fired, in
|
|
145803
|
+
* a step guard against the trigger the run carries. A run no event leaf
|
|
145804
|
+
* started (a state-only tree becoming true) is false.
|
|
145805
|
+
*/
|
|
145806
|
+
var TriggeredByLeafSchema = object({
|
|
145807
|
+
kind: literal("triggered-by"),
|
|
145808
|
+
leafIds: array(string().regex(EVENT_LEAF_ID_RE)).min(1).max(20)
|
|
145809
|
+
});
|
|
145810
|
+
/**
|
|
145760
145811
|
* The escape hatch: the bounded expression engine over named device bindings.
|
|
145761
145812
|
* Declared as a plain object so a discriminated union can read `kind`; the
|
|
145762
145813
|
* author-time validation is the SAME function `ExpressionSourceSchema` runs.
|
|
@@ -145802,7 +145853,9 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
|
|
|
145802
145853
|
StationaryLeafSchema,
|
|
145803
145854
|
DeviceIsLeafSchema,
|
|
145804
145855
|
StationaryPresentLeafSchema,
|
|
145805
|
-
ExpressionLeafSchema
|
|
145856
|
+
ExpressionLeafSchema,
|
|
145857
|
+
TimeIsLeafSchema,
|
|
145858
|
+
TriggeredByLeafSchema
|
|
145806
145859
|
]));
|
|
145807
145860
|
var EVENT_KINDS = new Set([
|
|
145808
145861
|
"device-becomes",
|
|
@@ -145856,6 +145909,28 @@ function hasEventLeaves(node) {
|
|
|
145856
145909
|
});
|
|
145857
145910
|
return found;
|
|
145858
145911
|
}
|
|
145912
|
+
/** The event leaves of the tree that carry an id, in tree order. */
|
|
145913
|
+
function identifiedEventLeaves(when) {
|
|
145914
|
+
const found = [];
|
|
145915
|
+
forEachLeaf(when, (leaf, path) => {
|
|
145916
|
+
if (isEventLeaf(leaf) && leaf.id !== void 0) found.push({
|
|
145917
|
+
id: leaf.id,
|
|
145918
|
+
path,
|
|
145919
|
+
leaf
|
|
145920
|
+
});
|
|
145921
|
+
});
|
|
145922
|
+
return found;
|
|
145923
|
+
}
|
|
145924
|
+
/** Does the tree hold a `triggered-by` leaf? */
|
|
145925
|
+
function hasTriggeredByLeaves(when) {
|
|
145926
|
+
let found = false;
|
|
145927
|
+
forEachLeaf(when, (leaf) => {
|
|
145928
|
+
if (leaf.kind === "triggered-by") found = true;
|
|
145929
|
+
});
|
|
145930
|
+
return found;
|
|
145931
|
+
}
|
|
145932
|
+
/** Why a `triggered-by` leaf is refused outside an automation: there is no trigger row to name. */
|
|
145933
|
+
var TRIGGERED_BY_NEEDS_AUTOMATION = "\"triggered by\" reads which trigger started an automation — an action or a scheduler has no trigger rows, so it could never be true here";
|
|
145859
145934
|
function hasEmptyContainer(node) {
|
|
145860
145935
|
if (isLeaf(node)) return false;
|
|
145861
145936
|
if (node.kind === "not") return hasEmptyContainer(node.child);
|
|
@@ -145914,6 +145989,11 @@ function validateWhenTree(when) {
|
|
|
145914
145989
|
if (depth > 4) return `the rules nest ${depth} levels deep — the limit is 4. "not (any of …)" is the same as "all of (not …)", which is one level shallower`;
|
|
145915
145990
|
const leaves = countWhenLeaves(when);
|
|
145916
145991
|
if (leaves > 32) return `the rules use ${leaves} rows — the limit is 32`;
|
|
145992
|
+
const seen = /* @__PURE__ */ new Set();
|
|
145993
|
+
for (const entry of identifiedEventLeaves(when)) {
|
|
145994
|
+
if (seen.has(entry.id)) return `two trigger rows share the id "${entry.id}" — an id names one row`;
|
|
145995
|
+
seen.add(entry.id);
|
|
145996
|
+
}
|
|
145917
145997
|
const need = eventNeed(when, "when", false);
|
|
145918
145998
|
if ("error" in need) return need.error;
|
|
145919
145999
|
const [first, second] = need.paths;
|
|
@@ -146204,7 +146284,18 @@ var GuardedCapStepSchema = AutomationCapStepBaseSchema.extend(stepGuardShape).re
|
|
|
146204
146284
|
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
146205
146285
|
path: ["actionId"]
|
|
146206
146286
|
}).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
146207
|
-
|
|
146287
|
+
/**
|
|
146288
|
+
* A step of a STANDALONE list (an action, a scheduler point, a preset): the
|
|
146289
|
+
* same two step kinds an automation runs, minus a guard that reads the
|
|
146290
|
+
* automation's trigger, which such a list does not have.
|
|
146291
|
+
*/
|
|
146292
|
+
var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, GuardedCapStepSchema]).superRefine((step, ctx) => {
|
|
146293
|
+
if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
|
|
146294
|
+
code: "custom",
|
|
146295
|
+
message: TRIGGERED_BY_NEEDS_AUTOMATION,
|
|
146296
|
+
path: ["if"]
|
|
146297
|
+
});
|
|
146298
|
+
});
|
|
146208
146299
|
var AutomationActionSchema = discriminatedUnion("kind", [
|
|
146209
146300
|
GuardedWaitStepSchema,
|
|
146210
146301
|
GuardedCapStepSchema,
|
|
@@ -146301,6 +146392,11 @@ var STATIONARY_DESCRIPTIONS = {
|
|
|
146301
146392
|
phase: "appeared or departed",
|
|
146302
146393
|
entryId: "the stopped object"
|
|
146303
146394
|
};
|
|
146395
|
+
var BECOMES_DESCRIPTIONS = {
|
|
146396
|
+
deviceId: "the device that changed",
|
|
146397
|
+
from: "the value before the change, empty when it is not known",
|
|
146398
|
+
to: "the value it changed to"
|
|
146399
|
+
};
|
|
146304
146400
|
function describe$1(descriptions) {
|
|
146305
146401
|
return Object.entries(descriptions).map(([name, description]) => ({
|
|
146306
146402
|
name,
|
|
@@ -146309,6 +146405,10 @@ function describe$1(descriptions) {
|
|
|
146309
146405
|
}
|
|
146310
146406
|
describe$1(DETECTION_DESCRIPTIONS);
|
|
146311
146407
|
describe$1(STATIONARY_DESCRIPTIONS);
|
|
146408
|
+
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
146409
|
+
...v,
|
|
146410
|
+
hintKey: "becomesDeviceId"
|
|
146411
|
+
} : v);
|
|
146312
146412
|
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
146313
146413
|
/**
|
|
146314
146414
|
* Schedulers (D983) — an entity that performs actions over the day.
|
|
@@ -146333,6 +146433,13 @@ var SchedulerStateTreeSchema = AutomationWhenSchema.superRefine((when, ctx) => {
|
|
|
146333
146433
|
});
|
|
146334
146434
|
return;
|
|
146335
146435
|
}
|
|
146436
|
+
if (hasTriggeredByLeaves(when)) {
|
|
146437
|
+
ctx.addIssue({
|
|
146438
|
+
code: "custom",
|
|
146439
|
+
message: TRIGGERED_BY_NEEDS_AUTOMATION
|
|
146440
|
+
});
|
|
146441
|
+
return;
|
|
146442
|
+
}
|
|
146336
146443
|
const problem = validateWhenTree(when);
|
|
146337
146444
|
if (problem !== null) ctx.addIssue({
|
|
146338
146445
|
code: "custom",
|
|
@@ -146553,6 +146660,8 @@ var AutomationConditionTraceNodeSchema = object({
|
|
|
146553
146660
|
"device-is",
|
|
146554
146661
|
"expression",
|
|
146555
146662
|
"stationary-present",
|
|
146663
|
+
"time-is",
|
|
146664
|
+
"triggered-by",
|
|
146556
146665
|
"device-becomes",
|
|
146557
146666
|
"device-event",
|
|
146558
146667
|
"schedule",
|
|
@@ -213127,6 +213236,20 @@ var UnmappedCodeLedger = class {
|
|
|
213127
213236
|
return true;
|
|
213128
213237
|
}
|
|
213129
213238
|
};
|
|
213239
|
+
/**
|
|
213240
|
+
* Whether a hub per-channel battery level is a MEASUREMENT (D393). The hub's cached read of a
|
|
213241
|
+
* channel that is asleep reports `0` — and so does a read taken while the cell is on an adapter
|
|
213242
|
+
* (a powered camera at 0% is not a reading, it is a placeholder). Both are UNMEASURED: the caller
|
|
213243
|
+
* keeps the last real level. A `0` from an awake, unpowered channel is a genuine empty cell and
|
|
213244
|
+
* passes, as does every non-zero level.
|
|
213245
|
+
*/
|
|
213246
|
+
function isMeasuredHubBatteryLevel(level, context) {
|
|
213247
|
+
if (typeof level !== "number") return false;
|
|
213248
|
+
if (level !== 0) return true;
|
|
213249
|
+
if (context.sleeping) return false;
|
|
213250
|
+
const { chargeStatus, adapterStatus } = context.power;
|
|
213251
|
+
return !(adapterStatus !== void 0 && adapterStatus !== "none" || chargeStatus === "charging" || chargeStatus === "chargeComplete");
|
|
213252
|
+
}
|
|
213130
213253
|
//#endregion
|
|
213131
213254
|
//#region src/hub-channel-reconcile.ts
|
|
213132
213255
|
/**
|
|
@@ -213690,8 +213813,21 @@ var ReolinkHubSession = class {
|
|
|
213690
213813
|
}
|
|
213691
213814
|
});
|
|
213692
213815
|
}
|
|
213816
|
+
const measured = isMeasuredHubBatteryLevel(info.batteryLevel, {
|
|
213817
|
+
sleeping: child.sleeping,
|
|
213818
|
+
power: power.fields
|
|
213819
|
+
});
|
|
213820
|
+
if (info.batteryLevel === 0) this.#logger.info("Reolink hub: battery entry reporting 0", {
|
|
213821
|
+
tags: { deviceId: child.id },
|
|
213822
|
+
meta: {
|
|
213823
|
+
channel: Number(chKey),
|
|
213824
|
+
sleeping: child.sleeping,
|
|
213825
|
+
measured,
|
|
213826
|
+
raw: info
|
|
213827
|
+
}
|
|
213828
|
+
});
|
|
213693
213829
|
child.applyHubBatteryInfo({
|
|
213694
|
-
batteryPercent: info.batteryLevel,
|
|
213830
|
+
...measured ? { batteryPercent: info.batteryLevel } : {},
|
|
213695
213831
|
...power.fields
|
|
213696
213832
|
});
|
|
213697
213833
|
}
|
package/dist/addon.mjs
CHANGED
|
@@ -145611,6 +145611,13 @@ var AutomationConditionOperatorSchema = _enum([
|
|
|
145611
145611
|
"in"
|
|
145612
145612
|
]);
|
|
145613
145613
|
/**
|
|
145614
|
+
* The stable name of an event leaf. A path (`when.0.1`) moves when a row is
|
|
145615
|
+
* reordered; the id does not, so a `triggered-by` leaf keeps pointing at the
|
|
145616
|
+
* same row. Optional: a leaf nothing refers to needs none.
|
|
145617
|
+
*/
|
|
145618
|
+
var EVENT_LEAF_ID_RE = /^[A-Za-z0-9_-]{1,40}$/;
|
|
145619
|
+
var eventLeafId = { id: string().regex(EVENT_LEAF_ID_RE).optional() };
|
|
145620
|
+
/**
|
|
145614
145621
|
* D8 compliance, and it is the reason a "becomes" leaf is not merely an event
|
|
145615
145622
|
* subscription: it evaluates against the **state mirror**, which is reconciled,
|
|
145616
145623
|
* and an event only WAKES the evaluation. A dropped event therefore DELAYS a
|
|
@@ -145618,6 +145625,7 @@ var AutomationConditionOperatorSchema = _enum([
|
|
|
145618
145625
|
*/
|
|
145619
145626
|
var DeviceBecomesLeafSchema = object({
|
|
145620
145627
|
kind: literal("device-becomes"),
|
|
145628
|
+
...eventLeafId,
|
|
145621
145629
|
deviceId: number$1().int().nonnegative(),
|
|
145622
145630
|
cap: string().min(1),
|
|
145623
145631
|
fieldPath: string().min(1),
|
|
@@ -145670,6 +145678,7 @@ var DeviceBecomesLeafSchema = object({
|
|
|
145670
145678
|
});
|
|
145671
145679
|
var DeviceEventLeafSchema = object({
|
|
145672
145680
|
kind: literal("device-event"),
|
|
145681
|
+
...eventLeafId,
|
|
145673
145682
|
/** An `EventCategory` value. */
|
|
145674
145683
|
category: string().min(1),
|
|
145675
145684
|
deviceId: number$1().int().nonnegative().optional()
|
|
@@ -145682,18 +145691,24 @@ var DeviceEventLeafSchema = object({
|
|
|
145682
145691
|
*/
|
|
145683
145692
|
var ScheduleLeafSchema = object({
|
|
145684
145693
|
kind: literal("schedule"),
|
|
145694
|
+
...eventLeafId,
|
|
145685
145695
|
at: TimeSpecSchema.optional(),
|
|
145686
145696
|
days: array(WeekdayKeySchema).min(1).max(7).optional(),
|
|
145687
145697
|
/** @deprecated legacy cron — new schedules use `at`. */
|
|
145688
145698
|
cron: string().min(1).max(120).optional()
|
|
145689
145699
|
}).refine((leaf) => leaf.at === void 0 !== (leaf.cron === void 0), { message: "a schedule names exactly one of `at` (a time spec) and `cron` (legacy)" }).refine((leaf) => leaf.days === void 0 || leaf.at !== void 0, { message: "`days` goes with `at`; a cron expression carries its own days" });
|
|
145690
|
-
var ManualLeafSchema = object({
|
|
145700
|
+
var ManualLeafSchema = object({
|
|
145701
|
+
kind: literal("manual"),
|
|
145702
|
+
...eventLeafId
|
|
145703
|
+
});
|
|
145691
145704
|
var IntervalLeafSchema = object({
|
|
145692
145705
|
kind: literal("interval"),
|
|
145706
|
+
...eventLeafId,
|
|
145693
145707
|
minutes: number$1().int().min(1).max(1440)
|
|
145694
145708
|
});
|
|
145695
145709
|
var DetectionLeafSchema = object({
|
|
145696
145710
|
kind: literal("detection"),
|
|
145711
|
+
...eventLeafId,
|
|
145697
145712
|
/** One macro class each, optionally narrowed by a label; a track of any listed subject fires. */
|
|
145698
145713
|
subjects: array(DetectionSubjectSchema).min(1),
|
|
145699
145714
|
deviceIds: array(number$1().int().nonnegative()).min(1),
|
|
@@ -145704,6 +145719,7 @@ var DetectionLeafSchema = object({
|
|
|
145704
145719
|
});
|
|
145705
145720
|
var StationaryLeafSchema = object({
|
|
145706
145721
|
kind: literal("stationary"),
|
|
145722
|
+
...eventLeafId,
|
|
145707
145723
|
deviceIds: array(number$1().int().nonnegative()).min(1),
|
|
145708
145724
|
subjects: array(StationarySubjectSchema).min(1).optional(),
|
|
145709
145725
|
zones: array(string().min(1)).min(1).optional(),
|
|
@@ -145749,6 +145765,41 @@ var StationaryPresentLeafSchema = object({
|
|
|
145749
145765
|
minCount: number$1().int().positive().optional()
|
|
145750
145766
|
});
|
|
145751
145767
|
/**
|
|
145768
|
+
* True while the site-local clock is inside a daily window and/or on one of
|
|
145769
|
+
* the named days. `days` names the local day a window STARTS on, so
|
|
145770
|
+
* 22:00-06:00 on weekdays is still inside at 01:00 Saturday. A one-date spec
|
|
145771
|
+
* (`kind: 'date'`) is refused: only a clock time or a sun event makes a window
|
|
145772
|
+
* that repeats every day.
|
|
145773
|
+
*/
|
|
145774
|
+
var TimeIsLeafSchema = object({
|
|
145775
|
+
kind: literal("time-is"),
|
|
145776
|
+
between: object({
|
|
145777
|
+
from: TimeSpecSchema,
|
|
145778
|
+
to: TimeSpecSchema
|
|
145779
|
+
}).optional(),
|
|
145780
|
+
days: array(WeekdayKeySchema).min(1).max(7).optional()
|
|
145781
|
+
}).superRefine((leaf, ctx) => {
|
|
145782
|
+
if (leaf.between === void 0 && leaf.days === void 0) ctx.addIssue({
|
|
145783
|
+
code: "custom",
|
|
145784
|
+
message: "a time-is leaf needs a between window, days, or both"
|
|
145785
|
+
});
|
|
145786
|
+
for (const end of ["from", "to"]) if (leaf.between?.[end].kind === "date") ctx.addIssue({
|
|
145787
|
+
code: "custom",
|
|
145788
|
+
message: "a one-date time cannot bound a daily window: use a clock time or a sun event",
|
|
145789
|
+
path: ["between", end]
|
|
145790
|
+
});
|
|
145791
|
+
});
|
|
145792
|
+
/**
|
|
145793
|
+
* True for the run that one of the named event leaves started. It reads the
|
|
145794
|
+
* run, not a device: in the tree it is judged against the leaf that fired, in
|
|
145795
|
+
* a step guard against the trigger the run carries. A run no event leaf
|
|
145796
|
+
* started (a state-only tree becoming true) is false.
|
|
145797
|
+
*/
|
|
145798
|
+
var TriggeredByLeafSchema = object({
|
|
145799
|
+
kind: literal("triggered-by"),
|
|
145800
|
+
leafIds: array(string().regex(EVENT_LEAF_ID_RE)).min(1).max(20)
|
|
145801
|
+
});
|
|
145802
|
+
/**
|
|
145752
145803
|
* The escape hatch: the bounded expression engine over named device bindings.
|
|
145753
145804
|
* Declared as a plain object so a discriminated union can read `kind`; the
|
|
145754
145805
|
* author-time validation is the SAME function `ExpressionSourceSchema` runs.
|
|
@@ -145794,7 +145845,9 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
|
|
|
145794
145845
|
StationaryLeafSchema,
|
|
145795
145846
|
DeviceIsLeafSchema,
|
|
145796
145847
|
StationaryPresentLeafSchema,
|
|
145797
|
-
ExpressionLeafSchema
|
|
145848
|
+
ExpressionLeafSchema,
|
|
145849
|
+
TimeIsLeafSchema,
|
|
145850
|
+
TriggeredByLeafSchema
|
|
145798
145851
|
]));
|
|
145799
145852
|
var EVENT_KINDS = new Set([
|
|
145800
145853
|
"device-becomes",
|
|
@@ -145848,6 +145901,28 @@ function hasEventLeaves(node) {
|
|
|
145848
145901
|
});
|
|
145849
145902
|
return found;
|
|
145850
145903
|
}
|
|
145904
|
+
/** The event leaves of the tree that carry an id, in tree order. */
|
|
145905
|
+
function identifiedEventLeaves(when) {
|
|
145906
|
+
const found = [];
|
|
145907
|
+
forEachLeaf(when, (leaf, path) => {
|
|
145908
|
+
if (isEventLeaf(leaf) && leaf.id !== void 0) found.push({
|
|
145909
|
+
id: leaf.id,
|
|
145910
|
+
path,
|
|
145911
|
+
leaf
|
|
145912
|
+
});
|
|
145913
|
+
});
|
|
145914
|
+
return found;
|
|
145915
|
+
}
|
|
145916
|
+
/** Does the tree hold a `triggered-by` leaf? */
|
|
145917
|
+
function hasTriggeredByLeaves(when) {
|
|
145918
|
+
let found = false;
|
|
145919
|
+
forEachLeaf(when, (leaf) => {
|
|
145920
|
+
if (leaf.kind === "triggered-by") found = true;
|
|
145921
|
+
});
|
|
145922
|
+
return found;
|
|
145923
|
+
}
|
|
145924
|
+
/** Why a `triggered-by` leaf is refused outside an automation: there is no trigger row to name. */
|
|
145925
|
+
var TRIGGERED_BY_NEEDS_AUTOMATION = "\"triggered by\" reads which trigger started an automation — an action or a scheduler has no trigger rows, so it could never be true here";
|
|
145851
145926
|
function hasEmptyContainer(node) {
|
|
145852
145927
|
if (isLeaf(node)) return false;
|
|
145853
145928
|
if (node.kind === "not") return hasEmptyContainer(node.child);
|
|
@@ -145906,6 +145981,11 @@ function validateWhenTree(when) {
|
|
|
145906
145981
|
if (depth > 4) return `the rules nest ${depth} levels deep — the limit is 4. "not (any of …)" is the same as "all of (not …)", which is one level shallower`;
|
|
145907
145982
|
const leaves = countWhenLeaves(when);
|
|
145908
145983
|
if (leaves > 32) return `the rules use ${leaves} rows — the limit is 32`;
|
|
145984
|
+
const seen = /* @__PURE__ */ new Set();
|
|
145985
|
+
for (const entry of identifiedEventLeaves(when)) {
|
|
145986
|
+
if (seen.has(entry.id)) return `two trigger rows share the id "${entry.id}" — an id names one row`;
|
|
145987
|
+
seen.add(entry.id);
|
|
145988
|
+
}
|
|
145909
145989
|
const need = eventNeed(when, "when", false);
|
|
145910
145990
|
if ("error" in need) return need.error;
|
|
145911
145991
|
const [first, second] = need.paths;
|
|
@@ -146196,7 +146276,18 @@ var GuardedCapStepSchema = AutomationCapStepBaseSchema.extend(stepGuardShape).re
|
|
|
146196
146276
|
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
146197
146277
|
path: ["actionId"]
|
|
146198
146278
|
}).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
146199
|
-
|
|
146279
|
+
/**
|
|
146280
|
+
* A step of a STANDALONE list (an action, a scheduler point, a preset): the
|
|
146281
|
+
* same two step kinds an automation runs, minus a guard that reads the
|
|
146282
|
+
* automation's trigger, which such a list does not have.
|
|
146283
|
+
*/
|
|
146284
|
+
var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, GuardedCapStepSchema]).superRefine((step, ctx) => {
|
|
146285
|
+
if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
|
|
146286
|
+
code: "custom",
|
|
146287
|
+
message: TRIGGERED_BY_NEEDS_AUTOMATION,
|
|
146288
|
+
path: ["if"]
|
|
146289
|
+
});
|
|
146290
|
+
});
|
|
146200
146291
|
var AutomationActionSchema = discriminatedUnion("kind", [
|
|
146201
146292
|
GuardedWaitStepSchema,
|
|
146202
146293
|
GuardedCapStepSchema,
|
|
@@ -146293,6 +146384,11 @@ var STATIONARY_DESCRIPTIONS = {
|
|
|
146293
146384
|
phase: "appeared or departed",
|
|
146294
146385
|
entryId: "the stopped object"
|
|
146295
146386
|
};
|
|
146387
|
+
var BECOMES_DESCRIPTIONS = {
|
|
146388
|
+
deviceId: "the device that changed",
|
|
146389
|
+
from: "the value before the change, empty when it is not known",
|
|
146390
|
+
to: "the value it changed to"
|
|
146391
|
+
};
|
|
146296
146392
|
function describe$1(descriptions) {
|
|
146297
146393
|
return Object.entries(descriptions).map(([name, description]) => ({
|
|
146298
146394
|
name,
|
|
@@ -146301,6 +146397,10 @@ function describe$1(descriptions) {
|
|
|
146301
146397
|
}
|
|
146302
146398
|
describe$1(DETECTION_DESCRIPTIONS);
|
|
146303
146399
|
describe$1(STATIONARY_DESCRIPTIONS);
|
|
146400
|
+
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
146401
|
+
...v,
|
|
146402
|
+
hintKey: "becomesDeviceId"
|
|
146403
|
+
} : v);
|
|
146304
146404
|
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
146305
146405
|
/**
|
|
146306
146406
|
* Schedulers (D983) — an entity that performs actions over the day.
|
|
@@ -146325,6 +146425,13 @@ var SchedulerStateTreeSchema = AutomationWhenSchema.superRefine((when, ctx) => {
|
|
|
146325
146425
|
});
|
|
146326
146426
|
return;
|
|
146327
146427
|
}
|
|
146428
|
+
if (hasTriggeredByLeaves(when)) {
|
|
146429
|
+
ctx.addIssue({
|
|
146430
|
+
code: "custom",
|
|
146431
|
+
message: TRIGGERED_BY_NEEDS_AUTOMATION
|
|
146432
|
+
});
|
|
146433
|
+
return;
|
|
146434
|
+
}
|
|
146328
146435
|
const problem = validateWhenTree(when);
|
|
146329
146436
|
if (problem !== null) ctx.addIssue({
|
|
146330
146437
|
code: "custom",
|
|
@@ -146545,6 +146652,8 @@ var AutomationConditionTraceNodeSchema = object({
|
|
|
146545
146652
|
"device-is",
|
|
146546
146653
|
"expression",
|
|
146547
146654
|
"stationary-present",
|
|
146655
|
+
"time-is",
|
|
146656
|
+
"triggered-by",
|
|
146548
146657
|
"device-becomes",
|
|
146549
146658
|
"device-event",
|
|
146550
146659
|
"schedule",
|
|
@@ -213119,6 +213228,20 @@ var UnmappedCodeLedger = class {
|
|
|
213119
213228
|
return true;
|
|
213120
213229
|
}
|
|
213121
213230
|
};
|
|
213231
|
+
/**
|
|
213232
|
+
* Whether a hub per-channel battery level is a MEASUREMENT (D393). The hub's cached read of a
|
|
213233
|
+
* channel that is asleep reports `0` — and so does a read taken while the cell is on an adapter
|
|
213234
|
+
* (a powered camera at 0% is not a reading, it is a placeholder). Both are UNMEASURED: the caller
|
|
213235
|
+
* keeps the last real level. A `0` from an awake, unpowered channel is a genuine empty cell and
|
|
213236
|
+
* passes, as does every non-zero level.
|
|
213237
|
+
*/
|
|
213238
|
+
function isMeasuredHubBatteryLevel(level, context) {
|
|
213239
|
+
if (typeof level !== "number") return false;
|
|
213240
|
+
if (level !== 0) return true;
|
|
213241
|
+
if (context.sleeping) return false;
|
|
213242
|
+
const { chargeStatus, adapterStatus } = context.power;
|
|
213243
|
+
return !(adapterStatus !== void 0 && adapterStatus !== "none" || chargeStatus === "charging" || chargeStatus === "chargeComplete");
|
|
213244
|
+
}
|
|
213122
213245
|
//#endregion
|
|
213123
213246
|
//#region src/hub-channel-reconcile.ts
|
|
213124
213247
|
/**
|
|
@@ -213682,8 +213805,21 @@ var ReolinkHubSession = class {
|
|
|
213682
213805
|
}
|
|
213683
213806
|
});
|
|
213684
213807
|
}
|
|
213808
|
+
const measured = isMeasuredHubBatteryLevel(info.batteryLevel, {
|
|
213809
|
+
sleeping: child.sleeping,
|
|
213810
|
+
power: power.fields
|
|
213811
|
+
});
|
|
213812
|
+
if (info.batteryLevel === 0) this.#logger.info("Reolink hub: battery entry reporting 0", {
|
|
213813
|
+
tags: { deviceId: child.id },
|
|
213814
|
+
meta: {
|
|
213815
|
+
channel: Number(chKey),
|
|
213816
|
+
sleeping: child.sleeping,
|
|
213817
|
+
measured,
|
|
213818
|
+
raw: info
|
|
213819
|
+
}
|
|
213820
|
+
});
|
|
213685
213821
|
child.applyHubBatteryInfo({
|
|
213686
|
-
batteryPercent: info.batteryLevel,
|
|
213822
|
+
...measured ? { batteryPercent: info.batteryLevel } : {},
|
|
213687
213823
|
...power.fields
|
|
213688
213824
|
});
|
|
213689
213825
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-reolink",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.238",
|
|
4
4
|
"description": "Reolink camera device provider addon for CamStack — native Baichuan protocol",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"werift"
|
|
97
97
|
],
|
|
98
98
|
"requires": {
|
|
99
|
-
"server": ">=1.2.
|
|
99
|
+
"server": ">=1.2.839"
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
102
|
"files": [
|