@camstack/addon-provider-homematic 1.2.189 → 1.2.191

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.js CHANGED
@@ -811,7 +811,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
811
811
  return EventCategory;
812
812
  }({});
813
813
  //#endregion
814
- //#region ../types/dist/composed-stable-id-jnvhwGoH.mjs
814
+ //#region ../types/dist/composed-stable-id-CPp3votu.mjs
815
815
  /**
816
816
  import { errMsg } from '@camstack/types'
817
817
  * Extract a human-readable message from an unknown error value.
@@ -824,17 +824,18 @@ function errMsg(err) {
824
824
  }
825
825
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
826
826
  DeviceType["Camera"] = "camera";
827
+ /** Legacy stored value, read only by the hub-to-integration migrations; no live device carries it. */
827
828
  DeviceType["Hub"] = "hub";
828
829
  DeviceType["Light"] = "light";
829
830
  DeviceType["Siren"] = "siren";
830
831
  DeviceType["Switch"] = "switch";
831
832
  DeviceType["Sensor"] = "sensor";
832
- DeviceType["Thermostat"] = "thermostat";
833
- /** Air-conditioner / heat-pump climate device (HVAC) — shares the
834
- * `climate-control` cap surface with `Thermostat` but renders a
835
- * dedicated AC-appropriate control UI (mode chips, fan speed,
836
- * independent vertical/horizontal swing). Sources: native Gree, and
837
- * reusable by other AC integrations. */
833
+ /** Every climate device: an air conditioner, a room thermostat, a radiator
834
+ * valve, a floor-heating zone, a heat-pump circuit. They share one set of
835
+ * controls (`climate-control`), so they are one type; WHICH kind of climate
836
+ * device it is is its {@link DeviceRole} (`climate-*`), which the UI and the
837
+ * exports branch on. The retired `thermostat` type is read as this one
838
+ * (`canonicalStoredDeviceType`). */
838
839
  DeviceType["Climate"] = "climate";
839
840
  DeviceType["Button"] = "button";
840
841
  /** Generic stateless event emitter — carries a device's EXACT declared
@@ -925,10 +926,6 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
925
926
  /** Washing machine. A plug-built one is running while its power stays
926
927
  * above a threshold. No program cap — that surface is the dishwasher's. */
927
928
  DeviceType["Washer"] = "washer";
928
- /** A dumb plug-in stove or heater: a switch (and, with a meter, a power
929
- * reading) that only runs while the plug is on. Built from a smart plug;
930
- * the `timed-run` cap switches it off again after a chosen time. */
931
- DeviceType["Heater"] = "heater";
932
929
  /** Tumble dryer. Same plug-built running surface as {@link Washer}. */
933
930
  DeviceType["Dryer"] = "dryer";
934
931
  /** The physical bridge box of a vendor ecosystem (Velux KLF-200, and later
@@ -1148,6 +1145,27 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1148
1145
  /** A smart plug: a `switch` whose source says it is an outlet (HA
1149
1146
  * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
1150
1147
  DeviceRole["Outlet"] = "outlet";
1148
+ /** A dumb plug-in stove or heater behind a switch: it runs only while the
1149
+ * switch is on. Offered `timed-run`, which switches it off again after a
1150
+ * chosen time. */
1151
+ DeviceRole["SwitchHeater"] = "switch-heater";
1152
+ /** A plain fan behind a switch (a smart plug powering it): drawn as a fan,
1153
+ * with the switch's on/off only. Speed or oscillation appear only when the
1154
+ * device also has a fan cap (D1033). */
1155
+ DeviceRole["SwitchFan"] = "switch-fan";
1156
+ /** Air conditioner / split unit: cooling, fan speed, louvres. */
1157
+ DeviceRole["ClimateAc"] = "climate-ac";
1158
+ /** Room thermostat: a setpoint and a room temperature. The default. */
1159
+ DeviceRole["ClimateThermostat"] = "climate-thermostat";
1160
+ /** Floor-heating zone actuator. */
1161
+ DeviceRole["ClimateFloor"] = "climate-floor";
1162
+ /** Radiator valve (thermostatic radiator head). */
1163
+ DeviceRole["ClimateRadiator"] = "climate-radiator";
1164
+ /** A heater with its own thermostat (stove, convector). */
1165
+ DeviceRole["ClimateHeater"] = "climate-heater";
1166
+ /** One heating/cooling circuit of a heat pump: a water loop with comfort /
1167
+ * eco setpoints and a heat/cool mode, no room sensor. */
1168
+ DeviceRole["ClimateHeatPumpCircuit"] = "climate-heat-pump-circuit";
1151
1169
  /** Generic motion / occupancy / moving event source. Distinct from
1152
1170
  * the camera accessory PirSensor role: that one is a camera child;
1153
1171
  * this is a standalone HA / 3rd-party motion sensor. */
@@ -6035,7 +6053,7 @@ var ZodIssueCode = {
6035
6053
  var ZodFirstPartyTypeKind;
6036
6054
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6037
6055
  //#endregion
6038
- //#region ../types/dist/sleep-Cw1uUXvl.mjs
6056
+ //#region ../types/dist/sleep-D0roI_CZ.mjs
6039
6057
  /**
6040
6058
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6041
6059
  * window to float samples (D455).
@@ -11752,6 +11770,50 @@ var ACTUATOR_CAP_VOCABULARY = {
11752
11770
  value: false
11753
11771
  },
11754
11772
  args: { oscillating: false }
11773
+ },
11774
+ {
11775
+ id: "fan.horizontalOscillateOn",
11776
+ method: "setOscillationAxis",
11777
+ label: t("Horizontal oscillation on", "Oscillazione orizzontale attiva"),
11778
+ phrase: t("Start the horizontal oscillation of {device}", "Attiva l’oscillazione orizzontale di {device}"),
11779
+ icon: "move-horizontal",
11780
+ args: {
11781
+ axis: "horizontal",
11782
+ oscillating: true
11783
+ }
11784
+ },
11785
+ {
11786
+ id: "fan.horizontalOscillateOff",
11787
+ method: "setOscillationAxis",
11788
+ label: t("Horizontal oscillation off", "Oscillazione orizzontale spenta"),
11789
+ phrase: t("Stop the horizontal oscillation of {device}", "Ferma l’oscillazione orizzontale di {device}"),
11790
+ icon: "move-horizontal",
11791
+ args: {
11792
+ axis: "horizontal",
11793
+ oscillating: false
11794
+ }
11795
+ },
11796
+ {
11797
+ id: "fan.verticalOscillateOn",
11798
+ method: "setOscillationAxis",
11799
+ label: t("Vertical oscillation on", "Oscillazione verticale attiva"),
11800
+ phrase: t("Start the vertical oscillation of {device}", "Attiva l’oscillazione verticale di {device}"),
11801
+ icon: "move-vertical",
11802
+ args: {
11803
+ axis: "vertical",
11804
+ oscillating: true
11805
+ }
11806
+ },
11807
+ {
11808
+ id: "fan.verticalOscillateOff",
11809
+ method: "setOscillationAxis",
11810
+ label: t("Vertical oscillation off", "Oscillazione verticale spenta"),
11811
+ phrase: t("Stop the vertical oscillation of {device}", "Ferma l’oscillazione verticale di {device}"),
11812
+ icon: "move-vertical",
11813
+ args: {
11814
+ axis: "vertical",
11815
+ oscillating: false
11816
+ }
11755
11817
  }
11756
11818
  ],
11757
11819
  state: [{
@@ -13841,10 +13903,6 @@ var CAMERA_CAP_VOCABULARY = {
13841
13903
  scope: "device",
13842
13904
  noun: t("Admin link", "Link di amministrazione")
13843
13905
  },
13844
- "device-discovery": {
13845
- scope: "device",
13846
- noun: t("Discovery", "Rilevamento dispositivi")
13847
- },
13848
13906
  "device-extension": {
13849
13907
  scope: "device",
13850
13908
  noun: t("Device extension", "Estensione del dispositivo")
@@ -15341,7 +15399,6 @@ var CAP_NAMES = Object.freeze([
15341
15399
  "device-admin-link",
15342
15400
  "device-adoption",
15343
15401
  "device-credentials",
15344
- "device-discovery",
15345
15402
  "device-export",
15346
15403
  "device-extension",
15347
15404
  "device-history",
@@ -15963,13 +16020,6 @@ Object.freeze({
15963
16020
  "valueType": "string"
15964
16021
  }
15965
16022
  ],
15966
- "device-discovery": [{
15967
- "path": "lastDiscoveryAt",
15968
- "valueType": "number"
15969
- }, {
15970
- "path": "lastError",
15971
- "valueType": "string"
15972
- }],
15973
16023
  "device-export": [
15974
16024
  {
15975
16025
  "path": "linkState",
@@ -16158,6 +16208,10 @@ Object.freeze({
16158
16208
  "path": "lastEvent.eventType",
16159
16209
  "valueType": "string"
16160
16210
  },
16211
+ {
16212
+ "path": "lastEvent.sourceId",
16213
+ "valueType": "string"
16214
+ },
16161
16215
  {
16162
16216
  "path": "lastEvent.timestamp",
16163
16217
  "valueType": "number"
@@ -17421,7 +17475,7 @@ Object.freeze({
17421
17475
  }
17422
17476
  });
17423
17477
  //#endregion
17424
- //#region ../types/dist/implemented-methods-OitwyO1Y.mjs
17478
+ //#region ../types/dist/implemented-methods-5YMDeE3f.mjs
17425
17479
  /**
17426
17480
  * The ffmpeg build every CamStack node downloads, per platform and arch.
17427
17481
  *
@@ -44149,6 +44203,13 @@ var AutomationConditionOperatorSchema = _enum([
44149
44203
  "in"
44150
44204
  ]);
44151
44205
  /**
44206
+ * The stable name of an event leaf. A path (`when.0.1`) moves when a row is
44207
+ * reordered; the id does not, so a `triggered-by` leaf keeps pointing at the
44208
+ * same row. Optional: a leaf nothing refers to needs none.
44209
+ */
44210
+ var EVENT_LEAF_ID_RE = /^[A-Za-z0-9_-]{1,40}$/;
44211
+ var eventLeafId = { id: string().regex(EVENT_LEAF_ID_RE).optional() };
44212
+ /**
44152
44213
  * D8 compliance, and it is the reason a "becomes" leaf is not merely an event
44153
44214
  * subscription: it evaluates against the **state mirror**, which is reconciled,
44154
44215
  * and an event only WAKES the evaluation. A dropped event therefore DELAYS a
@@ -44156,6 +44217,7 @@ var AutomationConditionOperatorSchema = _enum([
44156
44217
  */
44157
44218
  var DeviceBecomesLeafSchema = object({
44158
44219
  kind: literal("device-becomes"),
44220
+ ...eventLeafId,
44159
44221
  deviceId: number$1().int().nonnegative(),
44160
44222
  cap: string().min(1),
44161
44223
  fieldPath: string().min(1),
@@ -44208,6 +44270,7 @@ var DeviceBecomesLeafSchema = object({
44208
44270
  });
44209
44271
  var DeviceEventLeafSchema = object({
44210
44272
  kind: literal("device-event"),
44273
+ ...eventLeafId,
44211
44274
  /** An `EventCategory` value. */
44212
44275
  category: string().min(1),
44213
44276
  deviceId: number$1().int().nonnegative().optional()
@@ -44220,18 +44283,24 @@ var DeviceEventLeafSchema = object({
44220
44283
  */
44221
44284
  var ScheduleLeafSchema = object({
44222
44285
  kind: literal("schedule"),
44286
+ ...eventLeafId,
44223
44287
  at: TimeSpecSchema.optional(),
44224
44288
  days: array(WeekdayKeySchema).min(1).max(7).optional(),
44225
44289
  /** @deprecated legacy cron — new schedules use `at`. */
44226
44290
  cron: string().min(1).max(120).optional()
44227
44291
  }).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" });
44228
- var ManualLeafSchema = object({ kind: literal("manual") });
44292
+ var ManualLeafSchema = object({
44293
+ kind: literal("manual"),
44294
+ ...eventLeafId
44295
+ });
44229
44296
  var IntervalLeafSchema = object({
44230
44297
  kind: literal("interval"),
44298
+ ...eventLeafId,
44231
44299
  minutes: number$1().int().min(1).max(1440)
44232
44300
  });
44233
44301
  var DetectionLeafSchema = object({
44234
44302
  kind: literal("detection"),
44303
+ ...eventLeafId,
44235
44304
  /** One macro class each, optionally narrowed by a label; a track of any listed subject fires. */
44236
44305
  subjects: array(DetectionSubjectSchema).min(1),
44237
44306
  deviceIds: array(number$1().int().nonnegative()).min(1),
@@ -44242,6 +44311,7 @@ var DetectionLeafSchema = object({
44242
44311
  });
44243
44312
  var StationaryLeafSchema = object({
44244
44313
  kind: literal("stationary"),
44314
+ ...eventLeafId,
44245
44315
  deviceIds: array(number$1().int().nonnegative()).min(1),
44246
44316
  subjects: array(StationarySubjectSchema).min(1).optional(),
44247
44317
  zones: array(string().min(1)).min(1).optional(),
@@ -44287,6 +44357,41 @@ var StationaryPresentLeafSchema = object({
44287
44357
  minCount: number$1().int().positive().optional()
44288
44358
  });
44289
44359
  /**
44360
+ * True while the site-local clock is inside a daily window and/or on one of
44361
+ * the named days. `days` names the local day a window STARTS on, so
44362
+ * 22:00-06:00 on weekdays is still inside at 01:00 Saturday. A one-date spec
44363
+ * (`kind: 'date'`) is refused: only a clock time or a sun event makes a window
44364
+ * that repeats every day.
44365
+ */
44366
+ var TimeIsLeafSchema = object({
44367
+ kind: literal("time-is"),
44368
+ between: object({
44369
+ from: TimeSpecSchema,
44370
+ to: TimeSpecSchema
44371
+ }).optional(),
44372
+ days: array(WeekdayKeySchema).min(1).max(7).optional()
44373
+ }).superRefine((leaf, ctx) => {
44374
+ if (leaf.between === void 0 && leaf.days === void 0) ctx.addIssue({
44375
+ code: "custom",
44376
+ message: "a time-is leaf needs a between window, days, or both"
44377
+ });
44378
+ for (const end of ["from", "to"]) if (leaf.between?.[end].kind === "date") ctx.addIssue({
44379
+ code: "custom",
44380
+ message: "a one-date time cannot bound a daily window: use a clock time or a sun event",
44381
+ path: ["between", end]
44382
+ });
44383
+ });
44384
+ /**
44385
+ * True for the run that one of the named event leaves started. It reads the
44386
+ * run, not a device: in the tree it is judged against the leaf that fired, in
44387
+ * a step guard against the trigger the run carries. A run no event leaf
44388
+ * started (a state-only tree becoming true) is false.
44389
+ */
44390
+ var TriggeredByLeafSchema = object({
44391
+ kind: literal("triggered-by"),
44392
+ leafIds: array(string().regex(EVENT_LEAF_ID_RE)).min(1).max(20)
44393
+ });
44394
+ /**
44290
44395
  * The escape hatch: the bounded expression engine over named device bindings.
44291
44396
  * Declared as a plain object so a discriminated union can read `kind`; the
44292
44397
  * author-time validation is the SAME function `ExpressionSourceSchema` runs.
@@ -44332,7 +44437,9 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
44332
44437
  StationaryLeafSchema,
44333
44438
  DeviceIsLeafSchema,
44334
44439
  StationaryPresentLeafSchema,
44335
- ExpressionLeafSchema
44440
+ ExpressionLeafSchema,
44441
+ TimeIsLeafSchema,
44442
+ TriggeredByLeafSchema
44336
44443
  ]));
44337
44444
  var EVENT_KINDS = new Set([
44338
44445
  "device-becomes",
@@ -44386,6 +44493,28 @@ function hasEventLeaves(node) {
44386
44493
  });
44387
44494
  return found;
44388
44495
  }
44496
+ /** The event leaves of the tree that carry an id, in tree order. */
44497
+ function identifiedEventLeaves(when) {
44498
+ const found = [];
44499
+ forEachLeaf(when, (leaf, path) => {
44500
+ if (isEventLeaf(leaf) && leaf.id !== void 0) found.push({
44501
+ id: leaf.id,
44502
+ path,
44503
+ leaf
44504
+ });
44505
+ });
44506
+ return found;
44507
+ }
44508
+ /** Does the tree hold a `triggered-by` leaf? */
44509
+ function hasTriggeredByLeaves(when) {
44510
+ let found = false;
44511
+ forEachLeaf(when, (leaf) => {
44512
+ if (leaf.kind === "triggered-by") found = true;
44513
+ });
44514
+ return found;
44515
+ }
44516
+ /** Why a `triggered-by` leaf is refused outside an automation: there is no trigger row to name. */
44517
+ var TRIGGERED_BY_NEEDS_AUTOMATION = "\"triggered by\" reads which trigger started an automation — an action or a scheduler has no trigger rows, so it could never be true here";
44389
44518
  function hasEmptyContainer(node) {
44390
44519
  if (isLeaf(node)) return false;
44391
44520
  if (node.kind === "not") return hasEmptyContainer(node.child);
@@ -44444,6 +44573,11 @@ function validateWhenTree(when) {
44444
44573
  if (depth > 4) return `the rules nest ${depth} levels deep — the limit is 4. "not (any of …)" is the same as "all of (not …)", which is one level shallower`;
44445
44574
  const leaves = countWhenLeaves(when);
44446
44575
  if (leaves > 32) return `the rules use ${leaves} rows — the limit is 32`;
44576
+ const seen = /* @__PURE__ */ new Set();
44577
+ for (const entry of identifiedEventLeaves(when)) {
44578
+ if (seen.has(entry.id)) return `two trigger rows share the id "${entry.id}" — an id names one row`;
44579
+ seen.add(entry.id);
44580
+ }
44447
44581
  const need = eventNeed(when, "when", false);
44448
44582
  if ("error" in need) return need.error;
44449
44583
  const [first, second] = need.paths;
@@ -44655,9 +44789,12 @@ function convertLegacyWhen(half) {
44655
44789
  * every caller — automations, Actions, and the notification centre, which runs
44656
44790
  * only Actions (planning#473).
44657
44791
  */
44792
+ /** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
44793
+ var WAIT_MAX_SECONDS = 3600;
44794
+ var WAIT_TOO_LONG = `a wait is at most one hour (${WAIT_MAX_SECONDS} s)`;
44658
44795
  var AutomationWaitStepSchema = object({
44659
44796
  kind: literal("wait"),
44660
- seconds: number$1().min(0).max(300)
44797
+ seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
44661
44798
  });
44662
44799
  /** The legacy `deviceId` of a cap step: still READ, never written (D983). */
44663
44800
  var LegacyStepDeviceSchema = union([
@@ -44727,28 +44864,227 @@ var elseNeedsIf = {
44727
44864
  path: ["else"]
44728
44865
  };
44729
44866
  var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
44730
- var GuardedCapStepSchema = AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44867
+ /**
44868
+ * A step of a STANDALONE list (an action, a scheduler point, a preset): the
44869
+ * same two step kinds an automation runs, minus a guard that reads the
44870
+ * automation's trigger, which such a list does not have.
44871
+ */
44872
+ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44873
+ message: "a cap step needs a target",
44874
+ path: ["target"]
44875
+ }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44876
+ message: "a domain target needs the vocabulary action it applies to (actionId)",
44877
+ path: ["actionId"]
44878
+ }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
44879
+ if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
44880
+ code: "custom",
44881
+ message: TRIGGERED_BY_NEEDS_AUTOMATION,
44882
+ path: ["if"]
44883
+ });
44884
+ });
44885
+ /**
44886
+ * Flow control of an AUTOMATION's list (#500). A standalone list (an action, a
44887
+ * scheduler point, a preset) stays `wait` and `cap`: it has no run of its own
44888
+ * to end and no variable bag to write.
44889
+ */
44890
+ var continueOnErrorShape = {
44891
+ /** A failure of this step is traced `failed-continued` and the next step runs. */
44892
+ continueOnError: literal(true).optional() };
44893
+ /** An automation's cap step: the shared guarded cap step, plus `continueOnError`. */
44894
+ var AutomationGuardedCapStepSchema = AutomationCapStepBaseSchema.extend({
44895
+ ...stepGuardShape,
44896
+ ...continueOnErrorShape
44897
+ }).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44731
44898
  message: "a cap step needs a target",
44732
44899
  path: ["target"]
44733
44900
  }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44734
44901
  message: "a domain target needs the vocabulary action it applies to (actionId)",
44735
44902
  path: ["actionId"]
44736
44903
  }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
44737
- var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, GuardedCapStepSchema]);
44904
+ /** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
44905
+ var AutomationStopStepSchema = object({
44906
+ kind: literal("stop"),
44907
+ reason: string().min(1, "a stop needs a reason: it is what the run trace shows").max(200),
44908
+ /** `ok`: the run ends as a success. `failed`: it ends as a failure, with the reason. */
44909
+ outcome: _enum(["ok", "failed"]),
44910
+ /** Stop only when this reads true; false or unknown does not stop. */
44911
+ if: AutomationWhenSchema.optional()
44912
+ });
44913
+ var SET_VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]{0,39}$/;
44914
+ /** Names the run itself writes and reads (`leaf` is what `triggered-by` judges): a step may not overwrite them. */
44915
+ var RESERVED_RUN_VARS = [
44916
+ "kind",
44917
+ "leaf",
44918
+ "at"
44919
+ ];
44920
+ /**
44921
+ * Write variables into the run's bag, for the steps after it. SUBSTITUTION
44922
+ * only, never evaluation: a text value may carry `{{vars.x}}` slots.
44923
+ */
44924
+ var AutomationSetStepSchema = object({
44925
+ kind: literal("set"),
44926
+ vars: record(string(), union([
44927
+ string().max(500),
44928
+ number$1(),
44929
+ boolean()
44930
+ ])).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` }),
44931
+ /** Set only when this reads true; false or unknown leaves the bag as it is. */
44932
+ if: AutomationWhenSchema.optional()
44933
+ });
44934
+ var AutomationRunActionStepSchema = object({
44935
+ kind: literal("action"),
44936
+ /** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
44937
+ actionId: string().min(1),
44938
+ /** Values for the action's declared variables; the others take their default. */
44939
+ variables: record(string(), union([
44940
+ string(),
44941
+ number$1(),
44942
+ boolean()
44943
+ ])).optional(),
44944
+ ...continueOnErrorShape
44945
+ });
44946
+ /**
44947
+ * A step INSIDE a branch of a `choose`: a flow step with no condition of its
44948
+ * own (the branch is the condition) and no block inside it. Strict, so an `if`
44949
+ * written on such a step is refused rather than dropped.
44950
+ */
44951
+ /** The longest a `wait-until` may wait: six hours. */
44952
+ var WAIT_UNTIL_TIMEOUT_MAX_S = 21600;
44953
+ /**
44954
+ * Pause the run until a condition is true (#500). The timeout is mandatory: a
44955
+ * run never waits without an end. `onTimeout` says what a wait that ran out
44956
+ * does: `continue` goes on to the next step, `stop` ends the run as a failure.
44957
+ * A condition that cannot be read is not "true": the wait goes on (D49).
44958
+ */
44959
+ var AutomationWaitUntilStepSchema = object({
44960
+ kind: literal("wait-until"),
44961
+ when: AutomationWhenSchema,
44962
+ 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)`),
44963
+ onTimeout: _enum(["continue", "stop"])
44964
+ }).strict();
44965
+ /** The step kinds that hold steps of their own, or pause on a condition: they nest two levels at most. */
44966
+ var BLOCK_STEP_KINDS = [
44967
+ "choose",
44968
+ "repeat",
44969
+ "parallel",
44970
+ "wait-until"
44971
+ ];
44972
+ var NEST_TOO_DEEP = `steps nest two levels at most: a step inside a nested choose or repeat can be a plain step only`;
44973
+ function kindOf(input) {
44974
+ return typeof input === "object" && input !== null ? Reflect.get(input, "kind") : void 0;
44975
+ }
44976
+ /** Where the nesting ends, a block step is refused in words rather than as an unknown kind. */
44977
+ function nestTooDeep(issue) {
44978
+ const kind = kindOf(issue.input);
44979
+ return typeof kind === "string" && BLOCK_STEP_KINDS.includes(kind) ? NEST_TOO_DEEP : void 0;
44980
+ }
44981
+ var plainStepSchemas = [
44982
+ AutomationWaitStepSchema.strict(),
44983
+ AutomationCapStepBaseSchema.extend(continueOnErrorShape).strict().refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44984
+ message: "a cap step needs a target",
44985
+ path: ["target"]
44986
+ }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44987
+ message: "a domain target needs the vocabulary action it applies to (actionId)",
44988
+ path: ["actionId"]
44989
+ }),
44990
+ AutomationStopStepSchema.omit({ if: true }).strict(),
44991
+ AutomationSetStepSchema.omit({ if: true }).strict(),
44992
+ AutomationRunActionStepSchema.strict()
44993
+ ];
44994
+ /**
44995
+ * A plain step: a flow step with no condition of its own and no step inside
44996
+ * it. The second (last) level of nesting holds these only.
44997
+ */
44998
+ var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
44999
+ /** A step that can run beside others: it writes no variable and does not end the run. */
45000
+ 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");
45001
+ /**
45002
+ * Several steps at once (#500): all are started together and all are awaited.
45003
+ * A failure fails the run once the others finished, as in a sequence; a member
45004
+ * marked "continue if this fails" does not.
45005
+ */
45006
+ var AutomationParallelStepSchema = object({
45007
+ kind: literal("parallel"),
45008
+ steps: array(AutomationParallelMemberSchema).min(2, "a parallel needs at least two steps").max(5, `a parallel takes at most 5 steps`)
45009
+ }).strict();
45010
+ var REPEAT_NEEDS_MAX = "a repeat on a condition needs a maximum number of iterations";
45011
+ /** A loop on a condition: the bound is mandatory, so a run never loops without an end. */
45012
+ var repeatConditionShape = {
45013
+ when: AutomationWhenSchema,
45014
+ 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`),
45015
+ /** A pause between two iterations, never after the last. */
45016
+ waitS: number$1().int().min(1).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG).optional()
45017
+ };
45018
+ /** What decides how many times a `repeat` runs. */
45019
+ var AutomationRepeatLoopSchema = discriminatedUnion("by", [
45020
+ object({
45021
+ by: literal("count"),
45022
+ count: number$1().int().min(1).max(20, `a repeat runs at most 20 times`)
45023
+ }).strict(),
45024
+ object({
45025
+ by: literal("while"),
45026
+ ...repeatConditionShape
45027
+ }).strict(),
45028
+ object({
45029
+ by: literal("until"),
45030
+ ...repeatConditionShape
45031
+ }).strict(),
45032
+ object({
45033
+ by: literal("forEach"),
45034
+ target: object({
45035
+ kind: literal("devices"),
45036
+ 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`)
45037
+ }).strict()
45038
+ }).strict()
45039
+ ]);
45040
+ /**
45041
+ * The same steps several times (#500). Every form is bounded at save, so a
45042
+ * run cannot loop without an end. A failure or a `stop` in the steps ends the
45043
+ * loop and the run, as in a sequence.
45044
+ */
45045
+ function repeatSchemaOf(step) {
45046
+ return object({
45047
+ kind: literal("repeat"),
45048
+ loop: AutomationRepeatLoopSchema,
45049
+ steps: array(step).min(1, "a repeat needs at least one step").max(10, `a repeat takes at most 10 steps`)
45050
+ }).strict();
45051
+ }
45052
+ /**
45053
+ * One step, several ways (#500): the branches are read in order and the FIRST
45054
+ * whose condition is true runs; `else` runs when every branch is false. A
45055
+ * branch that cannot be read ends the choice: nothing runs, not the branches
45056
+ * after it and not the else (D49). The #472 `if` / `else` of a wait or cap
45057
+ * step is the one-branch case and stays as it is stored.
45058
+ */
45059
+ function chooseSchemaOf(step) {
45060
+ const steps = array(step).max(10);
45061
+ return object({
45062
+ kind: literal("choose"),
45063
+ branches: array(object({
45064
+ if: AutomationWhenSchema,
45065
+ steps: steps.min(1, "a branch needs at least one step")
45066
+ })).min(1, "a choose needs at least one branch").max(6, `a choose takes at most 6 branches`),
45067
+ else: steps.optional()
45068
+ });
45069
+ }
45070
+ var AutomationBodyStepSchema = discriminatedUnion("kind", [
45071
+ ...plainStepSchemas,
45072
+ AutomationWaitUntilStepSchema,
45073
+ AutomationParallelStepSchema,
45074
+ chooseSchemaOf(AutomationBranchStepSchema),
45075
+ repeatSchemaOf(AutomationBranchStepSchema)
45076
+ ]);
45077
+ var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
44738
45078
  var AutomationActionSchema = discriminatedUnion("kind", [
44739
45079
  GuardedWaitStepSchema,
44740
- GuardedCapStepSchema,
44741
- object({
44742
- kind: literal("action"),
44743
- /** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
44744
- actionId: string().min(1),
44745
- /** Values for the action's declared variables; the others take their default. */
44746
- variables: record(string(), union([
44747
- string(),
44748
- number$1(),
44749
- boolean()
44750
- ])).optional()
44751
- }),
45080
+ AutomationGuardedCapStepSchema,
45081
+ AutomationStopStepSchema,
45082
+ AutomationSetStepSchema,
45083
+ chooseSchemaOf(AutomationBodyStepSchema),
45084
+ AutomationWaitUntilStepSchema,
45085
+ AutomationParallelStepSchema,
45086
+ AutomationRepeatStepSchema,
45087
+ AutomationRunActionStepSchema,
44752
45088
  object({
44753
45089
  kind: literal("code"),
44754
45090
  /** Compiled into the automation's OWN block by esbuild — not a third
@@ -44811,11 +45147,6 @@ function convertLegacyRecipe(legacy) {
44811
45147
  ...rest
44812
45148
  };
44813
45149
  }
44814
- /**
44815
- * Where recipes are PARSED (the core-blocks cap, the MCP tool, the literal a
44816
- * saved block carries): the new shape as it is, or the old shape converted to
44817
- * it. The output type is always the new one.
44818
- */
44819
45150
  var AutomationRecipeSchema = union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
44820
45151
  var DETECTION_DESCRIPTIONS = {
44821
45152
  deviceId: "the camera that saw it",
@@ -44831,6 +45162,11 @@ var STATIONARY_DESCRIPTIONS = {
44831
45162
  phase: "appeared or departed",
44832
45163
  entryId: "the stopped object"
44833
45164
  };
45165
+ var BECOMES_DESCRIPTIONS = {
45166
+ deviceId: "the device that changed",
45167
+ from: "the value before the change, empty when it is not known",
45168
+ to: "the value it changed to"
45169
+ };
44834
45170
  function describe$1(descriptions) {
44835
45171
  return Object.entries(descriptions).map(([name, description]) => ({
44836
45172
  name,
@@ -44839,6 +45175,10 @@ function describe$1(descriptions) {
44839
45175
  }
44840
45176
  describe$1(DETECTION_DESCRIPTIONS);
44841
45177
  describe$1(STATIONARY_DESCRIPTIONS);
45178
+ describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45179
+ ...v,
45180
+ hintKey: "becomesDeviceId"
45181
+ } : v);
44842
45182
  new Set(Object.values(COCO_TO_MACRO.mapping));
44843
45183
  /**
44844
45184
  * Schedulers (D983) — an entity that performs actions over the day.
@@ -44863,6 +45203,13 @@ var SchedulerStateTreeSchema = AutomationWhenSchema.superRefine((when, ctx) => {
44863
45203
  });
44864
45204
  return;
44865
45205
  }
45206
+ if (hasTriggeredByLeaves(when)) {
45207
+ ctx.addIssue({
45208
+ code: "custom",
45209
+ message: TRIGGERED_BY_NEEDS_AUTOMATION
45210
+ });
45211
+ return;
45212
+ }
44866
45213
  const problem = validateWhenTree(when);
44867
45214
  if (problem !== null) ctx.addIssue({
44868
45215
  code: "custom",
@@ -44884,12 +45231,16 @@ var HoldOverrideSchema = discriminatedUnion("mode", [object({ mode: literal("res
44884
45231
  })]);
44885
45232
  /** A missed edge up to this late still runs. */
44886
45233
  var DEFAULT_MAX_LATE_MS = 10 * 6e4;
45234
+ var SchedulerStepSchema = ActionStepSchema.refine((step) => step.kind !== "wait" || step.seconds <= 300, {
45235
+ message: `a scheduler point waits at most five minutes (300 s); put a longer wait in an action`,
45236
+ path: ["seconds"]
45237
+ });
44887
45238
  var SchedulerPointSchema = object({
44888
45239
  id: string().min(1).max(64),
44889
45240
  at: SchedulerTimeSpecSchema,
44890
45241
  mode: SchedulerPointModeSchema,
44891
45242
  /** The actions of an `edge` or `hold`; a `release` has none. */
44892
- steps: array(ActionStepSchema).max(20).default([]),
45243
+ steps: array(SchedulerStepSchema).max(20).default([]),
44893
45244
  /** Checked when the point runs (an edge) or is applied (a hold). */
44894
45245
  conditions: SchedulerStateTreeSchema.optional(),
44895
45246
  /** Hold only; absent means `respect`. */
@@ -45083,6 +45434,8 @@ var AutomationConditionTraceNodeSchema = object({
45083
45434
  "device-is",
45084
45435
  "expression",
45085
45436
  "stationary-present",
45437
+ "time-is",
45438
+ "triggered-by",
45086
45439
  "device-becomes",
45087
45440
  "device-event",
45088
45441
  "schedule",
@@ -45155,18 +45508,46 @@ var StepTraceBaseSchema = object({
45155
45508
  ]).optional(),
45156
45509
  /** Why the condition read what it read, in the evaluator's own words. */
45157
45510
  conditionReason: string().optional(),
45158
- /** `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. */
45511
+ /** `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). */
45159
45512
  outcome: _enum([
45160
45513
  "ok",
45161
45514
  "error",
45162
45515
  "not-run",
45163
45516
  "empty",
45164
- "skipped"
45517
+ "skipped",
45518
+ "failed-continued",
45519
+ "timed-out"
45165
45520
  ]),
45166
45521
  message: string().optional()
45167
45522
  });
45523
+ /** What a block step adds to its row: which list ran, what each branch read, how many rounds. */
45524
+ var blockTraceShape = {
45525
+ /** A `choose` step (#500): the list that ran, `branches.<n>` or `else`. Absent when none did. */
45526
+ branch: string().optional(),
45527
+ /** A `choose` step: what each branch read, in order, up to the one that decided. */
45528
+ branchChecks: array(object({
45529
+ condition: _enum([
45530
+ "true",
45531
+ "false",
45532
+ "unknown"
45533
+ ]),
45534
+ conditionReason: string().optional()
45535
+ })).optional(),
45536
+ /** A `repeat` step (#500): how many times its steps ran. */
45537
+ iterations: number$1().int().optional()
45538
+ };
45539
+ /** A step one level down: it may be a block step itself, whose own steps are plain rows (the nesting ends there). */
45540
+ var NestedStepTraceSchema = StepTraceBaseSchema.extend({
45541
+ ...blockTraceShape,
45542
+ steps: array(StepTraceBaseSchema).optional()
45543
+ });
45168
45544
  /** A step trace; the `else` steps that ran are one level of the same shape (the nesting is bounded at one). */
45169
- var AutomationStepTraceSchema = StepTraceBaseSchema.extend({ else: array(StepTraceBaseSchema).optional() });
45545
+ var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
45546
+ else: array(StepTraceBaseSchema).optional(),
45547
+ ...blockTraceShape,
45548
+ /** A `choose` step: the steps of the list that ran. A `parallel`: its members. A `repeat`: the LAST iteration. */
45549
+ steps: array(NestedStepTraceSchema).optional()
45550
+ });
45170
45551
  var AutomationRunTraceSchema = object({
45171
45552
  runId: string().min(1),
45172
45553
  startedAt: number$1(),
@@ -45416,7 +45797,7 @@ object({
45416
45797
  * is irrelevant; the array is treated as a set by consumers. */
45417
45798
  hiddenChildIds: array(number$1()).readonly()
45418
45799
  });
45419
- DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Light, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Cover, DeviceType.Lock, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Generic, method(object({
45800
+ DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Sensor, DeviceType.Climate, DeviceType.Cover, DeviceType.Lock, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Generic, method(object({
45420
45801
  deviceId: number$1().int().nonnegative(),
45421
45802
  childDeviceId: number$1().int().nonnegative(),
45422
45803
  hidden: boolean()
@@ -45573,7 +45954,9 @@ var AddonHttpRouteSchema = object({
45573
45954
  ]).optional(),
45574
45955
  description: string().optional(),
45575
45956
  /** The hub limits this route per client address before the handler runs. */
45576
- rateLimit: _enum(["auth"]).optional()
45957
+ rateLimit: _enum(["auth"]).optional(),
45958
+ /** Served once per integration instance; the handler reads `instanceId`. */
45959
+ perInstance: boolean().optional()
45577
45960
  });
45578
45961
  /**
45579
45962
  * Cross-process route invocation envelope. The hub captures the
@@ -45590,6 +45973,8 @@ var InvokeRequestSchema = object({
45590
45973
  query: record(string(), string()),
45591
45974
  body: unknown(),
45592
45975
  headers: record(string(), string()),
45976
+ /** The instance the hub resolved for a `perInstance` route. */
45977
+ instanceId: string().optional(),
45593
45978
  user: object({
45594
45979
  id: string(),
45595
45980
  username: string(),
@@ -47714,7 +48099,7 @@ var BATTERY_DEVICE_TYPES = [
47714
48099
  DeviceType.Switch,
47715
48100
  DeviceType.PetFeeder,
47716
48101
  DeviceType.Container,
47717
- DeviceType.Thermostat,
48102
+ DeviceType.Climate,
47718
48103
  DeviceType.EventEmitter
47719
48104
  ];
47720
48105
  /** Generic Customize target for the percentage reading (D936). */
@@ -49477,7 +49862,14 @@ var climateControlCapability = {
49477
49862
  scope: "device",
49478
49863
  deviceNative: true,
49479
49864
  mode: "singleton",
49480
- deviceTypes: [DeviceType.Thermostat, DeviceType.Climate],
49865
+ deviceTypes: [DeviceType.Climate],
49866
+ power: {
49867
+ kind: "mode",
49868
+ field: "mode",
49869
+ offValue: "off",
49870
+ set: "setMode",
49871
+ lastField: "lastActiveMode"
49872
+ },
49481
49873
  methods: {
49482
49874
  setMode: method(object({
49483
49875
  deviceId: number$1().int().nonnegative(),
@@ -49862,6 +50254,7 @@ var CompositionProblemSchema = object({
49862
50254
  "nested-field",
49863
50255
  "missing-field",
49864
50256
  "kind-mismatch",
50257
+ "source-kind-mismatch",
49865
50258
  "may-be-null",
49866
50259
  "source-missing",
49867
50260
  "source-unreadable",
@@ -49883,7 +50276,8 @@ var CompositionProblemSchema = object({
49883
50276
  "command-method-unknown",
49884
50277
  "command-source-unknown",
49885
50278
  "command-input-unknown",
49886
- "command-input-missing"
50279
+ "command-input-missing",
50280
+ "power-source-is-actuator"
49887
50281
  ]),
49888
50282
  path: string(),
49889
50283
  message: string()
@@ -50921,6 +51315,13 @@ var mediaPlayerCapability = {
50921
51315
  deviceNative: true,
50922
51316
  mode: "singleton",
50923
51317
  deviceTypes: [DeviceType.MediaPlayer],
51318
+ power: {
51319
+ kind: "methods",
51320
+ field: "state",
51321
+ offValues: ["off", "standby"],
51322
+ on: "turnOn",
51323
+ off: "turnOff"
51324
+ },
50924
51325
  methods: {
50925
51326
  turnOn: optionalMethod(deviceOnly, _void(), {
50926
51327
  kind: "mutation",
@@ -51051,7 +51452,7 @@ var mediaPlayerCapability = {
51051
51452
  isMuted: { kind: "boolean" }
51052
51453
  } }
51053
51454
  };
51054
- DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Heater, DeviceType.Dryer, DeviceType.Gateway, DeviceType.HeatPump, DeviceType.Camera, DeviceType.Fan, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Gateway, DeviceType.Hub, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.MediaPlayer;
51455
+ 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;
51055
51456
  var NUMBER = {
51056
51457
  kind: "fixed",
51057
51458
  result: ["number"]
@@ -51134,7 +51535,7 @@ function numeric(input) {
51134
51535
  }, ...alsoFrom === void 0 ? [] : [alsoFrom.accept]]
51135
51536
  };
51136
51537
  }
51137
- var CLIMATE_DEVICES = [DeviceType.Thermostat, DeviceType.Climate];
51538
+ var CLIMATE_DEVICES = [DeviceType.Climate];
51138
51539
  function binary(input) {
51139
51540
  return {
51140
51541
  ...input,
@@ -51456,8 +51857,8 @@ var GROUP_TEMPLATES = [
51456
51857
  actuator({
51457
51858
  id: "climate",
51458
51859
  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.",
51459
- deviceType: DeviceType.Thermostat,
51460
- memberDeviceTypes: [DeviceType.Thermostat, DeviceType.Climate],
51860
+ deviceType: DeviceType.Climate,
51861
+ memberDeviceTypes: [DeviceType.Climate],
51461
51862
  outputCap: "group-active",
51462
51863
  outputField: "active",
51463
51864
  member: {
@@ -51500,6 +51901,118 @@ function actuator(input) {
51500
51901
  new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
51501
51902
  DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
51502
51903
  DeviceType.Camera;
51904
+ var PowerSourceRefusalReasonSchema = _enum([
51905
+ "no-power-source",
51906
+ "switch-missing",
51907
+ "switch-offline",
51908
+ "switch-unknown",
51909
+ "restart-in-progress",
51910
+ "switch-call-failed",
51911
+ "switch-is-actuator"
51912
+ ]);
51913
+ var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
51914
+ accepted: literal(false),
51915
+ reason: PowerSourceRefusalReasonSchema,
51916
+ /** One line for the operator, naming the switch. */
51917
+ message: string()
51918
+ })]);
51919
+ var PowerSourceInfoSchema = object({
51920
+ /** False when the device has no power source linked; the rest is then empty. */
51921
+ linked: boolean(),
51922
+ switchDeviceId: number$1().nullable(),
51923
+ switchName: string().nullable(),
51924
+ /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
51925
+ switchOn: boolean().nullable(),
51926
+ switchOnline: boolean().nullable(),
51927
+ restartInProgress: boolean(),
51928
+ offSeconds: number$1().int()
51929
+ });
51930
+ /** The composed slice: the switch state the link mirrors, plus the stored off time. */
51931
+ var PowerSourceStateSchema = object({
51932
+ /** Null while the switch has not reported: unknown is never `false` (D393). */
51933
+ switchOn: boolean().nullable(),
51934
+ offSeconds: number$1().int(),
51935
+ lastFetchedAt: number$1()
51936
+ });
51937
+ var POWER_SOURCE_DEVICE_TYPES = [
51938
+ DeviceType.Gateway,
51939
+ DeviceType.Camera,
51940
+ DeviceType.Sensor,
51941
+ DeviceType.MediaPlayer,
51942
+ DeviceType.Vacuum,
51943
+ DeviceType.Generic,
51944
+ DeviceType.Washer,
51945
+ DeviceType.Dryer,
51946
+ DeviceType.Dishwasher,
51947
+ DeviceType.PetFountain,
51948
+ DeviceType.Fan,
51949
+ DeviceType.Humidifier,
51950
+ DeviceType.Climate,
51951
+ DeviceType.WaterHeater
51952
+ ];
51953
+ var powerSourceCustomize = {
51954
+ version: 1,
51955
+ targets: [{
51956
+ id: "switch",
51957
+ cardinality: "scalar",
51958
+ vocabulary: {
51959
+ cap: "power-source",
51960
+ stateField: "switchOn"
51961
+ },
51962
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
51963
+ apply: "add",
51964
+ path: "switchOn",
51965
+ sources: [{
51966
+ kind: "switch",
51967
+ transforms: [{ kind: "identity" }]
51968
+ }],
51969
+ companions: [{
51970
+ kind: "constant",
51971
+ path: "offSeconds",
51972
+ value: 10,
51973
+ when: "add",
51974
+ formerValues: [0]
51975
+ }, {
51976
+ kind: "clock",
51977
+ path: "lastFetchedAt",
51978
+ when: "always"
51979
+ }],
51980
+ sourceReport: { status: "assignment-status" }
51981
+ }]
51982
+ };
51983
+ var deviceInput$2 = object({ deviceId: number$1().int().nonnegative() });
51984
+ var powerSourceCapability = {
51985
+ name: "power-source",
51986
+ scope: "device",
51987
+ mode: "singleton",
51988
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
51989
+ methods: {
51990
+ getStatus: systemMethod(deviceInput$2, PowerSourceInfoSchema, { auth: "protected" }),
51991
+ powerOn: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
51992
+ kind: "mutation",
51993
+ auth: "protected"
51994
+ }),
51995
+ powerOff: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
51996
+ kind: "mutation",
51997
+ auth: "protected"
51998
+ }),
51999
+ forceRestart: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
52000
+ kind: "mutation",
52001
+ auth: "protected"
52002
+ })
52003
+ },
52004
+ runtimeState: PowerSourceStateSchema,
52005
+ customize: powerSourceCustomize,
52006
+ /**
52007
+ * Runtime-state durability: **session** — mirrored from the linked switch on
52008
+ * its next report; a restored value would outlive the reading it names.
52009
+ *
52010
+ * See `RuntimeStateDurability`. Enforced by
52011
+ * `scripts/check-runtime-state-durability.ts`.
52012
+ */
52013
+ durability: "session",
52014
+ history: "none"
52015
+ };
51503
52016
  `${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
51504
52017
  /**
51505
52018
  * What a composition may BUILD on a device type (G2, D676): the caps a new
@@ -52544,27 +53057,35 @@ var deviceAdminLinkCapability = {
52544
53057
  getAdminLink: method(object({ deviceId: number$1().int().nonnegative() }), DeviceAdminLinkSchema.nullable(), { auth: "admin" }) }
52545
53058
  };
52546
53059
  /**
52547
- * device-discovery — device-scoped capability for parents that host /
52548
- * enumerate child devices (Reolink Hub / NVR, ONVIF gateway, future
52549
- * integrations). The parent advertises a list of discoverable children,
52550
- * and the operator promotes a subset to real devices via `adoptDevice`.
52551
- * Child lifecycle (kernel device create/remove, parent reference) is
52552
- * owned by the framework so a single shared `<DiscoveryPanel />` can
52553
- * drive any integration.
52554
- *
52555
- * Boundaries:
52556
- * - The cap exposes ENUMERATION + ADOPT/RELEASE only. The protocol
52557
- * used to discover children (CGI poll, mDNS, push from hub, ...)
52558
- * is the integration's business; results land in `runtimeState`
52559
- * so the panel can render without a fresh round-trip.
52560
- * - `childNativeId` is integration-defined and must be stable across
52561
- * reboots so re-discovery doesn't duplicate adopted children.
52562
- * - `adoptDevice` returns the new `deviceId` so the UI can navigate
52563
- * directly to the freshly-created child's settings page.
52564
- */
52565
- /**
52566
- * Status enum for a discovered device. Mirrors the Reolink simpleEvent
52567
- * lifecycle (`online` / `sleeping` / `offline`) — generic enough for
53060
+ * `device-adoption` — generic discovery + adoption surface,
53061
+ * system-scoped collection (one provider per integration addon), routed
53062
+ * by explicit `{ addonId }` on direct `deviceAdoption.*` calls — the same
53063
+ * pin model as `connection-test`. The admin UI keeps using
53064
+ * `deviceManager.adoption*` (which already threads `addonId`). The de-HA-ified
53065
+ * successor to `ha-discovery`:
53066
+ * keyed by `integrationId` (the addon resolves integrationId → broker
53067
+ * internally) rather than a connection-specific `brokerId`, and it
53068
+ * OWNS the shared `DiscoveredChildDevice` candidate type
53069
+ * (declared below) so a single shared adoption modal renders any integration's
53070
+ * candidate tree.
53071
+ *
53072
+ * UI flow (Integrations page → integration detail):
53073
+ * 1. `listCandidates({integrationId, page, pageSize, filter})` →
53074
+ * paginated candidate list, each row collapsed.
53075
+ * 2. User expands a row → `getCandidate({integrationId,
53076
+ * childNativeId})` returns the single candidate (with its nested
53077
+ * `children`) for the accordion render.
53078
+ * 3. User clicks "Adopt" on one or more candidates →
53079
+ * `adopt({integrationId, childNativeIds, perCandidate?})`
53080
+ * materialises one parent CamStack device per candidate plus its
53081
+ * accessory children. `perCandidate[childNativeId]` carries an
53082
+ * optional display-name override + a `hiddenChildIds` pre-hide set
53083
+ * (the parent's `accessories.hiddenChildIds` gates UI visibility).
53084
+ * 4. User clicks "Release" → `release({integrationId, camDeviceId})`
53085
+ * removes the parent + every child from the kernel registry.
53086
+ */
53087
+ /**
53088
+ * Status enum for a discovered device. Generic enough for
52568
53089
  * battery cams, awake cams, and unreachable cams alike.
52569
53090
  */
52570
53091
  var DiscoveredChildStatusSchema = _enum([
@@ -52581,12 +53102,12 @@ var DiscoveredChildDeviceSchema = lazy(() => object({
52581
53102
  /** DeviceType the child should be created with on adopt. */
52582
53103
  type: _enum(DeviceType),
52583
53104
  status: DiscoveredChildStatusSchema,
52584
- /** Free-form integration-specific metadata surfaced in the panel. */
53105
+ /** Free-form integration-specific metadata surfaced in the adoption modal. */
52585
53106
  metadata: object({
52586
53107
  model: string().optional(),
52587
53108
  serialNumber: string().optional(),
52588
53109
  uid: string().optional(),
52589
- /** Reolink: 0-based channel index inside the parent NVR/Hub. */
53110
+ /** Reolink: 0-based channel index inside the parent NVR. */
52590
53111
  rtspChannel: number$1().int().nonnegative().optional(),
52591
53112
  isBattery: boolean().optional(),
52592
53113
  isDoorbell: boolean().optional(),
@@ -52602,137 +53123,24 @@ var DiscoveredChildDeviceSchema = lazy(() => object({
52602
53123
  }).default({}),
52603
53124
  /**
52604
53125
  * `true` when the framework already created a child device for this
52605
- * `childNativeId` under the current parent. The panel uses it to
53126
+ * `childNativeId` under the current parent. The adoption modal uses it to
52606
53127
  * gate the Add/Remove button and surface the existing `deviceId`.
52607
53128
  */
52608
53129
  alreadyAdopted: boolean(),
52609
53130
  /** When `alreadyAdopted=true`, the framework-assigned child device id. */
52610
53131
  adoptedDeviceId: number$1().int().nonnegative().nullable(),
52611
- /** Capability names the candidate advertises — integrations populate, Hubs omit. */
53132
+ /** Capability names the candidate advertises — integrations populate, flat enumerations omit. */
52612
53133
  capabilities: array(string()).readonly().optional(),
52613
- /** Feature flags the candidate advertises — integrations populate, Hubs omit. */
53134
+ /** Feature flags the candidate advertises — integrations populate, flat enumerations omit. */
52614
53135
  features: array(string()).readonly().optional(),
52615
53136
  /** Upstream-system identity + rendering hints for the candidate. */
52616
53137
  sourceInfo: SourceInfoSchema.optional(),
52617
- /** Nested entity-children for accordion preview — integrations populate, Hubs omit. */
53138
+ /** Nested entity-children for accordion preview — integrations populate, flat enumerations omit. */
52618
53139
  children: array(DiscoveredChildDeviceSchema).readonly().optional(),
52619
53140
  /** `childNativeId` of the gateway candidate in the same list this device sits behind. */
52620
53141
  parentStableId: string().optional()
52621
53142
  }));
52622
53143
  /**
52623
- * Status block — populated by the integration after each
52624
- * `refreshDiscovery` (or push-driven update). The runtime-state slice
52625
- * is what the panel reads via the per-device proxy; `getStatus`
52626
- * returns the same payload via the codegen'd auto-injection.
52627
- */
52628
- var DeviceDiscoveryStatusSchema = object({
52629
- discovered: array(DiscoveredChildDeviceSchema),
52630
- /** Wall-clock ms of the last successful enumeration. */
52631
- lastDiscoveryAt: number$1().int().nonnegative().nullable(),
52632
- /** Last error surfaced from the source (rendered as a banner). */
52633
- lastError: string().nullable()
52634
- });
52635
- var deviceDiscoveryCapability = {
52636
- name: "device-discovery",
52637
- scope: "device",
52638
- deviceNative: true,
52639
- mode: "singleton",
52640
- deviceTypes: [DeviceType.Hub],
52641
- status: {
52642
- schema: DeviceDiscoveryStatusSchema,
52643
- kind: "poll"
52644
- },
52645
- runtimeState: DeviceDiscoveryStatusSchema.extend({ lastFetchedAt: number$1().int().nonnegative() }),
52646
- /**
52647
- * Runtime-state durability: **session** — 5.7 KB of scan output on the largest device, fully re-derivable by re-scanning.
52648
- *
52649
- * See `RuntimeStateDurability`. Enforced by
52650
- * `scripts/check-runtime-state-durability.ts`.
52651
- */
52652
- durability: "session",
52653
- /**
52654
- * History (D850): none — inventory.
52655
- */
52656
- history: "none",
52657
- methods: {
52658
- /**
52659
- * Snapshot of the current `discovered` list. Returns the
52660
- * runtime-state cache — call `refreshDiscovery` first if a
52661
- * fresh round-trip to the source is required.
52662
- */
52663
- listDiscovered: method(object({ deviceId: number$1().int().nonnegative() }), array(DiscoveredChildDeviceSchema).readonly()),
52664
- /**
52665
- * Force the integration to re-enumerate and update the
52666
- * runtime-state slice. Returns the freshly-enumerated list (also
52667
- * available via `listDiscovered` post-call).
52668
- */
52669
- refreshDiscovery: method(object({ deviceId: number$1().int().nonnegative() }), array(DiscoveredChildDeviceSchema).readonly(), {
52670
- kind: "mutation",
52671
- auth: "admin"
52672
- }),
52673
- /**
52674
- * Promote a discovered entry to a real child device. The framework
52675
- * creates the child via `kernel.devices.create()` with
52676
- * `parentDeviceId = parent.id` and seeds the child's config from
52677
- * `childInitialConfig` (driver-defined; usually carries channel +
52678
- * uid + parent reference). Returns the kernel-assigned numeric id.
52679
- */
52680
- adoptDevice: method(object({
52681
- deviceId: number$1().int().nonnegative(),
52682
- childNativeId: string(),
52683
- /** Optional override for the child's display name. */
52684
- name: string().optional()
52685
- }), object({
52686
- deviceId: number$1().int().nonnegative(),
52687
- stableId: string()
52688
- }), {
52689
- kind: "mutation",
52690
- auth: "admin"
52691
- }),
52692
- /**
52693
- * Inverse of `adoptDevice`: removes the child device from the
52694
- * kernel registry. The discovered entry remains in the
52695
- * enumeration (status updates resume) so the operator can re-adopt
52696
- * it later without a fresh refresh.
52697
- */
52698
- releaseDevice: method(object({
52699
- deviceId: number$1().int().nonnegative(),
52700
- childDeviceId: number$1().int().nonnegative()
52701
- }), _void(), {
52702
- kind: "mutation",
52703
- auth: "admin"
52704
- })
52705
- }
52706
- };
52707
- /**
52708
- * `device-adoption` — generic discovery + adoption surface,
52709
- * system-scoped collection (one provider per integration addon), routed
52710
- * by explicit `{ addonId }` on direct `deviceAdoption.*` calls — the same
52711
- * pin model as `connection-test`. The admin UI keeps using
52712
- * `deviceManager.adoption*` (which already threads `addonId`). The de-HA-ified
52713
- * successor to `ha-discovery`:
52714
- * keyed by `integrationId` (the addon resolves integrationId → broker
52715
- * internally) rather than a connection-specific `brokerId`, and it
52716
- * REUSES the shared `DiscoveredChildDevice` candidate type from
52717
- * `device-discovery.cap.ts` so a single shared adoption panel renders
52718
- * any integration's candidate tree.
52719
- *
52720
- * UI flow (Integrations page → integration detail):
52721
- * 1. `listCandidates({integrationId, page, pageSize, filter})` →
52722
- * paginated candidate list, each row collapsed.
52723
- * 2. User expands a row → `getCandidate({integrationId,
52724
- * childNativeId})` returns the single candidate (with its nested
52725
- * `children`) for the accordion render.
52726
- * 3. User clicks "Adopt" on one or more candidates →
52727
- * `adopt({integrationId, childNativeIds, perCandidate?})`
52728
- * materialises one parent CamStack device per candidate plus its
52729
- * accessory children. `perCandidate[childNativeId]` carries an
52730
- * optional display-name override + a `hiddenChildIds` pre-hide set
52731
- * (the parent's `accessories.hiddenChildIds` gates UI visibility).
52732
- * 4. User clicks "Release" → `release({integrationId, camDeviceId})`
52733
- * removes the parent + every child from the kernel registry.
52734
- */
52735
- /**
52736
53144
  * Provider-declared discovery *granularity* filter (the keystone of the
52737
53145
  * single-entity-import design). A provider advertises which discovery
52738
53146
  * granularities it supports via `listCandidateFilters`; the operator picks
@@ -54160,8 +54568,14 @@ method(object({
54160
54568
  "string",
54161
54569
  "number",
54162
54570
  "boolean",
54163
- "enum"
54571
+ "enum",
54572
+ "union"
54164
54573
  ]),
54574
+ unionMembers: array(_enum([
54575
+ "string",
54576
+ "number",
54577
+ "boolean"
54578
+ ])).optional(),
54165
54579
  enumValues: array(string()).optional(),
54166
54580
  item: boolean().optional(),
54167
54581
  quantity: ReadingQuantitySchema.optional()
@@ -56253,25 +56667,89 @@ var enumSensorCapability = {
56253
56667
  * whether persisting is worth a SQLite commit. */
56254
56668
  volatileStateFields: ["lastFetchedAt", "timestamp"]
56255
56669
  };
56670
+ var EventVocabularyKindSchema = _enum([
56671
+ "press",
56672
+ "long-press",
56673
+ "long-press-start",
56674
+ "release",
56675
+ "repeat",
56676
+ "double-press",
56677
+ "other"
56678
+ ]);
56679
+ /** The part of the device an event comes from: a button, a channel. */
56680
+ var EventVocabularySourceSchema = object({
56681
+ id: string().min(1),
56682
+ label: string().min(1)
56683
+ });
56684
+ /** One scalar field of an event's `data`, by dotted path. */
56685
+ var EventVocabularyFieldSchema = object({
56686
+ path: string().min(1),
56687
+ kind: _enum([
56688
+ "string",
56689
+ "number",
56690
+ "boolean",
56691
+ "enum"
56692
+ ]),
56693
+ enumValues: array(string()).optional(),
56694
+ label: string().min(1).optional()
56695
+ });
56696
+ var EventVocabularyEntrySchema = object({
56697
+ /** The native token, verbatim. */
56698
+ id: string().min(1),
56699
+ source: EventVocabularySourceSchema.optional(),
56700
+ label: string().min(1),
56701
+ description: string().optional(),
56702
+ kind: EventVocabularyKindSchema.optional(),
56703
+ payload: array(EventVocabularyFieldSchema).optional()
56704
+ });
56705
+ /**
56706
+ * The vocabulary of a source that declares tokens and nothing else: one
56707
+ * entry per token, labelled with the token itself.
56708
+ */
56709
+ function plainEventVocabulary(eventTypes) {
56710
+ return [...new Set(eventTypes)].filter((eventType) => eventType !== "").map((eventType) => ({
56711
+ id: eventType,
56712
+ label: eventType
56713
+ }));
56714
+ }
56715
+ /** The native tokens of a vocabulary, each once, in declaration order. */
56716
+ function eventTypesOfVocabulary(vocabulary) {
56717
+ return [...new Set(vocabulary.map((entry) => entry.id))];
56718
+ }
56719
+ /** The entry a fire belongs to: same token, same source (or both without one). */
56720
+ function findVocabularyEntry(vocabulary, eventType, sourceId) {
56721
+ return vocabulary.find((entry) => entry.id === eventType && entry.source?.id === sourceId);
56722
+ }
56256
56723
  /**
56257
56724
  * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
56258
56725
  * device. Carries the device's EXACT declared event vocabulary verbatim
56259
56726
  * (NO normalization). Two shapes:
56260
- * - structured source (HA `event.*` entity) → `eventTypes` is the fixed
56261
- * declared vocabulary (e.g. ['press_short','press_long',...]).
56262
- * - generic/legacy source (HA bus events, e.g. zha_event) → `eventTypes`
56727
+ * - structured source (HA `event.*` entity) → `vocabulary` is the fixed
56728
+ * declared set (e.g. press_short, press_long, …).
56729
+ * - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
56263
56730
  * is [] (open) and `lastEvent.data` carries the complex payload.
56731
+ * `vocabulary` (D1044) names each event for a person and types it for a
56732
+ * rule; `eventTypes` is its list of native tokens, kept for older readers.
56733
+ * A fire names the part of the device it came from in `sourceId` when the
56734
+ * vocabulary declares sources (a remote's buttons).
56264
56735
  * `seq` is monotonic so two identical events still produce distinct slice writes.
56265
56736
  */
56266
56737
  var EventFireSchema = object({
56267
56738
  deviceId: number$1(),
56268
56739
  eventType: string(),
56740
+ sourceId: string().optional(),
56269
56741
  data: record(string(), unknown()).nullable(),
56270
56742
  timestamp: number$1().meta(readingMeta("none")),
56271
56743
  seq: number$1().meta(readingMeta("count"))
56272
56744
  });
56273
56745
  var EventEmitterStatusSchema = object({
56274
56746
  eventTypes: array(string()),
56747
+ /**
56748
+ * Required of a provider by the type. A status written before the field
56749
+ * existed still parses, as an empty vocabulary: read it through
56750
+ * `readEventVocabulary`, which then answers with the plain tokens.
56751
+ */
56752
+ vocabulary: array(EventVocabularyEntrySchema).default([]),
56275
56753
  lastEvent: EventFireSchema.nullable(),
56276
56754
  eventCountSinceStart: number$1().meta(readingMeta("count"))
56277
56755
  });
@@ -56789,8 +57267,85 @@ method(_void(), array(FailureContributionSchema).readonly());
56789
57267
  * - `FanPreset` — preset selector
56790
57268
  * - `FanDirection` — direction toggle (ceiling fans)
56791
57269
  * - `FanOscillating` — oscillation toggle
57270
+ *
57271
+ * Per-axis oscillation (`oscillationAxes`, `setOscillationAxis`, D1034): an air
57272
+ * circulator sweeps horizontally and vertically, each axis with its own
57273
+ * switch, fixed angle, sweep bounds and limits. A provider may report them
57274
+ * natively; otherwise the OPERATOR links sibling devices to each field in
57275
+ * Customize (a `replace` over the fields listed in `overridable` — nothing is
57276
+ * linked or inferred by itself), and a write to a linked field is forwarded to
57277
+ * its source. `oscillating` stays the single summary flag: when axes exist it
57278
+ * means "any axis oscillates" (`anyAxisOscillating`).
56792
57279
  */
56793
57280
  var FanDirectionSchema = _enum(["forward", "reverse"]);
57281
+ var FAN_OSCILLATION_AXES = ["horizontal", "vertical"];
57282
+ var FanOscillationAxisNameSchema = _enum(FAN_OSCILLATION_AXES);
57283
+ var FanOscillationAxisFieldSchema = _enum([
57284
+ "oscillating",
57285
+ "angle",
57286
+ "sweepFrom",
57287
+ "sweepTo"
57288
+ ]);
57289
+ /** The limits of one axis, read from the source that serves its angle. */
57290
+ var FAN_OSCILLATION_AXIS_LIMITS = [
57291
+ "min",
57292
+ "max",
57293
+ "step"
57294
+ ];
57295
+ /**
57296
+ * One oscillation axis. Every reading the device has not reported is `null`,
57297
+ * never `0` (D393): `0°` is a real position. Each leaf defaults to `null`, so
57298
+ * a slice that names only the leaves it knows (a Customize link of one field)
57299
+ * is still a whole axis.
57300
+ */
57301
+ var FanOscillationAxisSchema = object({
57302
+ /** Whether the axis sweeps. */
57303
+ oscillating: boolean().nullable().default(null),
57304
+ /** The fixed position (degrees) the axis holds when it does not sweep. */
57305
+ angle: number$1().nullable().default(null),
57306
+ /** The sweep bounds (degrees): left → right, bottom → top. */
57307
+ sweepFrom: number$1().nullable().default(null),
57308
+ sweepTo: number$1().nullable().default(null),
57309
+ /** The angles the axis accepts. Null when the device states none. */
57310
+ min: number$1().nullable().default(null),
57311
+ max: number$1().nullable().default(null),
57312
+ step: number$1().nullable().default(null)
57313
+ });
57314
+ /** Both axes; an axis the device does not have is `null`. */
57315
+ var FanOscillationAxesSchema = object({
57316
+ horizontal: FanOscillationAxisSchema.nullable().default(null),
57317
+ vertical: FanOscillationAxisSchema.nullable().default(null)
57318
+ });
57319
+ var FanOscillationAxisRefusalSchema = _enum([
57320
+ "nothing-to-set",
57321
+ "axis-not-linked",
57322
+ "out-of-range",
57323
+ "source-gone",
57324
+ "source-unknown",
57325
+ "source-call-failed"
57326
+ ]);
57327
+ var FanOscillationAxisResultSchema = discriminatedUnion("status", [object({ status: literal("applied") }), object({
57328
+ status: literal("refused"),
57329
+ reason: FanOscillationAxisRefusalSchema,
57330
+ /** The field at fault, when one is. */
57331
+ field: FanOscillationAxisFieldSchema.optional(),
57332
+ /** One line for the operator, naming the axis, the field and the source. */
57333
+ detail: string(),
57334
+ /** Fields that DID land before the refusal (writes run in order, stop at the first failure). */
57335
+ applied: array(FanOscillationAxisFieldSchema)
57336
+ })]);
57337
+ var SetOscillationAxisInputSchema = object({
57338
+ deviceId: number$1().int().nonnegative(),
57339
+ axis: FanOscillationAxisNameSchema,
57340
+ oscillating: boolean().optional(),
57341
+ angle: number$1().optional(),
57342
+ sweepFrom: number$1().optional(),
57343
+ sweepTo: number$1().optional()
57344
+ });
57345
+ /** The state path of one axis field: `oscillationAxes.<axis>.<field>`. */
57346
+ function fanAxisPath(axis, field) {
57347
+ return `oscillationAxes.${axis}.${field}`;
57348
+ }
56794
57349
  var FanControlStatusSchema = object({
56795
57350
  /** Active speed as 0..100 inclusive. Null when the device has no
56796
57351
  * speed surface (single-speed fan). */
@@ -56809,9 +57364,102 @@ var FanControlStatusSchema = object({
56809
57364
  /** Oscillation toggle. Null when the device has no oscillation
56810
57365
  * surface. */
56811
57366
  oscillating: boolean().nullable(),
57367
+ /**
57368
+ * Per-axis oscillation (air circulators). Absent when the device has no
57369
+ * per-axis surface and nothing is linked in Customize.
57370
+ */
57371
+ oscillationAxes: FanOscillationAxesSchema.optional(),
56812
57372
  /** Ms epoch when the slice was last updated. */
56813
57373
  lastChangedAt: number$1()
56814
57374
  });
57375
+ var FAN_CUSTOMIZE_DEVICE_TYPES = [DeviceType.Fan];
57376
+ /** The Customize section the axis targets are listed under. */
57377
+ var AXES_SECTION = "oscillation-axes";
57378
+ function axisOscillatingTarget(axis) {
57379
+ return {
57380
+ id: `${axis}-oscillating`,
57381
+ cardinality: "scalar",
57382
+ vocabulary: {
57383
+ cap: "fan-control",
57384
+ stateField: "oscillating"
57385
+ },
57386
+ deviceTypes: FAN_CUSTOMIZE_DEVICE_TYPES,
57387
+ apply: "replace",
57388
+ section: AXES_SECTION,
57389
+ path: fanAxisPath(axis, "oscillating"),
57390
+ sources: [{
57391
+ kind: "switch",
57392
+ transforms: [{ kind: "identity" }]
57393
+ }],
57394
+ sourceReport: { status: "assignment-status" }
57395
+ };
57396
+ }
57397
+ /**
57398
+ * A numeric axis field. The `angle` link also carries the axis limits, read
57399
+ * from the SAME linked control's own range (`min`/`max`/`step`), so the limits
57400
+ * are the source's, never guessed.
57401
+ */
57402
+ function axisNumericTarget(axis, field) {
57403
+ const base = {
57404
+ id: `${axis}-${field}`,
57405
+ cardinality: "scalar",
57406
+ vocabulary: { cap: "fan-control" },
57407
+ deviceTypes: FAN_CUSTOMIZE_DEVICE_TYPES,
57408
+ apply: "replace",
57409
+ section: AXES_SECTION,
57410
+ path: fanAxisPath(axis, field),
57411
+ sources: [{
57412
+ kind: "numeric",
57413
+ transforms: [{ kind: "identity" }]
57414
+ }],
57415
+ sourceReport: { status: "assignment-status" }
57416
+ };
57417
+ if (field !== "angle") return base;
57418
+ return {
57419
+ ...base,
57420
+ companions: FAN_OSCILLATION_AXIS_LIMITS.map((limit) => ({
57421
+ kind: "source-field",
57422
+ path: fanAxisPath(axis, limit),
57423
+ field: limit
57424
+ }))
57425
+ };
57426
+ }
57427
+ var AXIS_TARGETS = FAN_OSCILLATION_AXES.flatMap((axis) => [
57428
+ axisOscillatingTarget(axis),
57429
+ axisNumericTarget(axis, "angle"),
57430
+ axisNumericTarget(axis, "sweepFrom"),
57431
+ axisNumericTarget(axis, "sweepTo")
57432
+ ]);
57433
+ /** A select (an enum control) the operator links to the fan's `preset`. */
57434
+ var PRESET_TARGET = {
57435
+ id: "preset",
57436
+ cardinality: "scalar",
57437
+ vocabulary: { cap: "fan-control" },
57438
+ deviceTypes: FAN_CUSTOMIZE_DEVICE_TYPES,
57439
+ apply: "replace",
57440
+ path: "preset",
57441
+ sources: [{
57442
+ kind: "field",
57443
+ valueKinds: ["string"],
57444
+ transforms: [{ kind: "identity" }]
57445
+ }],
57446
+ sourceReport: { status: "assignment-status" }
57447
+ };
57448
+ var FAN_CONTROL_TARGETS = [...AXIS_TARGETS, PRESET_TARGET];
57449
+ /**
57450
+ * Customize (D1034): the fan already serves `fan-control` natively, so every
57451
+ * target is a `replace` over a field listed in `overridable` — the axis leaves
57452
+ * and `preset`, nothing else. Nothing is pre-linked: the operator picks each
57453
+ * source (D356).
57454
+ */
57455
+ var fanControlCustomize = {
57456
+ version: 1,
57457
+ overridable: FAN_CONTROL_TARGETS.map((target) => ({
57458
+ path: target.path,
57459
+ by: target.id
57460
+ })),
57461
+ targets: FAN_CONTROL_TARGETS
57462
+ };
56815
57463
  var fanControlCapability = {
56816
57464
  name: "fan-control",
56817
57465
  scope: "device",
@@ -56846,6 +57494,18 @@ var fanControlCapability = {
56846
57494
  }), _void(), {
56847
57495
  kind: "mutation",
56848
57496
  auth: "protected"
57497
+ }),
57498
+ /**
57499
+ * Sets one oscillation axis: its switch, fixed angle and/or sweep bounds.
57500
+ * Fields left out are untouched. A field linked in Customize is forwarded
57501
+ * to its linked source (D1034); otherwise the native provider serves it;
57502
+ * neither → `axis-not-linked`. Ranges are checked against the axis limits
57503
+ * before anything is written; writes run in order and stop at the first
57504
+ * failure, which the result names.
57505
+ */
57506
+ setOscillationAxis: optionalMethod(SetOscillationAxisInputSchema, FanOscillationAxisResultSchema, {
57507
+ kind: "mutation",
57508
+ auth: "protected"
56849
57509
  })
56850
57510
  },
56851
57511
  status: {
@@ -56857,6 +57517,7 @@ var fanControlCapability = {
56857
57517
  * sliders read `speed` for live updates.
56858
57518
  */
56859
57519
  runtimeState: FanControlStatusSchema,
57520
+ customize: fanControlCustomize,
56860
57521
  /**
56861
57522
  * Runtime-state durability: **session** — as `brightness`.
56862
57523
  *
@@ -56876,16 +57537,33 @@ var fanControlCapability = {
56876
57537
  oscillating: { kind: "boolean" }
56877
57538
  } }
56878
57539
  };
57540
+ /** One axis as a preset wants it; an absent field is left as it is. */
57541
+ var FanPresetAxisSchema = object({
57542
+ oscillating: boolean().optional(),
57543
+ angle: number$1().optional(),
57544
+ sweepFrom: number$1().optional(),
57545
+ sweepTo: number$1().optional()
57546
+ });
57547
+ /** The fan-control state a preset sets; an absent field is left as it is. */
57548
+ var FanPresetStateSchema = object({
57549
+ speed: number$1().min(0).max(100).optional(),
57550
+ /** The fan's own preset mode (or the linked select's option). */
57551
+ preset: string().min(1).optional(),
57552
+ direction: FanDirectionSchema.optional(),
57553
+ oscillationAxes: object({
57554
+ horizontal: FanPresetAxisSchema.optional(),
57555
+ vertical: FanPresetAxisSchema.optional()
57556
+ }).optional()
57557
+ });
56879
57558
  var FanPresetSchema = object({
56880
57559
  /** Stable key; never reused after a delete within one device's list. */
56881
57560
  id: string().min(1).max(64),
56882
57561
  /** What the operator and a voice assistant call it. */
56883
57562
  name: string().trim().min(1).max(40),
56884
- steps: array(ActionStepSchema).min(1).max(20)
57563
+ state: FanPresetStateSchema
56885
57564
  });
56886
57565
  var FanPresetsRefusalSchema = _enum([
56887
- "not-sibling",
56888
- "bad-target",
57566
+ "empty-state",
56889
57567
  "duplicate-name",
56890
57568
  "duplicate-id",
56891
57569
  "too-many",
@@ -56897,72 +57575,55 @@ var FanPresetsSetResultSchema = discriminatedUnion("status", [object({
56897
57575
  }), object({
56898
57576
  status: literal("refused"),
56899
57577
  reason: FanPresetsRefusalSchema,
56900
- /** Names the preset and step at fault. */
57578
+ /** Names the preset at fault. */
56901
57579
  detail: string()
56902
57580
  })]);
56903
- var FanPresetStepResultSchema = object({
56904
- index: number$1().int().nonnegative(),
57581
+ var FanPresetFieldResultSchema = object({
57582
+ /** The state path: `speed`, `preset`, `direction`, `oscillationAxes.horizontal.angle`. */
57583
+ field: string(),
56905
57584
  outcome: _enum([
56906
57585
  "applied",
56907
57586
  "failed",
56908
57587
  "not-run",
56909
57588
  "refused"
56910
57589
  ]),
56911
- deviceId: number$1().int().nonnegative().optional(),
56912
- cap: string().optional(),
56913
- method: string().optional(),
56914
57590
  /** The cause, for every outcome but `applied`. */
56915
57591
  message: string().optional()
56916
57592
  });
56917
57593
  var FanPresetApplyResultSchema = object({
56918
- /** `applied`: every step ran. `partial`: some ran, one failed. `refused`: nothing ran. */
57594
+ /** `applied`: every field landed. `partial`: some did, one did not. `refused`: nothing ran. */
56919
57595
  status: _enum([
56920
57596
  "applied",
56921
57597
  "partial",
56922
57598
  "refused"
56923
57599
  ]),
56924
- steps: array(FanPresetStepResultSchema)
57600
+ fields: array(FanPresetFieldResultSchema)
56925
57601
  });
56926
57602
  var FanCaptureFieldSchema = _enum([
56927
57603
  "speed",
56928
- "oscillating",
56929
57604
  "direction",
56930
- "preset"
57605
+ "preset",
57606
+ "oscillationAxes"
56931
57607
  ]);
56932
- var FanCaptureOmissionSchema = object({
56933
- /** A fan field (`speed`) or `step <n>` for a sibling step. */
56934
- what: string(),
56935
- /** Why no value was taken: unknown reading (never stored as 0, D393), or a step that cannot be read. */
56936
- reason: string()
56937
- });
56938
- var FanCaptureItemSchema = object({
56939
- group: _enum([
56940
- "fan",
56941
- "oscillation",
56942
- "angles"
56943
- ]),
56944
- /** What the step sets, in the operator's words (a device name, a fan field). */
56945
- label: string()
56946
- });
56947
57608
  var FanPresetCaptureResultSchema = object({
56948
- /** The steps filled from the device's current values; NOT saved. */
56949
- steps: array(ActionStepSchema),
56950
- /** One entry per step, same order: its review group and label. */
56951
- items: array(FanCaptureItemSchema),
56952
- omitted: array(FanCaptureOmissionSchema)
57609
+ /** The fan's CURRENT fan-control state, as a preset; NOT saved. */
57610
+ state: FanPresetStateSchema,
57611
+ omitted: array(object({
57612
+ /** A state path (`speed`, `oscillationAxes.vertical.angle`). */
57613
+ what: string(),
57614
+ /** Why no value was taken: an unknown reading is never stored as 0 (D393). */
57615
+ reason: string()
57616
+ }))
56953
57617
  });
56954
- var deviceInput$2 = object({ deviceId: number$1().int().nonnegative() });
57618
+ var deviceInput$1 = object({ deviceId: number$1().int().nonnegative() });
56955
57619
  DeviceType.Fan;
56956
- method(deviceInput$2, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$2.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
57620
+ method(deviceInput$1, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$1.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
56957
57621
  kind: "mutation",
56958
57622
  auth: "admin"
56959
- }), method(deviceInput$2.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
57623
+ }), method(deviceInput$1.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
56960
57624
  kind: "mutation",
56961
57625
  auth: "protected"
56962
- }), method(deviceInput$2.extend({
56963
- fields: array(FanCaptureFieldSchema).optional(),
56964
- steps: array(ActionStepSchema).max(20).default([])
56965
- }), FanPresetCaptureResultSchema, { auth: "protected" });
57626
+ }), method(deviceInput$1.extend({ fields: array(FanCaptureFieldSchema).optional() }), FanPresetCaptureResultSchema, { auth: "protected" });
56966
57627
  /**
56967
57628
  * Per-device feature/identity probe slice. Holds the runtime-resolved
56968
57629
  * truth about what a device CAN do — which the kernel uses to:
@@ -57174,8 +57835,7 @@ var groupActiveCapability = {
57174
57835
  DeviceType.Valve,
57175
57836
  DeviceType.Lock,
57176
57837
  DeviceType.MediaPlayer,
57177
- DeviceType.Climate,
57178
- DeviceType.Thermostat
57838
+ DeviceType.Climate
57179
57839
  ],
57180
57840
  methods: {},
57181
57841
  status: {
@@ -57217,7 +57877,6 @@ var groupCommandsCapability = {
57217
57877
  DeviceType.Valve,
57218
57878
  DeviceType.Lock,
57219
57879
  DeviceType.MediaPlayer,
57220
- DeviceType.Thermostat,
57221
57880
  DeviceType.Climate
57222
57881
  ],
57223
57882
  methods: {},
@@ -57273,7 +57932,6 @@ var groupStatusCapability = {
57273
57932
  DeviceType.Valve,
57274
57933
  DeviceType.Lock,
57275
57934
  DeviceType.MediaPlayer,
57276
- DeviceType.Thermostat,
57277
57935
  DeviceType.Climate
57278
57936
  ],
57279
57937
  methods: {},
@@ -57602,7 +58260,7 @@ var heatingValveCapability = {
57602
58260
  scope: "device",
57603
58261
  deviceNative: true,
57604
58262
  mode: "singleton",
57605
- deviceTypes: [DeviceType.Thermostat],
58263
+ deviceTypes: [DeviceType.Climate],
57606
58264
  methods: {},
57607
58265
  status: {
57608
58266
  schema: HeatingValveStatusSchema,
@@ -57632,13 +58290,18 @@ var heatingValveCapability = {
57632
58290
  * retried in a loop - D49); a future one is re-armed.
57633
58291
  *
57634
58292
  * What a device may be run for, and for how long at most, is per device type
57635
- * ({@link TIMED_RUN_LIMITS}): the maximum is a safety bound, not a preference,
58293
+ * and role ({@link timedRunLimitOf}): the maximum is a safety bound, not a preference,
57636
58294
  * so a request above it is REFUSED with a typed reason, never clamped.
57637
58295
  */
57638
58296
  var TimedRunUnitSchema = _enum(["s", "min"]);
57639
58297
  _enum(["switch", "pet-fountain"]);
57640
- DeviceType.Heater, DeviceType.PetFountain;
57641
- var TIMED_RUN_DEVICE_TYPES = [DeviceType.Heater, DeviceType.PetFountain];
58298
+ /**
58299
+ * The device types `timed-run` may be offered on. A `switch` is narrowed by
58300
+ * role ({@link TIMED_RUN_DEVICE_ROLES}): only a plug-in heater runs on a timer.
58301
+ */
58302
+ var TIMED_RUN_DEVICE_TYPES = [DeviceType.Switch, DeviceType.PetFountain];
58303
+ /** The roles that make a device of these types timed-run-able (D1033). */
58304
+ var TIMED_RUN_DEVICE_ROLES = { [DeviceType.Switch]: [DeviceRole.SwitchHeater] };
57642
58305
  /** One duration, as the one-tap run asks for it. */
57643
58306
  var TimedRunQuickRunSchema = object({
57644
58307
  duration: number$1().positive().finite(),
@@ -57688,6 +58351,7 @@ var timedRunCapability = {
57688
58351
  kind: "wrapper",
57689
58352
  defaultActive: true,
57690
58353
  deviceTypes: TIMED_RUN_DEVICE_TYPES,
58354
+ deviceRoles: TIMED_RUN_DEVICE_ROLES,
57691
58355
  deviceConfig: { ui: {
57692
58356
  kind: "derived-form",
57693
58357
  builderId: "timed-run",
@@ -57848,8 +58512,8 @@ var HeroSceneSchema = object({
57848
58512
  /** 0..1: volume, cover position, cycle progress. */
57849
58513
  level: number$1().min(0).max(1).nullable()
57850
58514
  });
57851
- 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;
57852
- 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;
58515
+ 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;
58516
+ 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;
57853
58517
  /** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
57854
58518
  var HeroTextSchema = object({
57855
58519
  en: string(),
@@ -58234,8 +58898,8 @@ var HeroRowModelSchema = object({
58234
58898
  extras: array(HeroControlSchema).max(2).optional(),
58235
58899
  trailing: HeroFactSchema.nullable()
58236
58900
  });
58237
- DeviceType.Climate, DeviceType.Thermostat;
58238
- DeviceType.Climate, DeviceType.Thermostat, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
58901
+ DeviceType.Climate;
58902
+ DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
58239
58903
  /**
58240
58904
  * hero-layout — what a device's hero says (D1023). Read-only: the FIXED
58241
58905
  * layouts live in `@camstack/types` and nothing here stores or edits one.
@@ -58267,7 +58931,10 @@ method(heroInput, HeroModelSchema.nullable(), {
58267
58931
  }), method(rowModelsInput, array(HeroRowModelSchema.nullable()), {
58268
58932
  auth: "protected",
58269
58933
  role: "viewer"
58270
- }), method(object({ deviceType: string() }), HeroLayoutRowsSchema, {
58934
+ }), method(object({
58935
+ deviceType: string(),
58936
+ role: string().nullable().optional()
58937
+ }), HeroLayoutRowsSchema, {
58271
58938
  auth: "protected",
58272
58939
  role: "viewer"
58273
58940
  });
@@ -58314,6 +58981,11 @@ var humidifierCapability = {
58314
58981
  deviceNative: true,
58315
58982
  mode: "singleton",
58316
58983
  deviceTypes: [DeviceType.Humidifier],
58984
+ power: {
58985
+ kind: "field",
58986
+ field: "on",
58987
+ set: "setOn"
58988
+ },
58317
58989
  methods: {
58318
58990
  setOn: method(object({
58319
58991
  deviceId: number$1().int().nonnegative(),
@@ -58387,7 +59059,7 @@ var humiditySensorCapability = {
58387
59059
  scope: "device",
58388
59060
  deviceNative: true,
58389
59061
  mode: "singleton",
58390
- deviceTypes: [DeviceType.Sensor, DeviceType.Thermostat],
59062
+ deviceTypes: [DeviceType.Sensor, DeviceType.Climate],
58391
59063
  methods: {},
58392
59064
  status: {
58393
59065
  schema: HumiditySensorStatusSchema,
@@ -71569,7 +72241,18 @@ var OauthIntegrationDescriptorSchema = object({
71569
72241
  * The value is baked into the authorization code at `/authorize` and travels
71570
72242
  * on the tokens, so editing this field changes FUTURE links only.
71571
72243
  */
71572
- refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional()
72244
+ refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional(),
72245
+ /**
72246
+ * The integration instances an account can be linked to (planning#415),
72247
+ * beside the default one. `/api/oauth2/authorize?instance=<id>` is accepted
72248
+ * only for an id listed here; with no `instance=` the link is made to the
72249
+ * default instance, which is never listed and always accepted — it is the
72250
+ * address third parties already hold. Omit for a single-instance integration.
72251
+ */
72252
+ instances: array(object({
72253
+ id: string(),
72254
+ displayName: string()
72255
+ })).optional()
71573
72256
  });
71574
72257
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
71575
72258
  /**
@@ -71992,9 +72675,13 @@ var petFeederCapability = {
71992
72675
  */
71993
72676
  durability: "session",
71994
72677
  /**
71995
- * History (D850): recorded series.
72678
+ * History (D850): recorded series. `feeding` / `eating` are the meals the
72679
+ * device hero's "Meals" button names — change-only booleans, so a dispense
72680
+ * or a pet at the bowl is one span on the history.
71996
72681
  */
71997
72682
  history: { fields: {
72683
+ feeding: { kind: "boolean" },
72684
+ eating: { kind: "boolean" },
71998
72685
  foodLevel: { kind: "gauge" },
71999
72686
  bowlFood: { kind: "gauge" },
72000
72687
  food1: { kind: "gauge" },
@@ -72055,6 +72742,11 @@ var petFountainCapability = {
72055
72742
  deviceNative: true,
72056
72743
  mode: "singleton",
72057
72744
  deviceTypes: [DeviceType.PetFountain],
72745
+ power: {
72746
+ kind: "field",
72747
+ field: "pumpRunning",
72748
+ set: "setPump"
72749
+ },
72058
72750
  methods: {
72059
72751
  /** Start or stop the pump. */
72060
72752
  setPump: method(object({
@@ -73630,7 +74322,6 @@ var POWER_METER_DEVICE_TYPES = [
73630
74322
  DeviceType.Light,
73631
74323
  DeviceType.Fan,
73632
74324
  DeviceType.Climate,
73633
- DeviceType.Thermostat,
73634
74325
  DeviceType.Humidifier,
73635
74326
  DeviceType.WaterHeater,
73636
74327
  DeviceType.MediaPlayer,
@@ -73639,8 +74330,7 @@ var POWER_METER_DEVICE_TYPES = [
73639
74330
  DeviceType.Dishwasher,
73640
74331
  DeviceType.Vacuum,
73641
74332
  DeviceType.LawnMower,
73642
- DeviceType.PetFeeder,
73643
- DeviceType.Heater
74333
+ DeviceType.PetFeeder
73644
74334
  ];
73645
74335
  /** Everything but a bare `Sensor`: a sensor that takes its reading from another sensor adds nothing. */
73646
74336
  var POWER_METER_CUSTOMIZE_DEVICE_TYPES = POWER_METER_DEVICE_TYPES.filter((type) => type !== DeviceType.Sensor);
@@ -73753,118 +74443,6 @@ var powerMeterCapability = {
73753
74443
  volatileStateFields: ["lastFetchedAt"],
73754
74444
  customize: powerMeterCustomize
73755
74445
  };
73756
- var PowerSourceRefusalReasonSchema = _enum([
73757
- "no-power-source",
73758
- "switch-missing",
73759
- "switch-offline",
73760
- "switch-unknown",
73761
- "restart-in-progress",
73762
- "switch-call-failed"
73763
- ]);
73764
- var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
73765
- accepted: literal(false),
73766
- reason: PowerSourceRefusalReasonSchema,
73767
- /** One line for the operator, naming the switch. */
73768
- message: string()
73769
- })]);
73770
- var PowerSourceInfoSchema = object({
73771
- /** False when the device has no power source linked; the rest is then empty. */
73772
- linked: boolean(),
73773
- switchDeviceId: number$1().nullable(),
73774
- switchName: string().nullable(),
73775
- /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
73776
- switchOn: boolean().nullable(),
73777
- switchOnline: boolean().nullable(),
73778
- restartInProgress: boolean(),
73779
- offSeconds: number$1().int()
73780
- });
73781
- /** The composed slice: the switch state the link mirrors, plus the stored off time. */
73782
- var PowerSourceStateSchema = object({
73783
- /** Null while the switch has not reported: unknown is never `false` (D393). */
73784
- switchOn: boolean().nullable(),
73785
- offSeconds: number$1().int(),
73786
- lastFetchedAt: number$1()
73787
- });
73788
- var POWER_SOURCE_DEVICE_TYPES = [
73789
- DeviceType.Gateway,
73790
- DeviceType.Hub,
73791
- DeviceType.Camera,
73792
- DeviceType.Sensor,
73793
- DeviceType.MediaPlayer,
73794
- DeviceType.Vacuum,
73795
- DeviceType.Generic,
73796
- DeviceType.Washer,
73797
- DeviceType.Dryer,
73798
- DeviceType.Dishwasher,
73799
- DeviceType.PetFountain,
73800
- DeviceType.Fan,
73801
- DeviceType.Humidifier,
73802
- DeviceType.Climate,
73803
- DeviceType.WaterHeater
73804
- ];
73805
- var powerSourceCustomize = {
73806
- version: 1,
73807
- targets: [{
73808
- id: "switch",
73809
- cardinality: "scalar",
73810
- vocabulary: {
73811
- cap: "power-source",
73812
- stateField: "switchOn"
73813
- },
73814
- deviceTypes: POWER_SOURCE_DEVICE_TYPES,
73815
- apply: "add",
73816
- path: "switchOn",
73817
- sources: [{
73818
- kind: "switch",
73819
- transforms: [{ kind: "identity" }]
73820
- }],
73821
- companions: [{
73822
- kind: "constant",
73823
- path: "offSeconds",
73824
- value: 10,
73825
- when: "add",
73826
- formerValues: [0]
73827
- }, {
73828
- kind: "clock",
73829
- path: "lastFetchedAt",
73830
- when: "always"
73831
- }],
73832
- sourceReport: { status: "assignment-status" }
73833
- }]
73834
- };
73835
- var deviceInput$1 = object({ deviceId: number$1().int().nonnegative() });
73836
- var powerSourceCapability = {
73837
- name: "power-source",
73838
- scope: "device",
73839
- mode: "singleton",
73840
- deviceTypes: POWER_SOURCE_DEVICE_TYPES,
73841
- methods: {
73842
- getStatus: systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "protected" }),
73843
- powerOn: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
73844
- kind: "mutation",
73845
- auth: "protected"
73846
- }),
73847
- powerOff: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
73848
- kind: "mutation",
73849
- auth: "protected"
73850
- }),
73851
- forceRestart: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
73852
- kind: "mutation",
73853
- auth: "protected"
73854
- })
73855
- },
73856
- runtimeState: PowerSourceStateSchema,
73857
- customize: powerSourceCustomize,
73858
- /**
73859
- * Runtime-state durability: **session** — mirrored from the linked switch on
73860
- * its next report; a restored value would outlive the reading it names.
73861
- *
73862
- * See `RuntimeStateDurability`. Enforced by
73863
- * `scripts/check-runtime-state-durability.ts`.
73864
- */
73865
- durability: "session",
73866
- history: "none"
73867
- };
73868
74446
  /**
73869
74447
  * Presence cap. Models HA `person.*` and `device_tracker.*` entities
73870
74448
  * on `DeviceType.Presence`. Read-only — no setters: presence is
@@ -77331,9 +77909,7 @@ var RUNNING_CUSTOMIZE_DEVICE_TYPES = [
77331
77909
  DeviceType.Humidifier,
77332
77910
  DeviceType.Fan,
77333
77911
  DeviceType.Climate,
77334
- DeviceType.Thermostat,
77335
- DeviceType.PetFeeder,
77336
- DeviceType.Heater
77912
+ DeviceType.PetFeeder
77337
77913
  ];
77338
77914
  var runningStateCapability = {
77339
77915
  name: "running-state",
@@ -78605,6 +79181,13 @@ var SsoBridgeClaimsSchema = object({
78605
79181
  /** OAuth authorization-code binding — set only on `oauth-code` tokens. */
78606
79182
  redirectUri: string().optional(),
78607
79183
  integrationId: string().optional(),
79184
+ /**
79185
+ * The integration INSTANCE an OAuth link was made for (planning#415). Set on
79186
+ * `oauth-code`, `oauth-access` and `oauth-refresh` tokens of a link made
79187
+ * with `instance=`; absent on a link to the default instance. A cloud relay
79188
+ * reads it off the access token to route; the hub answers from the session.
79189
+ */
79190
+ instanceId: string().optional(),
78608
79191
  /** JWT ID — unique per issued code; consumed-set enforces single-use. */
78609
79192
  jti: string().optional(),
78610
79193
  /** PKCE S256 challenge — set only on `oauth-code` tokens issued to a public
@@ -79421,8 +80004,7 @@ var switchCapability = {
79421
80004
  DeviceType.Switch,
79422
80005
  DeviceType.Siren,
79423
80006
  DeviceType.Light,
79424
- DeviceType.Fan,
79425
- DeviceType.Heater
80007
+ DeviceType.Fan
79426
80008
  ],
79427
80009
  methods: { setState: method(object({
79428
80010
  deviceId: number$1(),
@@ -80116,7 +80698,7 @@ var temperatureSensorCapability = {
80116
80698
  scope: "device",
80117
80699
  deviceNative: true,
80118
80700
  mode: "singleton",
80119
- deviceTypes: [DeviceType.Sensor, DeviceType.Thermostat],
80701
+ deviceTypes: [DeviceType.Sensor, DeviceType.Climate],
80120
80702
  methods: {},
80121
80703
  status: {
80122
80704
  schema: TemperatureSensorStatusSchema,
@@ -80984,6 +81566,8 @@ var OauthSessionSummarySchema = object({
80984
81566
  userId: string(),
80985
81567
  username: string(),
80986
81568
  integrationId: string(),
81569
+ /** The instance the link was made for; `null` = the default instance. */
81570
+ instanceId: string().nullable().optional(),
80987
81571
  scopes: array(TokenScopeSchema),
80988
81572
  createdAt: number$1(),
80989
81573
  lastUsedAt: number$1(),
@@ -81083,6 +81667,9 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
81083
81667
  access: "view"
81084
81668
  }), method(object({
81085
81669
  integrationId: string(),
81670
+ /** The integration instance the link is for. Omit for the default
81671
+ * instance — never pass the addon id to mean it. */
81672
+ instanceId: string().optional(),
81086
81673
  userId: string(),
81087
81674
  username: string(),
81088
81675
  scopes: array(TokenScopeSchema),
@@ -81121,7 +81708,13 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
81121
81708
  }), method(object({ token: string() }), object({
81122
81709
  userId: string(),
81123
81710
  username: string(),
81124
- scopes: array(TokenScopeSchema)
81711
+ scopes: array(TokenScopeSchema),
81712
+ /** The instance the link was made for, read from the SESSION.
81713
+ * Absent = the default instance. `oauthLinkServesInstance` is the
81714
+ * helper a per-instance route calls to compare it with the instance
81715
+ * of its path; no route declares `perInstance` yet (the Alexa
81716
+ * per-instance route, T3, is the first consumer). */
81717
+ instanceId: string().optional()
81125
81718
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
81126
81719
  userId: string(),
81127
81720
  issuer: string()
@@ -81763,6 +82356,13 @@ var waterHeaterCapability = {
81763
82356
  deviceNative: true,
81764
82357
  mode: "singleton",
81765
82358
  deviceTypes: [DeviceType.WaterHeater],
82359
+ power: {
82360
+ kind: "mode",
82361
+ field: "operationMode",
82362
+ offValue: "off",
82363
+ set: "setOperationMode",
82364
+ lastField: "lastActiveMode"
82365
+ },
81766
82366
  methods: {
81767
82367
  setTargetTemp: method(object({
81768
82368
  deviceId: number$1().int().nonnegative(),
@@ -83421,7 +84021,6 @@ var DEVICE_LOCAL_STATE_CAPS = {
83421
84021
  control: controlCapability,
83422
84022
  cover: coverCapability,
83423
84023
  dayNight: dayNightCapability,
83424
- deviceDiscovery: deviceDiscoveryCapability,
83425
84024
  deviceStatus: deviceStatusCapability,
83426
84025
  dishwasher: dishwasherCapability,
83427
84026
  doNotDisturb: doNotDisturbCapability,
@@ -84516,15 +85115,16 @@ var BaseDeviceProvider = class extends BaseAddon {
84516
85115
  });
84517
85116
  const meta = await this.ctx.api.deviceManager.loadMeta.query({ deviceId: id });
84518
85117
  if (meta === null) throw new Error(`${this.providerName}: no persisted meta for "${stableId}" (id ${id}) — cannot reload`);
84519
- const deviceType = Object.values(DeviceType).find((t) => t === meta.type);
84520
- const Class = deviceType !== void 0 ? this.deviceClasses[deviceType] : void 0;
85118
+ const Class = this.deviceClassForRow({
85119
+ type: meta.type,
85120
+ stableId
85121
+ });
84521
85122
  if (!Class) throw new Error(`${this.providerName}: no device class for type "${meta.type}" — "${stableId}" is an accessory child; reload its parent instead`);
84522
85123
  await devices.create(stableId, Class, {}, meta.parentDeviceId ?? null);
84523
85124
  const rows = await this.ctx.api.deviceManager.listPersistedByAddon.query({ addonId: this.addonId });
84524
85125
  for (const row of rows) {
84525
85126
  if (row.parentDeviceId !== id) continue;
84526
- const childType = Object.values(DeviceType).find((t) => t === row.type);
84527
- const ChildClass = childType !== void 0 ? this.deviceClasses[childType] : void 0;
85127
+ const ChildClass = this.deviceClassForRow(row);
84528
85128
  if (!ChildClass) continue;
84529
85129
  try {
84530
85130
  await devices.create(row.stableId, ChildClass, {}, id);
@@ -84551,6 +85151,16 @@ var BaseDeviceProvider = class extends BaseAddon {
84551
85151
  return { deviceId: id };
84552
85152
  }
84553
85153
  /**
85154
+ * The class a PERSISTED row is rebuilt with. Default: by type, from
85155
+ * `deviceClasses`. A provider whose distinct devices share one type (D1033:
85156
+ * a radiator valve and a room climate are both `climate`) overrides this
85157
+ * and tells them apart by the row's stable id or config.
85158
+ */
85159
+ deviceClassForRow(row) {
85160
+ const type = Object.values(DeviceType).find((t) => t === row.type);
85161
+ return type !== void 0 ? this.deviceClasses[type] : void 0;
85162
+ }
85163
+ /**
84554
85164
  * Restore devices from persisted state. Two-pass:
84555
85165
  *
84556
85166
  * 1. **Top-level pass** — invokes `kernel.devices.create()` for every
@@ -84611,7 +85221,7 @@ var BaseDeviceProvider = class extends BaseAddon {
84611
85221
  restored.add(saved.id);
84612
85222
  return;
84613
85223
  }
84614
- const Class = this.deviceClasses[saved.type];
85224
+ const Class = this.deviceClassForRow(saved);
84615
85225
  if (!Class) throw new Error(`no device class registered for type "${saved.type}"`);
84616
85226
  if (saved.parentDeviceId !== null && !restored.has(saved.parentDeviceId)) throw new Error(`parent device ${saved.parentDeviceId} not restored`);
84617
85227
  await this.healSavedConfig(saved, savedDevices);
@@ -84628,7 +85238,7 @@ var BaseDeviceProvider = class extends BaseAddon {
84628
85238
  };
84629
85239
  const topLevel = savedDevices.filter((saved) => saved.parentDeviceId === null);
84630
85240
  const restoreOne = async (saved) => {
84631
- if (!this.deviceClasses[saved.type]) {
85241
+ if (!this.deviceClassForRow(saved)) {
84632
85242
  this.ctx.logger.warn("No device class registered for restored type — skipping", {
84633
85243
  tags: {
84634
85244
  deviceId: saved.id,
@@ -84667,7 +85277,7 @@ var BaseDeviceProvider = class extends BaseAddon {
84667
85277
  const failedTopLevelIds = new Set(failures.map((failure) => failure.saved.id));
84668
85278
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
84669
85279
  for (const saved of childRows) {
84670
- if (!this.deviceClasses[saved.type]) continue;
85280
+ if (!this.deviceClassForRow(saved)) continue;
84671
85281
  if (saved.parentDeviceId === null) continue;
84672
85282
  if (restored.has(saved.parentDeviceId)) {
84673
85283
  try {
@@ -84721,7 +85331,9 @@ var BaseDeviceProvider = class extends BaseAddon {
84721
85331
  }
84722
85332
  };
84723
85333
  DeviceType.HeatPump;
84724
- 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;
85334
+ DeviceType.Climate;
85335
+ DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
85336
+ 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;
84725
85337
  new Set(Object.values(DeviceType));
84726
85338
  /** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
84727
85339
  function contribution(cap, schema, build) {
@@ -86727,7 +87339,7 @@ var HEAT_PUMP_FAMILY_CONTRIBUTIONS = { "heat-pump-status": contribution("heat-pu
86727
87339
  ...Object.values(CLIMATE_FAMILY_CONTRIBUTIONS),
86728
87340
  ...Object.values(HEAT_PUMP_FAMILY_CONTRIBUTIONS)
86729
87341
  ];
86730
- 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;
87342
+ 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;
86731
87343
  /**
86732
87344
  * Who looks like what (D1023). One look per {@link DeviceType}, refined by a
86733
87345
  * {@link DeviceRole} where the role changes how the device reads (a leak
@@ -87371,9 +87983,9 @@ lookOf({
87371
87983
  idle: INFO,
87372
87984
  standby: MUTED
87373
87985
  });
87374
- DeviceType.Climate, DeviceType.Thermostat;
87375
- 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;
87376
- 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;
87986
+ DeviceType.Climate;
87987
+ 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;
87988
+ 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;
87377
87989
  Object.freeze({
87378
87990
  "accessories.getStatus": {
87379
87991
  capName: "accessories",
@@ -89223,41 +89835,6 @@ Object.freeze({
89223
89835
  access: "create",
89224
89836
  role: "admin"
89225
89837
  },
89226
- "deviceDiscovery.adoptDevice": {
89227
- capName: "device-discovery",
89228
- capScope: "device",
89229
- addonId: null,
89230
- access: "create",
89231
- role: "admin"
89232
- },
89233
- "deviceDiscovery.getStatus": {
89234
- capName: "device-discovery",
89235
- capScope: "device",
89236
- addonId: null,
89237
- access: "view",
89238
- role: "viewer"
89239
- },
89240
- "deviceDiscovery.listDiscovered": {
89241
- capName: "device-discovery",
89242
- capScope: "device",
89243
- addonId: null,
89244
- access: "view",
89245
- role: "viewer"
89246
- },
89247
- "deviceDiscovery.refreshDiscovery": {
89248
- capName: "device-discovery",
89249
- capScope: "device",
89250
- addonId: null,
89251
- access: "create",
89252
- role: "admin"
89253
- },
89254
- "deviceDiscovery.releaseDevice": {
89255
- capName: "device-discovery",
89256
- capScope: "device",
89257
- addonId: null,
89258
- access: "create",
89259
- role: "admin"
89260
- },
89261
89838
  "deviceExport.applyDeviceSettingsPatch": {
89262
89839
  capName: "device-export",
89263
89840
  capScope: "system",
@@ -90805,6 +91382,13 @@ Object.freeze({
90805
91382
  access: "create",
90806
91383
  role: "viewer"
90807
91384
  },
91385
+ "fanControl.setOscillationAxis": {
91386
+ capName: "fan-control",
91387
+ capScope: "device",
91388
+ addonId: null,
91389
+ access: "create",
91390
+ role: "viewer"
91391
+ },
90808
91392
  "fanControl.setPercentage": {
90809
91393
  capName: "fan-control",
90810
91394
  capScope: "device",
@@ -97826,7 +98410,7 @@ function projectAction(cap, action) {
97826
98410
  };
97827
98411
  }
97828
98412
  Object.entries(CAP_VOCABULARY_BY_NAME).flatMap(([cap, entry]) => entry.scope === "device" ? (entry.actions ?? []).map((a) => projectAction(cap, a)) : []);
97829
- 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;
98413
+ 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;
97830
98414
  DeviceFeature.BatteryOperated;
97831
98415
  function bound(cap, methods = [], authority = "reported") {
97832
98416
  return {
@@ -97885,6 +98469,149 @@ function offered(received) {
97885
98469
  };
97886
98470
  }
97887
98471
  offered(HA_AS), withheld(HOMEKIT_REASON), withheld(ALEXA_REASON), withheld(GOOGLE_REASON), withheld(MATTER_REASON);
98472
+ var PowerSwitchRefusedError = class extends Error {
98473
+ reason;
98474
+ constructor(reason, message) {
98475
+ super(message);
98476
+ this.name = "PowerSwitchRefusedError";
98477
+ this.reason = reason;
98478
+ }
98479
+ };
98480
+ /** `true` / `false` from the owner slice, `null` when the hinted field is
98481
+ * absent or not of the hinted shape. */
98482
+ function powerOnFromSlice(hint, slice) {
98483
+ const value = slice?.[hint.field];
98484
+ switch (hint.kind) {
98485
+ case "field": return typeof value === "boolean" ? value : null;
98486
+ case "methods": return typeof value === "string" ? !hint.offValues.includes(value) : null;
98487
+ case "mode": return typeof value === "string" ? value !== hint.offValue : null;
98488
+ }
98489
+ }
98490
+ function ownerMethod(owner, name, capName) {
98491
+ const fn = Reflect.get(owner, name);
98492
+ if (typeof fn !== "function") throw new PowerSwitchRefusedError("owner-method-missing", `${capName} provider does not serve '${name}', which its power hint names`);
98493
+ return async (input) => fn.call(owner, input);
98494
+ }
98495
+ async function lastNonOffMode(host, capName, hint) {
98496
+ const isMode = (v) => typeof v === "string" && v.length > 0 && v !== hint.offValue;
98497
+ const fromHub = (await host.readHubSlice(capName).catch(() => null))?.[hint.lastField];
98498
+ if (isMode(fromHub)) return fromHub;
98499
+ const local = host.runtimeState.getCapState(capName)?.[hint.lastField];
98500
+ return isMode(local) ? local : null;
98501
+ }
98502
+ async function applyPower(host, capName, hint, owner, on) {
98503
+ const deviceId = host.deviceId;
98504
+ switch (hint.kind) {
98505
+ case "field":
98506
+ await ownerMethod(owner, hint.set, capName)({
98507
+ deviceId,
98508
+ on
98509
+ });
98510
+ return;
98511
+ case "methods":
98512
+ await ownerMethod(owner, on ? hint.on : hint.off, capName)({ deviceId });
98513
+ return;
98514
+ case "mode": {
98515
+ const set = ownerMethod(owner, hint.set, capName);
98516
+ if (!on) {
98517
+ await set({
98518
+ deviceId,
98519
+ mode: hint.offValue
98520
+ });
98521
+ return;
98522
+ }
98523
+ const mode = await lastNonOffMode(host, capName, hint);
98524
+ if (mode === null) throw new PowerSwitchRefusedError("no-last-mode", `device ${deviceId}: ${capName} has no last non-off mode to restore; pick a mode instead`);
98525
+ await set({
98526
+ deviceId,
98527
+ mode
98528
+ });
98529
+ return;
98530
+ }
98531
+ }
98532
+ }
98533
+ function hintedMethods(hint) {
98534
+ return hint.kind === "methods" ? [hint.on, hint.off] : [hint.set];
98535
+ }
98536
+ /** Whether `owner` serves every method its cap's power hint names. A media
98537
+ * player whose `turnOn` / `turnOff` are not served has no power, so no switch. */
98538
+ function powerServedBy(hint, owner) {
98539
+ if (hint === void 0) return false;
98540
+ return hintedMethods(hint).every((name) => typeof Reflect.get(owner, name) === "function");
98541
+ }
98542
+ /** Builds the `switch` provider and starts the slice projection. Exported
98543
+ * for the specs; providers call `registerPowerSwitch`. */
98544
+ function buildPowerSwitch(host, cap, owner) {
98545
+ const hint = cap.power;
98546
+ if (hint === void 0) throw new Error(`capability '${cap.name}' has no power hint: it has no switch to project`);
98547
+ const read = () => powerOnFromSlice(hint, host.runtimeState.getCapState(cap.name));
98548
+ const project = () => {
98549
+ const on = read();
98550
+ const current = host.runtimeState.getCapState(switchCapability.name);
98551
+ if (current !== void 0 && current["on"] === on) return;
98552
+ const next = {
98553
+ on,
98554
+ lastChangedAt: Date.now()
98555
+ };
98556
+ host.runtimeState.setCapState(switchCapability.name, next);
98557
+ };
98558
+ const stop = host.runtimeState.subscribeCap(cap.name, project);
98559
+ if (host.runtimeState.getCapState(cap.name) !== void 0) project();
98560
+ return {
98561
+ provider: {
98562
+ getStatus: async () => {
98563
+ const current = host.runtimeState.getCapState(switchCapability.name);
98564
+ const lastChangedAt = typeof current?.["lastChangedAt"] === "number" ? current["lastChangedAt"] : 0;
98565
+ return {
98566
+ on: read(),
98567
+ lastChangedAt
98568
+ };
98569
+ },
98570
+ setState: async ({ on }) => applyPower(host, cap.name, hint, owner, on)
98571
+ },
98572
+ dispose: stop
98573
+ };
98574
+ }
98575
+ /**
98576
+ * Registers `switch` for a device whose `cap` carries a `power` hint, built
98577
+ * from `owner` (the provider the device registered for `cap`). Call it right
98578
+ * after `registerNativeCap(cap, owner)`.
98579
+ */
98580
+ function registerPowerSwitch(device, cap, owner) {
98581
+ const deviceId = device.ctx.id;
98582
+ if (cap.power !== void 0 && !powerServedBy(cap.power, owner)) {
98583
+ device.ctx.logger.debug("power switch: owner serves no power control, no switch registered", {
98584
+ tags: { deviceId },
98585
+ meta: { capName: cap.name }
98586
+ });
98587
+ return () => {};
98588
+ }
98589
+ const host = {
98590
+ deviceId,
98591
+ runtimeState: device.runtimeState,
98592
+ registerNativeCap: (c, p) => device.ctx.registerNativeCap(c, p),
98593
+ readHubSlice: async (capName) => {
98594
+ try {
98595
+ return await device.ctx.api.deviceState.getCapSlice.query({
98596
+ deviceId,
98597
+ capName
98598
+ });
98599
+ } catch (err) {
98600
+ device.ctx.logger.warn("power switch: hub slice read failed", {
98601
+ tags: { deviceId },
98602
+ meta: {
98603
+ capName,
98604
+ error: err instanceof Error ? err.message : String(err)
98605
+ }
98606
+ });
98607
+ return null;
98608
+ }
98609
+ }
98610
+ };
98611
+ const built = buildPowerSwitch(host, cap, owner);
98612
+ host.registerNativeCap(switchCapability, built.provider);
98613
+ return built.dispose;
98614
+ }
97888
98615
  Object.freeze({
97889
98616
  "accessories.getStatus": [{
97890
98617
  name: "deviceId",
@@ -98315,35 +99042,6 @@ Object.freeze({
98315
99042
  form: "single",
98316
99043
  optional: false
98317
99044
  }],
98318
- "deviceDiscovery.adoptDevice": [{
98319
- name: "deviceId",
98320
- form: "single",
98321
- optional: false
98322
- }],
98323
- "deviceDiscovery.getStatus": [{
98324
- name: "deviceId",
98325
- form: "single",
98326
- optional: false
98327
- }],
98328
- "deviceDiscovery.listDiscovered": [{
98329
- name: "deviceId",
98330
- form: "single",
98331
- optional: false
98332
- }],
98333
- "deviceDiscovery.refreshDiscovery": [{
98334
- name: "deviceId",
98335
- form: "single",
98336
- optional: false
98337
- }],
98338
- "deviceDiscovery.releaseDevice": [{
98339
- name: "childDeviceId",
98340
- form: "single",
98341
- optional: false
98342
- }, {
98343
- name: "deviceId",
98344
- form: "single",
98345
- optional: false
98346
- }],
98347
99045
  "deviceExport.applyDeviceSettingsPatch": [{
98348
99046
  name: "deviceId",
98349
99047
  form: "single",
@@ -98907,6 +99605,11 @@ Object.freeze({
98907
99605
  form: "single",
98908
99606
  optional: false
98909
99607
  }],
99608
+ "fanControl.setOscillationAxis": [{
99609
+ name: "deviceId",
99610
+ form: "single",
99611
+ optional: false
99612
+ }],
98910
99613
  "fanControl.setPercentage": [{
98911
99614
  name: "deviceId",
98912
99615
  form: "single",
@@ -127295,7 +127998,7 @@ function mapHmChannel(channelType) {
127295
127998
  capabilities: ["cover"]
127296
127999
  };
127297
128000
  case "HEATING_CLIMATECONTROL_TRANSCEIVER": return {
127298
- deviceType: DeviceType.Thermostat,
128001
+ deviceType: DeviceType.Climate,
127299
128002
  role: null,
127300
128003
  capabilities: [
127301
128004
  "climate-control",
@@ -127334,12 +128037,12 @@ function mapHmChannel(channelType) {
127334
128037
  * from the union of its channel mappings. Actuators win over sensors so
127335
128038
  * a switch + energy-meter device (HmIP-BSM) reports as a Switch, not a
127336
128039
  * Sensor, and a thermostat with a humidity sensor reports as a
127337
- * Thermostat. A remote/wall-switch is primarily an EventEmitter: it is
128040
+ * Climate device (D1033). A remote/wall-switch is primarily an EventEmitter: it is
127338
128041
  * ranked above Sensor so its battery / maintenance sensor channels don't
127339
128042
  * win the parent type. Returns `DeviceType.Generic` when no channel maps.
127340
128043
  */
127341
128044
  var PARENT_TYPE_PRIORITY = [
127342
- DeviceType.Thermostat,
128045
+ DeviceType.Climate,
127343
128046
  DeviceType.Lock,
127344
128047
  DeviceType.Cover,
127345
128048
  DeviceType.Light,
@@ -127451,9 +128154,10 @@ var HM_KEY_PRESS_DATAPOINTS = [
127451
128154
  /** Set form for O(1) fire-detection membership tests. */
127452
128155
  var HM_KEY_PRESS_SET = new Set(HM_KEY_PRESS_DATAPOINTS);
127453
128156
  /** Cold-start event-emitter slice; vocabulary supplied per-device. */
127454
- function coldEventEmitter(eventTypes) {
128157
+ function coldEventEmitter(vocabulary) {
127455
128158
  return {
127456
- eventTypes: [...eventTypes],
128159
+ eventTypes: eventTypesOfVocabulary(vocabulary),
128160
+ vocabulary: [...vocabulary],
127457
128161
  lastEvent: null,
127458
128162
  eventCountSinceStart: 0
127459
128163
  };
@@ -127523,7 +128227,7 @@ function actuatorInfo(kind) {
127523
128227
  case "climate": return {
127524
128228
  kind: "climate",
127525
128229
  capName: "climate-control",
127526
- type: DeviceType.Thermostat
128230
+ type: DeviceType.Climate
127527
128231
  };
127528
128232
  default: return null;
127529
128233
  }
@@ -127533,13 +128237,28 @@ function actuatorInfo(kind) {
127533
128237
  * tilt), a plain `cover` entity is the roller shutter (HmIP-BROLL). Exporters
127534
128238
  * read it; every other actuator has no role.
127535
128239
  */
127536
- function actuatorRole(kind) {
128240
+ function actuatorRole(kind, model) {
127537
128241
  if (kind === "blind") return DeviceRole.CoverBlind;
127538
128242
  if (kind === "cover") return DeviceRole.CoverShutter;
128243
+ if (kind === "climate") return climateRoleOfModel(model);
127539
128244
  return null;
127540
128245
  }
128246
+ /** Radiator valves: HmIP-eTRV-* and the classic HM-CC-RT-DN. */
128247
+ var RADIATOR_MODEL = /eTRV|HM-CC-RT-DN/i;
128248
+ /** Floor-heating actuators: HmIP-FAL* / HmIP-FALMOT-*. */
128249
+ var FLOOR_MODEL = /FAL/i;
128250
+ /**
128251
+ * D1033 — which climate device a Homematic model is. A radiator valve and a
128252
+ * floor-heating actuator are told apart by model; a wall thermostat, a
128253
+ * heating group and an unknown model are thermostats.
128254
+ */
128255
+ function climateRoleOfModel(model) {
128256
+ if (model !== void 0 && RADIATOR_MODEL.test(model)) return DeviceRole.ClimateRadiator;
128257
+ if (model !== void 0 && FLOOR_MODEL.test(model)) return DeviceRole.ClimateFloor;
128258
+ return DeviceRole.ClimateThermostat;
128259
+ }
127541
128260
  /** Actuator specs from the library's typed custom entities (correct channel). */
127542
- function deriveActuatorSpecs(customEntities) {
128261
+ function deriveActuatorSpecs(customEntities, model) {
127543
128262
  const out = [];
127544
128263
  for (const entity of customEntities) {
127545
128264
  const info = actuatorInfo(entity.kind);
@@ -127547,7 +128266,7 @@ function deriveActuatorSpecs(customEntities) {
127547
128266
  out.push({
127548
128267
  key: `act-${entity.channel}`,
127549
128268
  deviceType: info.type,
127550
- role: actuatorRole(entity.kind),
128269
+ role: actuatorRole(entity.kind, model),
127551
128270
  capabilities: [info.capName],
127552
128271
  name: `${entity.kind} ${entity.channel}`,
127553
128272
  config: {
@@ -127647,7 +128366,7 @@ function deriveUpdateSpec(device) {
127647
128366
  */
127648
128367
  function deriveHmEntitySpecs(device, customEntities) {
127649
128368
  return [
127650
- ...deriveActuatorSpecs(customEntities),
128369
+ ...deriveActuatorSpecs(customEntities, device.type),
127651
128370
  ...deriveSensorAndEventSpecs(device),
127652
128371
  ...deriveDiagnosticSpecs(device, device.address),
127653
128372
  ...deriveUpdateSpec(device)
@@ -128282,7 +129001,7 @@ var HmActuatorDevice = class extends HmChildDevice {
128282
129001
  }
128283
129002
  registerClimateCap() {
128284
129003
  const channel = this.actuatorChannel;
128285
- this.ctx.registerNativeCap(climateControlCapability, {
129004
+ const provider = {
128286
129005
  getStatus: async () => this.runtimeState.getCapState("climate-control") ?? COLD_CLIMATE,
128287
129006
  setMode: async ({ mode }) => {
128288
129007
  await this.requireFacade().climateSetMode(this.address, channel, toHmClimateMode(mode));
@@ -128298,7 +129017,9 @@ var HmActuatorDevice = class extends HmChildDevice {
128298
129017
  setTargetHumidity: async () => this.unsupported("climate humidity control"),
128299
129018
  setSwingVertical: async () => this.unsupported("climate vertical swing"),
128300
129019
  setSwingHorizontal: async () => this.unsupported("climate horizontal swing")
128301
- });
129020
+ };
129021
+ this.ctx.registerNativeCap(climateControlCapability, provider);
129022
+ registerPowerSwitch(this, climateControlCapability, provider);
128302
129023
  this.runtimeState.setCapState("climate-control", COLD_CLIMATE);
128303
129024
  this.registeredCap = "climate-control";
128304
129025
  }
@@ -128516,6 +129237,64 @@ var HmSensorDevice = class extends HmChildDevice {
128516
129237
  }
128517
129238
  };
128518
129239
  //#endregion
129240
+ //#region src/devices/hm-key-vocabulary.ts
129241
+ var PRESS_MEANING = {
129242
+ PRESS_SHORT: {
129243
+ label: "Short press",
129244
+ kind: "press"
129245
+ },
129246
+ PRESS_LONG: {
129247
+ label: "Long press",
129248
+ kind: "long-press"
129249
+ },
129250
+ PRESS_LONG_START: {
129251
+ label: "Long press started",
129252
+ kind: "long-press-start"
129253
+ },
129254
+ PRESS_LONG_RELEASE: {
129255
+ label: "Long press released",
129256
+ kind: "release"
129257
+ },
129258
+ PRESS_CONT: {
129259
+ label: "Long press held",
129260
+ kind: "repeat"
129261
+ }
129262
+ };
129263
+ /** The channels of a device that are buttons, in channel order. */
129264
+ function hmKeyChannels(device) {
129265
+ return mapHmDeviceChannels(device).filter(({ mapping }) => mapping.capabilities.includes("event-emitter")).map(({ channel }) => channel);
129266
+ }
129267
+ /** The presses one key channel has; the standard set when it lists none. */
129268
+ function pressesOf(channel) {
129269
+ const listed = new Set((channel.dataPoints ?? []).map((dataPoint) => dataPoint.parameter).filter((parameter) => HM_KEY_PRESS_SET.has(parameter)));
129270
+ if (listed.size === 0) return HM_KEY_PRESS_DATAPOINTS;
129271
+ return HM_KEY_PRESS_DATAPOINTS.filter((parameter) => listed.has(parameter));
129272
+ }
129273
+ function entryOf(parameter, source) {
129274
+ const meaning = PRESS_MEANING[parameter];
129275
+ if (meaning === void 0) return {
129276
+ id: parameter,
129277
+ source,
129278
+ label: parameter
129279
+ };
129280
+ return {
129281
+ id: parameter,
129282
+ source,
129283
+ label: meaning.label,
129284
+ kind: meaning.kind
129285
+ };
129286
+ }
129287
+ function hmKeyVocabulary(device) {
129288
+ return hmKeyChannels(device).flatMap((channel, position) => {
129289
+ const index = channelIndexFromAddress(channel.address) ?? String(channel.index);
129290
+ const source = {
129291
+ id: index,
129292
+ label: `Button ${position + 1} (channel ${index})`
129293
+ };
129294
+ return pressesOf(channel).map((parameter) => entryOf(parameter, source));
129295
+ });
129296
+ }
129297
+ //#endregion
128519
129298
  //#region src/devices/hm-event-emitter-device.ts
128520
129299
  /**
128521
129300
  * Event-emitter child config: the persisted native press vocabulary for the
@@ -128526,31 +129305,93 @@ var hmEventEmitterSchema = hmChildSchema.extend({ eventTypes: array(string()).op
128526
129305
  /**
128527
129306
  * ONE Homematic event-emitter accessory child collapsing all of a device's key
128528
129307
  * channels (HmIP-WRC* wall switches / HmIP-RC* remotes / KEY channels). The
128529
- * event vocabulary is the verbatim union of the channels' native `PRESS_*`
128530
- * datapoints (persisted in config at adoption). Presses fire
128531
- * `EventCategory.EventEmitted` with the button index (`:N` channel suffix) in
128532
- * `data.channel` — lifted VERBATIM from the legacy flat device.
129308
+ * event vocabulary is one source per key channel with that channel's native
129309
+ * `PRESS_*` datapoints, verbatim (`hm-key-vocabulary.ts`). Presses fire
129310
+ * `EventCategory.EventEmitted` with the button index (`:N` channel suffix)
129311
+ * as `sourceId`.
128533
129312
  */
128534
129313
  var HmEventEmitterDevice = class extends HmChildDevice {
128535
- eventTypes;
129314
+ /** The tokens persisted at adoption: the vocabulary of last resort. */
129315
+ persistedEventTypes;
129316
+ /** The vocabulary read from the CCU's channel list, once it answered. */
129317
+ #declared = null;
129318
+ /** Fires already reported as outside the vocabulary, as `source:token`. */
129319
+ #undeclaredLogged = /* @__PURE__ */ new Set();
128536
129320
  #eventSeq = 0;
128537
129321
  #eventCount = 0;
129322
+ /** Unsubscribe for the integration's state-change fan-out. */
129323
+ #snapshotUnsub = null;
128538
129324
  constructor(ctx) {
128539
129325
  super(ctx, hmEventEmitterSchema);
128540
129326
  const persisted = this.config.values.eventTypes;
128541
- this.eventTypes = persisted && persisted.length > 0 ? persisted : HM_KEY_PRESS_DATAPOINTS;
129327
+ this.persistedEventTypes = persisted && persisted.length > 0 ? persisted : HM_KEY_PRESS_DATAPOINTS;
128542
129328
  this.registerEventEmitterCap();
128543
129329
  this.attachValueChangedListener((event) => this.decodeKeyPress(event));
129330
+ if (this.integrationId !== void 0) this.#snapshotUnsub = homematicFacades.onSnapshot(this.integrationId, () => this.refreshDeclaredVocabulary());
129331
+ }
129332
+ /**
129333
+ * Rewrite the slice with the buttons once the CCU's channel list carries
129334
+ * them. A no-op while it does not, and after the buttons were declared.
129335
+ */
129336
+ refreshDeclaredVocabulary() {
129337
+ if (this.#declared !== null) return;
129338
+ const vocabulary = this.vocabulary();
129339
+ if (this.#declared === null) return;
129340
+ const current = this.runtimeState.getCapState("event-emitter");
129341
+ this.runtimeState.setCapState("event-emitter", {
129342
+ eventTypes: eventTypesOfVocabulary(vocabulary),
129343
+ vocabulary: [...vocabulary],
129344
+ lastEvent: current?.lastEvent ?? null,
129345
+ eventCountSinceStart: current?.eventCountSinceStart ?? 0
129346
+ });
129347
+ }
129348
+ async removeDevice() {
129349
+ this.#snapshotUnsub?.();
129350
+ this.#snapshotUnsub = null;
129351
+ await super.removeDevice();
128544
129352
  }
128545
129353
  registerEventEmitterCap() {
128546
- this.ctx.registerNativeCap(eventEmitterCapability, { getStatus: async () => this.runtimeState.getCapState("event-emitter") ?? coldEventEmitter(this.eventTypes) });
128547
- this.runtimeState.setCapState("event-emitter", coldEventEmitter(this.eventTypes));
129354
+ this.ctx.registerNativeCap(eventEmitterCapability, { getStatus: async () => this.runtimeState.getCapState("event-emitter") ?? coldEventEmitter(this.vocabulary()) });
129355
+ this.runtimeState.setCapState("event-emitter", coldEventEmitter(this.vocabulary()));
129356
+ }
129357
+ /**
129358
+ * The buttons and their presses, read LIVE from the CCU's channel list.
129359
+ *
129360
+ * Not from the child's config: that is written once, at adoption, so a
129361
+ * remote adopted before the vocabulary existed would never get its
129362
+ * buttons. While the CCU has not answered, the persisted tokens stand in,
129363
+ * with no button; the next write after it answers carries the buttons.
129364
+ */
129365
+ vocabulary() {
129366
+ if (this.#declared !== null) return this.#declared;
129367
+ const device = this.resolveHmDevice();
129368
+ const live = device === null ? [] : hmKeyVocabulary(device);
129369
+ if (live.length === 0) return plainEventVocabulary(this.persistedEventTypes);
129370
+ this.#declared = live;
129371
+ return live;
129372
+ }
129373
+ /** A press the vocabulary does not declare is delivered, and said once. */
129374
+ noteUndeclared(vocabulary, eventType, sourceId) {
129375
+ if (this.#declared === null) return;
129376
+ if (findVocabularyEntry(vocabulary, eventType, sourceId ?? void 0) !== void 0) return;
129377
+ const key = `${sourceId ?? ""}:${eventType}`;
129378
+ if (this.#undeclaredLogged.has(key)) return;
129379
+ this.#undeclaredLogged.add(key);
129380
+ this.ctx.logger.warn("Homematic press is not in the declared event vocabulary", {
129381
+ tags: { deviceId: this.ctx.id },
129382
+ meta: {
129383
+ address: this.address,
129384
+ eventType,
129385
+ sourceId
129386
+ }
129387
+ });
128548
129388
  }
128549
129389
  /**
128550
129390
  * Translate a key-channel `PRESS_*` datapoint into an `EventFire`: emit
128551
129391
  * `EventCategory.EventEmitted` on the bus and write the `event-emitter`
128552
129392
  * slice. The `eventType` is the native datapoint name VERBATIM; the button
128553
- * index (`:N` suffix of the channel address) travels in `data.channel`.
129393
+ * index (`:N` suffix of the channel address) is the fire's `sourceId`, and
129394
+ * stays in `data.channel` for readers older than the vocabulary.
128554
129395
  * Non-key datapoints and value resets are ignored.
128555
129396
  */
128556
129397
  decodeKeyPress(event) {
@@ -128562,6 +129403,7 @@ var HmEventEmitterDevice = class extends HmChildDevice {
128562
129403
  const fire = {
128563
129404
  deviceId: this.id,
128564
129405
  eventType: parameter,
129406
+ ...channelIndex !== null ? { sourceId: channelIndex } : {},
128565
129407
  data: channelIndex !== null ? { channel: channelIndex } : {},
128566
129408
  timestamp: now,
128567
129409
  seq: ++this.#eventSeq
@@ -128572,8 +129414,11 @@ var HmEventEmitterDevice = class extends HmChildDevice {
128572
129414
  deviceId: this.id,
128573
129415
  addonId: this.ctx.deviceMeta.addonId
128574
129416
  }, fire));
129417
+ const vocabulary = this.vocabulary();
129418
+ this.noteUndeclared(vocabulary, parameter, channelIndex);
128575
129419
  const slice = {
128576
- eventTypes: [...this.eventTypes],
129420
+ eventTypes: eventTypesOfVocabulary(vocabulary),
129421
+ vocabulary: [...vocabulary],
128577
129422
  lastEvent: fire,
128578
129423
  eventCountSinceStart: ++this.#eventCount
128579
129424
  };