@camstack/addon-provider-reolink 1.2.238 → 1.2.240

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.js CHANGED
@@ -101498,7 +101498,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
101498
101498
  return EventCategory;
101499
101499
  }({});
101500
101500
  //#endregion
101501
- //#region ../types/dist/composed-stable-id-DFNyOFzz.mjs
101501
+ //#region ../types/dist/composed-stable-id-CPp3votu.mjs
101502
101502
  /**
101503
101503
  import { errMsg } from '@camstack/types'
101504
101504
  * Extract a human-readable message from an unknown error value.
@@ -101517,12 +101517,12 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
101517
101517
  DeviceType["Siren"] = "siren";
101518
101518
  DeviceType["Switch"] = "switch";
101519
101519
  DeviceType["Sensor"] = "sensor";
101520
- DeviceType["Thermostat"] = "thermostat";
101521
- /** Air-conditioner / heat-pump climate device (HVAC) — shares the
101522
- * `climate-control` cap surface with `Thermostat` but renders a
101523
- * dedicated AC-appropriate control UI (mode chips, fan speed,
101524
- * independent vertical/horizontal swing). Sources: native Gree, and
101525
- * reusable by other AC integrations. */
101520
+ /** Every climate device: an air conditioner, a room thermostat, a radiator
101521
+ * valve, a floor-heating zone, a heat-pump circuit. They share one set of
101522
+ * controls (`climate-control`), so they are one type; WHICH kind of climate
101523
+ * device it is is its {@link DeviceRole} (`climate-*`), which the UI and the
101524
+ * exports branch on. The retired `thermostat` type is read as this one
101525
+ * (`canonicalStoredDeviceType`). */
101526
101526
  DeviceType["Climate"] = "climate";
101527
101527
  DeviceType["Button"] = "button";
101528
101528
  /** Generic stateless event emitter — carries a device's EXACT declared
@@ -101613,10 +101613,6 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
101613
101613
  /** Washing machine. A plug-built one is running while its power stays
101614
101614
  * above a threshold. No program cap — that surface is the dishwasher's. */
101615
101615
  DeviceType["Washer"] = "washer";
101616
- /** A dumb plug-in stove or heater: a switch (and, with a meter, a power
101617
- * reading) that only runs while the plug is on. Built from a smart plug;
101618
- * the `timed-run` cap switches it off again after a chosen time. */
101619
- DeviceType["Heater"] = "heater";
101620
101616
  /** Tumble dryer. Same plug-built running surface as {@link Washer}. */
101621
101617
  DeviceType["Dryer"] = "dryer";
101622
101618
  /** The physical bridge box of a vendor ecosystem (Velux KLF-200, and later
@@ -101836,6 +101832,27 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
101836
101832
  /** A smart plug: a `switch` whose source says it is an outlet (HA
101837
101833
  * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
101838
101834
  DeviceRole["Outlet"] = "outlet";
101835
+ /** A dumb plug-in stove or heater behind a switch: it runs only while the
101836
+ * switch is on. Offered `timed-run`, which switches it off again after a
101837
+ * chosen time. */
101838
+ DeviceRole["SwitchHeater"] = "switch-heater";
101839
+ /** A plain fan behind a switch (a smart plug powering it): drawn as a fan,
101840
+ * with the switch's on/off only. Speed or oscillation appear only when the
101841
+ * device also has a fan cap (D1033). */
101842
+ DeviceRole["SwitchFan"] = "switch-fan";
101843
+ /** Air conditioner / split unit: cooling, fan speed, louvres. */
101844
+ DeviceRole["ClimateAc"] = "climate-ac";
101845
+ /** Room thermostat: a setpoint and a room temperature. The default. */
101846
+ DeviceRole["ClimateThermostat"] = "climate-thermostat";
101847
+ /** Floor-heating zone actuator. */
101848
+ DeviceRole["ClimateFloor"] = "climate-floor";
101849
+ /** Radiator valve (thermostatic radiator head). */
101850
+ DeviceRole["ClimateRadiator"] = "climate-radiator";
101851
+ /** A heater with its own thermostat (stove, convector). */
101852
+ DeviceRole["ClimateHeater"] = "climate-heater";
101853
+ /** One heating/cooling circuit of a heat pump: a water loop with comfort /
101854
+ * eco setpoints and a heat/cool mode, no room sensor. */
101855
+ DeviceRole["ClimateHeatPumpCircuit"] = "climate-heat-pump-circuit";
101839
101856
  /** Generic motion / occupancy / moving event source. Distinct from
101840
101857
  * the camera accessory PirSensor role: that one is a camera child;
101841
101858
  * this is a standalone HA / 3rd-party motion sensor. */
@@ -106723,7 +106740,7 @@ var ZodIssueCode = {
106723
106740
  var ZodFirstPartyTypeKind;
106724
106741
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
106725
106742
  //#endregion
106726
- //#region ../types/dist/sleep-D_NpiLFP.mjs
106743
+ //#region ../types/dist/sleep-D0roI_CZ.mjs
106727
106744
  /**
106728
106745
  * The audio chunk plane's byte format, and the ONE expansion from a coded
106729
106746
  * window to float samples (D455).
@@ -112536,6 +112553,50 @@ var ACTUATOR_CAP_VOCABULARY = {
112536
112553
  value: false
112537
112554
  },
112538
112555
  args: { oscillating: false }
112556
+ },
112557
+ {
112558
+ id: "fan.horizontalOscillateOn",
112559
+ method: "setOscillationAxis",
112560
+ label: t("Horizontal oscillation on", "Oscillazione orizzontale attiva"),
112561
+ phrase: t("Start the horizontal oscillation of {device}", "Attiva l’oscillazione orizzontale di {device}"),
112562
+ icon: "move-horizontal",
112563
+ args: {
112564
+ axis: "horizontal",
112565
+ oscillating: true
112566
+ }
112567
+ },
112568
+ {
112569
+ id: "fan.horizontalOscillateOff",
112570
+ method: "setOscillationAxis",
112571
+ label: t("Horizontal oscillation off", "Oscillazione orizzontale spenta"),
112572
+ phrase: t("Stop the horizontal oscillation of {device}", "Ferma l’oscillazione orizzontale di {device}"),
112573
+ icon: "move-horizontal",
112574
+ args: {
112575
+ axis: "horizontal",
112576
+ oscillating: false
112577
+ }
112578
+ },
112579
+ {
112580
+ id: "fan.verticalOscillateOn",
112581
+ method: "setOscillationAxis",
112582
+ label: t("Vertical oscillation on", "Oscillazione verticale attiva"),
112583
+ phrase: t("Start the vertical oscillation of {device}", "Attiva l’oscillazione verticale di {device}"),
112584
+ icon: "move-vertical",
112585
+ args: {
112586
+ axis: "vertical",
112587
+ oscillating: true
112588
+ }
112589
+ },
112590
+ {
112591
+ id: "fan.verticalOscillateOff",
112592
+ method: "setOscillationAxis",
112593
+ label: t("Vertical oscillation off", "Oscillazione verticale spenta"),
112594
+ phrase: t("Stop the vertical oscillation of {device}", "Ferma l’oscillazione verticale di {device}"),
112595
+ icon: "move-vertical",
112596
+ args: {
112597
+ axis: "vertical",
112598
+ oscillating: false
112599
+ }
112539
112600
  }
112540
112601
  ],
112541
112602
  state: [{
@@ -116925,6 +116986,10 @@ Object.freeze({
116925
116986
  "path": "lastEvent.eventType",
116926
116987
  "valueType": "string"
116927
116988
  },
116989
+ {
116990
+ "path": "lastEvent.sourceId",
116991
+ "valueType": "string"
116992
+ },
116928
116993
  {
116929
116994
  "path": "lastEvent.timestamp",
116930
116995
  "valueType": "number"
@@ -118212,7 +118277,7 @@ function sleep(ms) {
118212
118277
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
118213
118278
  }
118214
118279
  //#endregion
118215
- //#region ../types/dist/implemented-methods-M5aguGon.mjs
118280
+ //#region ../types/dist/implemented-methods-5YMDeE3f.mjs
118216
118281
  /**
118217
118282
  * The ffmpeg build every CamStack node downloads, per platform and arch.
118218
118283
  *
@@ -145498,6 +145563,41 @@ function macroOnly(macro) {
145498
145563
  };
145499
145564
  }
145500
145565
  }
145566
+ var EventVocabularyKindSchema = _enum([
145567
+ "press",
145568
+ "long-press",
145569
+ "long-press-start",
145570
+ "release",
145571
+ "repeat",
145572
+ "double-press",
145573
+ "other"
145574
+ ]);
145575
+ /** The part of the device an event comes from: a button, a channel. */
145576
+ var EventVocabularySourceSchema = object({
145577
+ id: string().min(1),
145578
+ label: string().min(1)
145579
+ });
145580
+ /** One scalar field of an event's `data`, by dotted path. */
145581
+ var EventVocabularyFieldSchema = object({
145582
+ path: string().min(1),
145583
+ kind: _enum([
145584
+ "string",
145585
+ "number",
145586
+ "boolean",
145587
+ "enum"
145588
+ ]),
145589
+ enumValues: array(string()).optional(),
145590
+ label: string().min(1).optional()
145591
+ });
145592
+ var EventVocabularyEntrySchema = object({
145593
+ /** The native token, verbatim. */
145594
+ id: string().min(1),
145595
+ source: EventVocabularySourceSchema.optional(),
145596
+ label: string().min(1),
145597
+ description: string().optional(),
145598
+ kind: EventVocabularyKindSchema.optional(),
145599
+ payload: array(EventVocabularyFieldSchema).optional()
145600
+ });
145501
145601
  Math.PI / 180;
145502
145602
  /**
145503
145603
  * WHEN something happens, as data (D983) — the one time vocabulary of the
@@ -145705,6 +145805,33 @@ var ScheduleLeafSchema = object({
145705
145805
  /** @deprecated legacy cron — new schedules use `at`. */
145706
145806
  cron: string().min(1).max(120).optional()
145707
145807
  }).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" });
145808
+ /**
145809
+ * One payload predicate of a `device-fired` row: the value at `path` inside
145810
+ * the fire's `data` (dotted) equals `equals`. Compared strictly, no coercion.
145811
+ */
145812
+ var DeviceFiredMatchSchema = object({
145813
+ path: string().min(1).max(120),
145814
+ equals: union([
145815
+ string(),
145816
+ number$1(),
145817
+ boolean()
145818
+ ])
145819
+ });
145820
+ /**
145821
+ * "fires": one device of the `event-emitter` capability reported an event
145822
+ * (D1045). Every list is an OR, the lists together an AND; an absent list does
145823
+ * not narrow. `eventIds` are the device's own tokens, `sourceIds` the parts of
145824
+ * the device (a button), `kinds` the shared press kinds of its vocabulary.
145825
+ */
145826
+ var DeviceFiredLeafSchema = object({
145827
+ kind: literal("device-fired"),
145828
+ ...eventLeafId,
145829
+ deviceId: number$1().int().nonnegative(),
145830
+ eventIds: array(string().min(1)).min(1).max(64).optional(),
145831
+ sourceIds: array(string().min(1)).min(1).max(64).optional(),
145832
+ kinds: array(EventVocabularyKindSchema).min(1).optional(),
145833
+ match: array(DeviceFiredMatchSchema).min(1).max(8).optional()
145834
+ });
145708
145835
  var ManualLeafSchema = object({
145709
145836
  kind: literal("manual"),
145710
145837
  ...eventLeafId
@@ -145846,6 +145973,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
145846
145973
  }),
145847
145974
  DeviceBecomesLeafSchema,
145848
145975
  DeviceEventLeafSchema,
145976
+ DeviceFiredLeafSchema,
145849
145977
  ScheduleLeafSchema,
145850
145978
  ManualLeafSchema,
145851
145979
  IntervalLeafSchema,
@@ -145860,6 +145988,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
145860
145988
  var EVENT_KINDS = new Set([
145861
145989
  "device-becomes",
145862
145990
  "device-event",
145991
+ "device-fired",
145863
145992
  "schedule",
145864
145993
  "manual",
145865
145994
  "interval",
@@ -145940,6 +146069,7 @@ function hasEmptyContainer(node) {
145940
146069
  var LEAF_WORDS = {
145941
146070
  "device-becomes": "a device value that becomes",
145942
146071
  "device-event": "a device event",
146072
+ "device-fired": "a device firing an event",
145943
146073
  schedule: "a schedule",
145944
146074
  manual: "a manual run",
145945
146075
  interval: "an interval",
@@ -146205,9 +146335,12 @@ function convertLegacyWhen(half) {
146205
146335
  * every caller — automations, Actions, and the notification centre, which runs
146206
146336
  * only Actions (planning#473).
146207
146337
  */
146338
+ /** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
146339
+ var WAIT_MAX_SECONDS = 3600;
146340
+ var WAIT_TOO_LONG = `a wait is at most one hour (${WAIT_MAX_SECONDS} s)`;
146208
146341
  var AutomationWaitStepSchema = object({
146209
146342
  kind: literal("wait"),
146210
- seconds: number$1().min(0).max(300)
146343
+ seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
146211
146344
  });
146212
146345
  /** The legacy `deviceId` of a cap step: still READ, never written (D983). */
146213
146346
  var LegacyStepDeviceSchema = union([
@@ -146277,39 +146410,227 @@ var elseNeedsIf = {
146277
146410
  path: ["else"]
146278
146411
  };
146279
146412
  var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
146280
- var GuardedCapStepSchema = AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
146281
- message: "a cap step needs a target",
146282
- path: ["target"]
146283
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
146284
- message: "a domain target needs the vocabulary action it applies to (actionId)",
146285
- path: ["actionId"]
146286
- }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
146287
146413
  /**
146288
146414
  * A step of a STANDALONE list (an action, a scheduler point, a preset): the
146289
146415
  * same two step kinds an automation runs, minus a guard that reads the
146290
146416
  * automation's trigger, which such a list does not have.
146291
146417
  */
146292
- var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, GuardedCapStepSchema]).superRefine((step, ctx) => {
146418
+ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
146419
+ message: "a cap step needs a target",
146420
+ path: ["target"]
146421
+ }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
146422
+ message: "a domain target needs the vocabulary action it applies to (actionId)",
146423
+ path: ["actionId"]
146424
+ }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
146293
146425
  if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
146294
146426
  code: "custom",
146295
146427
  message: TRIGGERED_BY_NEEDS_AUTOMATION,
146296
146428
  path: ["if"]
146297
146429
  });
146298
146430
  });
146431
+ /**
146432
+ * Flow control of an AUTOMATION's list (#500). A standalone list (an action, a
146433
+ * scheduler point, a preset) stays `wait` and `cap`: it has no run of its own
146434
+ * to end and no variable bag to write.
146435
+ */
146436
+ var continueOnErrorShape = {
146437
+ /** A failure of this step is traced `failed-continued` and the next step runs. */
146438
+ continueOnError: literal(true).optional() };
146439
+ /** An automation's cap step: the shared guarded cap step, plus `continueOnError`. */
146440
+ var AutomationGuardedCapStepSchema = AutomationCapStepBaseSchema.extend({
146441
+ ...stepGuardShape,
146442
+ ...continueOnErrorShape
146443
+ }).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
146444
+ message: "a cap step needs a target",
146445
+ path: ["target"]
146446
+ }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
146447
+ message: "a domain target needs the vocabulary action it applies to (actionId)",
146448
+ path: ["actionId"]
146449
+ }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
146450
+ /** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
146451
+ var AutomationStopStepSchema = object({
146452
+ kind: literal("stop"),
146453
+ reason: string().min(1, "a stop needs a reason: it is what the run trace shows").max(200),
146454
+ /** `ok`: the run ends as a success. `failed`: it ends as a failure, with the reason. */
146455
+ outcome: _enum(["ok", "failed"]),
146456
+ /** Stop only when this reads true; false or unknown does not stop. */
146457
+ if: AutomationWhenSchema.optional()
146458
+ });
146459
+ var SET_VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]{0,39}$/;
146460
+ /** Names the run itself writes and reads (`leaf` is what `triggered-by` judges): a step may not overwrite them. */
146461
+ var RESERVED_RUN_VARS = [
146462
+ "kind",
146463
+ "leaf",
146464
+ "at"
146465
+ ];
146466
+ /**
146467
+ * Write variables into the run's bag, for the steps after it. SUBSTITUTION
146468
+ * only, never evaluation: a text value may carry `{{vars.x}}` slots.
146469
+ */
146470
+ var AutomationSetStepSchema = object({
146471
+ kind: literal("set"),
146472
+ vars: record(string(), union([
146473
+ string().max(500),
146474
+ number$1(),
146475
+ boolean()
146476
+ ])).refine((vars) => Object.keys(vars).every((name) => SET_VAR_NAME_RE.test(name)), { message: "a variable name is letters, digits and _, not starting with a digit (max 40)" }).refine((vars) => Object.keys(vars).length >= 1, { message: "set needs at least one variable" }).refine((vars) => Object.keys(vars).length <= 20, { message: `set holds at most 20 variables` }).refine((vars) => Object.keys(vars).every((name) => !RESERVED_RUN_VARS.includes(name)), { message: `the names ${RESERVED_RUN_VARS.join(", ")} belong to the run and cannot be set` }),
146477
+ /** Set only when this reads true; false or unknown leaves the bag as it is. */
146478
+ if: AutomationWhenSchema.optional()
146479
+ });
146480
+ var AutomationRunActionStepSchema = object({
146481
+ kind: literal("action"),
146482
+ /** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
146483
+ actionId: string().min(1),
146484
+ /** Values for the action's declared variables; the others take their default. */
146485
+ variables: record(string(), union([
146486
+ string(),
146487
+ number$1(),
146488
+ boolean()
146489
+ ])).optional(),
146490
+ ...continueOnErrorShape
146491
+ });
146492
+ /**
146493
+ * A step INSIDE a branch of a `choose`: a flow step with no condition of its
146494
+ * own (the branch is the condition) and no block inside it. Strict, so an `if`
146495
+ * written on such a step is refused rather than dropped.
146496
+ */
146497
+ /** The longest a `wait-until` may wait: six hours. */
146498
+ var WAIT_UNTIL_TIMEOUT_MAX_S = 21600;
146499
+ /**
146500
+ * Pause the run until a condition is true (#500). The timeout is mandatory: a
146501
+ * run never waits without an end. `onTimeout` says what a wait that ran out
146502
+ * does: `continue` goes on to the next step, `stop` ends the run as a failure.
146503
+ * A condition that cannot be read is not "true": the wait goes on (D49).
146504
+ */
146505
+ var AutomationWaitUntilStepSchema = object({
146506
+ kind: literal("wait-until"),
146507
+ when: AutomationWhenSchema,
146508
+ timeoutS: number$1().int().min(1, "a wait needs a timeout of at least one second").max(WAIT_UNTIL_TIMEOUT_MAX_S, `a wait for a condition is at most six hours (${WAIT_UNTIL_TIMEOUT_MAX_S} s)`),
146509
+ onTimeout: _enum(["continue", "stop"])
146510
+ }).strict();
146511
+ /** The step kinds that hold steps of their own, or pause on a condition: they nest two levels at most. */
146512
+ var BLOCK_STEP_KINDS = [
146513
+ "choose",
146514
+ "repeat",
146515
+ "parallel",
146516
+ "wait-until"
146517
+ ];
146518
+ var NEST_TOO_DEEP = `steps nest two levels at most: a step inside a nested choose or repeat can be a plain step only`;
146519
+ function kindOf(input) {
146520
+ return typeof input === "object" && input !== null ? Reflect.get(input, "kind") : void 0;
146521
+ }
146522
+ /** Where the nesting ends, a block step is refused in words rather than as an unknown kind. */
146523
+ function nestTooDeep(issue) {
146524
+ const kind = kindOf(issue.input);
146525
+ return typeof kind === "string" && BLOCK_STEP_KINDS.includes(kind) ? NEST_TOO_DEEP : void 0;
146526
+ }
146527
+ var plainStepSchemas = [
146528
+ AutomationWaitStepSchema.strict(),
146529
+ AutomationCapStepBaseSchema.extend(continueOnErrorShape).strict().refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
146530
+ message: "a cap step needs a target",
146531
+ path: ["target"]
146532
+ }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
146533
+ message: "a domain target needs the vocabulary action it applies to (actionId)",
146534
+ path: ["actionId"]
146535
+ }),
146536
+ AutomationStopStepSchema.omit({ if: true }).strict(),
146537
+ AutomationSetStepSchema.omit({ if: true }).strict(),
146538
+ AutomationRunActionStepSchema.strict()
146539
+ ];
146540
+ /**
146541
+ * A plain step: a flow step with no condition of its own and no step inside
146542
+ * it. The second (last) level of nesting holds these only.
146543
+ */
146544
+ var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
146545
+ /** A step that can run beside others: it writes no variable and does not end the run. */
146546
+ var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) => step.kind === "cap" || step.kind === "action" || step.kind === "wait", "a parallel holds device commands, actions and waits only: a set or a stop beside other steps has no order");
146547
+ /**
146548
+ * Several steps at once (#500): all are started together and all are awaited.
146549
+ * A failure fails the run once the others finished, as in a sequence; a member
146550
+ * marked "continue if this fails" does not.
146551
+ */
146552
+ var AutomationParallelStepSchema = object({
146553
+ kind: literal("parallel"),
146554
+ steps: array(AutomationParallelMemberSchema).min(2, "a parallel needs at least two steps").max(5, `a parallel takes at most 5 steps`)
146555
+ }).strict();
146556
+ var REPEAT_NEEDS_MAX = "a repeat on a condition needs a maximum number of iterations";
146557
+ /** A loop on a condition: the bound is mandatory, so a run never loops without an end. */
146558
+ var repeatConditionShape = {
146559
+ when: AutomationWhenSchema,
146560
+ maxIterations: number$1({ error: REPEAT_NEEDS_MAX }).int().min(1, REPEAT_NEEDS_MAX).max(50, `a repeat on a condition runs at most 50 times`),
146561
+ /** A pause between two iterations, never after the last. */
146562
+ waitS: number$1().int().min(1).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG).optional()
146563
+ };
146564
+ /** What decides how many times a `repeat` runs. */
146565
+ var AutomationRepeatLoopSchema = discriminatedUnion("by", [
146566
+ object({
146567
+ by: literal("count"),
146568
+ count: number$1().int().min(1).max(20, `a repeat runs at most 20 times`)
146569
+ }).strict(),
146570
+ object({
146571
+ by: literal("while"),
146572
+ ...repeatConditionShape
146573
+ }).strict(),
146574
+ object({
146575
+ by: literal("until"),
146576
+ ...repeatConditionShape
146577
+ }).strict(),
146578
+ object({
146579
+ by: literal("forEach"),
146580
+ target: object({
146581
+ kind: literal("devices"),
146582
+ ids: array(number$1().int()).min(1, "a repeat over devices needs at least one device").max(50, `a repeat over devices takes at most 50 devices`)
146583
+ }).strict()
146584
+ }).strict()
146585
+ ]);
146586
+ /**
146587
+ * The same steps several times (#500). Every form is bounded at save, so a
146588
+ * run cannot loop without an end. A failure or a `stop` in the steps ends the
146589
+ * loop and the run, as in a sequence.
146590
+ */
146591
+ function repeatSchemaOf(step) {
146592
+ return object({
146593
+ kind: literal("repeat"),
146594
+ loop: AutomationRepeatLoopSchema,
146595
+ steps: array(step).min(1, "a repeat needs at least one step").max(10, `a repeat takes at most 10 steps`)
146596
+ }).strict();
146597
+ }
146598
+ /**
146599
+ * One step, several ways (#500): the branches are read in order and the FIRST
146600
+ * whose condition is true runs; `else` runs when every branch is false. A
146601
+ * branch that cannot be read ends the choice: nothing runs, not the branches
146602
+ * after it and not the else (D49). The #472 `if` / `else` of a wait or cap
146603
+ * step is the one-branch case and stays as it is stored.
146604
+ */
146605
+ function chooseSchemaOf(step) {
146606
+ const steps = array(step).max(10);
146607
+ return object({
146608
+ kind: literal("choose"),
146609
+ branches: array(object({
146610
+ if: AutomationWhenSchema,
146611
+ steps: steps.min(1, "a branch needs at least one step")
146612
+ })).min(1, "a choose needs at least one branch").max(6, `a choose takes at most 6 branches`),
146613
+ else: steps.optional()
146614
+ });
146615
+ }
146616
+ var AutomationBodyStepSchema = discriminatedUnion("kind", [
146617
+ ...plainStepSchemas,
146618
+ AutomationWaitUntilStepSchema,
146619
+ AutomationParallelStepSchema,
146620
+ chooseSchemaOf(AutomationBranchStepSchema),
146621
+ repeatSchemaOf(AutomationBranchStepSchema)
146622
+ ]);
146623
+ var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
146299
146624
  var AutomationActionSchema = discriminatedUnion("kind", [
146300
146625
  GuardedWaitStepSchema,
146301
- GuardedCapStepSchema,
146302
- object({
146303
- kind: literal("action"),
146304
- /** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
146305
- actionId: string().min(1),
146306
- /** Values for the action's declared variables; the others take their default. */
146307
- variables: record(string(), union([
146308
- string(),
146309
- number$1(),
146310
- boolean()
146311
- ])).optional()
146312
- }),
146626
+ AutomationGuardedCapStepSchema,
146627
+ AutomationStopStepSchema,
146628
+ AutomationSetStepSchema,
146629
+ chooseSchemaOf(AutomationBodyStepSchema),
146630
+ AutomationWaitUntilStepSchema,
146631
+ AutomationParallelStepSchema,
146632
+ AutomationRepeatStepSchema,
146633
+ AutomationRunActionStepSchema,
146313
146634
  object({
146314
146635
  kind: literal("code"),
146315
146636
  /** Compiled into the automation's OWN block by esbuild — not a third
@@ -146372,11 +146693,6 @@ function convertLegacyRecipe(legacy) {
146372
146693
  ...rest
146373
146694
  };
146374
146695
  }
146375
- /**
146376
- * Where recipes are PARSED (the core-blocks cap, the MCP tool, the literal a
146377
- * saved block carries): the new shape as it is, or the old shape converted to
146378
- * it. The output type is always the new one.
146379
- */
146380
146696
  var AutomationRecipeSchema = union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
146381
146697
  var DETECTION_DESCRIPTIONS = {
146382
146698
  deviceId: "the camera that saw it",
@@ -146397,6 +146713,16 @@ var BECOMES_DESCRIPTIONS = {
146397
146713
  from: "the value before the change, empty when it is not known",
146398
146714
  to: "the value it changed to"
146399
146715
  };
146716
+ /**
146717
+ * A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
146718
+ * those names depend on the device, so they are not in this list.
146719
+ */
146720
+ var FIRED_DESCRIPTIONS = {
146721
+ deviceId: "the device that fired",
146722
+ eventType: "the event, as the device names it",
146723
+ sourceId: "the part of the device that fired (a button), empty when it names none",
146724
+ eventKind: "the kind of press (press, long-press …), empty when the device declares none"
146725
+ };
146400
146726
  function describe$1(descriptions) {
146401
146727
  return Object.entries(descriptions).map(([name, description]) => ({
146402
146728
  name,
@@ -146405,12 +146731,74 @@ function describe$1(descriptions) {
146405
146731
  }
146406
146732
  describe$1(DETECTION_DESCRIPTIONS);
146407
146733
  describe$1(STATIONARY_DESCRIPTIONS);
146734
+ describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
146735
+ ...v,
146736
+ hintKey: "firedDeviceId"
146737
+ } : v);
146408
146738
  describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
146409
146739
  ...v,
146410
146740
  hintKey: "becomesDeviceId"
146411
146741
  } : v);
146412
146742
  new Set(Object.values(COCO_TO_MACRO.mapping));
146413
146743
  /**
146744
+ * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
146745
+ * device. Carries the device's EXACT declared event vocabulary verbatim
146746
+ * (NO normalization). Two shapes:
146747
+ * - structured source (HA `event.*` entity) → `vocabulary` is the fixed
146748
+ * declared set (e.g. press_short, press_long, …).
146749
+ * - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
146750
+ * is [] (open) and `lastEvent.data` carries the complex payload.
146751
+ * `vocabulary` (D1044) names each event for a person and types it for a
146752
+ * rule; `eventTypes` is its list of native tokens, kept for older readers.
146753
+ * A fire names the part of the device it came from in `sourceId` when the
146754
+ * vocabulary declares sources (a remote's buttons).
146755
+ * `seq` is monotonic so two identical events still produce distinct slice writes.
146756
+ */
146757
+ var EventFireSchema = object({
146758
+ deviceId: number$1(),
146759
+ eventType: string(),
146760
+ sourceId: string().optional(),
146761
+ data: record(string(), unknown()).nullable(),
146762
+ timestamp: number$1().meta(readingMeta("none")),
146763
+ seq: number$1().meta(readingMeta("count"))
146764
+ });
146765
+ var EventEmitterStatusSchema = object({
146766
+ eventTypes: array(string()),
146767
+ /**
146768
+ * Required of a provider by the type. A status written before the field
146769
+ * existed still parses, as an empty vocabulary: read it through
146770
+ * `readEventVocabulary`, which then answers with the plain tokens.
146771
+ */
146772
+ vocabulary: array(EventVocabularyEntrySchema).default([]),
146773
+ lastEvent: EventFireSchema.nullable(),
146774
+ eventCountSinceStart: number$1().meta(readingMeta("count"))
146775
+ });
146776
+ var eventEmitterCapability = {
146777
+ name: "event-emitter",
146778
+ scope: "device",
146779
+ deviceNative: true,
146780
+ mode: "singleton",
146781
+ deviceTypes: [DeviceType.EventEmitter],
146782
+ methods: {},
146783
+ events: { onEvent: { data: EventFireSchema } },
146784
+ status: {
146785
+ schema: EventEmitterStatusSchema,
146786
+ kind: "push"
146787
+ },
146788
+ runtimeState: EventEmitterStatusSchema,
146789
+ /**
146790
+ * Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
146791
+ *
146792
+ * See `RuntimeStateDurability`. Enforced by
146793
+ * `scripts/check-runtime-state-durability.ts`.
146794
+ */
146795
+ durability: "session",
146796
+ /**
146797
+ * History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
146798
+ */
146799
+ history: "none"
146800
+ };
146801
+ /**
146414
146802
  * Schedulers (D983) — an entity that performs actions over the day.
146415
146803
  *
146416
146804
  * A scheduler has profiles; a profile has weekdays and a timeline of POINTS.
@@ -146461,12 +146849,16 @@ var HoldOverrideSchema = discriminatedUnion("mode", [object({ mode: literal("res
146461
146849
  })]);
146462
146850
  /** A missed edge up to this late still runs. */
146463
146851
  var DEFAULT_MAX_LATE_MS = 10 * 6e4;
146852
+ var SchedulerStepSchema = ActionStepSchema.refine((step) => step.kind !== "wait" || step.seconds <= 300, {
146853
+ message: `a scheduler point waits at most five minutes (300 s); put a longer wait in an action`,
146854
+ path: ["seconds"]
146855
+ });
146464
146856
  var SchedulerPointSchema = object({
146465
146857
  id: string().min(1).max(64),
146466
146858
  at: SchedulerTimeSpecSchema,
146467
146859
  mode: SchedulerPointModeSchema,
146468
146860
  /** The actions of an `edge` or `hold`; a `release` has none. */
146469
- steps: array(ActionStepSchema).max(20).default([]),
146861
+ steps: array(SchedulerStepSchema).max(20).default([]),
146470
146862
  /** Checked when the point runs (an edge) or is applied (a hold). */
146471
146863
  conditions: SchedulerStateTreeSchema.optional(),
146472
146864
  /** Hold only; absent means `respect`. */
@@ -146664,6 +147056,7 @@ var AutomationConditionTraceNodeSchema = object({
146664
147056
  "triggered-by",
146665
147057
  "device-becomes",
146666
147058
  "device-event",
147059
+ "device-fired",
146667
147060
  "schedule",
146668
147061
  "interval",
146669
147062
  "manual",
@@ -146734,18 +147127,46 @@ var StepTraceBaseSchema = object({
146734
147127
  ]).optional(),
146735
147128
  /** Why the condition read what it read, in the evaluator's own words. */
146736
147129
  conditionReason: string().optional(),
146737
- /** `empty`: the target resolved to no device, so nothing was done — never silently `ok`. `skipped`: its `if` was false (or unknown) and nothing ran in its place. */
147130
+ /** `empty`: the target resolved to no device, so nothing was done — never silently `ok`. `skipped`: its `if` was false (or unknown) and nothing ran in its place. `failed-continued`: it failed and was marked to be passed over (#500). */
146738
147131
  outcome: _enum([
146739
147132
  "ok",
146740
147133
  "error",
146741
147134
  "not-run",
146742
147135
  "empty",
146743
- "skipped"
147136
+ "skipped",
147137
+ "failed-continued",
147138
+ "timed-out"
146744
147139
  ]),
146745
147140
  message: string().optional()
146746
147141
  });
147142
+ /** What a block step adds to its row: which list ran, what each branch read, how many rounds. */
147143
+ var blockTraceShape = {
147144
+ /** A `choose` step (#500): the list that ran, `branches.<n>` or `else`. Absent when none did. */
147145
+ branch: string().optional(),
147146
+ /** A `choose` step: what each branch read, in order, up to the one that decided. */
147147
+ branchChecks: array(object({
147148
+ condition: _enum([
147149
+ "true",
147150
+ "false",
147151
+ "unknown"
147152
+ ]),
147153
+ conditionReason: string().optional()
147154
+ })).optional(),
147155
+ /** A `repeat` step (#500): how many times its steps ran. */
147156
+ iterations: number$1().int().optional()
147157
+ };
147158
+ /** A step one level down: it may be a block step itself, whose own steps are plain rows (the nesting ends there). */
147159
+ var NestedStepTraceSchema = StepTraceBaseSchema.extend({
147160
+ ...blockTraceShape,
147161
+ steps: array(StepTraceBaseSchema).optional()
147162
+ });
146747
147163
  /** A step trace; the `else` steps that ran are one level of the same shape (the nesting is bounded at one). */
146748
- var AutomationStepTraceSchema = StepTraceBaseSchema.extend({ else: array(StepTraceBaseSchema).optional() });
147164
+ var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
147165
+ else: array(StepTraceBaseSchema).optional(),
147166
+ ...blockTraceShape,
147167
+ /** A `choose` step: the steps of the list that ran. A `parallel`: its members. A `repeat`: the LAST iteration. */
147168
+ steps: array(NestedStepTraceSchema).optional()
147169
+ });
146749
147170
  var AutomationRunTraceSchema = object({
146750
147171
  runId: string().min(1),
146751
147172
  startedAt: number$1(),
@@ -146995,7 +147416,7 @@ object({
146995
147416
  * is irrelevant; the array is treated as a set by consumers. */
146996
147417
  hiddenChildIds: array(number$1()).readonly()
146997
147418
  });
146998
- DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Cover, DeviceType.Lock, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Generic, method(object({
147419
+ DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Sensor, DeviceType.Climate, DeviceType.Cover, DeviceType.Lock, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Generic, method(object({
146999
147420
  deviceId: number$1().int().nonnegative(),
147000
147421
  childDeviceId: number$1().int().nonnegative(),
147001
147422
  hidden: boolean()
@@ -147152,7 +147573,9 @@ var AddonHttpRouteSchema = object({
147152
147573
  ]).optional(),
147153
147574
  description: string().optional(),
147154
147575
  /** The hub limits this route per client address before the handler runs. */
147155
- rateLimit: _enum(["auth"]).optional()
147576
+ rateLimit: _enum(["auth"]).optional(),
147577
+ /** Served once per integration instance; the handler reads `instanceId`. */
147578
+ perInstance: boolean().optional()
147156
147579
  });
147157
147580
  /**
147158
147581
  * Cross-process route invocation envelope. The hub captures the
@@ -147169,6 +147592,8 @@ var InvokeRequestSchema = object({
147169
147592
  query: record(string(), string()),
147170
147593
  body: unknown(),
147171
147594
  headers: record(string(), string()),
147595
+ /** The instance the hub resolved for a `perInstance` route. */
147596
+ instanceId: string().optional(),
147172
147597
  user: object({
147173
147598
  id: string(),
147174
147599
  username: string(),
@@ -149293,7 +149718,7 @@ var BATTERY_DEVICE_TYPES = [
149293
149718
  DeviceType.Switch,
149294
149719
  DeviceType.PetFeeder,
149295
149720
  DeviceType.Container,
149296
- DeviceType.Thermostat,
149721
+ DeviceType.Climate,
149297
149722
  DeviceType.EventEmitter
149298
149723
  ];
149299
149724
  /** Generic Customize target for the percentage reading (D936). */
@@ -151056,7 +151481,14 @@ var climateControlCapability = {
151056
151481
  scope: "device",
151057
151482
  deviceNative: true,
151058
151483
  mode: "singleton",
151059
- deviceTypes: [DeviceType.Thermostat, DeviceType.Climate],
151484
+ deviceTypes: [DeviceType.Climate],
151485
+ power: {
151486
+ kind: "mode",
151487
+ field: "mode",
151488
+ offValue: "off",
151489
+ set: "setMode",
151490
+ lastField: "lastActiveMode"
151491
+ },
151060
151492
  methods: {
151061
151493
  setMode: method(object({
151062
151494
  deviceId: number$1().int().nonnegative(),
@@ -151441,6 +151873,7 @@ var CompositionProblemSchema = object({
151441
151873
  "nested-field",
151442
151874
  "missing-field",
151443
151875
  "kind-mismatch",
151876
+ "source-kind-mismatch",
151444
151877
  "may-be-null",
151445
151878
  "source-missing",
151446
151879
  "source-unreadable",
@@ -151462,7 +151895,8 @@ var CompositionProblemSchema = object({
151462
151895
  "command-method-unknown",
151463
151896
  "command-source-unknown",
151464
151897
  "command-input-unknown",
151465
- "command-input-missing"
151898
+ "command-input-missing",
151899
+ "power-source-is-actuator"
151466
151900
  ]),
151467
151901
  path: string(),
151468
151902
  message: string()
@@ -152500,6 +152934,13 @@ var mediaPlayerCapability = {
152500
152934
  deviceNative: true,
152501
152935
  mode: "singleton",
152502
152936
  deviceTypes: [DeviceType.MediaPlayer],
152937
+ power: {
152938
+ kind: "methods",
152939
+ field: "state",
152940
+ offValues: ["off", "standby"],
152941
+ on: "turnOn",
152942
+ off: "turnOff"
152943
+ },
152503
152944
  methods: {
152504
152945
  turnOn: optionalMethod(deviceOnly, _void(), {
152505
152946
  kind: "mutation",
@@ -152630,7 +153071,7 @@ var mediaPlayerCapability = {
152630
153071
  isMuted: { kind: "boolean" }
152631
153072
  } }
152632
153073
  };
152633
- 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;
153074
+ DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Climate, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway, DeviceType.HeatPump, DeviceType.Camera, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Gateway, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.PetFeeder, DeviceType.MediaPlayer;
152634
153075
  var NUMBER = {
152635
153076
  kind: "fixed",
152636
153077
  result: ["number"]
@@ -152713,7 +153154,7 @@ function numeric(input) {
152713
153154
  }, ...alsoFrom === void 0 ? [] : [alsoFrom.accept]]
152714
153155
  };
152715
153156
  }
152716
- var CLIMATE_DEVICES = [DeviceType.Thermostat, DeviceType.Climate];
153157
+ var CLIMATE_DEVICES = [DeviceType.Climate];
152717
153158
  function binary(input) {
152718
153159
  return {
152719
153160
  ...input,
@@ -153035,8 +153476,8 @@ var GROUP_TEMPLATES = [
153035
153476
  actuator({
153036
153477
  id: "climate",
153037
153478
  summary: "Running when at least one thermostat or air conditioner is not off, or only when all of them are. Target temperature and fan are offered only when every device has them. A device that reports nothing is left out, never read as off.",
153038
- deviceType: DeviceType.Thermostat,
153039
- memberDeviceTypes: [DeviceType.Thermostat, DeviceType.Climate],
153479
+ deviceType: DeviceType.Climate,
153480
+ memberDeviceTypes: [DeviceType.Climate],
153040
153481
  outputCap: "group-active",
153041
153482
  outputField: "active",
153042
153483
  member: {
@@ -153079,6 +153520,118 @@ function actuator(input) {
153079
153520
  new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
153080
153521
  DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
153081
153522
  DeviceType.Camera;
153523
+ var PowerSourceRefusalReasonSchema = _enum([
153524
+ "no-power-source",
153525
+ "switch-missing",
153526
+ "switch-offline",
153527
+ "switch-unknown",
153528
+ "restart-in-progress",
153529
+ "switch-call-failed",
153530
+ "switch-is-actuator"
153531
+ ]);
153532
+ var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
153533
+ accepted: literal(false),
153534
+ reason: PowerSourceRefusalReasonSchema,
153535
+ /** One line for the operator, naming the switch. */
153536
+ message: string()
153537
+ })]);
153538
+ var PowerSourceInfoSchema = object({
153539
+ /** False when the device has no power source linked; the rest is then empty. */
153540
+ linked: boolean(),
153541
+ switchDeviceId: number$1().nullable(),
153542
+ switchName: string().nullable(),
153543
+ /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
153544
+ switchOn: boolean().nullable(),
153545
+ switchOnline: boolean().nullable(),
153546
+ restartInProgress: boolean(),
153547
+ offSeconds: number$1().int()
153548
+ });
153549
+ /** The composed slice: the switch state the link mirrors, plus the stored off time. */
153550
+ var PowerSourceStateSchema = object({
153551
+ /** Null while the switch has not reported: unknown is never `false` (D393). */
153552
+ switchOn: boolean().nullable(),
153553
+ offSeconds: number$1().int(),
153554
+ lastFetchedAt: number$1()
153555
+ });
153556
+ var POWER_SOURCE_DEVICE_TYPES = [
153557
+ DeviceType.Gateway,
153558
+ DeviceType.Camera,
153559
+ DeviceType.Sensor,
153560
+ DeviceType.MediaPlayer,
153561
+ DeviceType.Vacuum,
153562
+ DeviceType.Generic,
153563
+ DeviceType.Washer,
153564
+ DeviceType.Dryer,
153565
+ DeviceType.Dishwasher,
153566
+ DeviceType.PetFountain,
153567
+ DeviceType.Fan,
153568
+ DeviceType.Humidifier,
153569
+ DeviceType.Climate,
153570
+ DeviceType.WaterHeater
153571
+ ];
153572
+ var powerSourceCustomize = {
153573
+ version: 1,
153574
+ targets: [{
153575
+ id: "switch",
153576
+ cardinality: "scalar",
153577
+ vocabulary: {
153578
+ cap: "power-source",
153579
+ stateField: "switchOn"
153580
+ },
153581
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
153582
+ apply: "add",
153583
+ path: "switchOn",
153584
+ sources: [{
153585
+ kind: "switch",
153586
+ transforms: [{ kind: "identity" }]
153587
+ }],
153588
+ companions: [{
153589
+ kind: "constant",
153590
+ path: "offSeconds",
153591
+ value: 10,
153592
+ when: "add",
153593
+ formerValues: [0]
153594
+ }, {
153595
+ kind: "clock",
153596
+ path: "lastFetchedAt",
153597
+ when: "always"
153598
+ }],
153599
+ sourceReport: { status: "assignment-status" }
153600
+ }]
153601
+ };
153602
+ var deviceInput$2 = object({ deviceId: number$1().int().nonnegative() });
153603
+ var powerSourceCapability = {
153604
+ name: "power-source",
153605
+ scope: "device",
153606
+ mode: "singleton",
153607
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
153608
+ methods: {
153609
+ getStatus: systemMethod(deviceInput$2, PowerSourceInfoSchema, { auth: "protected" }),
153610
+ powerOn: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
153611
+ kind: "mutation",
153612
+ auth: "protected"
153613
+ }),
153614
+ powerOff: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
153615
+ kind: "mutation",
153616
+ auth: "protected"
153617
+ }),
153618
+ forceRestart: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
153619
+ kind: "mutation",
153620
+ auth: "protected"
153621
+ })
153622
+ },
153623
+ runtimeState: PowerSourceStateSchema,
153624
+ customize: powerSourceCustomize,
153625
+ /**
153626
+ * Runtime-state durability: **session** — mirrored from the linked switch on
153627
+ * its next report; a restored value would outlive the reading it names.
153628
+ *
153629
+ * See `RuntimeStateDurability`. Enforced by
153630
+ * `scripts/check-runtime-state-durability.ts`.
153631
+ */
153632
+ durability: "session",
153633
+ history: "none"
153634
+ };
153082
153635
  `${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
153083
153636
  /**
153084
153637
  * What a composition may BUILD on a device type (G2, D676): the caps a new
@@ -155634,8 +156187,14 @@ method(object({
155634
156187
  "string",
155635
156188
  "number",
155636
156189
  "boolean",
155637
- "enum"
156190
+ "enum",
156191
+ "union"
155638
156192
  ]),
156193
+ unionMembers: array(_enum([
156194
+ "string",
156195
+ "number",
156196
+ "boolean"
156197
+ ])).optional(),
155639
156198
  enumValues: array(string()).optional(),
155640
156199
  item: boolean().optional(),
155641
156200
  quantity: ReadingQuantitySchema.optional()
@@ -157740,53 +158299,6 @@ var enumSensorCapability = {
157740
158299
  * whether persisting is worth a SQLite commit. */
157741
158300
  volatileStateFields: ["lastFetchedAt", "timestamp"]
157742
158301
  };
157743
- /**
157744
- * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
157745
- * device. Carries the device's EXACT declared event vocabulary verbatim
157746
- * (NO normalization). Two shapes:
157747
- * - structured source (HA `event.*` entity) → `eventTypes` is the fixed
157748
- * declared vocabulary (e.g. ['press_short','press_long',...]).
157749
- * - generic/legacy source (HA bus events, e.g. zha_event) → `eventTypes`
157750
- * is [] (open) and `lastEvent.data` carries the complex payload.
157751
- * `seq` is monotonic so two identical events still produce distinct slice writes.
157752
- */
157753
- var EventFireSchema = object({
157754
- deviceId: number$1(),
157755
- eventType: string(),
157756
- data: record(string(), unknown()).nullable(),
157757
- timestamp: number$1().meta(readingMeta("none")),
157758
- seq: number$1().meta(readingMeta("count"))
157759
- });
157760
- var EventEmitterStatusSchema = object({
157761
- eventTypes: array(string()),
157762
- lastEvent: EventFireSchema.nullable(),
157763
- eventCountSinceStart: number$1().meta(readingMeta("count"))
157764
- });
157765
- var eventEmitterCapability = {
157766
- name: "event-emitter",
157767
- scope: "device",
157768
- deviceNative: true,
157769
- mode: "singleton",
157770
- deviceTypes: [DeviceType.EventEmitter],
157771
- methods: {},
157772
- events: { onEvent: { data: EventFireSchema } },
157773
- status: {
157774
- schema: EventEmitterStatusSchema,
157775
- kind: "push"
157776
- },
157777
- runtimeState: EventEmitterStatusSchema,
157778
- /**
157779
- * Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
157780
- *
157781
- * See `RuntimeStateDurability`. Enforced by
157782
- * `scripts/check-runtime-state-durability.ts`.
157783
- */
157784
- durability: "session",
157785
- /**
157786
- * History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
157787
- */
157788
- history: "none"
157789
- };
157790
158302
  var IdentitySchema = object({
157791
158303
  id: string(),
157792
158304
  name: string(),
@@ -158295,8 +158807,85 @@ list: method(_void(), array(FailureContributionSchema).readonly()) },
158295
158807
  * - `FanPreset` — preset selector
158296
158808
  * - `FanDirection` — direction toggle (ceiling fans)
158297
158809
  * - `FanOscillating` — oscillation toggle
158810
+ *
158811
+ * Per-axis oscillation (`oscillationAxes`, `setOscillationAxis`, D1034): an air
158812
+ * circulator sweeps horizontally and vertically, each axis with its own
158813
+ * switch, fixed angle, sweep bounds and limits. A provider may report them
158814
+ * natively; otherwise the OPERATOR links sibling devices to each field in
158815
+ * Customize (a `replace` over the fields listed in `overridable` — nothing is
158816
+ * linked or inferred by itself), and a write to a linked field is forwarded to
158817
+ * its source. `oscillating` stays the single summary flag: when axes exist it
158818
+ * means "any axis oscillates" (`anyAxisOscillating`).
158298
158819
  */
158299
158820
  var FanDirectionSchema = _enum(["forward", "reverse"]);
158821
+ var FAN_OSCILLATION_AXES = ["horizontal", "vertical"];
158822
+ var FanOscillationAxisNameSchema = _enum(FAN_OSCILLATION_AXES);
158823
+ var FanOscillationAxisFieldSchema = _enum([
158824
+ "oscillating",
158825
+ "angle",
158826
+ "sweepFrom",
158827
+ "sweepTo"
158828
+ ]);
158829
+ /** The limits of one axis, read from the source that serves its angle. */
158830
+ var FAN_OSCILLATION_AXIS_LIMITS = [
158831
+ "min",
158832
+ "max",
158833
+ "step"
158834
+ ];
158835
+ /**
158836
+ * One oscillation axis. Every reading the device has not reported is `null`,
158837
+ * never `0` (D393): `0°` is a real position. Each leaf defaults to `null`, so
158838
+ * a slice that names only the leaves it knows (a Customize link of one field)
158839
+ * is still a whole axis.
158840
+ */
158841
+ var FanOscillationAxisSchema = object({
158842
+ /** Whether the axis sweeps. */
158843
+ oscillating: boolean().nullable().default(null),
158844
+ /** The fixed position (degrees) the axis holds when it does not sweep. */
158845
+ angle: number$1().nullable().default(null),
158846
+ /** The sweep bounds (degrees): left → right, bottom → top. */
158847
+ sweepFrom: number$1().nullable().default(null),
158848
+ sweepTo: number$1().nullable().default(null),
158849
+ /** The angles the axis accepts. Null when the device states none. */
158850
+ min: number$1().nullable().default(null),
158851
+ max: number$1().nullable().default(null),
158852
+ step: number$1().nullable().default(null)
158853
+ });
158854
+ /** Both axes; an axis the device does not have is `null`. */
158855
+ var FanOscillationAxesSchema = object({
158856
+ horizontal: FanOscillationAxisSchema.nullable().default(null),
158857
+ vertical: FanOscillationAxisSchema.nullable().default(null)
158858
+ });
158859
+ var FanOscillationAxisRefusalSchema = _enum([
158860
+ "nothing-to-set",
158861
+ "axis-not-linked",
158862
+ "out-of-range",
158863
+ "source-gone",
158864
+ "source-unknown",
158865
+ "source-call-failed"
158866
+ ]);
158867
+ var FanOscillationAxisResultSchema = discriminatedUnion("status", [object({ status: literal("applied") }), object({
158868
+ status: literal("refused"),
158869
+ reason: FanOscillationAxisRefusalSchema,
158870
+ /** The field at fault, when one is. */
158871
+ field: FanOscillationAxisFieldSchema.optional(),
158872
+ /** One line for the operator, naming the axis, the field and the source. */
158873
+ detail: string(),
158874
+ /** Fields that DID land before the refusal (writes run in order, stop at the first failure). */
158875
+ applied: array(FanOscillationAxisFieldSchema)
158876
+ })]);
158877
+ var SetOscillationAxisInputSchema = object({
158878
+ deviceId: number$1().int().nonnegative(),
158879
+ axis: FanOscillationAxisNameSchema,
158880
+ oscillating: boolean().optional(),
158881
+ angle: number$1().optional(),
158882
+ sweepFrom: number$1().optional(),
158883
+ sweepTo: number$1().optional()
158884
+ });
158885
+ /** The state path of one axis field: `oscillationAxes.<axis>.<field>`. */
158886
+ function fanAxisPath(axis, field) {
158887
+ return `oscillationAxes.${axis}.${field}`;
158888
+ }
158300
158889
  var FanControlStatusSchema = object({
158301
158890
  /** Active speed as 0..100 inclusive. Null when the device has no
158302
158891
  * speed surface (single-speed fan). */
@@ -158315,9 +158904,102 @@ var FanControlStatusSchema = object({
158315
158904
  /** Oscillation toggle. Null when the device has no oscillation
158316
158905
  * surface. */
158317
158906
  oscillating: boolean().nullable(),
158907
+ /**
158908
+ * Per-axis oscillation (air circulators). Absent when the device has no
158909
+ * per-axis surface and nothing is linked in Customize.
158910
+ */
158911
+ oscillationAxes: FanOscillationAxesSchema.optional(),
158318
158912
  /** Ms epoch when the slice was last updated. */
158319
158913
  lastChangedAt: number$1()
158320
158914
  });
158915
+ var FAN_CUSTOMIZE_DEVICE_TYPES = [DeviceType.Fan];
158916
+ /** The Customize section the axis targets are listed under. */
158917
+ var AXES_SECTION = "oscillation-axes";
158918
+ function axisOscillatingTarget(axis) {
158919
+ return {
158920
+ id: `${axis}-oscillating`,
158921
+ cardinality: "scalar",
158922
+ vocabulary: {
158923
+ cap: "fan-control",
158924
+ stateField: "oscillating"
158925
+ },
158926
+ deviceTypes: FAN_CUSTOMIZE_DEVICE_TYPES,
158927
+ apply: "replace",
158928
+ section: AXES_SECTION,
158929
+ path: fanAxisPath(axis, "oscillating"),
158930
+ sources: [{
158931
+ kind: "switch",
158932
+ transforms: [{ kind: "identity" }]
158933
+ }],
158934
+ sourceReport: { status: "assignment-status" }
158935
+ };
158936
+ }
158937
+ /**
158938
+ * A numeric axis field. The `angle` link also carries the axis limits, read
158939
+ * from the SAME linked control's own range (`min`/`max`/`step`), so the limits
158940
+ * are the source's, never guessed.
158941
+ */
158942
+ function axisNumericTarget(axis, field) {
158943
+ const base = {
158944
+ id: `${axis}-${field}`,
158945
+ cardinality: "scalar",
158946
+ vocabulary: { cap: "fan-control" },
158947
+ deviceTypes: FAN_CUSTOMIZE_DEVICE_TYPES,
158948
+ apply: "replace",
158949
+ section: AXES_SECTION,
158950
+ path: fanAxisPath(axis, field),
158951
+ sources: [{
158952
+ kind: "numeric",
158953
+ transforms: [{ kind: "identity" }]
158954
+ }],
158955
+ sourceReport: { status: "assignment-status" }
158956
+ };
158957
+ if (field !== "angle") return base;
158958
+ return {
158959
+ ...base,
158960
+ companions: FAN_OSCILLATION_AXIS_LIMITS.map((limit) => ({
158961
+ kind: "source-field",
158962
+ path: fanAxisPath(axis, limit),
158963
+ field: limit
158964
+ }))
158965
+ };
158966
+ }
158967
+ var AXIS_TARGETS = FAN_OSCILLATION_AXES.flatMap((axis) => [
158968
+ axisOscillatingTarget(axis),
158969
+ axisNumericTarget(axis, "angle"),
158970
+ axisNumericTarget(axis, "sweepFrom"),
158971
+ axisNumericTarget(axis, "sweepTo")
158972
+ ]);
158973
+ /** A select (an enum control) the operator links to the fan's `preset`. */
158974
+ var PRESET_TARGET = {
158975
+ id: "preset",
158976
+ cardinality: "scalar",
158977
+ vocabulary: { cap: "fan-control" },
158978
+ deviceTypes: FAN_CUSTOMIZE_DEVICE_TYPES,
158979
+ apply: "replace",
158980
+ path: "preset",
158981
+ sources: [{
158982
+ kind: "field",
158983
+ valueKinds: ["string"],
158984
+ transforms: [{ kind: "identity" }]
158985
+ }],
158986
+ sourceReport: { status: "assignment-status" }
158987
+ };
158988
+ var FAN_CONTROL_TARGETS = [...AXIS_TARGETS, PRESET_TARGET];
158989
+ /**
158990
+ * Customize (D1034): the fan already serves `fan-control` natively, so every
158991
+ * target is a `replace` over a field listed in `overridable` — the axis leaves
158992
+ * and `preset`, nothing else. Nothing is pre-linked: the operator picks each
158993
+ * source (D356).
158994
+ */
158995
+ var fanControlCustomize = {
158996
+ version: 1,
158997
+ overridable: FAN_CONTROL_TARGETS.map((target) => ({
158998
+ path: target.path,
158999
+ by: target.id
159000
+ })),
159001
+ targets: FAN_CONTROL_TARGETS
159002
+ };
158321
159003
  var fanControlCapability = {
158322
159004
  name: "fan-control",
158323
159005
  scope: "device",
@@ -158352,6 +159034,18 @@ var fanControlCapability = {
158352
159034
  }), _void(), {
158353
159035
  kind: "mutation",
158354
159036
  auth: "protected"
159037
+ }),
159038
+ /**
159039
+ * Sets one oscillation axis: its switch, fixed angle and/or sweep bounds.
159040
+ * Fields left out are untouched. A field linked in Customize is forwarded
159041
+ * to its linked source (D1034); otherwise the native provider serves it;
159042
+ * neither → `axis-not-linked`. Ranges are checked against the axis limits
159043
+ * before anything is written; writes run in order and stop at the first
159044
+ * failure, which the result names.
159045
+ */
159046
+ setOscillationAxis: optionalMethod(SetOscillationAxisInputSchema, FanOscillationAxisResultSchema, {
159047
+ kind: "mutation",
159048
+ auth: "protected"
158355
159049
  })
158356
159050
  },
158357
159051
  status: {
@@ -158363,6 +159057,7 @@ var fanControlCapability = {
158363
159057
  * sliders read `speed` for live updates.
158364
159058
  */
158365
159059
  runtimeState: FanControlStatusSchema,
159060
+ customize: fanControlCustomize,
158366
159061
  /**
158367
159062
  * Runtime-state durability: **session** — as `brightness`.
158368
159063
  *
@@ -158382,16 +159077,33 @@ var fanControlCapability = {
158382
159077
  oscillating: { kind: "boolean" }
158383
159078
  } }
158384
159079
  };
159080
+ /** One axis as a preset wants it; an absent field is left as it is. */
159081
+ var FanPresetAxisSchema = object({
159082
+ oscillating: boolean().optional(),
159083
+ angle: number$1().optional(),
159084
+ sweepFrom: number$1().optional(),
159085
+ sweepTo: number$1().optional()
159086
+ });
159087
+ /** The fan-control state a preset sets; an absent field is left as it is. */
159088
+ var FanPresetStateSchema = object({
159089
+ speed: number$1().min(0).max(100).optional(),
159090
+ /** The fan's own preset mode (or the linked select's option). */
159091
+ preset: string().min(1).optional(),
159092
+ direction: FanDirectionSchema.optional(),
159093
+ oscillationAxes: object({
159094
+ horizontal: FanPresetAxisSchema.optional(),
159095
+ vertical: FanPresetAxisSchema.optional()
159096
+ }).optional()
159097
+ });
158385
159098
  var FanPresetSchema = object({
158386
159099
  /** Stable key; never reused after a delete within one device's list. */
158387
159100
  id: string().min(1).max(64),
158388
159101
  /** What the operator and a voice assistant call it. */
158389
159102
  name: string().trim().min(1).max(40),
158390
- steps: array(ActionStepSchema).min(1).max(20)
159103
+ state: FanPresetStateSchema
158391
159104
  });
158392
159105
  var FanPresetsRefusalSchema = _enum([
158393
- "not-sibling",
158394
- "bad-target",
159106
+ "empty-state",
158395
159107
  "duplicate-name",
158396
159108
  "duplicate-id",
158397
159109
  "too-many",
@@ -158403,72 +159115,55 @@ var FanPresetsSetResultSchema = discriminatedUnion("status", [object({
158403
159115
  }), object({
158404
159116
  status: literal("refused"),
158405
159117
  reason: FanPresetsRefusalSchema,
158406
- /** Names the preset and step at fault. */
159118
+ /** Names the preset at fault. */
158407
159119
  detail: string()
158408
159120
  })]);
158409
- var FanPresetStepResultSchema = object({
158410
- index: number$1().int().nonnegative(),
159121
+ var FanPresetFieldResultSchema = object({
159122
+ /** The state path: `speed`, `preset`, `direction`, `oscillationAxes.horizontal.angle`. */
159123
+ field: string(),
158411
159124
  outcome: _enum([
158412
159125
  "applied",
158413
159126
  "failed",
158414
159127
  "not-run",
158415
159128
  "refused"
158416
159129
  ]),
158417
- deviceId: number$1().int().nonnegative().optional(),
158418
- cap: string().optional(),
158419
- method: string().optional(),
158420
159130
  /** The cause, for every outcome but `applied`. */
158421
159131
  message: string().optional()
158422
159132
  });
158423
159133
  var FanPresetApplyResultSchema = object({
158424
- /** `applied`: every step ran. `partial`: some ran, one failed. `refused`: nothing ran. */
159134
+ /** `applied`: every field landed. `partial`: some did, one did not. `refused`: nothing ran. */
158425
159135
  status: _enum([
158426
159136
  "applied",
158427
159137
  "partial",
158428
159138
  "refused"
158429
159139
  ]),
158430
- steps: array(FanPresetStepResultSchema)
159140
+ fields: array(FanPresetFieldResultSchema)
158431
159141
  });
158432
159142
  var FanCaptureFieldSchema = _enum([
158433
159143
  "speed",
158434
- "oscillating",
158435
159144
  "direction",
158436
- "preset"
159145
+ "preset",
159146
+ "oscillationAxes"
158437
159147
  ]);
158438
- var FanCaptureOmissionSchema = object({
158439
- /** A fan field (`speed`) or `step <n>` for a sibling step. */
158440
- what: string(),
158441
- /** Why no value was taken: unknown reading (never stored as 0, D393), or a step that cannot be read. */
158442
- reason: string()
158443
- });
158444
- var FanCaptureItemSchema = object({
158445
- group: _enum([
158446
- "fan",
158447
- "oscillation",
158448
- "angles"
158449
- ]),
158450
- /** What the step sets, in the operator's words (a device name, a fan field). */
158451
- label: string()
158452
- });
158453
159148
  var FanPresetCaptureResultSchema = object({
158454
- /** The steps filled from the device's current values; NOT saved. */
158455
- steps: array(ActionStepSchema),
158456
- /** One entry per step, same order: its review group and label. */
158457
- items: array(FanCaptureItemSchema),
158458
- omitted: array(FanCaptureOmissionSchema)
159149
+ /** The fan's CURRENT fan-control state, as a preset; NOT saved. */
159150
+ state: FanPresetStateSchema,
159151
+ omitted: array(object({
159152
+ /** A state path (`speed`, `oscillationAxes.vertical.angle`). */
159153
+ what: string(),
159154
+ /** Why no value was taken: an unknown reading is never stored as 0 (D393). */
159155
+ reason: string()
159156
+ }))
158459
159157
  });
158460
- var deviceInput$2 = object({ deviceId: number$1().int().nonnegative() });
159158
+ var deviceInput$1 = object({ deviceId: number$1().int().nonnegative() });
158461
159159
  DeviceType.Fan;
158462
- method(deviceInput$2, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$2.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
159160
+ method(deviceInput$1, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$1.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
158463
159161
  kind: "mutation",
158464
159162
  auth: "admin"
158465
- }), method(deviceInput$2.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
159163
+ }), method(deviceInput$1.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
158466
159164
  kind: "mutation",
158467
159165
  auth: "protected"
158468
- }), method(deviceInput$2.extend({
158469
- fields: array(FanCaptureFieldSchema).optional(),
158470
- steps: array(ActionStepSchema).max(20).default([])
158471
- }), FanPresetCaptureResultSchema, { auth: "protected" });
159166
+ }), method(deviceInput$1.extend({ fields: array(FanCaptureFieldSchema).optional() }), FanPresetCaptureResultSchema, { auth: "protected" });
158472
159167
  /**
158473
159168
  * Per-device feature/identity probe slice. Holds the runtime-resolved
158474
159169
  * truth about what a device CAN do — which the kernel uses to:
@@ -158680,8 +159375,7 @@ var groupActiveCapability = {
158680
159375
  DeviceType.Valve,
158681
159376
  DeviceType.Lock,
158682
159377
  DeviceType.MediaPlayer,
158683
- DeviceType.Climate,
158684
- DeviceType.Thermostat
159378
+ DeviceType.Climate
158685
159379
  ],
158686
159380
  methods: {},
158687
159381
  status: {
@@ -158723,7 +159417,6 @@ var groupCommandsCapability = {
158723
159417
  DeviceType.Valve,
158724
159418
  DeviceType.Lock,
158725
159419
  DeviceType.MediaPlayer,
158726
- DeviceType.Thermostat,
158727
159420
  DeviceType.Climate
158728
159421
  ],
158729
159422
  methods: {},
@@ -158779,7 +159472,6 @@ var groupStatusCapability = {
158779
159472
  DeviceType.Valve,
158780
159473
  DeviceType.Lock,
158781
159474
  DeviceType.MediaPlayer,
158782
- DeviceType.Thermostat,
158783
159475
  DeviceType.Climate
158784
159476
  ],
158785
159477
  methods: {},
@@ -159108,7 +159800,7 @@ var heatingValveCapability = {
159108
159800
  scope: "device",
159109
159801
  deviceNative: true,
159110
159802
  mode: "singleton",
159111
- deviceTypes: [DeviceType.Thermostat],
159803
+ deviceTypes: [DeviceType.Climate],
159112
159804
  methods: {},
159113
159805
  status: {
159114
159806
  schema: HeatingValveStatusSchema,
@@ -159138,13 +159830,18 @@ var heatingValveCapability = {
159138
159830
  * retried in a loop - D49); a future one is re-armed.
159139
159831
  *
159140
159832
  * What a device may be run for, and for how long at most, is per device type
159141
- * ({@link TIMED_RUN_LIMITS}): the maximum is a safety bound, not a preference,
159833
+ * and role ({@link timedRunLimitOf}): the maximum is a safety bound, not a preference,
159142
159834
  * so a request above it is REFUSED with a typed reason, never clamped.
159143
159835
  */
159144
159836
  var TimedRunUnitSchema = _enum(["s", "min"]);
159145
159837
  _enum(["switch", "pet-fountain"]);
159146
- DeviceType.Heater, DeviceType.PetFountain;
159147
- var TIMED_RUN_DEVICE_TYPES = [DeviceType.Heater, DeviceType.PetFountain];
159838
+ /**
159839
+ * The device types `timed-run` may be offered on. A `switch` is narrowed by
159840
+ * role ({@link TIMED_RUN_DEVICE_ROLES}): only a plug-in heater runs on a timer.
159841
+ */
159842
+ var TIMED_RUN_DEVICE_TYPES = [DeviceType.Switch, DeviceType.PetFountain];
159843
+ /** The roles that make a device of these types timed-run-able (D1033). */
159844
+ var TIMED_RUN_DEVICE_ROLES = { [DeviceType.Switch]: [DeviceRole.SwitchHeater] };
159148
159845
  /** One duration, as the one-tap run asks for it. */
159149
159846
  var TimedRunQuickRunSchema = object({
159150
159847
  duration: number$1().positive().finite(),
@@ -159194,6 +159891,7 @@ var timedRunCapability = {
159194
159891
  kind: "wrapper",
159195
159892
  defaultActive: true,
159196
159893
  deviceTypes: TIMED_RUN_DEVICE_TYPES,
159894
+ deviceRoles: TIMED_RUN_DEVICE_ROLES,
159197
159895
  deviceConfig: { ui: {
159198
159896
  kind: "derived-form",
159199
159897
  builderId: "timed-run",
@@ -159354,8 +160052,8 @@ var HeroSceneSchema = object({
159354
160052
  /** 0..1: volume, cover position, cycle progress. */
159355
160053
  level: number$1().min(0).max(1).nullable()
159356
160054
  });
159357
- 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.HeatPump, 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;
159358
- DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
160055
+ DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, 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.Dryer, DeviceType.Gateway;
160056
+ DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
159359
160057
  /** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
159360
160058
  var HeroTextSchema = object({
159361
160059
  en: string(),
@@ -159740,8 +160438,8 @@ var HeroRowModelSchema = object({
159740
160438
  extras: array(HeroControlSchema).max(2).optional(),
159741
160439
  trailing: HeroFactSchema.nullable()
159742
160440
  });
159743
- DeviceType.Climate, DeviceType.Thermostat;
159744
- DeviceType.Climate, DeviceType.Thermostat, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
160441
+ DeviceType.Climate;
160442
+ DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
159745
160443
  /**
159746
160444
  * hero-layout — what a device's hero says (D1023). Read-only: the FIXED
159747
160445
  * layouts live in `@camstack/types` and nothing here stores or edits one.
@@ -159773,7 +160471,10 @@ method(heroInput, HeroModelSchema.nullable(), {
159773
160471
  }), method(rowModelsInput, array(HeroRowModelSchema.nullable()), {
159774
160472
  auth: "protected",
159775
160473
  role: "viewer"
159776
- }), method(object({ deviceType: string() }), HeroLayoutRowsSchema, {
160474
+ }), method(object({
160475
+ deviceType: string(),
160476
+ role: string().nullable().optional()
160477
+ }), HeroLayoutRowsSchema, {
159777
160478
  auth: "protected",
159778
160479
  role: "viewer"
159779
160480
  });
@@ -159820,6 +160521,11 @@ var humidifierCapability = {
159820
160521
  deviceNative: true,
159821
160522
  mode: "singleton",
159822
160523
  deviceTypes: [DeviceType.Humidifier],
160524
+ power: {
160525
+ kind: "field",
160526
+ field: "on",
160527
+ set: "setOn"
160528
+ },
159823
160529
  methods: {
159824
160530
  setOn: method(object({
159825
160531
  deviceId: number$1().int().nonnegative(),
@@ -159893,7 +160599,7 @@ var humiditySensorCapability = {
159893
160599
  scope: "device",
159894
160600
  deviceNative: true,
159895
160601
  mode: "singleton",
159896
- deviceTypes: [DeviceType.Sensor, DeviceType.Thermostat],
160602
+ deviceTypes: [DeviceType.Sensor, DeviceType.Climate],
159897
160603
  methods: {},
159898
160604
  status: {
159899
160605
  schema: HumiditySensorStatusSchema,
@@ -160187,6 +160893,12 @@ var IntegrationLiteSchema = object({
160187
160893
  var AvailableIntegrationTypeSchema = object({
160188
160894
  addonId: string(),
160189
160895
  name: string(),
160896
+ /**
160897
+ * Product name a new integration is prefilled from (`<label> - Home`).
160898
+ * Absent: the client uses `name`. Set when the catalog title is not the
160899
+ * product (Bosch SHC, MQTT).
160900
+ */
160901
+ providerLabel: string().optional(),
160190
160902
  description: string(),
160191
160903
  iconUrl: string().nullable(),
160192
160904
  color: string(),
@@ -173116,7 +173828,18 @@ var OauthIntegrationDescriptorSchema = object({
173116
173828
  * The value is baked into the authorization code at `/authorize` and travels
173117
173829
  * on the tokens, so editing this field changes FUTURE links only.
173118
173830
  */
173119
- refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional()
173831
+ refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional(),
173832
+ /**
173833
+ * The integration instances an account can be linked to (planning#415),
173834
+ * beside the default one. `/api/oauth2/authorize?instance=<id>` is accepted
173835
+ * only for an id listed here; with no `instance=` the link is made to the
173836
+ * default instance, which is never listed and always accepted — it is the
173837
+ * address third parties already hold. Omit for a single-instance integration.
173838
+ */
173839
+ instances: array(object({
173840
+ id: string(),
173841
+ displayName: string()
173842
+ })).optional()
173120
173843
  });
173121
173844
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
173122
173845
  /**
@@ -173652,6 +174375,11 @@ var petFountainCapability = {
173652
174375
  deviceNative: true,
173653
174376
  mode: "singleton",
173654
174377
  deviceTypes: [DeviceType.PetFountain],
174378
+ power: {
174379
+ kind: "field",
174380
+ field: "pumpRunning",
174381
+ set: "setPump"
174382
+ },
173655
174383
  methods: {
173656
174384
  /** Start or stop the pump. */
173657
174385
  setPump: method(object({
@@ -175227,7 +175955,6 @@ var POWER_METER_DEVICE_TYPES = [
175227
175955
  DeviceType.Light,
175228
175956
  DeviceType.Fan,
175229
175957
  DeviceType.Climate,
175230
- DeviceType.Thermostat,
175231
175958
  DeviceType.Humidifier,
175232
175959
  DeviceType.WaterHeater,
175233
175960
  DeviceType.MediaPlayer,
@@ -175236,8 +175963,7 @@ var POWER_METER_DEVICE_TYPES = [
175236
175963
  DeviceType.Dishwasher,
175237
175964
  DeviceType.Vacuum,
175238
175965
  DeviceType.LawnMower,
175239
- DeviceType.PetFeeder,
175240
- DeviceType.Heater
175966
+ DeviceType.PetFeeder
175241
175967
  ];
175242
175968
  /** Everything but a bare `Sensor`: a sensor that takes its reading from another sensor adds nothing. */
175243
175969
  var POWER_METER_CUSTOMIZE_DEVICE_TYPES = POWER_METER_DEVICE_TYPES.filter((type) => type !== DeviceType.Sensor);
@@ -175350,117 +176076,6 @@ var powerMeterCapability = {
175350
176076
  volatileStateFields: ["lastFetchedAt"],
175351
176077
  customize: powerMeterCustomize
175352
176078
  };
175353
- var PowerSourceRefusalReasonSchema = _enum([
175354
- "no-power-source",
175355
- "switch-missing",
175356
- "switch-offline",
175357
- "switch-unknown",
175358
- "restart-in-progress",
175359
- "switch-call-failed"
175360
- ]);
175361
- var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
175362
- accepted: literal(false),
175363
- reason: PowerSourceRefusalReasonSchema,
175364
- /** One line for the operator, naming the switch. */
175365
- message: string()
175366
- })]);
175367
- var PowerSourceInfoSchema = object({
175368
- /** False when the device has no power source linked; the rest is then empty. */
175369
- linked: boolean(),
175370
- switchDeviceId: number$1().nullable(),
175371
- switchName: string().nullable(),
175372
- /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
175373
- switchOn: boolean().nullable(),
175374
- switchOnline: boolean().nullable(),
175375
- restartInProgress: boolean(),
175376
- offSeconds: number$1().int()
175377
- });
175378
- /** The composed slice: the switch state the link mirrors, plus the stored off time. */
175379
- var PowerSourceStateSchema = object({
175380
- /** Null while the switch has not reported: unknown is never `false` (D393). */
175381
- switchOn: boolean().nullable(),
175382
- offSeconds: number$1().int(),
175383
- lastFetchedAt: number$1()
175384
- });
175385
- var POWER_SOURCE_DEVICE_TYPES = [
175386
- DeviceType.Gateway,
175387
- DeviceType.Camera,
175388
- DeviceType.Sensor,
175389
- DeviceType.MediaPlayer,
175390
- DeviceType.Vacuum,
175391
- DeviceType.Generic,
175392
- DeviceType.Washer,
175393
- DeviceType.Dryer,
175394
- DeviceType.Dishwasher,
175395
- DeviceType.PetFountain,
175396
- DeviceType.Fan,
175397
- DeviceType.Humidifier,
175398
- DeviceType.Climate,
175399
- DeviceType.WaterHeater
175400
- ];
175401
- var powerSourceCustomize = {
175402
- version: 1,
175403
- targets: [{
175404
- id: "switch",
175405
- cardinality: "scalar",
175406
- vocabulary: {
175407
- cap: "power-source",
175408
- stateField: "switchOn"
175409
- },
175410
- deviceTypes: POWER_SOURCE_DEVICE_TYPES,
175411
- apply: "add",
175412
- path: "switchOn",
175413
- sources: [{
175414
- kind: "switch",
175415
- transforms: [{ kind: "identity" }]
175416
- }],
175417
- companions: [{
175418
- kind: "constant",
175419
- path: "offSeconds",
175420
- value: 10,
175421
- when: "add",
175422
- formerValues: [0]
175423
- }, {
175424
- kind: "clock",
175425
- path: "lastFetchedAt",
175426
- when: "always"
175427
- }],
175428
- sourceReport: { status: "assignment-status" }
175429
- }]
175430
- };
175431
- var deviceInput$1 = object({ deviceId: number$1().int().nonnegative() });
175432
- var powerSourceCapability = {
175433
- name: "power-source",
175434
- scope: "device",
175435
- mode: "singleton",
175436
- deviceTypes: POWER_SOURCE_DEVICE_TYPES,
175437
- methods: {
175438
- getStatus: systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "protected" }),
175439
- powerOn: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
175440
- kind: "mutation",
175441
- auth: "protected"
175442
- }),
175443
- powerOff: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
175444
- kind: "mutation",
175445
- auth: "protected"
175446
- }),
175447
- forceRestart: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
175448
- kind: "mutation",
175449
- auth: "protected"
175450
- })
175451
- },
175452
- runtimeState: PowerSourceStateSchema,
175453
- customize: powerSourceCustomize,
175454
- /**
175455
- * Runtime-state durability: **session** — mirrored from the linked switch on
175456
- * its next report; a restored value would outlive the reading it names.
175457
- *
175458
- * See `RuntimeStateDurability`. Enforced by
175459
- * `scripts/check-runtime-state-durability.ts`.
175460
- */
175461
- durability: "session",
175462
- history: "none"
175463
- };
175464
176079
  /**
175465
176080
  * Presence cap. Models HA `person.*` and `device_tracker.*` entities
175466
176081
  * on `DeviceType.Presence`. Read-only — no setters: presence is
@@ -179487,9 +180102,7 @@ var RUNNING_CUSTOMIZE_DEVICE_TYPES = [
179487
180102
  DeviceType.Humidifier,
179488
180103
  DeviceType.Fan,
179489
180104
  DeviceType.Climate,
179490
- DeviceType.Thermostat,
179491
- DeviceType.PetFeeder,
179492
- DeviceType.Heater
180105
+ DeviceType.PetFeeder
179493
180106
  ];
179494
180107
  var runningStateCapability = {
179495
180108
  name: "running-state",
@@ -180865,6 +181478,13 @@ var SsoBridgeClaimsSchema = object({
180865
181478
  /** OAuth authorization-code binding — set only on `oauth-code` tokens. */
180866
181479
  redirectUri: string().optional(),
180867
181480
  integrationId: string().optional(),
181481
+ /**
181482
+ * The integration INSTANCE an OAuth link was made for (planning#415). Set on
181483
+ * `oauth-code`, `oauth-access` and `oauth-refresh` tokens of a link made
181484
+ * with `instance=`; absent on a link to the default instance. A cloud relay
181485
+ * reads it off the access token to route; the hub answers from the session.
181486
+ */
181487
+ instanceId: string().optional(),
180868
181488
  /** JWT ID — unique per issued code; consumed-set enforces single-use. */
180869
181489
  jti: string().optional(),
180870
181490
  /** PKCE S256 challenge — set only on `oauth-code` tokens issued to a public
@@ -181681,8 +182301,7 @@ var switchCapability = {
181681
182301
  DeviceType.Switch,
181682
182302
  DeviceType.Siren,
181683
182303
  DeviceType.Light,
181684
- DeviceType.Fan,
181685
- DeviceType.Heater
182304
+ DeviceType.Fan
181686
182305
  ],
181687
182306
  methods: { setState: method(object({
181688
182307
  deviceId: number$1(),
@@ -182376,7 +182995,7 @@ var temperatureSensorCapability = {
182376
182995
  scope: "device",
182377
182996
  deviceNative: true,
182378
182997
  mode: "singleton",
182379
- deviceTypes: [DeviceType.Sensor, DeviceType.Thermostat],
182998
+ deviceTypes: [DeviceType.Sensor, DeviceType.Climate],
182380
182999
  methods: {},
182381
183000
  status: {
182382
183001
  schema: TemperatureSensorStatusSchema,
@@ -183244,6 +183863,8 @@ var OauthSessionSummarySchema = object({
183244
183863
  userId: string(),
183245
183864
  username: string(),
183246
183865
  integrationId: string(),
183866
+ /** The instance the link was made for; `null` = the default instance. */
183867
+ instanceId: string().nullable().optional(),
183247
183868
  scopes: array(TokenScopeSchema),
183248
183869
  createdAt: number$1(),
183249
183870
  lastUsedAt: number$1(),
@@ -183343,6 +183964,9 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
183343
183964
  access: "view"
183344
183965
  }), method(object({
183345
183966
  integrationId: string(),
183967
+ /** The integration instance the link is for. Omit for the default
183968
+ * instance — never pass the addon id to mean it. */
183969
+ instanceId: string().optional(),
183346
183970
  userId: string(),
183347
183971
  username: string(),
183348
183972
  scopes: array(TokenScopeSchema),
@@ -183381,7 +184005,13 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
183381
184005
  }), method(object({ token: string() }), object({
183382
184006
  userId: string(),
183383
184007
  username: string(),
183384
- scopes: array(TokenScopeSchema)
184008
+ scopes: array(TokenScopeSchema),
184009
+ /** The instance the link was made for, read from the SESSION.
184010
+ * Absent = the default instance. `oauthLinkServesInstance` is the
184011
+ * helper a per-instance route calls to compare it with the instance
184012
+ * of its path; no route declares `perInstance` yet (the Alexa
184013
+ * per-instance route, T3, is the first consumer). */
184014
+ instanceId: string().optional()
183385
184015
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
183386
184016
  userId: string(),
183387
184017
  issuer: string()
@@ -184023,6 +184653,13 @@ var waterHeaterCapability = {
184023
184653
  deviceNative: true,
184024
184654
  mode: "singleton",
184025
184655
  deviceTypes: [DeviceType.WaterHeater],
184656
+ power: {
184657
+ kind: "mode",
184658
+ field: "operationMode",
184659
+ offValue: "off",
184660
+ set: "setOperationMode",
184661
+ lastField: "lastActiveMode"
184662
+ },
184026
184663
  methods: {
184027
184664
  setTargetTemp: method(object({
184028
184665
  deviceId: number$1().int().nonnegative(),
@@ -187286,15 +187923,16 @@ var BaseDeviceProvider = class extends BaseAddon {
187286
187923
  });
187287
187924
  const meta = await this.ctx.api.deviceManager.loadMeta.query({ deviceId: id });
187288
187925
  if (meta === null) throw new Error(`${this.providerName}: no persisted meta for "${stableId}" (id ${id}) — cannot reload`);
187289
- const deviceType = Object.values(DeviceType).find((t) => t === meta.type);
187290
- const Class = deviceType !== void 0 ? this.deviceClasses[deviceType] : void 0;
187926
+ const Class = this.deviceClassForRow({
187927
+ type: meta.type,
187928
+ stableId
187929
+ });
187291
187930
  if (!Class) throw new Error(`${this.providerName}: no device class for type "${meta.type}" — "${stableId}" is an accessory child; reload its parent instead`);
187292
187931
  await devices.create(stableId, Class, {}, meta.parentDeviceId ?? null);
187293
187932
  const rows = await this.ctx.api.deviceManager.listPersistedByAddon.query({ addonId: this.addonId });
187294
187933
  for (const row of rows) {
187295
187934
  if (row.parentDeviceId !== id) continue;
187296
- const childType = Object.values(DeviceType).find((t) => t === row.type);
187297
- const ChildClass = childType !== void 0 ? this.deviceClasses[childType] : void 0;
187935
+ const ChildClass = this.deviceClassForRow(row);
187298
187936
  if (!ChildClass) continue;
187299
187937
  try {
187300
187938
  await devices.create(row.stableId, ChildClass, {}, id);
@@ -187321,6 +187959,16 @@ var BaseDeviceProvider = class extends BaseAddon {
187321
187959
  return { deviceId: id };
187322
187960
  }
187323
187961
  /**
187962
+ * The class a PERSISTED row is rebuilt with. Default: by type, from
187963
+ * `deviceClasses`. A provider whose distinct devices share one type (D1033:
187964
+ * a radiator valve and a room climate are both `climate`) overrides this
187965
+ * and tells them apart by the row's stable id or config.
187966
+ */
187967
+ deviceClassForRow(row) {
187968
+ const type = Object.values(DeviceType).find((t) => t === row.type);
187969
+ return type !== void 0 ? this.deviceClasses[type] : void 0;
187970
+ }
187971
+ /**
187324
187972
  * Restore devices from persisted state. Two-pass:
187325
187973
  *
187326
187974
  * 1. **Top-level pass** — invokes `kernel.devices.create()` for every
@@ -187381,7 +188029,7 @@ var BaseDeviceProvider = class extends BaseAddon {
187381
188029
  restored.add(saved.id);
187382
188030
  return;
187383
188031
  }
187384
- const Class = this.deviceClasses[saved.type];
188032
+ const Class = this.deviceClassForRow(saved);
187385
188033
  if (!Class) throw new Error(`no device class registered for type "${saved.type}"`);
187386
188034
  if (saved.parentDeviceId !== null && !restored.has(saved.parentDeviceId)) throw new Error(`parent device ${saved.parentDeviceId} not restored`);
187387
188035
  await this.healSavedConfig(saved, savedDevices);
@@ -187398,7 +188046,7 @@ var BaseDeviceProvider = class extends BaseAddon {
187398
188046
  };
187399
188047
  const topLevel = savedDevices.filter((saved) => saved.parentDeviceId === null);
187400
188048
  const restoreOne = async (saved) => {
187401
- if (!this.deviceClasses[saved.type]) {
188049
+ if (!this.deviceClassForRow(saved)) {
187402
188050
  this.ctx.logger.warn("No device class registered for restored type — skipping", {
187403
188051
  tags: {
187404
188052
  deviceId: saved.id,
@@ -187437,7 +188085,7 @@ var BaseDeviceProvider = class extends BaseAddon {
187437
188085
  const failedTopLevelIds = new Set(failures.map((failure) => failure.saved.id));
187438
188086
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
187439
188087
  for (const saved of childRows) {
187440
- if (!this.deviceClasses[saved.type]) continue;
188088
+ if (!this.deviceClassForRow(saved)) continue;
187441
188089
  if (saved.parentDeviceId === null) continue;
187442
188090
  if (restored.has(saved.parentDeviceId)) {
187443
188091
  try {
@@ -187491,7 +188139,9 @@ var BaseDeviceProvider = class extends BaseAddon {
187491
188139
  }
187492
188140
  };
187493
188141
  DeviceType.HeatPump;
187494
- DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Heater, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
188142
+ DeviceType.Climate;
188143
+ DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
188144
+ DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, 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.Dryer, DeviceType.Gateway;
187495
188145
  new Set(Object.values(DeviceType));
187496
188146
  /** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
187497
188147
  function contribution(cap, schema, build) {
@@ -189497,7 +190147,7 @@ var HEAT_PUMP_FAMILY_CONTRIBUTIONS = { "heat-pump-status": contribution("heat-pu
189497
190147
  ...Object.values(CLIMATE_FAMILY_CONTRIBUTIONS),
189498
190148
  ...Object.values(HEAT_PUMP_FAMILY_CONTRIBUTIONS)
189499
190149
  ];
189500
- 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.HeatPump, 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;
190150
+ DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, 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.Dryer, DeviceType.Gateway;
189501
190151
  /**
189502
190152
  * Who looks like what (D1023). One look per {@link DeviceType}, refined by a
189503
190153
  * {@link DeviceRole} where the role changes how the device reads (a leak
@@ -190141,9 +190791,9 @@ lookOf({
190141
190791
  idle: INFO,
190142
190792
  standby: MUTED
190143
190793
  });
190144
- DeviceType.Climate, DeviceType.Thermostat;
190145
- 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.HeatPump, 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;
190146
- DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
190794
+ DeviceType.Climate;
190795
+ DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, 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.Dryer, DeviceType.Gateway;
190796
+ DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
190147
190797
  Object.freeze({
190148
190798
  "accessories.getStatus": {
190149
190799
  capName: "accessories",
@@ -193540,6 +194190,13 @@ Object.freeze({
193540
194190
  access: "create",
193541
194191
  role: "viewer"
193542
194192
  },
194193
+ "fanControl.setOscillationAxis": {
194194
+ capName: "fan-control",
194195
+ capScope: "device",
194196
+ addonId: null,
194197
+ access: "create",
194198
+ role: "viewer"
194199
+ },
193543
194200
  "fanControl.setPercentage": {
193544
194201
  capName: "fan-control",
193545
194202
  capScope: "device",
@@ -200561,7 +201218,7 @@ function projectAction(cap, action) {
200561
201218
  };
200562
201219
  }
200563
201220
  Object.entries(CAP_VOCABULARY_BY_NAME).flatMap(([cap, entry]) => entry.scope === "device" ? (entry.actions ?? []).map((a) => projectAction(cap, a)) : []);
200564
- 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.HeatPump, 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.Heater, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
201221
+ DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, 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.Dryer, DeviceType.Gateway;
200565
201222
  DeviceFeature.BatteryOperated;
200566
201223
  function bound(cap, methods = [], authority = "reported") {
200567
201224
  return {
@@ -201765,6 +202422,11 @@ Object.freeze({
201765
202422
  form: "single",
201766
202423
  optional: false
201767
202424
  }],
202425
+ "fanControl.setOscillationAxis": [{
202426
+ name: "deviceId",
202427
+ form: "single",
202428
+ optional: false
202429
+ }],
201768
202430
  "fanControl.setPercentage": [{
201769
202431
  name: "deviceId",
201770
202432
  form: "single",
@@ -205247,6 +205909,38 @@ DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
205247
205909
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
205248
205910
  DEFAULT_NATIVE_LEASE_SETTINGS.sceneBudgetMb;
205249
205911
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
205912
+ /**
205913
+ * Names chosen when an integration or a Gateway device is created.
205914
+ * A stored name is never rewritten from these helpers.
205915
+ */
205916
+ var HOME_SUFFIX = "Home";
205917
+ function collapse(value) {
205918
+ return value.trim().replace(/\s+/g, " ");
205919
+ }
205920
+ /** "KLF-200" → "KLF200". A hyphen between words ("Home Hub") stays. */
205921
+ function compactModelToken(value) {
205922
+ return value.replace(/([A-Za-z])-(\d)/g, "$1$2");
205923
+ }
205924
+ /** Prefill for a new integration: "<provider> - Home". The operator can edit it. */
205925
+ function defaultIntegrationName(providerLabel) {
205926
+ const label = collapse(providerLabel);
205927
+ if (label.length === 0) return HOME_SUFFIX;
205928
+ return `${label} - ${HOME_SUFFIX}`;
205929
+ }
205930
+ /**
205931
+ * A Gateway device: "<Brand> <Model>". An unknown model is the brand alone
205932
+ * (the caller passes the brand-level fallback it already has, e.g. "Velux KLF-200").
205933
+ */
205934
+ function gatewayDeviceName(brand, model) {
205935
+ const brandPart = compactModelToken(collapse(brand));
205936
+ const raw = collapse(model ?? "");
205937
+ if (raw.length === 0) return brandPart;
205938
+ const modelPart = compactModelToken(raw);
205939
+ const prefix = `${brandPart.toLowerCase()} `;
205940
+ if (modelPart.toLowerCase() === brandPart.toLowerCase()) return brandPart;
205941
+ if (modelPart.toLowerCase().startsWith(prefix)) return modelPart;
205942
+ return `${brandPart} ${modelPart}`;
205943
+ }
205250
205944
  String.raw`(?<=^|["'(\s>,\[{])`;
205251
205945
  var MB = 1024 * 1024;
205252
205946
  1024 * MB, 3072 * MB;
@@ -211899,6 +212593,20 @@ function deriveChargingSource(adapterStatus, chargeStatus) {
211899
212593
  function reportsPowerSource(info) {
211900
212594
  return info.adapterStatus !== void 0 || info.chargeStatus !== void 0;
211901
212595
  }
212596
+ /**
212597
+ * Whether a level the CAMERA itself reported (push or direct read) is a
212598
+ * MEASUREMENT (D393). A battery camera answering a read on the way in or out of
212599
+ * sleep, or while on mains or a panel, reports `0` as a placeholder — device
212600
+ * 3628 sat at 100% on its adapter and raised a low-battery notification on
212601
+ * every hourly wake. Those zeros are UNMEASURED: the caller keeps the last real
212602
+ * level. A `0` from an awake camera running on its cell alone (or of unknown
212603
+ * source) is a genuine empty cell and passes, as does every non-zero level.
212604
+ */
212605
+ function isMeasuredCameraBatteryLevel(level, context) {
212606
+ if (level !== 0) return true;
212607
+ if (context.sleeping) return false;
212608
+ return context.charging !== "dc" && context.charging !== "solar";
212609
+ }
211902
212610
  /** The settings key, per device. */
211903
212611
  var BATTERY_REFRESH_MINUTES_KEY = "batteryRefreshMinutes";
211904
212612
  /** How often the in-memory check runs. Costs nothing: no I/O unless it fires. */
@@ -213050,6 +213758,8 @@ var reolinkHubConnectionSchema = object({
213050
213758
  transport: _enum(["tcp", "udp"]).default("tcp"),
213051
213759
  /** UID of a hub that was paired by it; unused for a plain TCP login. */
213052
213760
  uid: string().optional(),
213761
+ /** Model reported when the hub was discovered. Absent on a hand-typed connection. */
213762
+ model: string().optional(),
213053
213763
  debugGeneral: boolean().default(false),
213054
213764
  debugSocketLogs: array(ReolinkSocketDebugFlagSchema).default([])
213055
213765
  });
@@ -213939,12 +214649,16 @@ function hubGatewayNativeId(integrationId) {
213939
214649
  * `reboot` (Baichuan `Reboot`) and the unit's web page.
213940
214650
  */
213941
214651
  function toDiscoveredGateway(input) {
214652
+ const model = input.model?.trim() ?? "";
213942
214653
  return {
213943
214654
  childNativeId: hubGatewayNativeId(input.integrationId),
213944
- name: input.name,
214655
+ name: gatewayDeviceName("Reolink", model.length > 0 ? model : "Home Hub"),
213945
214656
  type: DeviceType.Gateway,
213946
214657
  status: input.online ? "online" : "offline",
213947
- metadata: { manufacturer: "Reolink" },
214658
+ metadata: {
214659
+ manufacturer: "Reolink",
214660
+ ...model.length > 0 ? { model } : { model: "Home Hub" }
214661
+ },
213948
214662
  alreadyAdopted: input.adoptedDeviceId !== null,
213949
214663
  adoptedDeviceId: input.adoptedDeviceId,
213950
214664
  capabilities: [rebootCapability.name, deviceAdminLinkCapability.name]
@@ -218936,10 +219650,26 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
218936
219650
  * tracker is more reliable.
218937
219651
  */
218938
219652
  mapBatteryInfo(info) {
219653
+ const charging = reportsPowerSource(info) ? deriveChargingSource(info.adapterStatus, info.chargeStatus) : this.state.battery.charging ?? "unknown";
219654
+ const sleeping = info.sleeping === true || this.sleeping;
219655
+ const reported = typeof info.batteryPercent === "number" ? Math.max(0, Math.min(100, Math.round(info.batteryPercent))) : void 0;
219656
+ const measured = reported !== void 0 && isMeasuredCameraBatteryLevel(reported, {
219657
+ sleeping,
219658
+ charging
219659
+ });
219660
+ if (reported === 0) this.ctx.logger.info("battery read reporting 0", {
219661
+ tags: { deviceId: this.id },
219662
+ meta: {
219663
+ measured,
219664
+ sleeping,
219665
+ charging,
219666
+ raw: info
219667
+ }
219668
+ });
218939
219669
  return {
218940
- level: typeof info.batteryPercent === "number" ? Math.max(0, Math.min(100, Math.round(info.batteryPercent))) : this.state.battery.level ?? null,
218941
- charging: reportsPowerSource(info) ? deriveChargingSource(info.adapterStatus, info.chargeStatus) : this.state.battery.charging ?? "unknown",
218942
- sleeping: info.sleeping === true || this.sleeping,
219670
+ level: reported !== void 0 && measured ? reported : this.state.battery.level ?? null,
219671
+ charging,
219672
+ sleeping,
218943
219673
  lastUpdated: Date.now()
218944
219674
  };
218945
219675
  }
@@ -226188,6 +226918,7 @@ var reolinkConnectionsEntryKind = defineEntryKind("connections", {
226188
226918
  password: string().optional().meta({ secret: true }),
226189
226919
  transport: _enum(["tcp", "udp"]).nullish(),
226190
226920
  uid: string().nullish(),
226921
+ model: string().nullish(),
226191
226922
  debugGeneral: boolean().nullish(),
226192
226923
  debugSocketLogs: array(ReolinkSocketDebugFlagSchema).nullish(),
226193
226924
  mailboxId: mailboxLinkField()
@@ -226434,11 +227165,12 @@ function mapReolinkDiscoveryToCandidates(devices, credentials, onboarded = [], h
226434
227165
  return [{
226435
227166
  stableId: reolinkHubStableId(d),
226436
227167
  type: DeviceType.Gateway,
226437
- suggestedName: displayName,
227168
+ suggestedName: defaultIntegrationName("Reolink"),
226438
227169
  prefilledConfig: {
226439
227170
  host: d.host,
226440
227171
  port: HUB_BAICHUAN_PORT,
226441
227172
  ...d.uid ? { uid: d.uid } : {},
227173
+ ...d.model ? { model: d.model } : {},
226442
227174
  ...username ? { username } : {}
226443
227175
  },
226444
227176
  setupIntegration: true
@@ -226903,7 +227635,7 @@ function buildReolinkAdoptionProvider(deps) {
226903
227635
  const gateways = await deps.listAdoptedGateways();
226904
227636
  return [toDiscoveredGateway({
226905
227637
  integrationId,
226906
- name: session.name,
227638
+ model: session.connection.model,
226907
227639
  online: session.isOnline,
226908
227640
  adoptedDeviceId: gateways.find((g) => g.integrationId === integrationId)?.id ?? null
226909
227641
  }), ...session.channelSnapshot().channels.map((channel) => toDiscoveredChild(channel, findAdoptedForChannel(adopted, integrationId, channel)))];
@@ -226971,7 +227703,7 @@ function buildReolinkAdoptionProvider(deps) {
226971
227703
  const known = (await deps.listAdoptedGateways()).find((g) => g.integrationId === integrationId);
226972
227704
  const { deviceId } = known !== void 0 ? { deviceId: known.id } : await deps.adoptGateway({
226973
227705
  integrationId,
226974
- name: perCandidate?.[childNativeId]?.name ?? session.name
227706
+ name: perCandidate?.[childNativeId]?.name ?? gatewayDeviceName("Reolink", session.connection.model?.trim() || "Home Hub")
226975
227707
  });
226976
227708
  adopted.push({
226977
227709
  childNativeId,