@camstack/addon-provider-reolink 1.2.236 → 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/dist/addon.mjs CHANGED
@@ -101490,7 +101490,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
101490
101490
  return EventCategory;
101491
101491
  }({});
101492
101492
  //#endregion
101493
- //#region ../types/dist/composed-stable-id-jnvhwGoH.mjs
101493
+ //#region ../types/dist/composed-stable-id-DFNyOFzz.mjs
101494
101494
  /**
101495
101495
  import { errMsg } from '@camstack/types'
101496
101496
  * Extract a human-readable message from an unknown error value.
@@ -101503,6 +101503,7 @@ function errMsg$3(err) {
101503
101503
  }
101504
101504
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
101505
101505
  DeviceType["Camera"] = "camera";
101506
+ /** Legacy stored value, read only by the hub-to-integration migrations; no live device carries it. */
101506
101507
  DeviceType["Hub"] = "hub";
101507
101508
  DeviceType["Light"] = "light";
101508
101509
  DeviceType["Siren"] = "siren";
@@ -106714,7 +106715,7 @@ var ZodIssueCode = {
106714
106715
  var ZodFirstPartyTypeKind;
106715
106716
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
106716
106717
  //#endregion
106717
- //#region ../types/dist/sleep-Dz1P6--1.mjs
106718
+ //#region ../types/dist/sleep-D_NpiLFP.mjs
106718
106719
  /**
106719
106720
  * The audio chunk plane's byte format, and the ONE expansion from a coded
106720
106721
  * window to float samples (D455).
@@ -114616,10 +114617,6 @@ var CAMERA_CAP_VOCABULARY = {
114616
114617
  scope: "device",
114617
114618
  noun: t("Admin link", "Link di amministrazione")
114618
114619
  },
114619
- "device-discovery": {
114620
- scope: "device",
114621
- noun: t("Discovery", "Rilevamento dispositivi")
114622
- },
114623
114620
  "device-extension": {
114624
114621
  scope: "device",
114625
114622
  noun: t("Device extension", "Estensione del dispositivo")
@@ -115791,6 +115788,7 @@ var SYSTEM_CAP_VOCABULARY = {
115791
115788
  backup: system("system backups — run and restored from the Backups page"),
115792
115789
  broker: system("message-broker connections — configured, not actuated"),
115793
115790
  "calendar-source": system(INTERNAL),
115791
+ "cluster-update": system(CLUSTER),
115794
115792
  calendars: system("calendars feed schedules and conditions, not device actions"),
115795
115793
  composer: system("device composition — an authoring tool, not an action"),
115796
115794
  "core-blocks": system(INTERNAL),
@@ -116092,6 +116090,7 @@ var CAP_NAMES = Object.freeze([
116092
116090
  "camera-streams",
116093
116091
  "carbon-monoxide",
116094
116092
  "climate-control",
116093
+ "cluster-update",
116095
116094
  "color",
116096
116095
  "composer",
116097
116096
  "connectivity",
@@ -116109,7 +116108,6 @@ var CAP_NAMES = Object.freeze([
116109
116108
  "device-admin-link",
116110
116109
  "device-adoption",
116111
116110
  "device-credentials",
116112
- "device-discovery",
116113
116111
  "device-export",
116114
116112
  "device-extension",
116115
116113
  "device-history",
@@ -116731,13 +116729,6 @@ Object.freeze({
116731
116729
  "valueType": "string"
116732
116730
  }
116733
116731
  ],
116734
- "device-discovery": [{
116735
- "path": "lastDiscoveryAt",
116736
- "valueType": "number"
116737
- }, {
116738
- "path": "lastError",
116739
- "valueType": "string"
116740
- }],
116741
116732
  "device-export": [
116742
116733
  {
116743
116734
  "path": "linkState",
@@ -118213,7 +118204,7 @@ function sleep(ms) {
118213
118204
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
118214
118205
  }
118215
118206
  //#endregion
118216
- //#region ../types/dist/implemented-methods-OitwyO1Y.mjs
118207
+ //#region ../types/dist/implemented-methods-M5aguGon.mjs
118217
118208
  /**
118218
118209
  * The ffmpeg build every CamStack node downloads, per platform and arch.
118219
118210
  *
@@ -145551,6 +145542,62 @@ var WeekdayKeySchema = _enum([
145551
145542
  "sat",
145552
145543
  "sun"
145553
145544
  ]);
145545
+ /**
145546
+ * Hold semantics — "for N seconds" on a leaf of the `when` tree (#498).
145547
+ *
145548
+ * ONE primitive, `for: { ms, mode, tolerance? }`, shared by `device-becomes`,
145549
+ * `device-is` and `expression`:
145550
+ *
145551
+ * - `held`: the condition stays true for `ms`;
145552
+ * - `stable`: the value does not move by more than `tolerance` (absolute, in
145553
+ * the field's base unit) for `ms` while the condition holds.
145554
+ *
145555
+ * {@link HoldCore} is the pure state machine (an input observation → a reading).
145556
+ * {@link HoldTracker} keys cores by a leaf path for the STATE leaves the tree
145557
+ * evaluator judges. {@link BecomesWatch} wraps a core with a timer for the
145558
+ * `device-becomes` EVENT leaf: the deadline is armed when the hold starts and
145559
+ * cancelled when it breaks, and the leaf fires ONCE per episode.
145560
+ *
145561
+ * Hold state is memory only. A hold that is already running when the watcher
145562
+ * first looks (a restart) is INHERITED: nobody knows when it began, so it never
145563
+ * fires for that episode and a state leaf reads it as unknown until the window
145564
+ * has elapsed from the moment the watcher started (D49: not-known is not false).
145565
+ */
145566
+ var HOLD_MAX_MS = 864e5;
145567
+ var HoldModeSchema = _enum(["held", "stable"]);
145568
+ var HoldSpecSchema = object({
145569
+ /** How long the condition (or the value) must hold. */
145570
+ ms: number$1().int().min(1).max(HOLD_MAX_MS),
145571
+ mode: HoldModeSchema,
145572
+ /** `stable` only: the largest move of the value that still counts as unchanged (absolute, base unit). */
145573
+ tolerance: number$1().min(0).optional()
145574
+ });
145575
+ /** What a trace says about a hold. */
145576
+ var HoldTraceSchema = object({
145577
+ phase: _enum([
145578
+ "pending",
145579
+ "cancelled",
145580
+ "fired",
145581
+ "reseeded"
145582
+ ]),
145583
+ ms: number$1().int(),
145584
+ mode: HoldModeSchema,
145585
+ /** When the hold started (ms epoch). */
145586
+ since: number$1().optional(),
145587
+ /** When it completes (ms epoch), for a pending hold. */
145588
+ deadline: number$1().optional()
145589
+ });
145590
+ /** The operators a `device-becomes` leaf may carry: a threshold or a range. */
145591
+ var BecomesOperatorSchema = _enum([
145592
+ "eq",
145593
+ "ne",
145594
+ "gt",
145595
+ "gte",
145596
+ "lt",
145597
+ "lte",
145598
+ "between",
145599
+ "outside"
145600
+ ]);
145554
145601
  /** How a state leaf compares a device field to a value. Derived from the
145555
145602
  * field's `kind` in `deviceManager.getWireableFields`, never hand-maintained. */
145556
145603
  var AutomationConditionOperatorSchema = _enum([
@@ -145564,6 +145611,13 @@ var AutomationConditionOperatorSchema = _enum([
145564
145611
  "in"
145565
145612
  ]);
145566
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
+ /**
145567
145621
  * D8 compliance, and it is the reason a "becomes" leaf is not merely an event
145568
145622
  * subscription: it evaluates against the **state mirror**, which is reconciled,
145569
145623
  * and an event only WAKES the evaluation. A dropped event therefore DELAYS a
@@ -145571,24 +145625,60 @@ var AutomationConditionOperatorSchema = _enum([
145571
145625
  */
145572
145626
  var DeviceBecomesLeafSchema = object({
145573
145627
  kind: literal("device-becomes"),
145628
+ ...eventLeafId,
145574
145629
  deviceId: number$1().int().nonnegative(),
145575
145630
  cap: string().min(1),
145576
145631
  fieldPath: string().min(1),
145577
- /** Fire when the field takes this value. Omit to fire on any change. */
145632
+ /** Fire when the field takes this value. Omit (with no `operator`) to fire on any change. */
145578
145633
  becomes: union([
145579
145634
  string(),
145580
145635
  number$1(),
145581
145636
  boolean()
145582
145637
  ]).optional(),
145583
- /** Only on a CHANGE of value, not on every re-report. */
145638
+ /**
145639
+ * A threshold or a range instead of an equality: "crosses above 3000", "enters
145640
+ * 18..24". The leaf fires on the TRANSITION into the predicate, never on a re-report.
145641
+ * `value` is in the field's base unit; `between` / `outside` take `[low, high]`.
145642
+ */
145643
+ operator: BecomesOperatorSchema.optional(),
145644
+ value: union([
145645
+ number$1(),
145646
+ string(),
145647
+ boolean(),
145648
+ array(number$1()).length(2)
145649
+ ]).optional(),
145650
+ /**
145651
+ * Hold: the transition (or, with no predicate, the new value) must stay for
145652
+ * `for.ms` before the leaf fires, ONCE per episode. See `hold.ts`.
145653
+ */
145654
+ for: HoldSpecSchema.optional(),
145655
+ /** @deprecated every leaf fires on a transition now; read as always on. */
145584
145656
  edge: boolean().optional(),
145585
- /** The new value must hold this long before it counts. */
145586
- forMs: number$1().int().min(0).max(864e5).optional(),
145657
+ /** @deprecated legacy `held` window — read through `holdOf` as `for: { ms, mode: 'held' }`. */
145658
+ forMs: number$1().int().min(0).max(HOLD_MAX_MS).optional(),
145587
145659
  /** Collapse a burst into one occurrence. */
145588
145660
  debounceMs: number$1().int().min(0).max(6e5).optional()
145661
+ }).superRefine((leaf, ctx) => {
145662
+ if (leaf.becomes !== void 0 && leaf.operator !== void 0) ctx.addIssue({
145663
+ code: "custom",
145664
+ message: "a leaf names `becomes` or `operator`, not both",
145665
+ path: ["operator"]
145666
+ });
145667
+ if (leaf.operator !== void 0 && leaf.value === void 0) ctx.addIssue({
145668
+ code: "custom",
145669
+ message: "an operator needs the value to compare to",
145670
+ path: ["value"]
145671
+ });
145672
+ const range = leaf.operator === "between" || leaf.operator === "outside";
145673
+ if (leaf.operator !== void 0 && range !== Array.isArray(leaf.value)) ctx.addIssue({
145674
+ code: "custom",
145675
+ message: range ? "a range takes [low, high]" : "only a range takes [low, high]",
145676
+ path: ["value"]
145677
+ });
145589
145678
  });
145590
145679
  var DeviceEventLeafSchema = object({
145591
145680
  kind: literal("device-event"),
145681
+ ...eventLeafId,
145592
145682
  /** An `EventCategory` value. */
145593
145683
  category: string().min(1),
145594
145684
  deviceId: number$1().int().nonnegative().optional()
@@ -145601,18 +145691,24 @@ var DeviceEventLeafSchema = object({
145601
145691
  */
145602
145692
  var ScheduleLeafSchema = object({
145603
145693
  kind: literal("schedule"),
145694
+ ...eventLeafId,
145604
145695
  at: TimeSpecSchema.optional(),
145605
145696
  days: array(WeekdayKeySchema).min(1).max(7).optional(),
145606
145697
  /** @deprecated legacy cron — new schedules use `at`. */
145607
145698
  cron: string().min(1).max(120).optional()
145608
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" });
145609
- var ManualLeafSchema = object({ kind: literal("manual") });
145700
+ var ManualLeafSchema = object({
145701
+ kind: literal("manual"),
145702
+ ...eventLeafId
145703
+ });
145610
145704
  var IntervalLeafSchema = object({
145611
145705
  kind: literal("interval"),
145706
+ ...eventLeafId,
145612
145707
  minutes: number$1().int().min(1).max(1440)
145613
145708
  });
145614
145709
  var DetectionLeafSchema = object({
145615
145710
  kind: literal("detection"),
145711
+ ...eventLeafId,
145616
145712
  /** One macro class each, optionally narrowed by a label; a track of any listed subject fires. */
145617
145713
  subjects: array(DetectionSubjectSchema).min(1),
145618
145714
  deviceIds: array(number$1().int().nonnegative()).min(1),
@@ -145623,6 +145719,7 @@ var DetectionLeafSchema = object({
145623
145719
  });
145624
145720
  var StationaryLeafSchema = object({
145625
145721
  kind: literal("stationary"),
145722
+ ...eventLeafId,
145626
145723
  deviceIds: array(number$1().int().nonnegative()).min(1),
145627
145724
  subjects: array(StationarySubjectSchema).min(1).optional(),
145628
145725
  zones: array(string().min(1)).min(1).optional(),
@@ -145650,7 +145747,9 @@ var DeviceIsLeafSchema = object({
145650
145747
  QuantityValueSchema
145651
145748
  ]),
145652
145749
  /** The unit the person picked for `value` (display only; `value` is in the base unit). */
145653
- unit: string().min(1).optional()
145750
+ unit: string().min(1).optional(),
145751
+ /** The comparison must hold (`held`) or the value stay put (`stable`) this long. */
145752
+ for: HoldSpecSchema.optional()
145654
145753
  });
145655
145754
  /**
145656
145755
  * True when the camera currently has a PARKED object matching `subjects` in at
@@ -145666,6 +145765,41 @@ var StationaryPresentLeafSchema = object({
145666
145765
  minCount: number$1().int().positive().optional()
145667
145766
  });
145668
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
+ /**
145669
145803
  * The escape hatch: the bounded expression engine over named device bindings.
145670
145804
  * Declared as a plain object so a discriminated union can read `kind`; the
145671
145805
  * author-time validation is the SAME function `ExpressionSourceSchema` runs.
@@ -145673,7 +145807,9 @@ var StationaryPresentLeafSchema = object({
145673
145807
  var ExpressionLeafSchema = object({
145674
145808
  kind: literal("expression"),
145675
145809
  expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
145676
- bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema)
145810
+ bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema),
145811
+ /** The expression must stay true this long. An expression has no single value, so only `held`. */
145812
+ for: HoldSpecSchema.optional()
145677
145813
  }).superRefine((src, ctx) => {
145678
145814
  const err = validateExpressionSource(src);
145679
145815
  if (err !== null) ctx.addIssue({
@@ -145681,6 +145817,11 @@ var ExpressionLeafSchema = object({
145681
145817
  message: err,
145682
145818
  path: ["expr"]
145683
145819
  });
145820
+ if (src.for?.mode === "stable") ctx.addIssue({
145821
+ code: "custom",
145822
+ message: "an expression is held, not stable: it has no single value to keep still",
145823
+ path: ["for", "mode"]
145824
+ });
145684
145825
  });
145685
145826
  var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
145686
145827
  object({
@@ -145704,7 +145845,9 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
145704
145845
  StationaryLeafSchema,
145705
145846
  DeviceIsLeafSchema,
145706
145847
  StationaryPresentLeafSchema,
145707
- ExpressionLeafSchema
145848
+ ExpressionLeafSchema,
145849
+ TimeIsLeafSchema,
145850
+ TriggeredByLeafSchema
145708
145851
  ]));
145709
145852
  var EVENT_KINDS = new Set([
145710
145853
  "device-becomes",
@@ -145758,6 +145901,28 @@ function hasEventLeaves(node) {
145758
145901
  });
145759
145902
  return found;
145760
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";
145761
145926
  function hasEmptyContainer(node) {
145762
145927
  if (isLeaf(node)) return false;
145763
145928
  if (node.kind === "not") return hasEmptyContainer(node.child);
@@ -145816,6 +145981,11 @@ function validateWhenTree(when) {
145816
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`;
145817
145982
  const leaves = countWhenLeaves(when);
145818
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
+ }
145819
145989
  const need = eventNeed(when, "when", false);
145820
145990
  if ("error" in need) return need.error;
145821
145991
  const [first, second] = need.paths;
@@ -146106,7 +146276,18 @@ var GuardedCapStepSchema = AutomationCapStepBaseSchema.extend(stepGuardShape).re
146106
146276
  message: "a domain target needs the vocabulary action it applies to (actionId)",
146107
146277
  path: ["actionId"]
146108
146278
  }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
146109
- var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, GuardedCapStepSchema]);
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
+ });
146110
146291
  var AutomationActionSchema = discriminatedUnion("kind", [
146111
146292
  GuardedWaitStepSchema,
146112
146293
  GuardedCapStepSchema,
@@ -146203,6 +146384,11 @@ var STATIONARY_DESCRIPTIONS = {
146203
146384
  phase: "appeared or departed",
146204
146385
  entryId: "the stopped object"
146205
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
+ };
146206
146392
  function describe$1(descriptions) {
146207
146393
  return Object.entries(descriptions).map(([name, description]) => ({
146208
146394
  name,
@@ -146211,6 +146397,10 @@ function describe$1(descriptions) {
146211
146397
  }
146212
146398
  describe$1(DETECTION_DESCRIPTIONS);
146213
146399
  describe$1(STATIONARY_DESCRIPTIONS);
146400
+ describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
146401
+ ...v,
146402
+ hintKey: "becomesDeviceId"
146403
+ } : v);
146214
146404
  new Set(Object.values(COCO_TO_MACRO.mapping));
146215
146405
  /**
146216
146406
  * Schedulers (D983) — an entity that performs actions over the day.
@@ -146235,6 +146425,13 @@ var SchedulerStateTreeSchema = AutomationWhenSchema.superRefine((when, ctx) => {
146235
146425
  });
146236
146426
  return;
146237
146427
  }
146428
+ if (hasTriggeredByLeaves(when)) {
146429
+ ctx.addIssue({
146430
+ code: "custom",
146431
+ message: TRIGGERED_BY_NEEDS_AUTOMATION
146432
+ });
146433
+ return;
146434
+ }
146238
146435
  const problem = validateWhenTree(when);
146239
146436
  if (problem !== null) ctx.addIssue({
146240
146437
  code: "custom",
@@ -146440,7 +146637,9 @@ var AutomationTriggerTraceSchema = object({
146440
146637
  /** Why an event was rejected ("class person not in [dog]") or what fired. */
146441
146638
  reason: string(),
146442
146639
  /** deviceId, className, trackId, score … — only what the trigger exposes. */
146443
- vars: record(string(), TraceValueSchema)
146640
+ vars: record(string(), TraceValueSchema),
146641
+ /** A hold (`for`) this occurrence went through: pending, cancelled, fired or re-seeded. */
146642
+ hold: HoldTraceSchema.optional()
146444
146643
  });
146445
146644
  var AutomationConditionTraceNodeSchema = object({
146446
146645
  /** `when` for the root, `when.<i>` for its i-th child, … (`conditions…` on an old trace). */
@@ -146453,6 +146652,8 @@ var AutomationConditionTraceNodeSchema = object({
146453
146652
  "device-is",
146454
146653
  "expression",
146455
146654
  "stationary-present",
146655
+ "time-is",
146656
+ "triggered-by",
146456
146657
  "device-becomes",
146457
146658
  "device-event",
146458
146659
  "schedule",
@@ -146786,7 +146987,7 @@ object({
146786
146987
  * is irrelevant; the array is treated as a set by consumers. */
146787
146988
  hiddenChildIds: array(number$1()).readonly()
146788
146989
  });
146789
- DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Light, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Cover, DeviceType.Lock, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Generic, method(object({
146990
+ DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Cover, DeviceType.Lock, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Generic, method(object({
146790
146991
  deviceId: number$1().int().nonnegative(),
146791
146992
  childDeviceId: number$1().int().nonnegative(),
146792
146993
  hidden: boolean()
@@ -150957,6 +151158,140 @@ var climateControlCapability = {
150957
151158
  } }
150958
151159
  };
150959
151160
  /**
151161
+ * cluster-update — the ONE flow that brings the whole cluster to a release
151162
+ * (planning#493). Hub-provided (`server-provided`), hub-only: the hub runs
151163
+ * the sequence itself, so the admin UI, the MCP and the CLI all start the same
151164
+ * job and read the same report instead of each driving their own loop.
151165
+ *
151166
+ * 1. backup (`backup.trigger`) — skipped only when the caller says so
151167
+ * 2. the hub's server closure (`applyServerUpdate`); the hub restarts and the
151168
+ * job RESUMES on the new boot, verified against the hub's running version
151169
+ * 3. every online agent behind the target, one at a time, verified: runs the
151170
+ * target, settled, online, and its capabilities registered (D848) — an
151171
+ * agent that comes back capless is a FAILED step, never a done one
151172
+ * 4. every stale addon on the hub (`addons.updatePackage`); agents follow by
151173
+ * reconciliation, which is verified, never pushed
151174
+ *
151175
+ * The job stops on the first failed step with a typed reason (D877). Its state
151176
+ * is durable on the hub and read by RPC (`getClusterUpdateJob`) — events are
151177
+ * telemetry and never carry it (D8, D11).
151178
+ */
151179
+ /** The steps, in the order they run. */
151180
+ var ClusterUpdateStepKindSchema = _enum([
151181
+ "backup",
151182
+ "hub-server",
151183
+ "agent-server",
151184
+ "addons"
151185
+ ]);
151186
+ /**
151187
+ * - `pending` — not reached yet.
151188
+ * - `running` — in progress (for `hub-server`: possibly across the restart).
151189
+ * - `ok` — done AND verified.
151190
+ * - `failed` — did not land; `reason` + `detail` say why. Stops the job.
151191
+ * - `skipped` — not run: nothing to do, opted out, the node is offline, or a
151192
+ * step before it failed. `detail` says which.
151193
+ */
151194
+ var ClusterUpdateStepStatusSchema = _enum([
151195
+ "pending",
151196
+ "running",
151197
+ "ok",
151198
+ "failed",
151199
+ "skipped"
151200
+ ]);
151201
+ /**
151202
+ * Why a step (and with it the job) failed. Stable, greppable; `detail` carries
151203
+ * the prose.
151204
+ */
151205
+ var ClusterUpdateFailureReasonSchema = _enum([
151206
+ "backup-unavailable",
151207
+ "backup-failed",
151208
+ "server-refused",
151209
+ "server-not-on-target",
151210
+ "node-capless",
151211
+ "status-unreadable",
151212
+ "addon-update-failed",
151213
+ "addons-not-converged",
151214
+ "interrupted"
151215
+ ]);
151216
+ var ClusterUpdateStepSchema = object({
151217
+ kind: ClusterUpdateStepKindSchema,
151218
+ /** The node the step acts on; absent for `backup` and `addons`. */
151219
+ nodeId: string().optional(),
151220
+ status: ClusterUpdateStepStatusSchema,
151221
+ /** One line for the operator: what happened, or why not. */
151222
+ detail: string(),
151223
+ reason: ClusterUpdateFailureReasonSchema.optional(),
151224
+ /** `hub-server` / `agent-server`: the version the node ran before. */
151225
+ fromVersion: string().nullable().optional(),
151226
+ /** `addons`: the packages this step updates, `name from -> to`. */
151227
+ packages: array(string()).readonly().optional(),
151228
+ startedAt: number$1().optional(),
151229
+ finishedAt: number$1().optional()
151230
+ });
151231
+ var ClusterUpdateJobStateSchema = _enum([
151232
+ "running",
151233
+ "succeeded",
151234
+ "failed"
151235
+ ]);
151236
+ var ClusterUpdateJobSchema = object({
151237
+ id: string(),
151238
+ state: ClusterUpdateJobStateSchema,
151239
+ /** The server version every node is brought to. */
151240
+ targetVersion: string(),
151241
+ /** Who started it (the user name, or `system`). */
151242
+ requestedBy: string(),
151243
+ startedAt: number$1(),
151244
+ finishedAt: number$1().optional(),
151245
+ /** Every step, in run order; later steps stay `pending` while it runs. */
151246
+ steps: array(ClusterUpdateStepSchema).readonly(),
151247
+ /** On `failed`: the step that stopped it (`nodeId` or the step kind). */
151248
+ stoppedAt: string().optional(),
151249
+ reason: ClusterUpdateFailureReasonSchema.optional(),
151250
+ /** Agents offline when the plan was read: never touched. */
151251
+ skippedOffline: array(string()).readonly()
151252
+ });
151253
+ var ClusterUpdateOptionsSchema = object({
151254
+ /** Explicit server target; omitted = the hub's latest registry check. */
151255
+ version: string().optional(),
151256
+ /** Update the addons too (default true). */
151257
+ addons: boolean().optional(),
151258
+ /**
151259
+ * Back up before touching anything (default true). `false` is an explicit
151260
+ * operator opt-out; a missing backup provider is otherwise a failure.
151261
+ */
151262
+ backup: boolean().optional()
151263
+ });
151264
+ /** Why a plan cannot start. */
151265
+ var ClusterUpdateBlockerSchema = _enum([
151266
+ "no-target",
151267
+ "node-busy",
151268
+ "job-running",
151269
+ "nothing-to-do",
151270
+ "status-unreadable"
151271
+ ]);
151272
+ var ClusterUpdatePlanSchema = object({
151273
+ /** `null` when no target could be resolved (`blocker: 'no-target'`). */
151274
+ targetVersion: string().nullable(),
151275
+ /** The steps the job WOULD run, all `pending` (or `skipped` with a reason). */
151276
+ steps: array(ClusterUpdateStepSchema).readonly(),
151277
+ skippedOffline: array(string()).readonly(),
151278
+ /** `null` = the plan can start. */
151279
+ blocker: ClusterUpdateBlockerSchema.nullable(),
151280
+ /** Prose for `blocker`. */
151281
+ blockerDetail: string().nullable()
151282
+ });
151283
+ var StartClusterUpdateResultSchema = object({
151284
+ accepted: boolean(),
151285
+ /** The job to follow with `getClusterUpdateJob`; `null` when refused. */
151286
+ jobId: string().nullable(),
151287
+ blocker: ClusterUpdateBlockerSchema.nullable(),
151288
+ message: string()
151289
+ });
151290
+ method(ClusterUpdateOptionsSchema, ClusterUpdatePlanSchema, { auth: "admin" }), method(ClusterUpdateOptionsSchema, StartClusterUpdateResultSchema, {
151291
+ kind: "mutation",
151292
+ auth: "admin"
151293
+ }), method(object({ jobId: string().optional() }), ClusterUpdateJobSchema.nullable(), { auth: "admin" });
151294
+ /**
150960
151295
  * Color-light cap. Coexists with `switch` (on/off) and `brightness`
150961
151296
  * (level) on the same device — `switch` toggles the bulb, `brightness`
150962
151297
  * sets the dim level, this cap sets the chromaticity.
@@ -152287,7 +152622,7 @@ var mediaPlayerCapability = {
152287
152622
  isMuted: { kind: "boolean" }
152288
152623
  } }
152289
152624
  };
152290
- DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, 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.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Heater, DeviceType.Dryer, DeviceType.Gateway, DeviceType.HeatPump, DeviceType.Camera, DeviceType.Fan, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Gateway, DeviceType.Hub, 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.Thermostat, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.MediaPlayer;
152625
+ DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, 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.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Heater, DeviceType.Dryer, DeviceType.Gateway, DeviceType.HeatPump, DeviceType.Camera, DeviceType.Fan, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, 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.Thermostat, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.MediaPlayer;
152291
152626
  var NUMBER = {
152292
152627
  kind: "fixed",
152293
152628
  result: ["number"]
@@ -153780,27 +154115,35 @@ var deviceAdminLinkCapability = {
153780
154115
  getAdminLink: method(object({ deviceId: number$1().int().nonnegative() }), DeviceAdminLinkSchema.nullable(), { auth: "admin" }) }
153781
154116
  };
153782
154117
  /**
153783
- * device-discovery — device-scoped capability for parents that host /
153784
- * enumerate child devices (Reolink Hub / NVR, ONVIF gateway, future
153785
- * integrations). The parent advertises a list of discoverable children,
153786
- * and the operator promotes a subset to real devices via `adoptDevice`.
153787
- * Child lifecycle (kernel device create/remove, parent reference) is
153788
- * owned by the framework so a single shared `<DiscoveryPanel />` can
153789
- * drive any integration.
153790
- *
153791
- * Boundaries:
153792
- * - The cap exposes ENUMERATION + ADOPT/RELEASE only. The protocol
153793
- * used to discover children (CGI poll, mDNS, push from hub, ...)
153794
- * is the integration's business; results land in `runtimeState`
153795
- * so the panel can render without a fresh round-trip.
153796
- * - `childNativeId` is integration-defined and must be stable across
153797
- * reboots so re-discovery doesn't duplicate adopted children.
153798
- * - `adoptDevice` returns the new `deviceId` so the UI can navigate
153799
- * directly to the freshly-created child's settings page.
153800
- */
153801
- /**
153802
- * Status enum for a discovered device. Mirrors the Reolink simpleEvent
153803
- * lifecycle (`online` / `sleeping` / `offline`) — generic enough for
154118
+ * `device-adoption` — generic discovery + adoption surface,
154119
+ * system-scoped collection (one provider per integration addon), routed
154120
+ * by explicit `{ addonId }` on direct `deviceAdoption.*` calls — the same
154121
+ * pin model as `connection-test`. The admin UI keeps using
154122
+ * `deviceManager.adoption*` (which already threads `addonId`). The de-HA-ified
154123
+ * successor to `ha-discovery`:
154124
+ * keyed by `integrationId` (the addon resolves integrationId → broker
154125
+ * internally) rather than a connection-specific `brokerId`, and it
154126
+ * OWNS the shared `DiscoveredChildDevice` candidate type
154127
+ * (declared below) so a single shared adoption modal renders any integration's
154128
+ * candidate tree.
154129
+ *
154130
+ * UI flow (Integrations page → integration detail):
154131
+ * 1. `listCandidates({integrationId, page, pageSize, filter})` →
154132
+ * paginated candidate list, each row collapsed.
154133
+ * 2. User expands a row → `getCandidate({integrationId,
154134
+ * childNativeId})` returns the single candidate (with its nested
154135
+ * `children`) for the accordion render.
154136
+ * 3. User clicks "Adopt" on one or more candidates →
154137
+ * `adopt({integrationId, childNativeIds, perCandidate?})`
154138
+ * materialises one parent CamStack device per candidate plus its
154139
+ * accessory children. `perCandidate[childNativeId]` carries an
154140
+ * optional display-name override + a `hiddenChildIds` pre-hide set
154141
+ * (the parent's `accessories.hiddenChildIds` gates UI visibility).
154142
+ * 4. User clicks "Release" → `release({integrationId, camDeviceId})`
154143
+ * removes the parent + every child from the kernel registry.
154144
+ */
154145
+ /**
154146
+ * Status enum for a discovered device. Generic enough for
153804
154147
  * battery cams, awake cams, and unreachable cams alike.
153805
154148
  */
153806
154149
  var DiscoveredChildStatusSchema = _enum([
@@ -153817,12 +154160,12 @@ var DiscoveredChildDeviceSchema = lazy(() => object({
153817
154160
  /** DeviceType the child should be created with on adopt. */
153818
154161
  type: _enum(DeviceType),
153819
154162
  status: DiscoveredChildStatusSchema,
153820
- /** Free-form integration-specific metadata surfaced in the panel. */
154163
+ /** Free-form integration-specific metadata surfaced in the adoption modal. */
153821
154164
  metadata: object({
153822
154165
  model: string().optional(),
153823
154166
  serialNumber: string().optional(),
153824
154167
  uid: string().optional(),
153825
- /** Reolink: 0-based channel index inside the parent NVR/Hub. */
154168
+ /** Reolink: 0-based channel index inside the parent NVR. */
153826
154169
  rtspChannel: number$1().int().nonnegative().optional(),
153827
154170
  isBattery: boolean().optional(),
153828
154171
  isDoorbell: boolean().optional(),
@@ -153838,137 +154181,24 @@ var DiscoveredChildDeviceSchema = lazy(() => object({
153838
154181
  }).default({}),
153839
154182
  /**
153840
154183
  * `true` when the framework already created a child device for this
153841
- * `childNativeId` under the current parent. The panel uses it to
154184
+ * `childNativeId` under the current parent. The adoption modal uses it to
153842
154185
  * gate the Add/Remove button and surface the existing `deviceId`.
153843
154186
  */
153844
154187
  alreadyAdopted: boolean(),
153845
154188
  /** When `alreadyAdopted=true`, the framework-assigned child device id. */
153846
154189
  adoptedDeviceId: number$1().int().nonnegative().nullable(),
153847
- /** Capability names the candidate advertises — integrations populate, Hubs omit. */
154190
+ /** Capability names the candidate advertises — integrations populate, flat enumerations omit. */
153848
154191
  capabilities: array(string()).readonly().optional(),
153849
- /** Feature flags the candidate advertises — integrations populate, Hubs omit. */
154192
+ /** Feature flags the candidate advertises — integrations populate, flat enumerations omit. */
153850
154193
  features: array(string()).readonly().optional(),
153851
154194
  /** Upstream-system identity + rendering hints for the candidate. */
153852
154195
  sourceInfo: SourceInfoSchema.optional(),
153853
- /** Nested entity-children for accordion preview — integrations populate, Hubs omit. */
154196
+ /** Nested entity-children for accordion preview — integrations populate, flat enumerations omit. */
153854
154197
  children: array(DiscoveredChildDeviceSchema).readonly().optional(),
153855
154198
  /** `childNativeId` of the gateway candidate in the same list this device sits behind. */
153856
154199
  parentStableId: string().optional()
153857
154200
  }));
153858
154201
  /**
153859
- * Status block — populated by the integration after each
153860
- * `refreshDiscovery` (or push-driven update). The runtime-state slice
153861
- * is what the panel reads via the per-device proxy; `getStatus`
153862
- * returns the same payload via the codegen'd auto-injection.
153863
- */
153864
- var DeviceDiscoveryStatusSchema = object({
153865
- discovered: array(DiscoveredChildDeviceSchema),
153866
- /** Wall-clock ms of the last successful enumeration. */
153867
- lastDiscoveryAt: number$1().int().nonnegative().nullable(),
153868
- /** Last error surfaced from the source (rendered as a banner). */
153869
- lastError: string().nullable()
153870
- });
153871
- var deviceDiscoveryCapability = {
153872
- name: "device-discovery",
153873
- scope: "device",
153874
- deviceNative: true,
153875
- mode: "singleton",
153876
- deviceTypes: [DeviceType.Hub],
153877
- status: {
153878
- schema: DeviceDiscoveryStatusSchema,
153879
- kind: "poll"
153880
- },
153881
- runtimeState: DeviceDiscoveryStatusSchema.extend({ lastFetchedAt: number$1().int().nonnegative() }),
153882
- /**
153883
- * Runtime-state durability: **session** — 5.7 KB of scan output on the largest device, fully re-derivable by re-scanning.
153884
- *
153885
- * See `RuntimeStateDurability`. Enforced by
153886
- * `scripts/check-runtime-state-durability.ts`.
153887
- */
153888
- durability: "session",
153889
- /**
153890
- * History (D850): none — inventory.
153891
- */
153892
- history: "none",
153893
- methods: {
153894
- /**
153895
- * Snapshot of the current `discovered` list. Returns the
153896
- * runtime-state cache — call `refreshDiscovery` first if a
153897
- * fresh round-trip to the source is required.
153898
- */
153899
- listDiscovered: method(object({ deviceId: number$1().int().nonnegative() }), array(DiscoveredChildDeviceSchema).readonly()),
153900
- /**
153901
- * Force the integration to re-enumerate and update the
153902
- * runtime-state slice. Returns the freshly-enumerated list (also
153903
- * available via `listDiscovered` post-call).
153904
- */
153905
- refreshDiscovery: method(object({ deviceId: number$1().int().nonnegative() }), array(DiscoveredChildDeviceSchema).readonly(), {
153906
- kind: "mutation",
153907
- auth: "admin"
153908
- }),
153909
- /**
153910
- * Promote a discovered entry to a real child device. The framework
153911
- * creates the child via `kernel.devices.create()` with
153912
- * `parentDeviceId = parent.id` and seeds the child's config from
153913
- * `childInitialConfig` (driver-defined; usually carries channel +
153914
- * uid + parent reference). Returns the kernel-assigned numeric id.
153915
- */
153916
- adoptDevice: method(object({
153917
- deviceId: number$1().int().nonnegative(),
153918
- childNativeId: string(),
153919
- /** Optional override for the child's display name. */
153920
- name: string().optional()
153921
- }), object({
153922
- deviceId: number$1().int().nonnegative(),
153923
- stableId: string()
153924
- }), {
153925
- kind: "mutation",
153926
- auth: "admin"
153927
- }),
153928
- /**
153929
- * Inverse of `adoptDevice`: removes the child device from the
153930
- * kernel registry. The discovered entry remains in the
153931
- * enumeration (status updates resume) so the operator can re-adopt
153932
- * it later without a fresh refresh.
153933
- */
153934
- releaseDevice: method(object({
153935
- deviceId: number$1().int().nonnegative(),
153936
- childDeviceId: number$1().int().nonnegative()
153937
- }), _void(), {
153938
- kind: "mutation",
153939
- auth: "admin"
153940
- })
153941
- }
153942
- };
153943
- /**
153944
- * `device-adoption` — generic discovery + adoption surface,
153945
- * system-scoped collection (one provider per integration addon), routed
153946
- * by explicit `{ addonId }` on direct `deviceAdoption.*` calls — the same
153947
- * pin model as `connection-test`. The admin UI keeps using
153948
- * `deviceManager.adoption*` (which already threads `addonId`). The de-HA-ified
153949
- * successor to `ha-discovery`:
153950
- * keyed by `integrationId` (the addon resolves integrationId → broker
153951
- * internally) rather than a connection-specific `brokerId`, and it
153952
- * REUSES the shared `DiscoveredChildDevice` candidate type from
153953
- * `device-discovery.cap.ts` so a single shared adoption panel renders
153954
- * any integration's candidate tree.
153955
- *
153956
- * UI flow (Integrations page → integration detail):
153957
- * 1. `listCandidates({integrationId, page, pageSize, filter})` →
153958
- * paginated candidate list, each row collapsed.
153959
- * 2. User expands a row → `getCandidate({integrationId,
153960
- * childNativeId})` returns the single candidate (with its nested
153961
- * `children`) for the accordion render.
153962
- * 3. User clicks "Adopt" on one or more candidates →
153963
- * `adopt({integrationId, childNativeIds, perCandidate?})`
153964
- * materialises one parent CamStack device per candidate plus its
153965
- * accessory children. `perCandidate[childNativeId]` carries an
153966
- * optional display-name override + a `hiddenChildIds` pre-hide set
153967
- * (the parent's `accessories.hiddenChildIds` gates UI visibility).
153968
- * 4. User clicks "Release" → `release({integrationId, camDeviceId})`
153969
- * removes the parent + every child from the kernel registry.
153970
- */
153971
- /**
153972
154202
  * Provider-declared discovery *granularity* filter (the keystone of the
153973
154203
  * single-entity-import design). A provider advertises which discovery
153974
154204
  * granularities it supports via `listCandidateFilters`; the operator picks
@@ -154429,6 +154659,90 @@ var SiteZoneSchema = object({
154429
154659
  * the ones that most want grouping. */
154430
154660
  locationKeys: array(string())
154431
154661
  });
154662
+ var DeviceSearchRequiresSchema = object({
154663
+ /** Capability names the field wants a value of. */
154664
+ caps: array(string()).readonly(),
154665
+ /** `any` (default): a device with one of them is compatible. `all`: it must hold every one. */
154666
+ mode: _enum(["any", "all"]).optional()
154667
+ });
154668
+ var DeviceSearchFiltersSchema = object({
154669
+ locations: array(string()).readonly().optional(),
154670
+ integrationIds: array(string()).readonly().optional(),
154671
+ types: array(string()).readonly().optional()
154672
+ });
154673
+ var DeviceSearchInputSchema = object({
154674
+ /** Matches name, location, type, integration (id and label) and id. Case-insensitive. */
154675
+ text: string().optional(),
154676
+ requires: DeviceSearchRequiresSchema.optional(),
154677
+ filters: DeviceSearchFiltersSchema.optional(),
154678
+ /** List the devices that do not provide the required cap too (greyed, not pickable). */
154679
+ includeIncompatible: boolean().optional(),
154680
+ /** The device the field belongs to: its location drives `suggested`. */
154681
+ contextDeviceId: number$1().optional(),
154682
+ /**
154683
+ * Resolve exactly these devices, regardless of every filter, so a picked
154684
+ * value can be rendered. When given, `items` is these devices in the order
154685
+ * asked (no paging, `nextCursor` null) and the ones that do not exist are
154686
+ * listed in `missingIds`.
154687
+ */
154688
+ ids: array(number$1()).readonly().optional(),
154689
+ cursor: string().nullable().optional(),
154690
+ limit: number$1().int().min(1).max(200).optional()
154691
+ });
154692
+ var DeviceValueOptionSchema = object({
154693
+ cap: string(),
154694
+ /** Status-schema field path inside the cap (same paths as `getWireableFields`). */
154695
+ path: string(),
154696
+ label: string(),
154697
+ /** The current value as text; `null` when it is unknown or the read FAILED — never `0`. */
154698
+ reading: string().nullable(),
154699
+ unit: string().nullable().optional(),
154700
+ /** The field's measured quantity, when the cap declares one, so a client can format the reading. */
154701
+ quantity: ReadingQuantitySchema.optional()
154702
+ });
154703
+ var DeviceSearchItemSchema = object({
154704
+ id: number$1(),
154705
+ name: string(),
154706
+ type: _enum(DeviceType),
154707
+ location: string().nullable(),
154708
+ integrationId: string().nullable(),
154709
+ integrationLabel: string().nullable(),
154710
+ online: boolean().nullable(),
154711
+ disabled: boolean(),
154712
+ compatible: boolean(),
154713
+ /** Only the required caps' fields; empty when nothing was required or the device is incompatible. */
154714
+ values: array(DeviceValueOptionSchema).readonly()
154715
+ });
154716
+ var DeviceSearchFacetValueSchema = object({
154717
+ value: string(),
154718
+ count: number$1()
154719
+ });
154720
+ var DeviceSearchFacetIntegrationSchema = object({
154721
+ id: string(),
154722
+ label: string(),
154723
+ count: number$1()
154724
+ });
154725
+ var DeviceSearchFacetsSchema = object({
154726
+ locations: array(DeviceSearchFacetValueSchema).readonly(),
154727
+ integrations: array(DeviceSearchFacetIntegrationSchema).readonly(),
154728
+ types: array(DeviceSearchFacetValueSchema).readonly()
154729
+ });
154730
+ var DeviceSearchResultSchema = object({
154731
+ items: array(DeviceSearchItemSchema).readonly(),
154732
+ nextCursor: string().nullable(),
154733
+ /** Devices listed by this query across all pages (filters + text applied; incompatible counted only when `includeIncompatible`). */
154734
+ total: number$1(),
154735
+ /** Compatible devices after filters + text. */
154736
+ compatibleTotal: number$1(),
154737
+ /** Every device the caller's fleet holds, before anything is applied. */
154738
+ fleetTotal: number$1(),
154739
+ /** Incompatible devices after filters + text — the K of "show the K that don't". */
154740
+ hiddenIncompatible: number$1(),
154741
+ facets: DeviceSearchFacetsSchema,
154742
+ /** Same location as `contextDeviceId`; first page only. */
154743
+ suggested: array(DeviceSearchItemSchema).readonly(),
154744
+ missingIds: array(number$1()).readonly()
154745
+ });
154432
154746
  var ProviderStatusSchema = object({
154433
154747
  connected: boolean(),
154434
154748
  deviceCount: number$1(),
@@ -154914,6 +155228,9 @@ var DeviceInfoSchema = object({
154914
155228
  * named accordion sections (with optional intra-section order). See
154915
155229
  * `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
154916
155230
  childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
155231
+ /** The children a container stands for, most preferred first, by accessory
155232
+ * `childKey`. Provider-declared. See `DeviceMeta.primaryChildPreference`. */
155233
+ primaryChildPreference: array(string()).readonly().optional(),
154917
155234
  /** Operator-authored per-device display override. See `DeviceMeta.display`. */
154918
155235
  display: DeviceDisplayOverrideSchema.optional()
154919
155236
  });
@@ -155062,6 +155379,9 @@ var DeviceMetaSchema = object({
155062
155379
  * accordion sections (with optional intra-section order). See
155063
155380
  * `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
155064
155381
  childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
155382
+ /** The children a container stands for, most preferred first, by accessory
155383
+ * `childKey`. Provider-declared. See `DeviceMeta.primaryChildPreference`. */
155384
+ primaryChildPreference: array(string()).readonly().optional(),
155065
155385
  /** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
155066
155386
  * Optional: only present for accessory children that carry a known role. */
155067
155387
  role: string().nullable().optional(),
@@ -155277,6 +155597,12 @@ method(object({
155277
155597
  }), _void(), {
155278
155598
  kind: "mutation",
155279
155599
  auth: "admin"
155600
+ }), method(object({
155601
+ deviceId: number$1(),
155602
+ primaryChildPreference: array(string()).readonly()
155603
+ }), _void(), {
155604
+ kind: "mutation",
155605
+ auth: "admin"
155280
155606
  }), method(object({
155281
155607
  deviceId: number$1(),
155282
155608
  display: DeviceDisplayOverrideSchema.nullable()
@@ -155414,7 +155740,7 @@ method(object({
155414
155740
  * it answers today and the caller filters as it already does.
155415
155741
  */
155416
155742
  deviceIds: array(number$1()).optional()
155417
- }), array(DeviceInfoSchema), { role: "viewer" }), method(object({ deviceId: number$1() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number$1() }), array(DeviceInfoSchema), { role: "viewer" }), method(object({ parentDeviceIds: array(number$1()).max(256) }), record(string(), array(DeviceInfoSchema))), method(object({ deviceId: number$1() }), object({
155743
+ }), array(DeviceInfoSchema), { role: "viewer" }), method(DeviceSearchInputSchema, DeviceSearchResultSchema, { role: "viewer" }), method(object({ deviceId: number$1() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number$1() }), array(DeviceInfoSchema), { role: "viewer" }), method(object({ parentDeviceIds: array(number$1()).max(256) }), record(string(), array(DeviceInfoSchema))), method(object({ deviceId: number$1() }), object({
155418
155744
  mode: LinkedDevicesModeSchema,
155419
155745
  devices: array(LinkedDeviceSchema)
155420
155746
  }), { role: "viewer" }), method(object({ deviceIds: array(number$1()) }), array(LinkedDevicesForDeviceSchema), { role: "viewer" }), method(object({ deviceId: number$1() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number$1() }), array(ConfigEntrySchema)), method(object({ deviceId: number$1() }), ConfigUISchemaOutput), method(object({
@@ -159087,13 +159413,11 @@ var HeroConfirmSchema = _enum([
159087
159413
  "press"
159088
159414
  ]);
159089
159415
  var HeroActionSchema = object({
159090
- /** Unique within the model; the `gated` list and the specs name it. */
159091
159416
  id: string(),
159092
159417
  label: HeroTextSchema,
159093
159418
  icon: IconKeySchema,
159094
159419
  call: HeroCallSchema,
159095
159420
  emphasis: _enum(["primary", "normal"]),
159096
- /** Ask before running it. */
159097
159421
  confirm: HeroConfirmSchema.nullable()
159098
159422
  });
159099
159423
  var HeroControlSchema = discriminatedUnion("kind", [
@@ -159144,6 +159468,8 @@ var HeroPillSchema = object({
159144
159468
  });
159145
159469
  var HeroRowSchema = object({
159146
159470
  id: HeroRowIdSchema,
159471
+ /** `scene`: the row's action and slider controls are drawn on the scene. Absent: an ordinary row. */
159472
+ placement: _enum(["row", "scene"]).optional(),
159147
159473
  /** The row's own name when the kind's label would not tell rows of one kind apart (a circuit's label). */
159148
159474
  label: HeroTextSchema.optional(),
159149
159475
  /** A group header drawn above the row when it differs from the previous row's ("System"). */
@@ -159174,9 +159500,16 @@ var HeroBadgeSchema = object({
159174
159500
  value: number$1().nullable(),
159175
159501
  label: HeroTextSchema
159176
159502
  });
159177
- var HeroRemoteSlotSchema = object({
159178
- /** Saved commands; `null` = not known yet (the button still shows). */
159179
- commands: number$1().int().nullable() });
159503
+ var HeroRemoteSlotSchema = object({
159504
+ /** Saved commands; `null` = not known yet (the button still shows). */
159505
+ commands: number$1().int().nullable(),
159506
+ /**
159507
+ * The control a list row draws as the "open the remote" icon. Recognised by its id
159508
+ * ({@link REMOTE_OPEN_ACTION_ID}); it changes no state, so a client opens the remote
159509
+ * instead of running `call`. Absent on a model from an older server.
159510
+ */
159511
+ open: HeroActionSchema.optional()
159512
+ });
159180
159513
  var HeroConsumablesSlotSchema = object({
159181
159514
  items: array(object({
159182
159515
  key: string(),
@@ -159344,6 +159677,8 @@ var HeroModelSchema = object({
159344
159677
  * the FIRST row that has any (a later row's control is never promoted). When
159345
159678
  * the model lists that part in `gated`, the row has no inline control: the
159346
159679
  * projection never falls through to another control the caller could use.
159680
+ * - a climate or thermostat row's primary is its `climate.mode` control (no power
159681
+ * toggle: "off" is a mode); when the model gates it the rule above applies as before;
159347
159682
  * - a timed run, when the model carries the slot, sits beside that primary:
159348
159683
  * Run while idle, Stop while armed. Gating the slot hides the control.
159349
159684
  * - the status line is the head (what plays, else the state) plus at most
@@ -159351,6 +159686,13 @@ var HeroModelSchema = object({
159351
159686
  * time left on an armed timed run;
159352
159687
  * - the trailing fact is the first of power, battery, consumables.
159353
159688
  *
159689
+ * - `extras` are the further inline controls of the types that carry more than one
159690
+ * ({@link ROW_EXTRAS_BY_TYPE}): climate setpoint, a robot's return to base,
159691
+ * a player's volume and remote. Each is a control the model already has, named by id,
159692
+ * in that order and at most {@link ROW_EXTRAS_MAX}; one the model lacks, or lists in
159693
+ * `gated`, is absent, and the one `primary` already is never repeats. Empty = the
159694
+ * row of an older server: `primary` alone.
159695
+ *
159354
159696
  * `projectDeviceRow` is pure and computes nothing: it selects from a
159355
159697
  * {@link HeroModel}. A row that needed a value the hero lacks would mean the
159356
159698
  * model is missing it, so the fix goes in the model.
@@ -159382,8 +159724,16 @@ var HeroRowModelSchema = object({
159382
159724
  * while armed. `null` when there is no slot, or the caller may not act.
159383
159725
  */
159384
159726
  timedRun: HeroRowTimedRunSchema.nullable(),
159727
+ /**
159728
+ * The further inline controls after `primary`, in order (see the header). The remote
159729
+ * is an `action` with id `remote.open`: the client opens the remote, it does not run
159730
+ * the call. Absent or empty = `primary` alone.
159731
+ */
159732
+ extras: array(HeroControlSchema).max(2).optional(),
159385
159733
  trailing: HeroFactSchema.nullable()
159386
159734
  });
159735
+ DeviceType.Climate, DeviceType.Thermostat;
159736
+ DeviceType.Climate, DeviceType.Thermostat, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
159387
159737
  /**
159388
159738
  * hero-layout — what a device's hero says (D1023). Read-only: the FIXED
159389
159739
  * layouts live in `@camstack/types` and nothing here stores or edits one.
@@ -170974,13 +171324,23 @@ var NcRuleTargetSchema = object({
170974
171324
  */
170975
171325
  params: record(string(), unknown()).optional()
170976
171326
  });
171327
+ /** Which picture kind one target receives (#487). */
171328
+ var NcTargetAttachmentSchema = _enum([
171329
+ "none",
171330
+ "image",
171331
+ "clip",
171332
+ "gif"
171333
+ ]);
170977
171334
  var NcTargetOverrideSchema = object({
170978
171335
  template: object({
170979
171336
  title: string().max(500).optional(),
170980
171337
  body: string().max(2e3).optional()
170981
171338
  }).optional(),
170982
171339
  schedule: NcScheduleSchema.optional(),
170983
- priority: number$1().int().min(1).max(5).optional()
171340
+ priority: number$1().int().min(1).max(5).optional(),
171341
+ attachment: NcTargetAttachmentSchema.optional(),
171342
+ /** `false` = no buttons for this target; `true` is the same as absent. */
171343
+ actions: boolean().optional()
170984
171344
  });
170985
171345
  /** Per-target settings keyed by target id (#487). */
170986
171346
  var NcTargetOverridesSchema = record(string(), NcTargetOverrideSchema);
@@ -173217,9 +173577,13 @@ var petFeederCapability = {
173217
173577
  */
173218
173578
  durability: "session",
173219
173579
  /**
173220
- * History (D850): recorded series.
173580
+ * History (D850): recorded series. `feeding` / `eating` are the meals the
173581
+ * device hero's "Meals" button names — change-only booleans, so a dispense
173582
+ * or a pet at the bowl is one span on the history.
173221
173583
  */
173222
173584
  history: { fields: {
173585
+ feeding: { kind: "boolean" },
173586
+ eating: { kind: "boolean" },
173223
173587
  foodLevel: { kind: "gauge" },
173224
173588
  bowlFood: { kind: "gauge" },
173225
173589
  food1: { kind: "gauge" },
@@ -175012,7 +175376,6 @@ var PowerSourceStateSchema = object({
175012
175376
  });
175013
175377
  var POWER_SOURCE_DEVICE_TYPES = [
175014
175378
  DeviceType.Gateway,
175015
- DeviceType.Hub,
175016
175379
  DeviceType.Camera,
175017
175380
  DeviceType.Sensor,
175018
175381
  DeviceType.MediaPlayer,
@@ -175064,18 +175427,18 @@ var powerSourceCapability = {
175064
175427
  mode: "singleton",
175065
175428
  deviceTypes: POWER_SOURCE_DEVICE_TYPES,
175066
175429
  methods: {
175067
- getStatus: systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "admin" }),
175430
+ getStatus: systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "protected" }),
175068
175431
  powerOn: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
175069
175432
  kind: "mutation",
175070
- auth: "admin"
175433
+ auth: "protected"
175071
175434
  }),
175072
175435
  powerOff: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
175073
175436
  kind: "mutation",
175074
- auth: "admin"
175437
+ auth: "protected"
175075
175438
  }),
175076
175439
  forceRestart: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
175077
175440
  kind: "mutation",
175078
- auth: "admin"
175441
+ auth: "protected"
175079
175442
  })
175080
175443
  },
175081
175444
  runtimeState: PowerSourceStateSchema,
@@ -185821,7 +186184,6 @@ var DEVICE_LOCAL_STATE_CAPS = {
185821
186184
  control: controlCapability,
185822
186185
  cover: coverCapability,
185823
186186
  dayNight: dayNightCapability,
185824
- deviceDiscovery: deviceDiscoveryCapability,
185825
186187
  deviceStatus: deviceStatusCapability,
185826
186188
  dishwasher: dishwasherCapability,
185827
186189
  doNotDisturb: doNotDisturbCapability,
@@ -191000,6 +191362,27 @@ Object.freeze({
191000
191362
  access: "create",
191001
191363
  role: "viewer"
191002
191364
  },
191365
+ "clusterUpdate.getClusterUpdateJob": {
191366
+ capName: "cluster-update",
191367
+ capScope: "system",
191368
+ addonId: null,
191369
+ access: "view",
191370
+ role: "admin"
191371
+ },
191372
+ "clusterUpdate.previewClusterUpdate": {
191373
+ capName: "cluster-update",
191374
+ capScope: "system",
191375
+ addonId: null,
191376
+ access: "view",
191377
+ role: "admin"
191378
+ },
191379
+ "clusterUpdate.startClusterUpdate": {
191380
+ capName: "cluster-update",
191381
+ capScope: "system",
191382
+ addonId: null,
191383
+ access: "create",
191384
+ role: "admin"
191385
+ },
191003
191386
  "color.getStatus": {
191004
191387
  capName: "color",
191005
191388
  capScope: "device",
@@ -191602,41 +191985,6 @@ Object.freeze({
191602
191985
  access: "create",
191603
191986
  role: "admin"
191604
191987
  },
191605
- "deviceDiscovery.adoptDevice": {
191606
- capName: "device-discovery",
191607
- capScope: "device",
191608
- addonId: null,
191609
- access: "create",
191610
- role: "admin"
191611
- },
191612
- "deviceDiscovery.getStatus": {
191613
- capName: "device-discovery",
191614
- capScope: "device",
191615
- addonId: null,
191616
- access: "view",
191617
- role: "viewer"
191618
- },
191619
- "deviceDiscovery.listDiscovered": {
191620
- capName: "device-discovery",
191621
- capScope: "device",
191622
- addonId: null,
191623
- access: "view",
191624
- role: "viewer"
191625
- },
191626
- "deviceDiscovery.refreshDiscovery": {
191627
- capName: "device-discovery",
191628
- capScope: "device",
191629
- addonId: null,
191630
- access: "create",
191631
- role: "admin"
191632
- },
191633
- "deviceDiscovery.releaseDevice": {
191634
- capName: "device-discovery",
191635
- capScope: "device",
191636
- addonId: null,
191637
- access: "create",
191638
- role: "admin"
191639
- },
191640
191988
  "deviceExport.applyDeviceSettingsPatch": {
191641
191989
  capName: "device-export",
191642
191990
  capScope: "system",
@@ -192372,6 +192720,13 @@ Object.freeze({
192372
192720
  access: "create",
192373
192721
  role: "admin"
192374
192722
  },
192723
+ "deviceManager.search": {
192724
+ capName: "device-manager",
192725
+ capScope: "system",
192726
+ addonId: null,
192727
+ access: "view",
192728
+ role: "viewer"
192729
+ },
192375
192730
  "deviceManager.setAlias": {
192376
192731
  capName: "device-manager",
192377
192732
  capScope: "system",
@@ -192463,6 +192818,13 @@ Object.freeze({
192463
192818
  access: "create",
192464
192819
  role: "admin"
192465
192820
  },
192821
+ "deviceManager.setPrimaryChildPreference": {
192822
+ capName: "device-manager",
192823
+ capScope: "system",
192824
+ addonId: null,
192825
+ access: "create",
192826
+ role: "admin"
192827
+ },
192466
192828
  "deviceManager.setRole": {
192467
192829
  capName: "device-manager",
192468
192830
  capScope: "system",
@@ -197102,28 +197464,28 @@ Object.freeze({
197102
197464
  capScope: "device",
197103
197465
  addonId: null,
197104
197466
  access: "create",
197105
- role: "admin"
197467
+ role: "viewer"
197106
197468
  },
197107
197469
  "powerSource.getStatus": {
197108
197470
  capName: "power-source",
197109
197471
  capScope: "device",
197110
197472
  addonId: null,
197111
197473
  access: "view",
197112
- role: "admin"
197474
+ role: "viewer"
197113
197475
  },
197114
197476
  "powerSource.powerOff": {
197115
197477
  capName: "power-source",
197116
197478
  capScope: "device",
197117
197479
  addonId: null,
197118
197480
  access: "create",
197119
- role: "admin"
197481
+ role: "viewer"
197120
197482
  },
197121
197483
  "powerSource.powerOn": {
197122
197484
  capName: "power-source",
197123
197485
  capScope: "device",
197124
197486
  addonId: null,
197125
197487
  access: "create",
197126
- role: "admin"
197488
+ role: "viewer"
197127
197489
  },
197128
197490
  "presence.getStatus": {
197129
197491
  capName: "presence",
@@ -200832,35 +201194,6 @@ Object.freeze({
200832
201194
  form: "single",
200833
201195
  optional: false
200834
201196
  }],
200835
- "deviceDiscovery.adoptDevice": [{
200836
- name: "deviceId",
200837
- form: "single",
200838
- optional: false
200839
- }],
200840
- "deviceDiscovery.getStatus": [{
200841
- name: "deviceId",
200842
- form: "single",
200843
- optional: false
200844
- }],
200845
- "deviceDiscovery.listDiscovered": [{
200846
- name: "deviceId",
200847
- form: "single",
200848
- optional: false
200849
- }],
200850
- "deviceDiscovery.refreshDiscovery": [{
200851
- name: "deviceId",
200852
- form: "single",
200853
- optional: false
200854
- }],
200855
- "deviceDiscovery.releaseDevice": [{
200856
- name: "childDeviceId",
200857
- form: "single",
200858
- optional: false
200859
- }, {
200860
- name: "deviceId",
200861
- form: "single",
200862
- optional: false
200863
- }],
200864
201197
  "deviceExport.applyDeviceSettingsPatch": [{
200865
201198
  name: "deviceId",
200866
201199
  form: "single",
@@ -201139,6 +201472,11 @@ Object.freeze({
201139
201472
  form: "single",
201140
201473
  optional: false
201141
201474
  }],
201475
+ "deviceManager.setPrimaryChildPreference": [{
201476
+ name: "deviceId",
201477
+ form: "single",
201478
+ optional: false
201479
+ }],
201142
201480
  "deviceManager.setRole": [{
201143
201481
  name: "deviceId",
201144
201482
  form: "single",
@@ -204607,7 +204945,9 @@ var TimelapseRuleInputSchema = object({
204607
204945
  /** Classes the notification counts — see {@link ReportClassesField}. */
204608
204946
  reportClasses: ReportClassesField.optional(),
204609
204947
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
204610
- priority: PriorityField.default(3)
204948
+ priority: PriorityField.default(3),
204949
+ /** Per-target settings keyed by target id (D1032) — absent = every target follows the rule. */
204950
+ targetOverrides: NcTargetOverridesSchema.optional()
204611
204951
  });
204612
204952
  object({
204613
204953
  name: NameField.optional(),
@@ -204623,7 +204963,9 @@ object({
204623
204963
  previewText: PreviewTextField.optional(),
204624
204964
  previewMode: PreviewModeField.optional(),
204625
204965
  reportClasses: ReportClassesField.optional(),
204626
- priority: PriorityField.optional()
204966
+ priority: PriorityField.optional(),
204967
+ /** Per-target settings keyed by target id (D1032) — absent = every target follows the rule. */
204968
+ targetOverrides: NcTargetOverridesSchema.optional()
204627
204969
  });
204628
204970
  TimelapseRuleInputSchema.extend({
204629
204971
  id: string(),
@@ -212886,6 +213228,20 @@ var UnmappedCodeLedger = class {
212886
213228
  return true;
212887
213229
  }
212888
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
+ }
212889
213245
  //#endregion
212890
213246
  //#region src/hub-channel-reconcile.ts
212891
213247
  /**
@@ -212981,6 +213337,19 @@ var HUB_DISCOVERY_REFRESH_TIMEOUT_MS = 8e3;
212981
213337
  var HUB_CHILD_SLEEP_RECONCILE_MS = 6e4;
212982
213338
  var HUB_RECONNECT_BASE_MS = 2e3;
212983
213339
  var HUB_RECONNECT_MAX_MS = 3e4;
213340
+ /**
213341
+ * Threshold for marking an adopted child offline when missing from consecutive refreshes.
213342
+ * 10 minutes covers ~3 default refresh cycles + transient firmware latency without
213343
+ * false-flagging battery cams that take a few cycles to wake into the list.
213344
+ */
213345
+ var HUB_MISSING_OFFLINE_MS = 10 * 6e4;
213346
+ /**
213347
+ * Longer grace for a child flagged asleep that drops off a non-empty hub list. A sleeping battery
213348
+ * camera may vanish from the summary for hours, but `battery.sleeping` is a persisted slice: a
213349
+ * camera that died or was unplugged while flagged asleep must still go offline eventually.
213350
+ * Measured from the last time the hub actually LISTED the child.
213351
+ */
213352
+ var SLEEPING_MISSING_OFFLINE_MS = 360 * 6e4;
212984
213353
  var UNROUTED_LOG_THROTTLE_MS = 6e4;
212985
213354
  /**
212986
213355
  * ONE Reolink NVR / Home Hub: a single Baichuan control + event socket fronting N channels,
@@ -213013,6 +213382,10 @@ var ReolinkHubSession = class {
213013
213382
  #refreshInFlight = null;
213014
213383
  /** Wall-clock ms of the last refresh that listed each child (by device id). */
213015
213384
  #childLastSeenAt = /* @__PURE__ */ new Map();
213385
+ /** The empty-list warning fired and the list has not been non-empty since. */
213386
+ #emptyListWarned = false;
213387
+ /** Children THIS session marked offline for being missing from the list (the only ones it may restore). */
213388
+ #offlineByMissing = /* @__PURE__ */ new Set();
213016
213389
  /** Channels the last good refresh listed but nobody adopted: their pushes are expected drops. */
213017
213390
  #knownUnadoptedChannels = /* @__PURE__ */ new Set();
213018
213391
  #unroutedLoggedAt = /* @__PURE__ */ new Map();
@@ -213311,13 +213684,25 @@ var ReolinkHubSession = class {
213311
213684
  */
213312
213685
  reconcileChildOnline(channels) {
213313
213686
  const now = this.#now();
213687
+ const cameras = this.#deps.children().filter((c) => c.channel !== void 0 && c.type === DeviceType.Camera);
213688
+ if (channels.length === 0 && cameras.length > 0) {
213689
+ if (!this.#emptyListWarned) {
213690
+ this.#emptyListWarned = true;
213691
+ this.#logger.warn("Reolink hub: channel list came back empty with adopted children — online state left unchanged", {
213692
+ tags: { integrationId: this.integrationId },
213693
+ meta: { adopted: cameras.length }
213694
+ });
213695
+ }
213696
+ return;
213697
+ }
213698
+ if (channels.length > 0) this.#emptyListWarned = false;
213314
213699
  const listed = new Set(channels.map((c) => c.channel));
213315
- for (const child of this.#deps.children()) {
213700
+ for (const child of cameras) {
213316
213701
  const ch = child.channel;
213317
213702
  if (ch === void 0) continue;
213318
- if (child.type !== DeviceType.Camera) continue;
213319
213703
  if (listed.has(ch)) {
213320
213704
  this.#childLastSeenAt.set(child.id, now);
213705
+ this.#offlineByMissing.delete(child.id);
213321
213706
  if (!child.online) {
213322
213707
  child.markOnline(true);
213323
213708
  this.#logger.info("Reolink hub: adopted child back online", {
@@ -213330,10 +213715,28 @@ var ReolinkHubSession = class {
213330
213715
  }
213331
213716
  continue;
213332
213717
  }
213333
- const lastSeen = this.#childLastSeenAt.get(child.id) ?? 0;
213334
- const missingMs = lastSeen > 0 ? now - lastSeen : Number.POSITIVE_INFINITY;
213335
- if (missingMs >= 6e5 && child.online) {
213718
+ let lastSeen = this.#childLastSeenAt.get(child.id);
213719
+ if (lastSeen === void 0) {
213720
+ lastSeen = now;
213721
+ this.#childLastSeenAt.set(child.id, now);
213722
+ }
213723
+ if (child.sleeping && !child.online && this.#offlineByMissing.has(child.id) && now - lastSeen < 216e5) {
213724
+ this.#offlineByMissing.delete(child.id);
213725
+ child.markOnline(true);
213726
+ this.#logger.info("Reolink hub: sleeping child restored to online", {
213727
+ tags: {
213728
+ deviceId: child.id,
213729
+ deviceName: child.name
213730
+ },
213731
+ meta: { channel: ch }
213732
+ });
213733
+ continue;
213734
+ }
213735
+ const graceMs = child.sleeping ? SLEEPING_MISSING_OFFLINE_MS : HUB_MISSING_OFFLINE_MS;
213736
+ const missingMs = now - lastSeen;
213737
+ if (missingMs >= graceMs && child.online) {
213336
213738
  child.markOnline(false);
213739
+ this.#offlineByMissing.add(child.id);
213337
213740
  this.#logger.warn("Reolink hub: adopted child marked offline (missing from the hub list)", {
213338
213741
  tags: {
213339
213742
  deviceId: child.id,
@@ -213402,8 +213805,21 @@ var ReolinkHubSession = class {
213402
213805
  }
213403
213806
  });
213404
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
+ });
213405
213821
  child.applyHubBatteryInfo({
213406
- batteryPercent: info.batteryLevel,
213822
+ ...measured ? { batteryPercent: info.batteryLevel } : {},
213407
213823
  ...power.fields
213408
213824
  });
213409
213825
  }
@@ -217455,6 +217871,9 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
217455
217871
  get online() {
217456
217872
  return camera.online;
217457
217873
  },
217874
+ get sleeping() {
217875
+ return camera.sleeping;
217876
+ },
217458
217877
  get debugGeneral() {
217459
217878
  return camera.config.get("debugGeneral") === true;
217460
217879
  },