@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.mjs CHANGED
@@ -101490,7 +101490,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
101490
101490
  return EventCategory;
101491
101491
  }({});
101492
101492
  //#endregion
101493
- //#region ../types/dist/composed-stable-id-DFNyOFzz.mjs
101493
+ //#region ../types/dist/composed-stable-id-CPp3votu.mjs
101494
101494
  /**
101495
101495
  import { errMsg } from '@camstack/types'
101496
101496
  * Extract a human-readable message from an unknown error value.
@@ -101509,12 +101509,12 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
101509
101509
  DeviceType["Siren"] = "siren";
101510
101510
  DeviceType["Switch"] = "switch";
101511
101511
  DeviceType["Sensor"] = "sensor";
101512
- DeviceType["Thermostat"] = "thermostat";
101513
- /** Air-conditioner / heat-pump climate device (HVAC) — shares the
101514
- * `climate-control` cap surface with `Thermostat` but renders a
101515
- * dedicated AC-appropriate control UI (mode chips, fan speed,
101516
- * independent vertical/horizontal swing). Sources: native Gree, and
101517
- * reusable by other AC integrations. */
101512
+ /** Every climate device: an air conditioner, a room thermostat, a radiator
101513
+ * valve, a floor-heating zone, a heat-pump circuit. They share one set of
101514
+ * controls (`climate-control`), so they are one type; WHICH kind of climate
101515
+ * device it is is its {@link DeviceRole} (`climate-*`), which the UI and the
101516
+ * exports branch on. The retired `thermostat` type is read as this one
101517
+ * (`canonicalStoredDeviceType`). */
101518
101518
  DeviceType["Climate"] = "climate";
101519
101519
  DeviceType["Button"] = "button";
101520
101520
  /** Generic stateless event emitter — carries a device's EXACT declared
@@ -101605,10 +101605,6 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
101605
101605
  /** Washing machine. A plug-built one is running while its power stays
101606
101606
  * above a threshold. No program cap — that surface is the dishwasher's. */
101607
101607
  DeviceType["Washer"] = "washer";
101608
- /** A dumb plug-in stove or heater: a switch (and, with a meter, a power
101609
- * reading) that only runs while the plug is on. Built from a smart plug;
101610
- * the `timed-run` cap switches it off again after a chosen time. */
101611
- DeviceType["Heater"] = "heater";
101612
101608
  /** Tumble dryer. Same plug-built running surface as {@link Washer}. */
101613
101609
  DeviceType["Dryer"] = "dryer";
101614
101610
  /** The physical bridge box of a vendor ecosystem (Velux KLF-200, and later
@@ -101828,6 +101824,27 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
101828
101824
  /** A smart plug: a `switch` whose source says it is an outlet (HA
101829
101825
  * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
101830
101826
  DeviceRole["Outlet"] = "outlet";
101827
+ /** A dumb plug-in stove or heater behind a switch: it runs only while the
101828
+ * switch is on. Offered `timed-run`, which switches it off again after a
101829
+ * chosen time. */
101830
+ DeviceRole["SwitchHeater"] = "switch-heater";
101831
+ /** A plain fan behind a switch (a smart plug powering it): drawn as a fan,
101832
+ * with the switch's on/off only. Speed or oscillation appear only when the
101833
+ * device also has a fan cap (D1033). */
101834
+ DeviceRole["SwitchFan"] = "switch-fan";
101835
+ /** Air conditioner / split unit: cooling, fan speed, louvres. */
101836
+ DeviceRole["ClimateAc"] = "climate-ac";
101837
+ /** Room thermostat: a setpoint and a room temperature. The default. */
101838
+ DeviceRole["ClimateThermostat"] = "climate-thermostat";
101839
+ /** Floor-heating zone actuator. */
101840
+ DeviceRole["ClimateFloor"] = "climate-floor";
101841
+ /** Radiator valve (thermostatic radiator head). */
101842
+ DeviceRole["ClimateRadiator"] = "climate-radiator";
101843
+ /** A heater with its own thermostat (stove, convector). */
101844
+ DeviceRole["ClimateHeater"] = "climate-heater";
101845
+ /** One heating/cooling circuit of a heat pump: a water loop with comfort /
101846
+ * eco setpoints and a heat/cool mode, no room sensor. */
101847
+ DeviceRole["ClimateHeatPumpCircuit"] = "climate-heat-pump-circuit";
101831
101848
  /** Generic motion / occupancy / moving event source. Distinct from
101832
101849
  * the camera accessory PirSensor role: that one is a camera child;
101833
101850
  * this is a standalone HA / 3rd-party motion sensor. */
@@ -106715,7 +106732,7 @@ var ZodIssueCode = {
106715
106732
  var ZodFirstPartyTypeKind;
106716
106733
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
106717
106734
  //#endregion
106718
- //#region ../types/dist/sleep-D_NpiLFP.mjs
106735
+ //#region ../types/dist/sleep-D0roI_CZ.mjs
106719
106736
  /**
106720
106737
  * The audio chunk plane's byte format, and the ONE expansion from a coded
106721
106738
  * window to float samples (D455).
@@ -112528,6 +112545,50 @@ var ACTUATOR_CAP_VOCABULARY = {
112528
112545
  value: false
112529
112546
  },
112530
112547
  args: { oscillating: false }
112548
+ },
112549
+ {
112550
+ id: "fan.horizontalOscillateOn",
112551
+ method: "setOscillationAxis",
112552
+ label: t("Horizontal oscillation on", "Oscillazione orizzontale attiva"),
112553
+ phrase: t("Start the horizontal oscillation of {device}", "Attiva l’oscillazione orizzontale di {device}"),
112554
+ icon: "move-horizontal",
112555
+ args: {
112556
+ axis: "horizontal",
112557
+ oscillating: true
112558
+ }
112559
+ },
112560
+ {
112561
+ id: "fan.horizontalOscillateOff",
112562
+ method: "setOscillationAxis",
112563
+ label: t("Horizontal oscillation off", "Oscillazione orizzontale spenta"),
112564
+ phrase: t("Stop the horizontal oscillation of {device}", "Ferma l’oscillazione orizzontale di {device}"),
112565
+ icon: "move-horizontal",
112566
+ args: {
112567
+ axis: "horizontal",
112568
+ oscillating: false
112569
+ }
112570
+ },
112571
+ {
112572
+ id: "fan.verticalOscillateOn",
112573
+ method: "setOscillationAxis",
112574
+ label: t("Vertical oscillation on", "Oscillazione verticale attiva"),
112575
+ phrase: t("Start the vertical oscillation of {device}", "Attiva l’oscillazione verticale di {device}"),
112576
+ icon: "move-vertical",
112577
+ args: {
112578
+ axis: "vertical",
112579
+ oscillating: true
112580
+ }
112581
+ },
112582
+ {
112583
+ id: "fan.verticalOscillateOff",
112584
+ method: "setOscillationAxis",
112585
+ label: t("Vertical oscillation off", "Oscillazione verticale spenta"),
112586
+ phrase: t("Stop the vertical oscillation of {device}", "Ferma l’oscillazione verticale di {device}"),
112587
+ icon: "move-vertical",
112588
+ args: {
112589
+ axis: "vertical",
112590
+ oscillating: false
112591
+ }
112531
112592
  }
112532
112593
  ],
112533
112594
  state: [{
@@ -116917,6 +116978,10 @@ Object.freeze({
116917
116978
  "path": "lastEvent.eventType",
116918
116979
  "valueType": "string"
116919
116980
  },
116981
+ {
116982
+ "path": "lastEvent.sourceId",
116983
+ "valueType": "string"
116984
+ },
116920
116985
  {
116921
116986
  "path": "lastEvent.timestamp",
116922
116987
  "valueType": "number"
@@ -118204,7 +118269,7 @@ function sleep(ms) {
118204
118269
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
118205
118270
  }
118206
118271
  //#endregion
118207
- //#region ../types/dist/implemented-methods-M5aguGon.mjs
118272
+ //#region ../types/dist/implemented-methods-5YMDeE3f.mjs
118208
118273
  /**
118209
118274
  * The ffmpeg build every CamStack node downloads, per platform and arch.
118210
118275
  *
@@ -145490,6 +145555,41 @@ function macroOnly(macro) {
145490
145555
  };
145491
145556
  }
145492
145557
  }
145558
+ var EventVocabularyKindSchema = _enum([
145559
+ "press",
145560
+ "long-press",
145561
+ "long-press-start",
145562
+ "release",
145563
+ "repeat",
145564
+ "double-press",
145565
+ "other"
145566
+ ]);
145567
+ /** The part of the device an event comes from: a button, a channel. */
145568
+ var EventVocabularySourceSchema = object({
145569
+ id: string().min(1),
145570
+ label: string().min(1)
145571
+ });
145572
+ /** One scalar field of an event's `data`, by dotted path. */
145573
+ var EventVocabularyFieldSchema = object({
145574
+ path: string().min(1),
145575
+ kind: _enum([
145576
+ "string",
145577
+ "number",
145578
+ "boolean",
145579
+ "enum"
145580
+ ]),
145581
+ enumValues: array(string()).optional(),
145582
+ label: string().min(1).optional()
145583
+ });
145584
+ var EventVocabularyEntrySchema = object({
145585
+ /** The native token, verbatim. */
145586
+ id: string().min(1),
145587
+ source: EventVocabularySourceSchema.optional(),
145588
+ label: string().min(1),
145589
+ description: string().optional(),
145590
+ kind: EventVocabularyKindSchema.optional(),
145591
+ payload: array(EventVocabularyFieldSchema).optional()
145592
+ });
145493
145593
  Math.PI / 180;
145494
145594
  /**
145495
145595
  * WHEN something happens, as data (D983) — the one time vocabulary of the
@@ -145697,6 +145797,33 @@ var ScheduleLeafSchema = object({
145697
145797
  /** @deprecated legacy cron — new schedules use `at`. */
145698
145798
  cron: string().min(1).max(120).optional()
145699
145799
  }).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" });
145800
+ /**
145801
+ * One payload predicate of a `device-fired` row: the value at `path` inside
145802
+ * the fire's `data` (dotted) equals `equals`. Compared strictly, no coercion.
145803
+ */
145804
+ var DeviceFiredMatchSchema = object({
145805
+ path: string().min(1).max(120),
145806
+ equals: union([
145807
+ string(),
145808
+ number$1(),
145809
+ boolean()
145810
+ ])
145811
+ });
145812
+ /**
145813
+ * "fires": one device of the `event-emitter` capability reported an event
145814
+ * (D1045). Every list is an OR, the lists together an AND; an absent list does
145815
+ * not narrow. `eventIds` are the device's own tokens, `sourceIds` the parts of
145816
+ * the device (a button), `kinds` the shared press kinds of its vocabulary.
145817
+ */
145818
+ var DeviceFiredLeafSchema = object({
145819
+ kind: literal("device-fired"),
145820
+ ...eventLeafId,
145821
+ deviceId: number$1().int().nonnegative(),
145822
+ eventIds: array(string().min(1)).min(1).max(64).optional(),
145823
+ sourceIds: array(string().min(1)).min(1).max(64).optional(),
145824
+ kinds: array(EventVocabularyKindSchema).min(1).optional(),
145825
+ match: array(DeviceFiredMatchSchema).min(1).max(8).optional()
145826
+ });
145700
145827
  var ManualLeafSchema = object({
145701
145828
  kind: literal("manual"),
145702
145829
  ...eventLeafId
@@ -145838,6 +145965,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
145838
145965
  }),
145839
145966
  DeviceBecomesLeafSchema,
145840
145967
  DeviceEventLeafSchema,
145968
+ DeviceFiredLeafSchema,
145841
145969
  ScheduleLeafSchema,
145842
145970
  ManualLeafSchema,
145843
145971
  IntervalLeafSchema,
@@ -145852,6 +145980,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
145852
145980
  var EVENT_KINDS = new Set([
145853
145981
  "device-becomes",
145854
145982
  "device-event",
145983
+ "device-fired",
145855
145984
  "schedule",
145856
145985
  "manual",
145857
145986
  "interval",
@@ -145932,6 +146061,7 @@ function hasEmptyContainer(node) {
145932
146061
  var LEAF_WORDS = {
145933
146062
  "device-becomes": "a device value that becomes",
145934
146063
  "device-event": "a device event",
146064
+ "device-fired": "a device firing an event",
145935
146065
  schedule: "a schedule",
145936
146066
  manual: "a manual run",
145937
146067
  interval: "an interval",
@@ -146197,9 +146327,12 @@ function convertLegacyWhen(half) {
146197
146327
  * every caller — automations, Actions, and the notification centre, which runs
146198
146328
  * only Actions (planning#473).
146199
146329
  */
146330
+ /** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
146331
+ var WAIT_MAX_SECONDS = 3600;
146332
+ var WAIT_TOO_LONG = `a wait is at most one hour (${WAIT_MAX_SECONDS} s)`;
146200
146333
  var AutomationWaitStepSchema = object({
146201
146334
  kind: literal("wait"),
146202
- seconds: number$1().min(0).max(300)
146335
+ seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
146203
146336
  });
146204
146337
  /** The legacy `deviceId` of a cap step: still READ, never written (D983). */
146205
146338
  var LegacyStepDeviceSchema = union([
@@ -146269,39 +146402,227 @@ var elseNeedsIf = {
146269
146402
  path: ["else"]
146270
146403
  };
146271
146404
  var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
146272
- var GuardedCapStepSchema = AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
146273
- message: "a cap step needs a target",
146274
- path: ["target"]
146275
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
146276
- message: "a domain target needs the vocabulary action it applies to (actionId)",
146277
- path: ["actionId"]
146278
- }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
146279
146405
  /**
146280
146406
  * A step of a STANDALONE list (an action, a scheduler point, a preset): the
146281
146407
  * same two step kinds an automation runs, minus a guard that reads the
146282
146408
  * automation's trigger, which such a list does not have.
146283
146409
  */
146284
- var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, GuardedCapStepSchema]).superRefine((step, ctx) => {
146410
+ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
146411
+ message: "a cap step needs a target",
146412
+ path: ["target"]
146413
+ }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
146414
+ message: "a domain target needs the vocabulary action it applies to (actionId)",
146415
+ path: ["actionId"]
146416
+ }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
146285
146417
  if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
146286
146418
  code: "custom",
146287
146419
  message: TRIGGERED_BY_NEEDS_AUTOMATION,
146288
146420
  path: ["if"]
146289
146421
  });
146290
146422
  });
146423
+ /**
146424
+ * Flow control of an AUTOMATION's list (#500). A standalone list (an action, a
146425
+ * scheduler point, a preset) stays `wait` and `cap`: it has no run of its own
146426
+ * to end and no variable bag to write.
146427
+ */
146428
+ var continueOnErrorShape = {
146429
+ /** A failure of this step is traced `failed-continued` and the next step runs. */
146430
+ continueOnError: literal(true).optional() };
146431
+ /** An automation's cap step: the shared guarded cap step, plus `continueOnError`. */
146432
+ var AutomationGuardedCapStepSchema = AutomationCapStepBaseSchema.extend({
146433
+ ...stepGuardShape,
146434
+ ...continueOnErrorShape
146435
+ }).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
146436
+ message: "a cap step needs a target",
146437
+ path: ["target"]
146438
+ }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
146439
+ message: "a domain target needs the vocabulary action it applies to (actionId)",
146440
+ path: ["actionId"]
146441
+ }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
146442
+ /** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
146443
+ var AutomationStopStepSchema = object({
146444
+ kind: literal("stop"),
146445
+ reason: string().min(1, "a stop needs a reason: it is what the run trace shows").max(200),
146446
+ /** `ok`: the run ends as a success. `failed`: it ends as a failure, with the reason. */
146447
+ outcome: _enum(["ok", "failed"]),
146448
+ /** Stop only when this reads true; false or unknown does not stop. */
146449
+ if: AutomationWhenSchema.optional()
146450
+ });
146451
+ var SET_VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]{0,39}$/;
146452
+ /** Names the run itself writes and reads (`leaf` is what `triggered-by` judges): a step may not overwrite them. */
146453
+ var RESERVED_RUN_VARS = [
146454
+ "kind",
146455
+ "leaf",
146456
+ "at"
146457
+ ];
146458
+ /**
146459
+ * Write variables into the run's bag, for the steps after it. SUBSTITUTION
146460
+ * only, never evaluation: a text value may carry `{{vars.x}}` slots.
146461
+ */
146462
+ var AutomationSetStepSchema = object({
146463
+ kind: literal("set"),
146464
+ vars: record(string(), union([
146465
+ string().max(500),
146466
+ number$1(),
146467
+ boolean()
146468
+ ])).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` }),
146469
+ /** Set only when this reads true; false or unknown leaves the bag as it is. */
146470
+ if: AutomationWhenSchema.optional()
146471
+ });
146472
+ var AutomationRunActionStepSchema = object({
146473
+ kind: literal("action"),
146474
+ /** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
146475
+ actionId: string().min(1),
146476
+ /** Values for the action's declared variables; the others take their default. */
146477
+ variables: record(string(), union([
146478
+ string(),
146479
+ number$1(),
146480
+ boolean()
146481
+ ])).optional(),
146482
+ ...continueOnErrorShape
146483
+ });
146484
+ /**
146485
+ * A step INSIDE a branch of a `choose`: a flow step with no condition of its
146486
+ * own (the branch is the condition) and no block inside it. Strict, so an `if`
146487
+ * written on such a step is refused rather than dropped.
146488
+ */
146489
+ /** The longest a `wait-until` may wait: six hours. */
146490
+ var WAIT_UNTIL_TIMEOUT_MAX_S = 21600;
146491
+ /**
146492
+ * Pause the run until a condition is true (#500). The timeout is mandatory: a
146493
+ * run never waits without an end. `onTimeout` says what a wait that ran out
146494
+ * does: `continue` goes on to the next step, `stop` ends the run as a failure.
146495
+ * A condition that cannot be read is not "true": the wait goes on (D49).
146496
+ */
146497
+ var AutomationWaitUntilStepSchema = object({
146498
+ kind: literal("wait-until"),
146499
+ when: AutomationWhenSchema,
146500
+ 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)`),
146501
+ onTimeout: _enum(["continue", "stop"])
146502
+ }).strict();
146503
+ /** The step kinds that hold steps of their own, or pause on a condition: they nest two levels at most. */
146504
+ var BLOCK_STEP_KINDS = [
146505
+ "choose",
146506
+ "repeat",
146507
+ "parallel",
146508
+ "wait-until"
146509
+ ];
146510
+ var NEST_TOO_DEEP = `steps nest two levels at most: a step inside a nested choose or repeat can be a plain step only`;
146511
+ function kindOf(input) {
146512
+ return typeof input === "object" && input !== null ? Reflect.get(input, "kind") : void 0;
146513
+ }
146514
+ /** Where the nesting ends, a block step is refused in words rather than as an unknown kind. */
146515
+ function nestTooDeep(issue) {
146516
+ const kind = kindOf(issue.input);
146517
+ return typeof kind === "string" && BLOCK_STEP_KINDS.includes(kind) ? NEST_TOO_DEEP : void 0;
146518
+ }
146519
+ var plainStepSchemas = [
146520
+ AutomationWaitStepSchema.strict(),
146521
+ AutomationCapStepBaseSchema.extend(continueOnErrorShape).strict().refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
146522
+ message: "a cap step needs a target",
146523
+ path: ["target"]
146524
+ }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
146525
+ message: "a domain target needs the vocabulary action it applies to (actionId)",
146526
+ path: ["actionId"]
146527
+ }),
146528
+ AutomationStopStepSchema.omit({ if: true }).strict(),
146529
+ AutomationSetStepSchema.omit({ if: true }).strict(),
146530
+ AutomationRunActionStepSchema.strict()
146531
+ ];
146532
+ /**
146533
+ * A plain step: a flow step with no condition of its own and no step inside
146534
+ * it. The second (last) level of nesting holds these only.
146535
+ */
146536
+ var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
146537
+ /** A step that can run beside others: it writes no variable and does not end the run. */
146538
+ 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");
146539
+ /**
146540
+ * Several steps at once (#500): all are started together and all are awaited.
146541
+ * A failure fails the run once the others finished, as in a sequence; a member
146542
+ * marked "continue if this fails" does not.
146543
+ */
146544
+ var AutomationParallelStepSchema = object({
146545
+ kind: literal("parallel"),
146546
+ steps: array(AutomationParallelMemberSchema).min(2, "a parallel needs at least two steps").max(5, `a parallel takes at most 5 steps`)
146547
+ }).strict();
146548
+ var REPEAT_NEEDS_MAX = "a repeat on a condition needs a maximum number of iterations";
146549
+ /** A loop on a condition: the bound is mandatory, so a run never loops without an end. */
146550
+ var repeatConditionShape = {
146551
+ when: AutomationWhenSchema,
146552
+ 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`),
146553
+ /** A pause between two iterations, never after the last. */
146554
+ waitS: number$1().int().min(1).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG).optional()
146555
+ };
146556
+ /** What decides how many times a `repeat` runs. */
146557
+ var AutomationRepeatLoopSchema = discriminatedUnion("by", [
146558
+ object({
146559
+ by: literal("count"),
146560
+ count: number$1().int().min(1).max(20, `a repeat runs at most 20 times`)
146561
+ }).strict(),
146562
+ object({
146563
+ by: literal("while"),
146564
+ ...repeatConditionShape
146565
+ }).strict(),
146566
+ object({
146567
+ by: literal("until"),
146568
+ ...repeatConditionShape
146569
+ }).strict(),
146570
+ object({
146571
+ by: literal("forEach"),
146572
+ target: object({
146573
+ kind: literal("devices"),
146574
+ 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`)
146575
+ }).strict()
146576
+ }).strict()
146577
+ ]);
146578
+ /**
146579
+ * The same steps several times (#500). Every form is bounded at save, so a
146580
+ * run cannot loop without an end. A failure or a `stop` in the steps ends the
146581
+ * loop and the run, as in a sequence.
146582
+ */
146583
+ function repeatSchemaOf(step) {
146584
+ return object({
146585
+ kind: literal("repeat"),
146586
+ loop: AutomationRepeatLoopSchema,
146587
+ steps: array(step).min(1, "a repeat needs at least one step").max(10, `a repeat takes at most 10 steps`)
146588
+ }).strict();
146589
+ }
146590
+ /**
146591
+ * One step, several ways (#500): the branches are read in order and the FIRST
146592
+ * whose condition is true runs; `else` runs when every branch is false. A
146593
+ * branch that cannot be read ends the choice: nothing runs, not the branches
146594
+ * after it and not the else (D49). The #472 `if` / `else` of a wait or cap
146595
+ * step is the one-branch case and stays as it is stored.
146596
+ */
146597
+ function chooseSchemaOf(step) {
146598
+ const steps = array(step).max(10);
146599
+ return object({
146600
+ kind: literal("choose"),
146601
+ branches: array(object({
146602
+ if: AutomationWhenSchema,
146603
+ steps: steps.min(1, "a branch needs at least one step")
146604
+ })).min(1, "a choose needs at least one branch").max(6, `a choose takes at most 6 branches`),
146605
+ else: steps.optional()
146606
+ });
146607
+ }
146608
+ var AutomationBodyStepSchema = discriminatedUnion("kind", [
146609
+ ...plainStepSchemas,
146610
+ AutomationWaitUntilStepSchema,
146611
+ AutomationParallelStepSchema,
146612
+ chooseSchemaOf(AutomationBranchStepSchema),
146613
+ repeatSchemaOf(AutomationBranchStepSchema)
146614
+ ]);
146615
+ var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
146291
146616
  var AutomationActionSchema = discriminatedUnion("kind", [
146292
146617
  GuardedWaitStepSchema,
146293
- GuardedCapStepSchema,
146294
- object({
146295
- kind: literal("action"),
146296
- /** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
146297
- actionId: string().min(1),
146298
- /** Values for the action's declared variables; the others take their default. */
146299
- variables: record(string(), union([
146300
- string(),
146301
- number$1(),
146302
- boolean()
146303
- ])).optional()
146304
- }),
146618
+ AutomationGuardedCapStepSchema,
146619
+ AutomationStopStepSchema,
146620
+ AutomationSetStepSchema,
146621
+ chooseSchemaOf(AutomationBodyStepSchema),
146622
+ AutomationWaitUntilStepSchema,
146623
+ AutomationParallelStepSchema,
146624
+ AutomationRepeatStepSchema,
146625
+ AutomationRunActionStepSchema,
146305
146626
  object({
146306
146627
  kind: literal("code"),
146307
146628
  /** Compiled into the automation's OWN block by esbuild — not a third
@@ -146364,11 +146685,6 @@ function convertLegacyRecipe(legacy) {
146364
146685
  ...rest
146365
146686
  };
146366
146687
  }
146367
- /**
146368
- * Where recipes are PARSED (the core-blocks cap, the MCP tool, the literal a
146369
- * saved block carries): the new shape as it is, or the old shape converted to
146370
- * it. The output type is always the new one.
146371
- */
146372
146688
  var AutomationRecipeSchema = union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
146373
146689
  var DETECTION_DESCRIPTIONS = {
146374
146690
  deviceId: "the camera that saw it",
@@ -146389,6 +146705,16 @@ var BECOMES_DESCRIPTIONS = {
146389
146705
  from: "the value before the change, empty when it is not known",
146390
146706
  to: "the value it changed to"
146391
146707
  };
146708
+ /**
146709
+ * A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
146710
+ * those names depend on the device, so they are not in this list.
146711
+ */
146712
+ var FIRED_DESCRIPTIONS = {
146713
+ deviceId: "the device that fired",
146714
+ eventType: "the event, as the device names it",
146715
+ sourceId: "the part of the device that fired (a button), empty when it names none",
146716
+ eventKind: "the kind of press (press, long-press …), empty when the device declares none"
146717
+ };
146392
146718
  function describe$1(descriptions) {
146393
146719
  return Object.entries(descriptions).map(([name, description]) => ({
146394
146720
  name,
@@ -146397,12 +146723,74 @@ function describe$1(descriptions) {
146397
146723
  }
146398
146724
  describe$1(DETECTION_DESCRIPTIONS);
146399
146725
  describe$1(STATIONARY_DESCRIPTIONS);
146726
+ describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
146727
+ ...v,
146728
+ hintKey: "firedDeviceId"
146729
+ } : v);
146400
146730
  describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
146401
146731
  ...v,
146402
146732
  hintKey: "becomesDeviceId"
146403
146733
  } : v);
146404
146734
  new Set(Object.values(COCO_TO_MACRO.mapping));
146405
146735
  /**
146736
+ * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
146737
+ * device. Carries the device's EXACT declared event vocabulary verbatim
146738
+ * (NO normalization). Two shapes:
146739
+ * - structured source (HA `event.*` entity) → `vocabulary` is the fixed
146740
+ * declared set (e.g. press_short, press_long, …).
146741
+ * - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
146742
+ * is [] (open) and `lastEvent.data` carries the complex payload.
146743
+ * `vocabulary` (D1044) names each event for a person and types it for a
146744
+ * rule; `eventTypes` is its list of native tokens, kept for older readers.
146745
+ * A fire names the part of the device it came from in `sourceId` when the
146746
+ * vocabulary declares sources (a remote's buttons).
146747
+ * `seq` is monotonic so two identical events still produce distinct slice writes.
146748
+ */
146749
+ var EventFireSchema = object({
146750
+ deviceId: number$1(),
146751
+ eventType: string(),
146752
+ sourceId: string().optional(),
146753
+ data: record(string(), unknown()).nullable(),
146754
+ timestamp: number$1().meta(readingMeta("none")),
146755
+ seq: number$1().meta(readingMeta("count"))
146756
+ });
146757
+ var EventEmitterStatusSchema = object({
146758
+ eventTypes: array(string()),
146759
+ /**
146760
+ * Required of a provider by the type. A status written before the field
146761
+ * existed still parses, as an empty vocabulary: read it through
146762
+ * `readEventVocabulary`, which then answers with the plain tokens.
146763
+ */
146764
+ vocabulary: array(EventVocabularyEntrySchema).default([]),
146765
+ lastEvent: EventFireSchema.nullable(),
146766
+ eventCountSinceStart: number$1().meta(readingMeta("count"))
146767
+ });
146768
+ var eventEmitterCapability = {
146769
+ name: "event-emitter",
146770
+ scope: "device",
146771
+ deviceNative: true,
146772
+ mode: "singleton",
146773
+ deviceTypes: [DeviceType.EventEmitter],
146774
+ methods: {},
146775
+ events: { onEvent: { data: EventFireSchema } },
146776
+ status: {
146777
+ schema: EventEmitterStatusSchema,
146778
+ kind: "push"
146779
+ },
146780
+ runtimeState: EventEmitterStatusSchema,
146781
+ /**
146782
+ * Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
146783
+ *
146784
+ * See `RuntimeStateDurability`. Enforced by
146785
+ * `scripts/check-runtime-state-durability.ts`.
146786
+ */
146787
+ durability: "session",
146788
+ /**
146789
+ * History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
146790
+ */
146791
+ history: "none"
146792
+ };
146793
+ /**
146406
146794
  * Schedulers (D983) — an entity that performs actions over the day.
146407
146795
  *
146408
146796
  * A scheduler has profiles; a profile has weekdays and a timeline of POINTS.
@@ -146453,12 +146841,16 @@ var HoldOverrideSchema = discriminatedUnion("mode", [object({ mode: literal("res
146453
146841
  })]);
146454
146842
  /** A missed edge up to this late still runs. */
146455
146843
  var DEFAULT_MAX_LATE_MS = 10 * 6e4;
146844
+ var SchedulerStepSchema = ActionStepSchema.refine((step) => step.kind !== "wait" || step.seconds <= 300, {
146845
+ message: `a scheduler point waits at most five minutes (300 s); put a longer wait in an action`,
146846
+ path: ["seconds"]
146847
+ });
146456
146848
  var SchedulerPointSchema = object({
146457
146849
  id: string().min(1).max(64),
146458
146850
  at: SchedulerTimeSpecSchema,
146459
146851
  mode: SchedulerPointModeSchema,
146460
146852
  /** The actions of an `edge` or `hold`; a `release` has none. */
146461
- steps: array(ActionStepSchema).max(20).default([]),
146853
+ steps: array(SchedulerStepSchema).max(20).default([]),
146462
146854
  /** Checked when the point runs (an edge) or is applied (a hold). */
146463
146855
  conditions: SchedulerStateTreeSchema.optional(),
146464
146856
  /** Hold only; absent means `respect`. */
@@ -146656,6 +147048,7 @@ var AutomationConditionTraceNodeSchema = object({
146656
147048
  "triggered-by",
146657
147049
  "device-becomes",
146658
147050
  "device-event",
147051
+ "device-fired",
146659
147052
  "schedule",
146660
147053
  "interval",
146661
147054
  "manual",
@@ -146726,18 +147119,46 @@ var StepTraceBaseSchema = object({
146726
147119
  ]).optional(),
146727
147120
  /** Why the condition read what it read, in the evaluator's own words. */
146728
147121
  conditionReason: string().optional(),
146729
- /** `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. */
147122
+ /** `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). */
146730
147123
  outcome: _enum([
146731
147124
  "ok",
146732
147125
  "error",
146733
147126
  "not-run",
146734
147127
  "empty",
146735
- "skipped"
147128
+ "skipped",
147129
+ "failed-continued",
147130
+ "timed-out"
146736
147131
  ]),
146737
147132
  message: string().optional()
146738
147133
  });
147134
+ /** What a block step adds to its row: which list ran, what each branch read, how many rounds. */
147135
+ var blockTraceShape = {
147136
+ /** A `choose` step (#500): the list that ran, `branches.<n>` or `else`. Absent when none did. */
147137
+ branch: string().optional(),
147138
+ /** A `choose` step: what each branch read, in order, up to the one that decided. */
147139
+ branchChecks: array(object({
147140
+ condition: _enum([
147141
+ "true",
147142
+ "false",
147143
+ "unknown"
147144
+ ]),
147145
+ conditionReason: string().optional()
147146
+ })).optional(),
147147
+ /** A `repeat` step (#500): how many times its steps ran. */
147148
+ iterations: number$1().int().optional()
147149
+ };
147150
+ /** A step one level down: it may be a block step itself, whose own steps are plain rows (the nesting ends there). */
147151
+ var NestedStepTraceSchema = StepTraceBaseSchema.extend({
147152
+ ...blockTraceShape,
147153
+ steps: array(StepTraceBaseSchema).optional()
147154
+ });
146739
147155
  /** A step trace; the `else` steps that ran are one level of the same shape (the nesting is bounded at one). */
146740
- var AutomationStepTraceSchema = StepTraceBaseSchema.extend({ else: array(StepTraceBaseSchema).optional() });
147156
+ var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
147157
+ else: array(StepTraceBaseSchema).optional(),
147158
+ ...blockTraceShape,
147159
+ /** A `choose` step: the steps of the list that ran. A `parallel`: its members. A `repeat`: the LAST iteration. */
147160
+ steps: array(NestedStepTraceSchema).optional()
147161
+ });
146741
147162
  var AutomationRunTraceSchema = object({
146742
147163
  runId: string().min(1),
146743
147164
  startedAt: number$1(),
@@ -146987,7 +147408,7 @@ object({
146987
147408
  * is irrelevant; the array is treated as a set by consumers. */
146988
147409
  hiddenChildIds: array(number$1()).readonly()
146989
147410
  });
146990
- DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Cover, DeviceType.Lock, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Generic, method(object({
147411
+ DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Sensor, DeviceType.Climate, DeviceType.Cover, DeviceType.Lock, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Generic, method(object({
146991
147412
  deviceId: number$1().int().nonnegative(),
146992
147413
  childDeviceId: number$1().int().nonnegative(),
146993
147414
  hidden: boolean()
@@ -147144,7 +147565,9 @@ var AddonHttpRouteSchema = object({
147144
147565
  ]).optional(),
147145
147566
  description: string().optional(),
147146
147567
  /** The hub limits this route per client address before the handler runs. */
147147
- rateLimit: _enum(["auth"]).optional()
147568
+ rateLimit: _enum(["auth"]).optional(),
147569
+ /** Served once per integration instance; the handler reads `instanceId`. */
147570
+ perInstance: boolean().optional()
147148
147571
  });
147149
147572
  /**
147150
147573
  * Cross-process route invocation envelope. The hub captures the
@@ -147161,6 +147584,8 @@ var InvokeRequestSchema = object({
147161
147584
  query: record(string(), string()),
147162
147585
  body: unknown(),
147163
147586
  headers: record(string(), string()),
147587
+ /** The instance the hub resolved for a `perInstance` route. */
147588
+ instanceId: string().optional(),
147164
147589
  user: object({
147165
147590
  id: string(),
147166
147591
  username: string(),
@@ -149285,7 +149710,7 @@ var BATTERY_DEVICE_TYPES = [
149285
149710
  DeviceType.Switch,
149286
149711
  DeviceType.PetFeeder,
149287
149712
  DeviceType.Container,
149288
- DeviceType.Thermostat,
149713
+ DeviceType.Climate,
149289
149714
  DeviceType.EventEmitter
149290
149715
  ];
149291
149716
  /** Generic Customize target for the percentage reading (D936). */
@@ -151048,7 +151473,14 @@ var climateControlCapability = {
151048
151473
  scope: "device",
151049
151474
  deviceNative: true,
151050
151475
  mode: "singleton",
151051
- deviceTypes: [DeviceType.Thermostat, DeviceType.Climate],
151476
+ deviceTypes: [DeviceType.Climate],
151477
+ power: {
151478
+ kind: "mode",
151479
+ field: "mode",
151480
+ offValue: "off",
151481
+ set: "setMode",
151482
+ lastField: "lastActiveMode"
151483
+ },
151052
151484
  methods: {
151053
151485
  setMode: method(object({
151054
151486
  deviceId: number$1().int().nonnegative(),
@@ -151433,6 +151865,7 @@ var CompositionProblemSchema = object({
151433
151865
  "nested-field",
151434
151866
  "missing-field",
151435
151867
  "kind-mismatch",
151868
+ "source-kind-mismatch",
151436
151869
  "may-be-null",
151437
151870
  "source-missing",
151438
151871
  "source-unreadable",
@@ -151454,7 +151887,8 @@ var CompositionProblemSchema = object({
151454
151887
  "command-method-unknown",
151455
151888
  "command-source-unknown",
151456
151889
  "command-input-unknown",
151457
- "command-input-missing"
151890
+ "command-input-missing",
151891
+ "power-source-is-actuator"
151458
151892
  ]),
151459
151893
  path: string(),
151460
151894
  message: string()
@@ -152492,6 +152926,13 @@ var mediaPlayerCapability = {
152492
152926
  deviceNative: true,
152493
152927
  mode: "singleton",
152494
152928
  deviceTypes: [DeviceType.MediaPlayer],
152929
+ power: {
152930
+ kind: "methods",
152931
+ field: "state",
152932
+ offValues: ["off", "standby"],
152933
+ on: "turnOn",
152934
+ off: "turnOff"
152935
+ },
152495
152936
  methods: {
152496
152937
  turnOn: optionalMethod(deviceOnly, _void(), {
152497
152938
  kind: "mutation",
@@ -152622,7 +153063,7 @@ var mediaPlayerCapability = {
152622
153063
  isMuted: { kind: "boolean" }
152623
153064
  } }
152624
153065
  };
152625
- DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Heater, DeviceType.Dryer, DeviceType.Gateway, DeviceType.HeatPump, DeviceType.Camera, DeviceType.Fan, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Gateway, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.MediaPlayer;
153066
+ 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;
152626
153067
  var NUMBER = {
152627
153068
  kind: "fixed",
152628
153069
  result: ["number"]
@@ -152705,7 +153146,7 @@ function numeric(input) {
152705
153146
  }, ...alsoFrom === void 0 ? [] : [alsoFrom.accept]]
152706
153147
  };
152707
153148
  }
152708
- var CLIMATE_DEVICES = [DeviceType.Thermostat, DeviceType.Climate];
153149
+ var CLIMATE_DEVICES = [DeviceType.Climate];
152709
153150
  function binary(input) {
152710
153151
  return {
152711
153152
  ...input,
@@ -153027,8 +153468,8 @@ var GROUP_TEMPLATES = [
153027
153468
  actuator({
153028
153469
  id: "climate",
153029
153470
  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.",
153030
- deviceType: DeviceType.Thermostat,
153031
- memberDeviceTypes: [DeviceType.Thermostat, DeviceType.Climate],
153471
+ deviceType: DeviceType.Climate,
153472
+ memberDeviceTypes: [DeviceType.Climate],
153032
153473
  outputCap: "group-active",
153033
153474
  outputField: "active",
153034
153475
  member: {
@@ -153071,6 +153512,118 @@ function actuator(input) {
153071
153512
  new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
153072
153513
  DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
153073
153514
  DeviceType.Camera;
153515
+ var PowerSourceRefusalReasonSchema = _enum([
153516
+ "no-power-source",
153517
+ "switch-missing",
153518
+ "switch-offline",
153519
+ "switch-unknown",
153520
+ "restart-in-progress",
153521
+ "switch-call-failed",
153522
+ "switch-is-actuator"
153523
+ ]);
153524
+ var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
153525
+ accepted: literal(false),
153526
+ reason: PowerSourceRefusalReasonSchema,
153527
+ /** One line for the operator, naming the switch. */
153528
+ message: string()
153529
+ })]);
153530
+ var PowerSourceInfoSchema = object({
153531
+ /** False when the device has no power source linked; the rest is then empty. */
153532
+ linked: boolean(),
153533
+ switchDeviceId: number$1().nullable(),
153534
+ switchName: string().nullable(),
153535
+ /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
153536
+ switchOn: boolean().nullable(),
153537
+ switchOnline: boolean().nullable(),
153538
+ restartInProgress: boolean(),
153539
+ offSeconds: number$1().int()
153540
+ });
153541
+ /** The composed slice: the switch state the link mirrors, plus the stored off time. */
153542
+ var PowerSourceStateSchema = object({
153543
+ /** Null while the switch has not reported: unknown is never `false` (D393). */
153544
+ switchOn: boolean().nullable(),
153545
+ offSeconds: number$1().int(),
153546
+ lastFetchedAt: number$1()
153547
+ });
153548
+ var POWER_SOURCE_DEVICE_TYPES = [
153549
+ DeviceType.Gateway,
153550
+ DeviceType.Camera,
153551
+ DeviceType.Sensor,
153552
+ DeviceType.MediaPlayer,
153553
+ DeviceType.Vacuum,
153554
+ DeviceType.Generic,
153555
+ DeviceType.Washer,
153556
+ DeviceType.Dryer,
153557
+ DeviceType.Dishwasher,
153558
+ DeviceType.PetFountain,
153559
+ DeviceType.Fan,
153560
+ DeviceType.Humidifier,
153561
+ DeviceType.Climate,
153562
+ DeviceType.WaterHeater
153563
+ ];
153564
+ var powerSourceCustomize = {
153565
+ version: 1,
153566
+ targets: [{
153567
+ id: "switch",
153568
+ cardinality: "scalar",
153569
+ vocabulary: {
153570
+ cap: "power-source",
153571
+ stateField: "switchOn"
153572
+ },
153573
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
153574
+ apply: "add",
153575
+ path: "switchOn",
153576
+ sources: [{
153577
+ kind: "switch",
153578
+ transforms: [{ kind: "identity" }]
153579
+ }],
153580
+ companions: [{
153581
+ kind: "constant",
153582
+ path: "offSeconds",
153583
+ value: 10,
153584
+ when: "add",
153585
+ formerValues: [0]
153586
+ }, {
153587
+ kind: "clock",
153588
+ path: "lastFetchedAt",
153589
+ when: "always"
153590
+ }],
153591
+ sourceReport: { status: "assignment-status" }
153592
+ }]
153593
+ };
153594
+ var deviceInput$2 = object({ deviceId: number$1().int().nonnegative() });
153595
+ var powerSourceCapability = {
153596
+ name: "power-source",
153597
+ scope: "device",
153598
+ mode: "singleton",
153599
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
153600
+ methods: {
153601
+ getStatus: systemMethod(deviceInput$2, PowerSourceInfoSchema, { auth: "protected" }),
153602
+ powerOn: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
153603
+ kind: "mutation",
153604
+ auth: "protected"
153605
+ }),
153606
+ powerOff: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
153607
+ kind: "mutation",
153608
+ auth: "protected"
153609
+ }),
153610
+ forceRestart: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
153611
+ kind: "mutation",
153612
+ auth: "protected"
153613
+ })
153614
+ },
153615
+ runtimeState: PowerSourceStateSchema,
153616
+ customize: powerSourceCustomize,
153617
+ /**
153618
+ * Runtime-state durability: **session** — mirrored from the linked switch on
153619
+ * its next report; a restored value would outlive the reading it names.
153620
+ *
153621
+ * See `RuntimeStateDurability`. Enforced by
153622
+ * `scripts/check-runtime-state-durability.ts`.
153623
+ */
153624
+ durability: "session",
153625
+ history: "none"
153626
+ };
153074
153627
  `${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
153075
153628
  /**
153076
153629
  * What a composition may BUILD on a device type (G2, D676): the caps a new
@@ -155626,8 +156179,14 @@ method(object({
155626
156179
  "string",
155627
156180
  "number",
155628
156181
  "boolean",
155629
- "enum"
156182
+ "enum",
156183
+ "union"
155630
156184
  ]),
156185
+ unionMembers: array(_enum([
156186
+ "string",
156187
+ "number",
156188
+ "boolean"
156189
+ ])).optional(),
155631
156190
  enumValues: array(string()).optional(),
155632
156191
  item: boolean().optional(),
155633
156192
  quantity: ReadingQuantitySchema.optional()
@@ -157732,53 +158291,6 @@ var enumSensorCapability = {
157732
158291
  * whether persisting is worth a SQLite commit. */
157733
158292
  volatileStateFields: ["lastFetchedAt", "timestamp"]
157734
158293
  };
157735
- /**
157736
- * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
157737
- * device. Carries the device's EXACT declared event vocabulary verbatim
157738
- * (NO normalization). Two shapes:
157739
- * - structured source (HA `event.*` entity) → `eventTypes` is the fixed
157740
- * declared vocabulary (e.g. ['press_short','press_long',...]).
157741
- * - generic/legacy source (HA bus events, e.g. zha_event) → `eventTypes`
157742
- * is [] (open) and `lastEvent.data` carries the complex payload.
157743
- * `seq` is monotonic so two identical events still produce distinct slice writes.
157744
- */
157745
- var EventFireSchema = object({
157746
- deviceId: number$1(),
157747
- eventType: string(),
157748
- data: record(string(), unknown()).nullable(),
157749
- timestamp: number$1().meta(readingMeta("none")),
157750
- seq: number$1().meta(readingMeta("count"))
157751
- });
157752
- var EventEmitterStatusSchema = object({
157753
- eventTypes: array(string()),
157754
- lastEvent: EventFireSchema.nullable(),
157755
- eventCountSinceStart: number$1().meta(readingMeta("count"))
157756
- });
157757
- var eventEmitterCapability = {
157758
- name: "event-emitter",
157759
- scope: "device",
157760
- deviceNative: true,
157761
- mode: "singleton",
157762
- deviceTypes: [DeviceType.EventEmitter],
157763
- methods: {},
157764
- events: { onEvent: { data: EventFireSchema } },
157765
- status: {
157766
- schema: EventEmitterStatusSchema,
157767
- kind: "push"
157768
- },
157769
- runtimeState: EventEmitterStatusSchema,
157770
- /**
157771
- * Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
157772
- *
157773
- * See `RuntimeStateDurability`. Enforced by
157774
- * `scripts/check-runtime-state-durability.ts`.
157775
- */
157776
- durability: "session",
157777
- /**
157778
- * History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
157779
- */
157780
- history: "none"
157781
- };
157782
158294
  var IdentitySchema = object({
157783
158295
  id: string(),
157784
158296
  name: string(),
@@ -158287,8 +158799,85 @@ list: method(_void(), array(FailureContributionSchema).readonly()) },
158287
158799
  * - `FanPreset` — preset selector
158288
158800
  * - `FanDirection` — direction toggle (ceiling fans)
158289
158801
  * - `FanOscillating` — oscillation toggle
158802
+ *
158803
+ * Per-axis oscillation (`oscillationAxes`, `setOscillationAxis`, D1034): an air
158804
+ * circulator sweeps horizontally and vertically, each axis with its own
158805
+ * switch, fixed angle, sweep bounds and limits. A provider may report them
158806
+ * natively; otherwise the OPERATOR links sibling devices to each field in
158807
+ * Customize (a `replace` over the fields listed in `overridable` — nothing is
158808
+ * linked or inferred by itself), and a write to a linked field is forwarded to
158809
+ * its source. `oscillating` stays the single summary flag: when axes exist it
158810
+ * means "any axis oscillates" (`anyAxisOscillating`).
158290
158811
  */
158291
158812
  var FanDirectionSchema = _enum(["forward", "reverse"]);
158813
+ var FAN_OSCILLATION_AXES = ["horizontal", "vertical"];
158814
+ var FanOscillationAxisNameSchema = _enum(FAN_OSCILLATION_AXES);
158815
+ var FanOscillationAxisFieldSchema = _enum([
158816
+ "oscillating",
158817
+ "angle",
158818
+ "sweepFrom",
158819
+ "sweepTo"
158820
+ ]);
158821
+ /** The limits of one axis, read from the source that serves its angle. */
158822
+ var FAN_OSCILLATION_AXIS_LIMITS = [
158823
+ "min",
158824
+ "max",
158825
+ "step"
158826
+ ];
158827
+ /**
158828
+ * One oscillation axis. Every reading the device has not reported is `null`,
158829
+ * never `0` (D393): `0°` is a real position. Each leaf defaults to `null`, so
158830
+ * a slice that names only the leaves it knows (a Customize link of one field)
158831
+ * is still a whole axis.
158832
+ */
158833
+ var FanOscillationAxisSchema = object({
158834
+ /** Whether the axis sweeps. */
158835
+ oscillating: boolean().nullable().default(null),
158836
+ /** The fixed position (degrees) the axis holds when it does not sweep. */
158837
+ angle: number$1().nullable().default(null),
158838
+ /** The sweep bounds (degrees): left → right, bottom → top. */
158839
+ sweepFrom: number$1().nullable().default(null),
158840
+ sweepTo: number$1().nullable().default(null),
158841
+ /** The angles the axis accepts. Null when the device states none. */
158842
+ min: number$1().nullable().default(null),
158843
+ max: number$1().nullable().default(null),
158844
+ step: number$1().nullable().default(null)
158845
+ });
158846
+ /** Both axes; an axis the device does not have is `null`. */
158847
+ var FanOscillationAxesSchema = object({
158848
+ horizontal: FanOscillationAxisSchema.nullable().default(null),
158849
+ vertical: FanOscillationAxisSchema.nullable().default(null)
158850
+ });
158851
+ var FanOscillationAxisRefusalSchema = _enum([
158852
+ "nothing-to-set",
158853
+ "axis-not-linked",
158854
+ "out-of-range",
158855
+ "source-gone",
158856
+ "source-unknown",
158857
+ "source-call-failed"
158858
+ ]);
158859
+ var FanOscillationAxisResultSchema = discriminatedUnion("status", [object({ status: literal("applied") }), object({
158860
+ status: literal("refused"),
158861
+ reason: FanOscillationAxisRefusalSchema,
158862
+ /** The field at fault, when one is. */
158863
+ field: FanOscillationAxisFieldSchema.optional(),
158864
+ /** One line for the operator, naming the axis, the field and the source. */
158865
+ detail: string(),
158866
+ /** Fields that DID land before the refusal (writes run in order, stop at the first failure). */
158867
+ applied: array(FanOscillationAxisFieldSchema)
158868
+ })]);
158869
+ var SetOscillationAxisInputSchema = object({
158870
+ deviceId: number$1().int().nonnegative(),
158871
+ axis: FanOscillationAxisNameSchema,
158872
+ oscillating: boolean().optional(),
158873
+ angle: number$1().optional(),
158874
+ sweepFrom: number$1().optional(),
158875
+ sweepTo: number$1().optional()
158876
+ });
158877
+ /** The state path of one axis field: `oscillationAxes.<axis>.<field>`. */
158878
+ function fanAxisPath(axis, field) {
158879
+ return `oscillationAxes.${axis}.${field}`;
158880
+ }
158292
158881
  var FanControlStatusSchema = object({
158293
158882
  /** Active speed as 0..100 inclusive. Null when the device has no
158294
158883
  * speed surface (single-speed fan). */
@@ -158307,9 +158896,102 @@ var FanControlStatusSchema = object({
158307
158896
  /** Oscillation toggle. Null when the device has no oscillation
158308
158897
  * surface. */
158309
158898
  oscillating: boolean().nullable(),
158899
+ /**
158900
+ * Per-axis oscillation (air circulators). Absent when the device has no
158901
+ * per-axis surface and nothing is linked in Customize.
158902
+ */
158903
+ oscillationAxes: FanOscillationAxesSchema.optional(),
158310
158904
  /** Ms epoch when the slice was last updated. */
158311
158905
  lastChangedAt: number$1()
158312
158906
  });
158907
+ var FAN_CUSTOMIZE_DEVICE_TYPES = [DeviceType.Fan];
158908
+ /** The Customize section the axis targets are listed under. */
158909
+ var AXES_SECTION = "oscillation-axes";
158910
+ function axisOscillatingTarget(axis) {
158911
+ return {
158912
+ id: `${axis}-oscillating`,
158913
+ cardinality: "scalar",
158914
+ vocabulary: {
158915
+ cap: "fan-control",
158916
+ stateField: "oscillating"
158917
+ },
158918
+ deviceTypes: FAN_CUSTOMIZE_DEVICE_TYPES,
158919
+ apply: "replace",
158920
+ section: AXES_SECTION,
158921
+ path: fanAxisPath(axis, "oscillating"),
158922
+ sources: [{
158923
+ kind: "switch",
158924
+ transforms: [{ kind: "identity" }]
158925
+ }],
158926
+ sourceReport: { status: "assignment-status" }
158927
+ };
158928
+ }
158929
+ /**
158930
+ * A numeric axis field. The `angle` link also carries the axis limits, read
158931
+ * from the SAME linked control's own range (`min`/`max`/`step`), so the limits
158932
+ * are the source's, never guessed.
158933
+ */
158934
+ function axisNumericTarget(axis, field) {
158935
+ const base = {
158936
+ id: `${axis}-${field}`,
158937
+ cardinality: "scalar",
158938
+ vocabulary: { cap: "fan-control" },
158939
+ deviceTypes: FAN_CUSTOMIZE_DEVICE_TYPES,
158940
+ apply: "replace",
158941
+ section: AXES_SECTION,
158942
+ path: fanAxisPath(axis, field),
158943
+ sources: [{
158944
+ kind: "numeric",
158945
+ transforms: [{ kind: "identity" }]
158946
+ }],
158947
+ sourceReport: { status: "assignment-status" }
158948
+ };
158949
+ if (field !== "angle") return base;
158950
+ return {
158951
+ ...base,
158952
+ companions: FAN_OSCILLATION_AXIS_LIMITS.map((limit) => ({
158953
+ kind: "source-field",
158954
+ path: fanAxisPath(axis, limit),
158955
+ field: limit
158956
+ }))
158957
+ };
158958
+ }
158959
+ var AXIS_TARGETS = FAN_OSCILLATION_AXES.flatMap((axis) => [
158960
+ axisOscillatingTarget(axis),
158961
+ axisNumericTarget(axis, "angle"),
158962
+ axisNumericTarget(axis, "sweepFrom"),
158963
+ axisNumericTarget(axis, "sweepTo")
158964
+ ]);
158965
+ /** A select (an enum control) the operator links to the fan's `preset`. */
158966
+ var PRESET_TARGET = {
158967
+ id: "preset",
158968
+ cardinality: "scalar",
158969
+ vocabulary: { cap: "fan-control" },
158970
+ deviceTypes: FAN_CUSTOMIZE_DEVICE_TYPES,
158971
+ apply: "replace",
158972
+ path: "preset",
158973
+ sources: [{
158974
+ kind: "field",
158975
+ valueKinds: ["string"],
158976
+ transforms: [{ kind: "identity" }]
158977
+ }],
158978
+ sourceReport: { status: "assignment-status" }
158979
+ };
158980
+ var FAN_CONTROL_TARGETS = [...AXIS_TARGETS, PRESET_TARGET];
158981
+ /**
158982
+ * Customize (D1034): the fan already serves `fan-control` natively, so every
158983
+ * target is a `replace` over a field listed in `overridable` — the axis leaves
158984
+ * and `preset`, nothing else. Nothing is pre-linked: the operator picks each
158985
+ * source (D356).
158986
+ */
158987
+ var fanControlCustomize = {
158988
+ version: 1,
158989
+ overridable: FAN_CONTROL_TARGETS.map((target) => ({
158990
+ path: target.path,
158991
+ by: target.id
158992
+ })),
158993
+ targets: FAN_CONTROL_TARGETS
158994
+ };
158313
158995
  var fanControlCapability = {
158314
158996
  name: "fan-control",
158315
158997
  scope: "device",
@@ -158344,6 +159026,18 @@ var fanControlCapability = {
158344
159026
  }), _void(), {
158345
159027
  kind: "mutation",
158346
159028
  auth: "protected"
159029
+ }),
159030
+ /**
159031
+ * Sets one oscillation axis: its switch, fixed angle and/or sweep bounds.
159032
+ * Fields left out are untouched. A field linked in Customize is forwarded
159033
+ * to its linked source (D1034); otherwise the native provider serves it;
159034
+ * neither → `axis-not-linked`. Ranges are checked against the axis limits
159035
+ * before anything is written; writes run in order and stop at the first
159036
+ * failure, which the result names.
159037
+ */
159038
+ setOscillationAxis: optionalMethod(SetOscillationAxisInputSchema, FanOscillationAxisResultSchema, {
159039
+ kind: "mutation",
159040
+ auth: "protected"
158347
159041
  })
158348
159042
  },
158349
159043
  status: {
@@ -158355,6 +159049,7 @@ var fanControlCapability = {
158355
159049
  * sliders read `speed` for live updates.
158356
159050
  */
158357
159051
  runtimeState: FanControlStatusSchema,
159052
+ customize: fanControlCustomize,
158358
159053
  /**
158359
159054
  * Runtime-state durability: **session** — as `brightness`.
158360
159055
  *
@@ -158374,16 +159069,33 @@ var fanControlCapability = {
158374
159069
  oscillating: { kind: "boolean" }
158375
159070
  } }
158376
159071
  };
159072
+ /** One axis as a preset wants it; an absent field is left as it is. */
159073
+ var FanPresetAxisSchema = object({
159074
+ oscillating: boolean().optional(),
159075
+ angle: number$1().optional(),
159076
+ sweepFrom: number$1().optional(),
159077
+ sweepTo: number$1().optional()
159078
+ });
159079
+ /** The fan-control state a preset sets; an absent field is left as it is. */
159080
+ var FanPresetStateSchema = object({
159081
+ speed: number$1().min(0).max(100).optional(),
159082
+ /** The fan's own preset mode (or the linked select's option). */
159083
+ preset: string().min(1).optional(),
159084
+ direction: FanDirectionSchema.optional(),
159085
+ oscillationAxes: object({
159086
+ horizontal: FanPresetAxisSchema.optional(),
159087
+ vertical: FanPresetAxisSchema.optional()
159088
+ }).optional()
159089
+ });
158377
159090
  var FanPresetSchema = object({
158378
159091
  /** Stable key; never reused after a delete within one device's list. */
158379
159092
  id: string().min(1).max(64),
158380
159093
  /** What the operator and a voice assistant call it. */
158381
159094
  name: string().trim().min(1).max(40),
158382
- steps: array(ActionStepSchema).min(1).max(20)
159095
+ state: FanPresetStateSchema
158383
159096
  });
158384
159097
  var FanPresetsRefusalSchema = _enum([
158385
- "not-sibling",
158386
- "bad-target",
159098
+ "empty-state",
158387
159099
  "duplicate-name",
158388
159100
  "duplicate-id",
158389
159101
  "too-many",
@@ -158395,72 +159107,55 @@ var FanPresetsSetResultSchema = discriminatedUnion("status", [object({
158395
159107
  }), object({
158396
159108
  status: literal("refused"),
158397
159109
  reason: FanPresetsRefusalSchema,
158398
- /** Names the preset and step at fault. */
159110
+ /** Names the preset at fault. */
158399
159111
  detail: string()
158400
159112
  })]);
158401
- var FanPresetStepResultSchema = object({
158402
- index: number$1().int().nonnegative(),
159113
+ var FanPresetFieldResultSchema = object({
159114
+ /** The state path: `speed`, `preset`, `direction`, `oscillationAxes.horizontal.angle`. */
159115
+ field: string(),
158403
159116
  outcome: _enum([
158404
159117
  "applied",
158405
159118
  "failed",
158406
159119
  "not-run",
158407
159120
  "refused"
158408
159121
  ]),
158409
- deviceId: number$1().int().nonnegative().optional(),
158410
- cap: string().optional(),
158411
- method: string().optional(),
158412
159122
  /** The cause, for every outcome but `applied`. */
158413
159123
  message: string().optional()
158414
159124
  });
158415
159125
  var FanPresetApplyResultSchema = object({
158416
- /** `applied`: every step ran. `partial`: some ran, one failed. `refused`: nothing ran. */
159126
+ /** `applied`: every field landed. `partial`: some did, one did not. `refused`: nothing ran. */
158417
159127
  status: _enum([
158418
159128
  "applied",
158419
159129
  "partial",
158420
159130
  "refused"
158421
159131
  ]),
158422
- steps: array(FanPresetStepResultSchema)
159132
+ fields: array(FanPresetFieldResultSchema)
158423
159133
  });
158424
159134
  var FanCaptureFieldSchema = _enum([
158425
159135
  "speed",
158426
- "oscillating",
158427
159136
  "direction",
158428
- "preset"
159137
+ "preset",
159138
+ "oscillationAxes"
158429
159139
  ]);
158430
- var FanCaptureOmissionSchema = object({
158431
- /** A fan field (`speed`) or `step <n>` for a sibling step. */
158432
- what: string(),
158433
- /** Why no value was taken: unknown reading (never stored as 0, D393), or a step that cannot be read. */
158434
- reason: string()
158435
- });
158436
- var FanCaptureItemSchema = object({
158437
- group: _enum([
158438
- "fan",
158439
- "oscillation",
158440
- "angles"
158441
- ]),
158442
- /** What the step sets, in the operator's words (a device name, a fan field). */
158443
- label: string()
158444
- });
158445
159140
  var FanPresetCaptureResultSchema = object({
158446
- /** The steps filled from the device's current values; NOT saved. */
158447
- steps: array(ActionStepSchema),
158448
- /** One entry per step, same order: its review group and label. */
158449
- items: array(FanCaptureItemSchema),
158450
- omitted: array(FanCaptureOmissionSchema)
159141
+ /** The fan's CURRENT fan-control state, as a preset; NOT saved. */
159142
+ state: FanPresetStateSchema,
159143
+ omitted: array(object({
159144
+ /** A state path (`speed`, `oscillationAxes.vertical.angle`). */
159145
+ what: string(),
159146
+ /** Why no value was taken: an unknown reading is never stored as 0 (D393). */
159147
+ reason: string()
159148
+ }))
158451
159149
  });
158452
- var deviceInput$2 = object({ deviceId: number$1().int().nonnegative() });
159150
+ var deviceInput$1 = object({ deviceId: number$1().int().nonnegative() });
158453
159151
  DeviceType.Fan;
158454
- method(deviceInput$2, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$2.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
159152
+ method(deviceInput$1, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$1.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
158455
159153
  kind: "mutation",
158456
159154
  auth: "admin"
158457
- }), method(deviceInput$2.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
159155
+ }), method(deviceInput$1.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
158458
159156
  kind: "mutation",
158459
159157
  auth: "protected"
158460
- }), method(deviceInput$2.extend({
158461
- fields: array(FanCaptureFieldSchema).optional(),
158462
- steps: array(ActionStepSchema).max(20).default([])
158463
- }), FanPresetCaptureResultSchema, { auth: "protected" });
159158
+ }), method(deviceInput$1.extend({ fields: array(FanCaptureFieldSchema).optional() }), FanPresetCaptureResultSchema, { auth: "protected" });
158464
159159
  /**
158465
159160
  * Per-device feature/identity probe slice. Holds the runtime-resolved
158466
159161
  * truth about what a device CAN do — which the kernel uses to:
@@ -158672,8 +159367,7 @@ var groupActiveCapability = {
158672
159367
  DeviceType.Valve,
158673
159368
  DeviceType.Lock,
158674
159369
  DeviceType.MediaPlayer,
158675
- DeviceType.Climate,
158676
- DeviceType.Thermostat
159370
+ DeviceType.Climate
158677
159371
  ],
158678
159372
  methods: {},
158679
159373
  status: {
@@ -158715,7 +159409,6 @@ var groupCommandsCapability = {
158715
159409
  DeviceType.Valve,
158716
159410
  DeviceType.Lock,
158717
159411
  DeviceType.MediaPlayer,
158718
- DeviceType.Thermostat,
158719
159412
  DeviceType.Climate
158720
159413
  ],
158721
159414
  methods: {},
@@ -158771,7 +159464,6 @@ var groupStatusCapability = {
158771
159464
  DeviceType.Valve,
158772
159465
  DeviceType.Lock,
158773
159466
  DeviceType.MediaPlayer,
158774
- DeviceType.Thermostat,
158775
159467
  DeviceType.Climate
158776
159468
  ],
158777
159469
  methods: {},
@@ -159100,7 +159792,7 @@ var heatingValveCapability = {
159100
159792
  scope: "device",
159101
159793
  deviceNative: true,
159102
159794
  mode: "singleton",
159103
- deviceTypes: [DeviceType.Thermostat],
159795
+ deviceTypes: [DeviceType.Climate],
159104
159796
  methods: {},
159105
159797
  status: {
159106
159798
  schema: HeatingValveStatusSchema,
@@ -159130,13 +159822,18 @@ var heatingValveCapability = {
159130
159822
  * retried in a loop - D49); a future one is re-armed.
159131
159823
  *
159132
159824
  * What a device may be run for, and for how long at most, is per device type
159133
- * ({@link TIMED_RUN_LIMITS}): the maximum is a safety bound, not a preference,
159825
+ * and role ({@link timedRunLimitOf}): the maximum is a safety bound, not a preference,
159134
159826
  * so a request above it is REFUSED with a typed reason, never clamped.
159135
159827
  */
159136
159828
  var TimedRunUnitSchema = _enum(["s", "min"]);
159137
159829
  _enum(["switch", "pet-fountain"]);
159138
- DeviceType.Heater, DeviceType.PetFountain;
159139
- var TIMED_RUN_DEVICE_TYPES = [DeviceType.Heater, DeviceType.PetFountain];
159830
+ /**
159831
+ * The device types `timed-run` may be offered on. A `switch` is narrowed by
159832
+ * role ({@link TIMED_RUN_DEVICE_ROLES}): only a plug-in heater runs on a timer.
159833
+ */
159834
+ var TIMED_RUN_DEVICE_TYPES = [DeviceType.Switch, DeviceType.PetFountain];
159835
+ /** The roles that make a device of these types timed-run-able (D1033). */
159836
+ var TIMED_RUN_DEVICE_ROLES = { [DeviceType.Switch]: [DeviceRole.SwitchHeater] };
159140
159837
  /** One duration, as the one-tap run asks for it. */
159141
159838
  var TimedRunQuickRunSchema = object({
159142
159839
  duration: number$1().positive().finite(),
@@ -159186,6 +159883,7 @@ var timedRunCapability = {
159186
159883
  kind: "wrapper",
159187
159884
  defaultActive: true,
159188
159885
  deviceTypes: TIMED_RUN_DEVICE_TYPES,
159886
+ deviceRoles: TIMED_RUN_DEVICE_ROLES,
159189
159887
  deviceConfig: { ui: {
159190
159888
  kind: "derived-form",
159191
159889
  builderId: "timed-run",
@@ -159346,8 +160044,8 @@ var HeroSceneSchema = object({
159346
160044
  /** 0..1: volume, cover position, cycle progress. */
159347
160045
  level: number$1().min(0).max(1).nullable()
159348
160046
  });
159349
- 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;
159350
- 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;
160047
+ 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;
160048
+ 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;
159351
160049
  /** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
159352
160050
  var HeroTextSchema = object({
159353
160051
  en: string(),
@@ -159732,8 +160430,8 @@ var HeroRowModelSchema = object({
159732
160430
  extras: array(HeroControlSchema).max(2).optional(),
159733
160431
  trailing: HeroFactSchema.nullable()
159734
160432
  });
159735
- DeviceType.Climate, DeviceType.Thermostat;
159736
- DeviceType.Climate, DeviceType.Thermostat, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
160433
+ DeviceType.Climate;
160434
+ DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
159737
160435
  /**
159738
160436
  * hero-layout — what a device's hero says (D1023). Read-only: the FIXED
159739
160437
  * layouts live in `@camstack/types` and nothing here stores or edits one.
@@ -159765,7 +160463,10 @@ method(heroInput, HeroModelSchema.nullable(), {
159765
160463
  }), method(rowModelsInput, array(HeroRowModelSchema.nullable()), {
159766
160464
  auth: "protected",
159767
160465
  role: "viewer"
159768
- }), method(object({ deviceType: string() }), HeroLayoutRowsSchema, {
160466
+ }), method(object({
160467
+ deviceType: string(),
160468
+ role: string().nullable().optional()
160469
+ }), HeroLayoutRowsSchema, {
159769
160470
  auth: "protected",
159770
160471
  role: "viewer"
159771
160472
  });
@@ -159812,6 +160513,11 @@ var humidifierCapability = {
159812
160513
  deviceNative: true,
159813
160514
  mode: "singleton",
159814
160515
  deviceTypes: [DeviceType.Humidifier],
160516
+ power: {
160517
+ kind: "field",
160518
+ field: "on",
160519
+ set: "setOn"
160520
+ },
159815
160521
  methods: {
159816
160522
  setOn: method(object({
159817
160523
  deviceId: number$1().int().nonnegative(),
@@ -159885,7 +160591,7 @@ var humiditySensorCapability = {
159885
160591
  scope: "device",
159886
160592
  deviceNative: true,
159887
160593
  mode: "singleton",
159888
- deviceTypes: [DeviceType.Sensor, DeviceType.Thermostat],
160594
+ deviceTypes: [DeviceType.Sensor, DeviceType.Climate],
159889
160595
  methods: {},
159890
160596
  status: {
159891
160597
  schema: HumiditySensorStatusSchema,
@@ -160179,6 +160885,12 @@ var IntegrationLiteSchema = object({
160179
160885
  var AvailableIntegrationTypeSchema = object({
160180
160886
  addonId: string(),
160181
160887
  name: string(),
160888
+ /**
160889
+ * Product name a new integration is prefilled from (`<label> - Home`).
160890
+ * Absent: the client uses `name`. Set when the catalog title is not the
160891
+ * product (Bosch SHC, MQTT).
160892
+ */
160893
+ providerLabel: string().optional(),
160182
160894
  description: string(),
160183
160895
  iconUrl: string().nullable(),
160184
160896
  color: string(),
@@ -173108,7 +173820,18 @@ var OauthIntegrationDescriptorSchema = object({
173108
173820
  * The value is baked into the authorization code at `/authorize` and travels
173109
173821
  * on the tokens, so editing this field changes FUTURE links only.
173110
173822
  */
173111
- refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional()
173823
+ refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional(),
173824
+ /**
173825
+ * The integration instances an account can be linked to (planning#415),
173826
+ * beside the default one. `/api/oauth2/authorize?instance=<id>` is accepted
173827
+ * only for an id listed here; with no `instance=` the link is made to the
173828
+ * default instance, which is never listed and always accepted — it is the
173829
+ * address third parties already hold. Omit for a single-instance integration.
173830
+ */
173831
+ instances: array(object({
173832
+ id: string(),
173833
+ displayName: string()
173834
+ })).optional()
173112
173835
  });
173113
173836
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
173114
173837
  /**
@@ -173644,6 +174367,11 @@ var petFountainCapability = {
173644
174367
  deviceNative: true,
173645
174368
  mode: "singleton",
173646
174369
  deviceTypes: [DeviceType.PetFountain],
174370
+ power: {
174371
+ kind: "field",
174372
+ field: "pumpRunning",
174373
+ set: "setPump"
174374
+ },
173647
174375
  methods: {
173648
174376
  /** Start or stop the pump. */
173649
174377
  setPump: method(object({
@@ -175219,7 +175947,6 @@ var POWER_METER_DEVICE_TYPES = [
175219
175947
  DeviceType.Light,
175220
175948
  DeviceType.Fan,
175221
175949
  DeviceType.Climate,
175222
- DeviceType.Thermostat,
175223
175950
  DeviceType.Humidifier,
175224
175951
  DeviceType.WaterHeater,
175225
175952
  DeviceType.MediaPlayer,
@@ -175228,8 +175955,7 @@ var POWER_METER_DEVICE_TYPES = [
175228
175955
  DeviceType.Dishwasher,
175229
175956
  DeviceType.Vacuum,
175230
175957
  DeviceType.LawnMower,
175231
- DeviceType.PetFeeder,
175232
- DeviceType.Heater
175958
+ DeviceType.PetFeeder
175233
175959
  ];
175234
175960
  /** Everything but a bare `Sensor`: a sensor that takes its reading from another sensor adds nothing. */
175235
175961
  var POWER_METER_CUSTOMIZE_DEVICE_TYPES = POWER_METER_DEVICE_TYPES.filter((type) => type !== DeviceType.Sensor);
@@ -175342,117 +176068,6 @@ var powerMeterCapability = {
175342
176068
  volatileStateFields: ["lastFetchedAt"],
175343
176069
  customize: powerMeterCustomize
175344
176070
  };
175345
- var PowerSourceRefusalReasonSchema = _enum([
175346
- "no-power-source",
175347
- "switch-missing",
175348
- "switch-offline",
175349
- "switch-unknown",
175350
- "restart-in-progress",
175351
- "switch-call-failed"
175352
- ]);
175353
- var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
175354
- accepted: literal(false),
175355
- reason: PowerSourceRefusalReasonSchema,
175356
- /** One line for the operator, naming the switch. */
175357
- message: string()
175358
- })]);
175359
- var PowerSourceInfoSchema = object({
175360
- /** False when the device has no power source linked; the rest is then empty. */
175361
- linked: boolean(),
175362
- switchDeviceId: number$1().nullable(),
175363
- switchName: string().nullable(),
175364
- /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
175365
- switchOn: boolean().nullable(),
175366
- switchOnline: boolean().nullable(),
175367
- restartInProgress: boolean(),
175368
- offSeconds: number$1().int()
175369
- });
175370
- /** The composed slice: the switch state the link mirrors, plus the stored off time. */
175371
- var PowerSourceStateSchema = object({
175372
- /** Null while the switch has not reported: unknown is never `false` (D393). */
175373
- switchOn: boolean().nullable(),
175374
- offSeconds: number$1().int(),
175375
- lastFetchedAt: number$1()
175376
- });
175377
- var POWER_SOURCE_DEVICE_TYPES = [
175378
- DeviceType.Gateway,
175379
- DeviceType.Camera,
175380
- DeviceType.Sensor,
175381
- DeviceType.MediaPlayer,
175382
- DeviceType.Vacuum,
175383
- DeviceType.Generic,
175384
- DeviceType.Washer,
175385
- DeviceType.Dryer,
175386
- DeviceType.Dishwasher,
175387
- DeviceType.PetFountain,
175388
- DeviceType.Fan,
175389
- DeviceType.Humidifier,
175390
- DeviceType.Climate,
175391
- DeviceType.WaterHeater
175392
- ];
175393
- var powerSourceCustomize = {
175394
- version: 1,
175395
- targets: [{
175396
- id: "switch",
175397
- cardinality: "scalar",
175398
- vocabulary: {
175399
- cap: "power-source",
175400
- stateField: "switchOn"
175401
- },
175402
- deviceTypes: POWER_SOURCE_DEVICE_TYPES,
175403
- apply: "add",
175404
- path: "switchOn",
175405
- sources: [{
175406
- kind: "switch",
175407
- transforms: [{ kind: "identity" }]
175408
- }],
175409
- companions: [{
175410
- kind: "constant",
175411
- path: "offSeconds",
175412
- value: 10,
175413
- when: "add",
175414
- formerValues: [0]
175415
- }, {
175416
- kind: "clock",
175417
- path: "lastFetchedAt",
175418
- when: "always"
175419
- }],
175420
- sourceReport: { status: "assignment-status" }
175421
- }]
175422
- };
175423
- var deviceInput$1 = object({ deviceId: number$1().int().nonnegative() });
175424
- var powerSourceCapability = {
175425
- name: "power-source",
175426
- scope: "device",
175427
- mode: "singleton",
175428
- deviceTypes: POWER_SOURCE_DEVICE_TYPES,
175429
- methods: {
175430
- getStatus: systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "protected" }),
175431
- powerOn: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
175432
- kind: "mutation",
175433
- auth: "protected"
175434
- }),
175435
- powerOff: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
175436
- kind: "mutation",
175437
- auth: "protected"
175438
- }),
175439
- forceRestart: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
175440
- kind: "mutation",
175441
- auth: "protected"
175442
- })
175443
- },
175444
- runtimeState: PowerSourceStateSchema,
175445
- customize: powerSourceCustomize,
175446
- /**
175447
- * Runtime-state durability: **session** — mirrored from the linked switch on
175448
- * its next report; a restored value would outlive the reading it names.
175449
- *
175450
- * See `RuntimeStateDurability`. Enforced by
175451
- * `scripts/check-runtime-state-durability.ts`.
175452
- */
175453
- durability: "session",
175454
- history: "none"
175455
- };
175456
176071
  /**
175457
176072
  * Presence cap. Models HA `person.*` and `device_tracker.*` entities
175458
176073
  * on `DeviceType.Presence`. Read-only — no setters: presence is
@@ -179479,9 +180094,7 @@ var RUNNING_CUSTOMIZE_DEVICE_TYPES = [
179479
180094
  DeviceType.Humidifier,
179480
180095
  DeviceType.Fan,
179481
180096
  DeviceType.Climate,
179482
- DeviceType.Thermostat,
179483
- DeviceType.PetFeeder,
179484
- DeviceType.Heater
180097
+ DeviceType.PetFeeder
179485
180098
  ];
179486
180099
  var runningStateCapability = {
179487
180100
  name: "running-state",
@@ -180857,6 +181470,13 @@ var SsoBridgeClaimsSchema = object({
180857
181470
  /** OAuth authorization-code binding — set only on `oauth-code` tokens. */
180858
181471
  redirectUri: string().optional(),
180859
181472
  integrationId: string().optional(),
181473
+ /**
181474
+ * The integration INSTANCE an OAuth link was made for (planning#415). Set on
181475
+ * `oauth-code`, `oauth-access` and `oauth-refresh` tokens of a link made
181476
+ * with `instance=`; absent on a link to the default instance. A cloud relay
181477
+ * reads it off the access token to route; the hub answers from the session.
181478
+ */
181479
+ instanceId: string().optional(),
180860
181480
  /** JWT ID — unique per issued code; consumed-set enforces single-use. */
180861
181481
  jti: string().optional(),
180862
181482
  /** PKCE S256 challenge — set only on `oauth-code` tokens issued to a public
@@ -181673,8 +182293,7 @@ var switchCapability = {
181673
182293
  DeviceType.Switch,
181674
182294
  DeviceType.Siren,
181675
182295
  DeviceType.Light,
181676
- DeviceType.Fan,
181677
- DeviceType.Heater
182296
+ DeviceType.Fan
181678
182297
  ],
181679
182298
  methods: { setState: method(object({
181680
182299
  deviceId: number$1(),
@@ -182368,7 +182987,7 @@ var temperatureSensorCapability = {
182368
182987
  scope: "device",
182369
182988
  deviceNative: true,
182370
182989
  mode: "singleton",
182371
- deviceTypes: [DeviceType.Sensor, DeviceType.Thermostat],
182990
+ deviceTypes: [DeviceType.Sensor, DeviceType.Climate],
182372
182991
  methods: {},
182373
182992
  status: {
182374
182993
  schema: TemperatureSensorStatusSchema,
@@ -183236,6 +183855,8 @@ var OauthSessionSummarySchema = object({
183236
183855
  userId: string(),
183237
183856
  username: string(),
183238
183857
  integrationId: string(),
183858
+ /** The instance the link was made for; `null` = the default instance. */
183859
+ instanceId: string().nullable().optional(),
183239
183860
  scopes: array(TokenScopeSchema),
183240
183861
  createdAt: number$1(),
183241
183862
  lastUsedAt: number$1(),
@@ -183335,6 +183956,9 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
183335
183956
  access: "view"
183336
183957
  }), method(object({
183337
183958
  integrationId: string(),
183959
+ /** The integration instance the link is for. Omit for the default
183960
+ * instance — never pass the addon id to mean it. */
183961
+ instanceId: string().optional(),
183338
183962
  userId: string(),
183339
183963
  username: string(),
183340
183964
  scopes: array(TokenScopeSchema),
@@ -183373,7 +183997,13 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
183373
183997
  }), method(object({ token: string() }), object({
183374
183998
  userId: string(),
183375
183999
  username: string(),
183376
- scopes: array(TokenScopeSchema)
184000
+ scopes: array(TokenScopeSchema),
184001
+ /** The instance the link was made for, read from the SESSION.
184002
+ * Absent = the default instance. `oauthLinkServesInstance` is the
184003
+ * helper a per-instance route calls to compare it with the instance
184004
+ * of its path; no route declares `perInstance` yet (the Alexa
184005
+ * per-instance route, T3, is the first consumer). */
184006
+ instanceId: string().optional()
183377
184007
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
183378
184008
  userId: string(),
183379
184009
  issuer: string()
@@ -184015,6 +184645,13 @@ var waterHeaterCapability = {
184015
184645
  deviceNative: true,
184016
184646
  mode: "singleton",
184017
184647
  deviceTypes: [DeviceType.WaterHeater],
184648
+ power: {
184649
+ kind: "mode",
184650
+ field: "operationMode",
184651
+ offValue: "off",
184652
+ set: "setOperationMode",
184653
+ lastField: "lastActiveMode"
184654
+ },
184018
184655
  methods: {
184019
184656
  setTargetTemp: method(object({
184020
184657
  deviceId: number$1().int().nonnegative(),
@@ -187278,15 +187915,16 @@ var BaseDeviceProvider = class extends BaseAddon {
187278
187915
  });
187279
187916
  const meta = await this.ctx.api.deviceManager.loadMeta.query({ deviceId: id });
187280
187917
  if (meta === null) throw new Error(`${this.providerName}: no persisted meta for "${stableId}" (id ${id}) — cannot reload`);
187281
- const deviceType = Object.values(DeviceType).find((t) => t === meta.type);
187282
- const Class = deviceType !== void 0 ? this.deviceClasses[deviceType] : void 0;
187918
+ const Class = this.deviceClassForRow({
187919
+ type: meta.type,
187920
+ stableId
187921
+ });
187283
187922
  if (!Class) throw new Error(`${this.providerName}: no device class for type "${meta.type}" — "${stableId}" is an accessory child; reload its parent instead`);
187284
187923
  await devices.create(stableId, Class, {}, meta.parentDeviceId ?? null);
187285
187924
  const rows = await this.ctx.api.deviceManager.listPersistedByAddon.query({ addonId: this.addonId });
187286
187925
  for (const row of rows) {
187287
187926
  if (row.parentDeviceId !== id) continue;
187288
- const childType = Object.values(DeviceType).find((t) => t === row.type);
187289
- const ChildClass = childType !== void 0 ? this.deviceClasses[childType] : void 0;
187927
+ const ChildClass = this.deviceClassForRow(row);
187290
187928
  if (!ChildClass) continue;
187291
187929
  try {
187292
187930
  await devices.create(row.stableId, ChildClass, {}, id);
@@ -187313,6 +187951,16 @@ var BaseDeviceProvider = class extends BaseAddon {
187313
187951
  return { deviceId: id };
187314
187952
  }
187315
187953
  /**
187954
+ * The class a PERSISTED row is rebuilt with. Default: by type, from
187955
+ * `deviceClasses`. A provider whose distinct devices share one type (D1033:
187956
+ * a radiator valve and a room climate are both `climate`) overrides this
187957
+ * and tells them apart by the row's stable id or config.
187958
+ */
187959
+ deviceClassForRow(row) {
187960
+ const type = Object.values(DeviceType).find((t) => t === row.type);
187961
+ return type !== void 0 ? this.deviceClasses[type] : void 0;
187962
+ }
187963
+ /**
187316
187964
  * Restore devices from persisted state. Two-pass:
187317
187965
  *
187318
187966
  * 1. **Top-level pass** — invokes `kernel.devices.create()` for every
@@ -187373,7 +188021,7 @@ var BaseDeviceProvider = class extends BaseAddon {
187373
188021
  restored.add(saved.id);
187374
188022
  return;
187375
188023
  }
187376
- const Class = this.deviceClasses[saved.type];
188024
+ const Class = this.deviceClassForRow(saved);
187377
188025
  if (!Class) throw new Error(`no device class registered for type "${saved.type}"`);
187378
188026
  if (saved.parentDeviceId !== null && !restored.has(saved.parentDeviceId)) throw new Error(`parent device ${saved.parentDeviceId} not restored`);
187379
188027
  await this.healSavedConfig(saved, savedDevices);
@@ -187390,7 +188038,7 @@ var BaseDeviceProvider = class extends BaseAddon {
187390
188038
  };
187391
188039
  const topLevel = savedDevices.filter((saved) => saved.parentDeviceId === null);
187392
188040
  const restoreOne = async (saved) => {
187393
- if (!this.deviceClasses[saved.type]) {
188041
+ if (!this.deviceClassForRow(saved)) {
187394
188042
  this.ctx.logger.warn("No device class registered for restored type — skipping", {
187395
188043
  tags: {
187396
188044
  deviceId: saved.id,
@@ -187429,7 +188077,7 @@ var BaseDeviceProvider = class extends BaseAddon {
187429
188077
  const failedTopLevelIds = new Set(failures.map((failure) => failure.saved.id));
187430
188078
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
187431
188079
  for (const saved of childRows) {
187432
- if (!this.deviceClasses[saved.type]) continue;
188080
+ if (!this.deviceClassForRow(saved)) continue;
187433
188081
  if (saved.parentDeviceId === null) continue;
187434
188082
  if (restored.has(saved.parentDeviceId)) {
187435
188083
  try {
@@ -187483,7 +188131,9 @@ var BaseDeviceProvider = class extends BaseAddon {
187483
188131
  }
187484
188132
  };
187485
188133
  DeviceType.HeatPump;
187486
- 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;
188134
+ DeviceType.Climate;
188135
+ DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
188136
+ 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;
187487
188137
  new Set(Object.values(DeviceType));
187488
188138
  /** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
187489
188139
  function contribution(cap, schema, build) {
@@ -189489,7 +190139,7 @@ var HEAT_PUMP_FAMILY_CONTRIBUTIONS = { "heat-pump-status": contribution("heat-pu
189489
190139
  ...Object.values(CLIMATE_FAMILY_CONTRIBUTIONS),
189490
190140
  ...Object.values(HEAT_PUMP_FAMILY_CONTRIBUTIONS)
189491
190141
  ];
189492
- 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;
190142
+ 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;
189493
190143
  /**
189494
190144
  * Who looks like what (D1023). One look per {@link DeviceType}, refined by a
189495
190145
  * {@link DeviceRole} where the role changes how the device reads (a leak
@@ -190133,9 +190783,9 @@ lookOf({
190133
190783
  idle: INFO,
190134
190784
  standby: MUTED
190135
190785
  });
190136
- DeviceType.Climate, DeviceType.Thermostat;
190137
- 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;
190138
- 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;
190786
+ DeviceType.Climate;
190787
+ 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;
190788
+ 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;
190139
190789
  Object.freeze({
190140
190790
  "accessories.getStatus": {
190141
190791
  capName: "accessories",
@@ -193532,6 +194182,13 @@ Object.freeze({
193532
194182
  access: "create",
193533
194183
  role: "viewer"
193534
194184
  },
194185
+ "fanControl.setOscillationAxis": {
194186
+ capName: "fan-control",
194187
+ capScope: "device",
194188
+ addonId: null,
194189
+ access: "create",
194190
+ role: "viewer"
194191
+ },
193535
194192
  "fanControl.setPercentage": {
193536
194193
  capName: "fan-control",
193537
194194
  capScope: "device",
@@ -200553,7 +201210,7 @@ function projectAction(cap, action) {
200553
201210
  };
200554
201211
  }
200555
201212
  Object.entries(CAP_VOCABULARY_BY_NAME).flatMap(([cap, entry]) => entry.scope === "device" ? (entry.actions ?? []).map((a) => projectAction(cap, a)) : []);
200556
- 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;
201213
+ 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;
200557
201214
  DeviceFeature.BatteryOperated;
200558
201215
  function bound(cap, methods = [], authority = "reported") {
200559
201216
  return {
@@ -201757,6 +202414,11 @@ Object.freeze({
201757
202414
  form: "single",
201758
202415
  optional: false
201759
202416
  }],
202417
+ "fanControl.setOscillationAxis": [{
202418
+ name: "deviceId",
202419
+ form: "single",
202420
+ optional: false
202421
+ }],
201760
202422
  "fanControl.setPercentage": [{
201761
202423
  name: "deviceId",
201762
202424
  form: "single",
@@ -205239,6 +205901,38 @@ DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
205239
205901
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
205240
205902
  DEFAULT_NATIVE_LEASE_SETTINGS.sceneBudgetMb;
205241
205903
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
205904
+ /**
205905
+ * Names chosen when an integration or a Gateway device is created.
205906
+ * A stored name is never rewritten from these helpers.
205907
+ */
205908
+ var HOME_SUFFIX = "Home";
205909
+ function collapse(value) {
205910
+ return value.trim().replace(/\s+/g, " ");
205911
+ }
205912
+ /** "KLF-200" → "KLF200". A hyphen between words ("Home Hub") stays. */
205913
+ function compactModelToken(value) {
205914
+ return value.replace(/([A-Za-z])-(\d)/g, "$1$2");
205915
+ }
205916
+ /** Prefill for a new integration: "<provider> - Home". The operator can edit it. */
205917
+ function defaultIntegrationName(providerLabel) {
205918
+ const label = collapse(providerLabel);
205919
+ if (label.length === 0) return HOME_SUFFIX;
205920
+ return `${label} - ${HOME_SUFFIX}`;
205921
+ }
205922
+ /**
205923
+ * A Gateway device: "<Brand> <Model>". An unknown model is the brand alone
205924
+ * (the caller passes the brand-level fallback it already has, e.g. "Velux KLF-200").
205925
+ */
205926
+ function gatewayDeviceName(brand, model) {
205927
+ const brandPart = compactModelToken(collapse(brand));
205928
+ const raw = collapse(model ?? "");
205929
+ if (raw.length === 0) return brandPart;
205930
+ const modelPart = compactModelToken(raw);
205931
+ const prefix = `${brandPart.toLowerCase()} `;
205932
+ if (modelPart.toLowerCase() === brandPart.toLowerCase()) return brandPart;
205933
+ if (modelPart.toLowerCase().startsWith(prefix)) return modelPart;
205934
+ return `${brandPart} ${modelPart}`;
205935
+ }
205242
205936
  String.raw`(?<=^|["'(\s>,\[{])`;
205243
205937
  var MB = 1024 * 1024;
205244
205938
  1024 * MB, 3072 * MB;
@@ -211891,6 +212585,20 @@ function deriveChargingSource(adapterStatus, chargeStatus) {
211891
212585
  function reportsPowerSource(info) {
211892
212586
  return info.adapterStatus !== void 0 || info.chargeStatus !== void 0;
211893
212587
  }
212588
+ /**
212589
+ * Whether a level the CAMERA itself reported (push or direct read) is a
212590
+ * MEASUREMENT (D393). A battery camera answering a read on the way in or out of
212591
+ * sleep, or while on mains or a panel, reports `0` as a placeholder — device
212592
+ * 3628 sat at 100% on its adapter and raised a low-battery notification on
212593
+ * every hourly wake. Those zeros are UNMEASURED: the caller keeps the last real
212594
+ * level. A `0` from an awake camera running on its cell alone (or of unknown
212595
+ * source) is a genuine empty cell and passes, as does every non-zero level.
212596
+ */
212597
+ function isMeasuredCameraBatteryLevel(level, context) {
212598
+ if (level !== 0) return true;
212599
+ if (context.sleeping) return false;
212600
+ return context.charging !== "dc" && context.charging !== "solar";
212601
+ }
211894
212602
  /** The settings key, per device. */
211895
212603
  var BATTERY_REFRESH_MINUTES_KEY = "batteryRefreshMinutes";
211896
212604
  /** How often the in-memory check runs. Costs nothing: no I/O unless it fires. */
@@ -213042,6 +213750,8 @@ var reolinkHubConnectionSchema = object({
213042
213750
  transport: _enum(["tcp", "udp"]).default("tcp"),
213043
213751
  /** UID of a hub that was paired by it; unused for a plain TCP login. */
213044
213752
  uid: string().optional(),
213753
+ /** Model reported when the hub was discovered. Absent on a hand-typed connection. */
213754
+ model: string().optional(),
213045
213755
  debugGeneral: boolean().default(false),
213046
213756
  debugSocketLogs: array(ReolinkSocketDebugFlagSchema).default([])
213047
213757
  });
@@ -213931,12 +214641,16 @@ function hubGatewayNativeId(integrationId) {
213931
214641
  * `reboot` (Baichuan `Reboot`) and the unit's web page.
213932
214642
  */
213933
214643
  function toDiscoveredGateway(input) {
214644
+ const model = input.model?.trim() ?? "";
213934
214645
  return {
213935
214646
  childNativeId: hubGatewayNativeId(input.integrationId),
213936
- name: input.name,
214647
+ name: gatewayDeviceName("Reolink", model.length > 0 ? model : "Home Hub"),
213937
214648
  type: DeviceType.Gateway,
213938
214649
  status: input.online ? "online" : "offline",
213939
- metadata: { manufacturer: "Reolink" },
214650
+ metadata: {
214651
+ manufacturer: "Reolink",
214652
+ ...model.length > 0 ? { model } : { model: "Home Hub" }
214653
+ },
213940
214654
  alreadyAdopted: input.adoptedDeviceId !== null,
213941
214655
  adoptedDeviceId: input.adoptedDeviceId,
213942
214656
  capabilities: [rebootCapability.name, deviceAdminLinkCapability.name]
@@ -218928,10 +219642,26 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
218928
219642
  * tracker is more reliable.
218929
219643
  */
218930
219644
  mapBatteryInfo(info) {
219645
+ const charging = reportsPowerSource(info) ? deriveChargingSource(info.adapterStatus, info.chargeStatus) : this.state.battery.charging ?? "unknown";
219646
+ const sleeping = info.sleeping === true || this.sleeping;
219647
+ const reported = typeof info.batteryPercent === "number" ? Math.max(0, Math.min(100, Math.round(info.batteryPercent))) : void 0;
219648
+ const measured = reported !== void 0 && isMeasuredCameraBatteryLevel(reported, {
219649
+ sleeping,
219650
+ charging
219651
+ });
219652
+ if (reported === 0) this.ctx.logger.info("battery read reporting 0", {
219653
+ tags: { deviceId: this.id },
219654
+ meta: {
219655
+ measured,
219656
+ sleeping,
219657
+ charging,
219658
+ raw: info
219659
+ }
219660
+ });
218931
219661
  return {
218932
- level: typeof info.batteryPercent === "number" ? Math.max(0, Math.min(100, Math.round(info.batteryPercent))) : this.state.battery.level ?? null,
218933
- charging: reportsPowerSource(info) ? deriveChargingSource(info.adapterStatus, info.chargeStatus) : this.state.battery.charging ?? "unknown",
218934
- sleeping: info.sleeping === true || this.sleeping,
219662
+ level: reported !== void 0 && measured ? reported : this.state.battery.level ?? null,
219663
+ charging,
219664
+ sleeping,
218935
219665
  lastUpdated: Date.now()
218936
219666
  };
218937
219667
  }
@@ -226180,6 +226910,7 @@ var reolinkConnectionsEntryKind = defineEntryKind("connections", {
226180
226910
  password: string().optional().meta({ secret: true }),
226181
226911
  transport: _enum(["tcp", "udp"]).nullish(),
226182
226912
  uid: string().nullish(),
226913
+ model: string().nullish(),
226183
226914
  debugGeneral: boolean().nullish(),
226184
226915
  debugSocketLogs: array(ReolinkSocketDebugFlagSchema).nullish(),
226185
226916
  mailboxId: mailboxLinkField()
@@ -226426,11 +227157,12 @@ function mapReolinkDiscoveryToCandidates(devices, credentials, onboarded = [], h
226426
227157
  return [{
226427
227158
  stableId: reolinkHubStableId(d),
226428
227159
  type: DeviceType.Gateway,
226429
- suggestedName: displayName,
227160
+ suggestedName: defaultIntegrationName("Reolink"),
226430
227161
  prefilledConfig: {
226431
227162
  host: d.host,
226432
227163
  port: HUB_BAICHUAN_PORT,
226433
227164
  ...d.uid ? { uid: d.uid } : {},
227165
+ ...d.model ? { model: d.model } : {},
226434
227166
  ...username ? { username } : {}
226435
227167
  },
226436
227168
  setupIntegration: true
@@ -226895,7 +227627,7 @@ function buildReolinkAdoptionProvider(deps) {
226895
227627
  const gateways = await deps.listAdoptedGateways();
226896
227628
  return [toDiscoveredGateway({
226897
227629
  integrationId,
226898
- name: session.name,
227630
+ model: session.connection.model,
226899
227631
  online: session.isOnline,
226900
227632
  adoptedDeviceId: gateways.find((g) => g.integrationId === integrationId)?.id ?? null
226901
227633
  }), ...session.channelSnapshot().channels.map((channel) => toDiscoveredChild(channel, findAdoptedForChannel(adopted, integrationId, channel)))];
@@ -226963,7 +227695,7 @@ function buildReolinkAdoptionProvider(deps) {
226963
227695
  const known = (await deps.listAdoptedGateways()).find((g) => g.integrationId === integrationId);
226964
227696
  const { deviceId } = known !== void 0 ? { deviceId: known.id } : await deps.adoptGateway({
226965
227697
  integrationId,
226966
- name: perCandidate?.[childNativeId]?.name ?? session.name
227698
+ name: perCandidate?.[childNativeId]?.name ?? gatewayDeviceName("Reolink", session.connection.model?.trim() || "Home Hub")
226967
227699
  });
226968
227700
  adopted.push({
226969
227701
  childNativeId,