@camstack/addon-export-alexa 1.2.195 → 1.2.197

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.
@@ -34,7 +34,7 @@ let node_path = require("node:path");
34
34
  node_path = __toESM(node_path, 1);
35
35
  require("node:child_process");
36
36
  require("node:zlib");
37
- //#region ../types/dist/event-category-78tcBemo.mjs
37
+ //#region ../types/dist/event-category-Dv-Gcv1f.mjs
38
38
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
39
39
  EventCategory["SystemBoot"] = "system.boot";
40
40
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -475,6 +475,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
475
475
  */
476
476
  EventCategory["DeviceStateChanged"] = "device.state-changed";
477
477
  /**
478
+ * A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
479
+ * transition audit (D1022): confirmed, already in place, unconfirmed or
480
+ * failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
481
+ * (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
482
+ * the Notification Center `device-command` kind. Telemetry (D8): losing one
483
+ * costs a notification, never state; the audit row is the record.
484
+ */
485
+ EventCategory["DeviceCommandSettled"] = "device.command-settled";
486
+ /**
478
487
  * The NATIVE shadow of a cap a composition has claimed fields of moved
479
488
  * (D663). Payload: `{ deviceId, capName, native }` — what the provider
480
489
  * wrote, BEFORE the owned fields are overlaid. Owner-only (D224): it is for
@@ -837,7 +846,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
837
846
  return EventCategory;
838
847
  }({});
839
848
  //#endregion
840
- //#region ../types/dist/composed-stable-id-CPp3votu.mjs
849
+ //#region ../types/dist/composed-stable-id-iddnCQ51.mjs
841
850
  /**
842
851
  import { errMsg } from '@camstack/types'
843
852
  * Extract a human-readable message from an unknown error value.
@@ -1179,6 +1188,11 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1179
1188
  * with the switch's on/off only. Speed or oscillation appear only when the
1180
1189
  * device also has a fan cap (D1033). */
1181
1190
  DeviceRole["SwitchFan"] = "switch-fan";
1191
+ /** A relay driving an on/off-only lamp: drawn as a light (bulb and glow, no
1192
+ * slider), presented to the exports as a light with power only. Not a
1193
+ * `light` type: the provider owns the type, and a light implies brightness
1194
+ * or colour this relay lacks. */
1195
+ DeviceRole["SwitchLight"] = "switch-light";
1182
1196
  /** Air conditioner / split unit: cooling, fan speed, louvres. */
1183
1197
  DeviceRole["ClimateAc"] = "climate-ac";
1184
1198
  /** Room thermostat: a setpoint and a room temperature. The default. */
@@ -6079,7 +6093,7 @@ var ZodIssueCode = {
6079
6093
  var ZodFirstPartyTypeKind;
6080
6094
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6081
6095
  //#endregion
6082
- //#region ../types/dist/sleep-D0roI_CZ.mjs
6096
+ //#region ../types/dist/sleep-BvVGLl30.mjs
6083
6097
  /**
6084
6098
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6085
6099
  * window to float samples (D455).
@@ -6762,6 +6776,13 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
6762
6776
  else skipped.push(id);
6763
6777
  };
6764
6778
  const selected = options.only === void 0 ? null : new Set(options.only);
6779
+ const deferred = /* @__PURE__ */ new Set();
6780
+ const deferredBy = (reason) => {
6781
+ if (selected === null || reason === null) return null;
6782
+ const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
6783
+ if (dep === void 0 || !byId.has(dep)) return null;
6784
+ return !selected.has(dep) || deferred.has(dep) ? dep : null;
6785
+ };
6765
6786
  for (const step of declaration.steps) {
6766
6787
  if (selected !== null && !selected.has(step.id)) continue;
6767
6788
  const bound = byId.get(step.id);
@@ -6773,6 +6794,19 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
6773
6794
  try {
6774
6795
  const gate = await host.startMigration({ id: step.id });
6775
6796
  if (!gate.proceed) {
6797
+ const waitsFor = deferredBy(gate.reason);
6798
+ if (waitsFor !== null) {
6799
+ log.info("migration deferred: its predecessor runs in another phase of this owner", {
6800
+ tags,
6801
+ meta: {
6802
+ waitsFor,
6803
+ reason: gate.reason
6804
+ }
6805
+ });
6806
+ deferred.add(step.id);
6807
+ skipped.push(step.id);
6808
+ continue;
6809
+ }
6776
6810
  log.warn("migration not run", {
6777
6811
  tags,
6778
6812
  meta: {
@@ -7817,7 +7851,7 @@ async function writeMembers(ctx, children, incoming, stored, pathOf) {
7817
7851
  for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
7818
7852
  return out;
7819
7853
  }
7820
- function rowId$3(row, idKey) {
7854
+ function rowId$4(row, idKey) {
7821
7855
  const raw = row[idKey];
7822
7856
  if (typeof raw === "string" && raw.length > 0) return raw;
7823
7857
  if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
@@ -7834,7 +7868,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
7834
7868
  }
7835
7869
  const storedById = /* @__PURE__ */ new Map();
7836
7870
  for (const row of storedRows) {
7837
- const id = rowId$3(row, node.idKey);
7871
+ const id = rowId$4(row, node.idKey);
7838
7872
  if (id !== null) storedById.set(id, row);
7839
7873
  }
7840
7874
  const kept = /* @__PURE__ */ new Set();
@@ -7844,13 +7878,13 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
7844
7878
  rows.push(row);
7845
7879
  continue;
7846
7880
  }
7847
- const id = rowId$3(row, node.idKey) ?? ctx.mintId();
7881
+ const id = rowId$4(row, node.idKey) ?? ctx.mintId();
7848
7882
  kept.add(id);
7849
7883
  const withId = {
7850
7884
  ...row,
7851
7885
  [node.idKey]: row[node.idKey] ?? id
7852
7886
  };
7853
- if (rowId$3(withId, node.idKey) === null) withId[node.idKey] = id;
7887
+ if (rowId$4(withId, node.idKey) === null) withId[node.idKey] = id;
7854
7888
  const storedRow = storedById.get(id) ?? {};
7855
7889
  rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
7856
7890
  }
@@ -10222,6 +10256,13 @@ var DeviceTransitionSchema = object({
10222
10256
  actor: TransitionActorSchema,
10223
10257
  command: TransitionCommandSchema.optional()
10224
10258
  });
10259
+ object({
10260
+ deviceId: number$1().int(),
10261
+ action: string(),
10262
+ outcome: TransitionOutcomeSchema,
10263
+ actor: TransitionActorSchema,
10264
+ at: number$1()
10265
+ });
10225
10266
  var READING_QUANTITIES = [
10226
10267
  "temperature",
10227
10268
  "pressure",
@@ -10765,6 +10806,13 @@ var ACTUATOR_CAP_VOCABULARY = {
10765
10806
  },
10766
10807
  state: { on: { icon: "lightbulb" } }
10767
10808
  },
10809
+ [DeviceRole.SwitchLight]: {
10810
+ actions: {
10811
+ "switch.on": { icon: "lightbulb" },
10812
+ "switch.off": { icon: "lightbulb-off" }
10813
+ },
10814
+ state: { on: { icon: "lightbulb" } }
10815
+ },
10768
10816
  [DeviceRole.Chime]: { actions: {
10769
10817
  "switch.on": {
10770
10818
  label: t("Enable chime", "Attiva il campanello"),
@@ -12245,7 +12293,10 @@ var ACTUATOR_CAP_VOCABULARY = {
12245
12293
  "ir-transmitter": {
12246
12294
  scope: "device",
12247
12295
  noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
12248
- notOperatorFacing: { send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it" }
12296
+ notOperatorFacing: {
12297
+ send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it",
12298
+ learn: "an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal"
12299
+ }
12249
12300
  },
12250
12301
  control: {
12251
12302
  scope: "device",
@@ -15166,6 +15217,32 @@ var CAP_VOCABULARY_BY_NAME = {
15166
15217
  ...SYSTEM_CAP_VOCABULARY
15167
15218
  };
15168
15219
  /**
15220
+ * Vocabulary actions by id (D983). An action step names a vocabulary action
15221
+ * (`cover.open`), never a raw cap method; this is the one lookup that turns the
15222
+ * id into its cap, method and effect — and a persisted legacy `cap` + `method`
15223
+ * pair back into the action id when exactly one action matches.
15224
+ */
15225
+ function buildIndex() {
15226
+ const byId = /* @__PURE__ */ new Map();
15227
+ for (const [cap, entry] of Object.entries(CAP_VOCABULARY_BY_NAME)) {
15228
+ if (entry.scope !== "device") continue;
15229
+ for (const action of entry.actions ?? []) byId.set(action.id, {
15230
+ cap,
15231
+ action
15232
+ });
15233
+ }
15234
+ return byId;
15235
+ }
15236
+ var index;
15237
+ function actionIndex() {
15238
+ index ??= buildIndex();
15239
+ return index;
15240
+ }
15241
+ /** The vocabulary action with this id, or `undefined`. */
15242
+ function findVocabAction(actionId) {
15243
+ return actionIndex().get(actionId);
15244
+ }
15245
+ /**
15169
15246
  * `addon-pages-source` — collection cap exposing per-provider raw page
15170
15247
  * declarations. Every addon that contributes a UI page registers a
15171
15248
  * provider here. The hub-side singleton aggregator (`addon-pages` cap,
@@ -17456,7 +17533,7 @@ Object.freeze({
17456
17533
  }
17457
17534
  });
17458
17535
  //#endregion
17459
- //#region ../types/dist/implemented-methods-5YMDeE3f.mjs
17536
+ //#region ../types/dist/implemented-methods-CSTk6zYK.mjs
17460
17537
  /**
17461
17538
  * The ffmpeg build every CamStack node downloads, per platform and arch.
17462
17539
  *
@@ -17510,6 +17587,52 @@ function portable(target) {
17510
17587
  }
17511
17588
  portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac64"), `${BASE$1}${FFMPEG_RELEASE}`;
17512
17589
  /**
17590
+ * A device's KIND is its type plus its role (D1033): the type is the set of
17591
+ * controls it has, the role says which thing it is among the devices that
17592
+ * share those controls. A plug-in heater is a `switch` with role
17593
+ * `switch-heater`; an air conditioner and a radiator valve are both `climate`,
17594
+ * told apart by their `climate-*` role.
17595
+ */
17596
+ /**
17597
+ * Type values a persisted row may still carry after the type was retired, and
17598
+ * the type each one is read as. The row is rewritten by the next registration
17599
+ * of the device (its provider stamps the live type), so this is a read alias,
17600
+ * not a migration.
17601
+ *
17602
+ * `heater` is deliberately absent: the only heaters were composed devices the
17603
+ * operator deletes. Such a row stays an unknown type, which every reader
17604
+ * treats as a generic device.
17605
+ */
17606
+ var RETIRED_DEVICE_TYPES = { thermostat: DeviceType.Climate };
17607
+ /** The live type a stored `type` value stands for (itself unless retired). */
17608
+ function canonicalStoredDeviceType(stored) {
17609
+ return RETIRED_DEVICE_TYPES[stored] ?? stored;
17610
+ }
17611
+ preprocess((value) => typeof value === "string" ? canonicalStoredDeviceType(value) : value, _enum(DeviceType));
17612
+ DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
17613
+ /**
17614
+ * A relay driving an on/off-only lamp (a `switch` with role `switch-light`):
17615
+ * drawn and exported as a light, with the switch's power only. The one place
17616
+ * that reads the role for it — a consumer asks this, never the role string.
17617
+ */
17618
+ function isSwitchLight(type, role) {
17619
+ return type === DeviceType.Switch && role === DeviceRole.SwitchLight;
17620
+ }
17621
+ /**
17622
+ * A smart plug (a `switch` with role `outlet`, D875): exported as a plug /
17623
+ * outlet. Exports ask this, never the role string.
17624
+ */
17625
+ function isOutlet(type, role) {
17626
+ return type === DeviceType.Switch && role === DeviceRole.Outlet;
17627
+ }
17628
+ /**
17629
+ * A plain fan behind a switch (a `switch` with role `switch-fan`): exported as
17630
+ * a fan with the switch's on/off only — no speed it does not have.
17631
+ */
17632
+ function isSwitchFan(type, role) {
17633
+ return type === DeviceType.Switch && role === DeviceRole.SwitchFan;
17634
+ }
17635
+ /**
17513
17636
  * THE table "which boolean of this device type counts as HIGH", and the
17514
17637
  * pure evaluator of its EDGE.
17515
17638
  *
@@ -23513,7 +23636,7 @@ var DeviceTokenScopeSchema = object({
23513
23636
  function migrateLegacyTokenScope(raw) {
23514
23637
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
23515
23638
  if (Reflect.get(raw, "type") !== "device") return raw;
23516
- if (Reflect.get(raw, "selector") !== void 0) return raw;
23639
+ if (Reflect.get(raw, "selector") !== void 0) return canonicalSelectorTypes(raw);
23517
23640
  const targets = Reflect.get(raw, "targets");
23518
23641
  if (!Array.isArray(targets)) return raw;
23519
23642
  return {
@@ -23525,6 +23648,27 @@ function migrateLegacyTokenScope(raw) {
23525
23648
  access: Reflect.get(raw, "access")
23526
23649
  };
23527
23650
  }
23651
+ /**
23652
+ * A stored `types` selector may name a type D1033 retired (`thermostat`). The
23653
+ * grant is read back through this same preprocess, so the retired name is
23654
+ * rewritten to its canonical type here and {@link DeviceSelectorSchema} itself
23655
+ * stays a strict enum on the wire.
23656
+ */
23657
+ function canonicalSelectorTypes(raw) {
23658
+ const selector = Reflect.get(raw, "selector");
23659
+ if (selector === null || typeof selector !== "object") return raw;
23660
+ if (Reflect.get(selector, "kind") !== "types") return raw;
23661
+ const types = Reflect.get(selector, "types");
23662
+ if (!Array.isArray(types)) return raw;
23663
+ const canonical = types.map((t) => typeof t === "string" ? canonicalStoredDeviceType(t) : t);
23664
+ return {
23665
+ ...raw,
23666
+ selector: {
23667
+ ...selector,
23668
+ types: canonical
23669
+ }
23670
+ };
23671
+ }
23528
23672
  var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
23529
23673
  object({
23530
23674
  type: literal("category"),
@@ -44837,21 +44981,23 @@ function convertLegacyWhen(half) {
44837
44981
  * (instants) and state leaves (durations). It replaces the flat trigger list
44838
44982
  * plus the separate condition tree; the firing rule is in that file and in
44839
44983
  * ADR "one tree".
44840
- * - **Actions** — the `wait` and `cap` steps, plus the `{kind:'code'}`
44984
+ * - **Actions** — the `wait` and device `command` steps, plus the `{kind:'code'}`
44841
44985
  * fragment of §3.2.2. See {@link AutomationActionSchema}.
44842
44986
  *
44843
44987
  * A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
44844
44988
  * {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
44845
44989
  */
44846
44990
  /**
44847
- * One action step: `wait`, or a `cap` call.
44991
+ * One action step: `wait`, or a device `command`.
44848
44992
  *
44849
- * A cap step's target is who it acts on (D983: `devices`, a `domain`, or a
44850
- * `{ $var }` resolved from the run's variables); the legacy `deviceId` is still
44851
- * READ, never written. The step runner (`runSteps`) owns the device-scope
44852
- * check, the stop-at-first-failure and the variable substitution, once, for
44853
- * every caller — automations, Actions, and the notification centre, which runs
44854
- * only Actions (planning#473).
44993
+ * A command step names a VOCABULARY action (`cover.open`) and who it acts on
44994
+ * (D983: `devices`, a `domain`, or a `{ $var }` resolved from the run's
44995
+ * variables). It never names a cap method: the step runner turns the action
44996
+ * id into its cap + method through the vocabulary index when the step runs
44997
+ * (`vocabCall`), the one place that mapping happens. The step runner
44998
+ * (`runSteps`) owns the device-scope check, the stop-at-first-failure and the
44999
+ * variable substitution, once, for every caller — automations, Actions, and
45000
+ * the notification centre, which runs only Actions (planning#473).
44855
45001
  */
44856
45002
  /** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
44857
45003
  var WAIT_MAX_SECONDS = 3600;
@@ -44860,39 +45006,22 @@ var AutomationWaitStepSchema = object({
44860
45006
  kind: literal("wait"),
44861
45007
  seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
44862
45008
  });
44863
- /** The legacy `deviceId` of a cap step: still READ, never written (D983). */
44864
- var LegacyStepDeviceSchema = union([
44865
- number$1().int(),
44866
- array(number$1().int()).min(1),
44867
- object({ $var: string().min(1) })
44868
- ]);
44869
45009
  /**
44870
- * The fields of a cap step, before the target rules are applied. Exported for
44871
- * a shape that is "a cap call, narrowed" (a remote-control binding is one
44872
- * device); a step is {@link AutomationCapStepSchema}.
45010
+ * The fields of a command step, before the vocabulary check. A step is
45011
+ * {@link AutomationCommandStepSchema}.
44873
45012
  */
44874
- var AutomationCapStepBaseSchema = object({
44875
- kind: literal("cap"),
44876
- /**
44877
- * The vocabulary action this step performs (`cover.open`). Required when
44878
- * `target` is a `domain` (the domain is "every device offering this
44879
- * action"); filled by {@link normalizeCapStep} for a legacy step whose
44880
- * cap + method match exactly one vocabulary action.
44881
- */
44882
- actionId: string().min(1).optional(),
44883
- /** WHO the step acts on. The only shape that is written. */
44884
- target: ActionTargetSchema.optional(),
45013
+ var AutomationCommandStepBaseSchema = object({
45014
+ kind: literal("command"),
45015
+ /** WHO the step acts on. */
45016
+ target: ActionTargetSchema,
45017
+ /** The vocabulary action this step performs (`cover.open`). */
45018
+ actionId: string().min(1),
44885
45019
  /**
44886
- * @deprecated The pre-D983 target: one device, several, or `{ $var }`.
44887
- * Still READ — {@link normalizeCapStep} maps it to `target` — and never
44888
- * written.
45020
+ * The values of the action's OPEN args (`position`, `presetId`); the args
45021
+ * the vocabulary bakes into the action are added when the step runs. Values
45022
+ * may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
45023
+ * SUBSTITUTE and do not evaluate (§3.2.3).
44889
45024
  */
44890
- deviceId: LegacyStepDeviceSchema.optional(),
44891
- cap: string().min(1),
44892
- method: string().min(1),
44893
- /** Values may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
44894
- * SUBSTITUTE and do not evaluate (§3.2.3). Anything beyond substitution is
44895
- * the expression leaf. */
44896
45025
  args: record(string(), unknown()).optional(),
44897
45026
  /**
44898
45027
  * The unit the person picked per arg (display only). `args` always hold the
@@ -44901,18 +45030,20 @@ var AutomationCapStepBaseSchema = object({
44901
45030
  */
44902
45031
  argUnits: record(string(), string().min(1)).optional()
44903
45032
  });
45033
+ /** The vocabulary check every command step passes: the action exists. */
45034
+ function refineKnownAction(step, ctx) {
45035
+ if (findVocabAction(step.actionId) === void 0) ctx.addIssue({
45036
+ code: "custom",
45037
+ message: `"${step.actionId}" is not a vocabulary action id`,
45038
+ path: ["actionId"]
45039
+ });
45040
+ }
44904
45041
  /**
44905
- * The steps an internal Action may contain: cap and wait, and nothing that can
45042
+ * The steps an internal Action may contain: command and wait, and nothing that can
44906
45043
  * call back into an Action — so an Action can never reach itself (no cycles).
44907
45044
  * This is the LEAF shape: no condition of its own.
44908
45045
  */
44909
- var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCapStepBaseSchema.refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44910
- message: "a cap step needs a target",
44911
- path: ["target"]
44912
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44913
- message: "a domain target needs the vocabulary action it applies to (actionId)",
44914
- path: ["actionId"]
44915
- })]);
45046
+ var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCommandStepBaseSchema.superRefine(refineKnownAction)]);
44916
45047
  /**
44917
45048
  * The optional guard of a step (#472): `if` is the ONE `when` tree (D980), read
44918
45049
  * on the state mirror when the step is reached; `else` runs when it is false.
@@ -44933,13 +45064,7 @@ var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refi
44933
45064
  * same two step kinds an automation runs, minus a guard that reads the
44934
45065
  * automation's trigger, which such a list does not have.
44935
45066
  */
44936
- var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44937
- message: "a cap step needs a target",
44938
- path: ["target"]
44939
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44940
- message: "a domain target needs the vocabulary action it applies to (actionId)",
44941
- path: ["actionId"]
44942
- }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
45067
+ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCommandStepBaseSchema.extend(stepGuardShape).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
44943
45068
  if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
44944
45069
  code: "custom",
44945
45070
  message: TRIGGERED_BY_NEEDS_AUTOMATION,
@@ -44954,17 +45079,11 @@ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, Automa
44954
45079
  var continueOnErrorShape = {
44955
45080
  /** A failure of this step is traced `failed-continued` and the next step runs. */
44956
45081
  continueOnError: literal(true).optional() };
44957
- /** An automation's cap step: the shared guarded cap step, plus `continueOnError`. */
44958
- var AutomationGuardedCapStepSchema = AutomationCapStepBaseSchema.extend({
45082
+ /** An automation's command step: the shared guarded command step, plus `continueOnError`. */
45083
+ var AutomationGuardedCommandStepSchema = AutomationCommandStepBaseSchema.extend({
44959
45084
  ...stepGuardShape,
44960
45085
  ...continueOnErrorShape
44961
- }).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44962
- message: "a cap step needs a target",
44963
- path: ["target"]
44964
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44965
- message: "a domain target needs the vocabulary action it applies to (actionId)",
44966
- path: ["actionId"]
44967
- }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
45086
+ }).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
44968
45087
  /** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
44969
45088
  var AutomationStopStepSchema = object({
44970
45089
  kind: literal("stop"),
@@ -45044,13 +45163,7 @@ function nestTooDeep(issue) {
45044
45163
  }
45045
45164
  var plainStepSchemas = [
45046
45165
  AutomationWaitStepSchema.strict(),
45047
- AutomationCapStepBaseSchema.extend(continueOnErrorShape).strict().refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
45048
- message: "a cap step needs a target",
45049
- path: ["target"]
45050
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
45051
- message: "a domain target needs the vocabulary action it applies to (actionId)",
45052
- path: ["actionId"]
45053
- }),
45166
+ AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
45054
45167
  AutomationStopStepSchema.omit({ if: true }).strict(),
45055
45168
  AutomationSetStepSchema.omit({ if: true }).strict(),
45056
45169
  AutomationRunActionStepSchema.strict()
@@ -45061,7 +45174,7 @@ var plainStepSchemas = [
45061
45174
  */
45062
45175
  var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
45063
45176
  /** A step that can run beside others: it writes no variable and does not end the run. */
45064
- 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");
45177
+ var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) => step.kind === "command" || 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");
45065
45178
  /**
45066
45179
  * Several steps at once (#500): all are started together and all are awaited.
45067
45180
  * A failure fails the run once the others finished, as in a sequence; a member
@@ -45141,7 +45254,7 @@ var AutomationBodyStepSchema = discriminatedUnion("kind", [
45141
45254
  var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
45142
45255
  var AutomationActionSchema = discriminatedUnion("kind", [
45143
45256
  GuardedWaitStepSchema,
45144
- AutomationGuardedCapStepSchema,
45257
+ AutomationGuardedCommandStepSchema,
45145
45258
  AutomationStopStepSchema,
45146
45259
  AutomationSetStepSchema,
45147
45260
  chooseSchemaOf(AutomationBodyStepSchema),
@@ -45212,86 +45325,6 @@ function convertLegacyRecipe(legacy) {
45212
45325
  };
45213
45326
  }
45214
45327
  var AutomationRecipeSchema = union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
45215
- var DETECTION_DESCRIPTIONS = {
45216
- deviceId: "the camera that saw it",
45217
- className: "what it saw",
45218
- trackId: "the track",
45219
- score: "how sure the detector was",
45220
- label: "the label it matched (a name, a plate), empty when none"
45221
- };
45222
- var STATIONARY_DESCRIPTIONS = {
45223
- deviceId: "the camera that saw it",
45224
- className: "what it saw",
45225
- zones: "the zones it is in",
45226
- phase: "appeared or departed",
45227
- entryId: "the stopped object"
45228
- };
45229
- var BECOMES_DESCRIPTIONS = {
45230
- deviceId: "the device that changed",
45231
- from: "the value before the change, empty when it is not known",
45232
- to: "the value it changed to"
45233
- };
45234
- /**
45235
- * A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
45236
- * those names depend on the device, so they are not in this list.
45237
- */
45238
- var FIRED_DESCRIPTIONS = {
45239
- deviceId: "the device that fired",
45240
- eventType: "the event, as the device names it",
45241
- sourceId: "the part of the device that fired (a button), empty when it names none",
45242
- eventKind: "the kind of press (press, long-press …), empty when the device declares none"
45243
- };
45244
- function describe$1(descriptions) {
45245
- return Object.entries(descriptions).map(([name, description]) => ({
45246
- name,
45247
- description
45248
- }));
45249
- }
45250
- describe$1(DETECTION_DESCRIPTIONS);
45251
- describe$1(STATIONARY_DESCRIPTIONS);
45252
- describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45253
- ...v,
45254
- hintKey: "firedDeviceId"
45255
- } : v);
45256
- describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45257
- ...v,
45258
- hintKey: "becomesDeviceId"
45259
- } : v);
45260
- new Set(Object.values(COCO_TO_MACRO.mapping));
45261
- /**
45262
- * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
45263
- * device. Carries the device's EXACT declared event vocabulary verbatim
45264
- * (NO normalization). Two shapes:
45265
- * - structured source (HA `event.*` entity) → `vocabulary` is the fixed
45266
- * declared set (e.g. press_short, press_long, …).
45267
- * - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
45268
- * is [] (open) and `lastEvent.data` carries the complex payload.
45269
- * `vocabulary` (D1044) names each event for a person and types it for a
45270
- * rule; `eventTypes` is its list of native tokens, kept for older readers.
45271
- * A fire names the part of the device it came from in `sourceId` when the
45272
- * vocabulary declares sources (a remote's buttons).
45273
- * `seq` is monotonic so two identical events still produce distinct slice writes.
45274
- */
45275
- var EventFireSchema = object({
45276
- deviceId: number$1(),
45277
- eventType: string(),
45278
- sourceId: string().optional(),
45279
- data: record(string(), unknown()).nullable(),
45280
- timestamp: number$1().meta(readingMeta("none")),
45281
- seq: number$1().meta(readingMeta("count"))
45282
- });
45283
- var EventEmitterStatusSchema = object({
45284
- eventTypes: array(string()),
45285
- /**
45286
- * Required of a provider by the type. A status written before the field
45287
- * existed still parses, as an empty vocabulary: read it through
45288
- * `readEventVocabulary`, which then answers with the plain tokens.
45289
- */
45290
- vocabulary: array(EventVocabularyEntrySchema).default([]),
45291
- lastEvent: EventFireSchema.nullable(),
45292
- eventCountSinceStart: number$1().meta(readingMeta("count"))
45293
- });
45294
- DeviceType.EventEmitter;
45295
45328
  /**
45296
45329
  * Schedulers (D983) — an entity that performs actions over the day.
45297
45330
  *
@@ -45690,6 +45723,86 @@ var AutomationStateDocSchema = object({
45690
45723
  lastRunStartedAt: number$1().nullable(),
45691
45724
  traces: array(AutomationRunTraceSchema)
45692
45725
  });
45726
+ var DETECTION_DESCRIPTIONS = {
45727
+ deviceId: "the camera that saw it",
45728
+ className: "what it saw",
45729
+ trackId: "the track",
45730
+ score: "how sure the detector was",
45731
+ label: "the label it matched (a name, a plate), empty when none"
45732
+ };
45733
+ var STATIONARY_DESCRIPTIONS = {
45734
+ deviceId: "the camera that saw it",
45735
+ className: "what it saw",
45736
+ zones: "the zones it is in",
45737
+ phase: "appeared or departed",
45738
+ entryId: "the stopped object"
45739
+ };
45740
+ var BECOMES_DESCRIPTIONS = {
45741
+ deviceId: "the device that changed",
45742
+ from: "the value before the change, empty when it is not known",
45743
+ to: "the value it changed to"
45744
+ };
45745
+ /**
45746
+ * A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
45747
+ * those names depend on the device, so they are not in this list.
45748
+ */
45749
+ var FIRED_DESCRIPTIONS = {
45750
+ deviceId: "the device that fired",
45751
+ eventType: "the event, as the device names it",
45752
+ sourceId: "the part of the device that fired (a button), empty when it names none",
45753
+ eventKind: "the kind of press (press, long-press …), empty when the device declares none"
45754
+ };
45755
+ function describe$1(descriptions) {
45756
+ return Object.entries(descriptions).map(([name, description]) => ({
45757
+ name,
45758
+ description
45759
+ }));
45760
+ }
45761
+ describe$1(DETECTION_DESCRIPTIONS);
45762
+ describe$1(STATIONARY_DESCRIPTIONS);
45763
+ describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45764
+ ...v,
45765
+ hintKey: "firedDeviceId"
45766
+ } : v);
45767
+ describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45768
+ ...v,
45769
+ hintKey: "becomesDeviceId"
45770
+ } : v);
45771
+ new Set(Object.values(COCO_TO_MACRO.mapping));
45772
+ /**
45773
+ * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
45774
+ * device. Carries the device's EXACT declared event vocabulary verbatim
45775
+ * (NO normalization). Two shapes:
45776
+ * - structured source (HA `event.*` entity) → `vocabulary` is the fixed
45777
+ * declared set (e.g. press_short, press_long, …).
45778
+ * - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
45779
+ * is [] (open) and `lastEvent.data` carries the complex payload.
45780
+ * `vocabulary` (D1044) names each event for a person and types it for a
45781
+ * rule; `eventTypes` is its list of native tokens, kept for older readers.
45782
+ * A fire names the part of the device it came from in `sourceId` when the
45783
+ * vocabulary declares sources (a remote's buttons).
45784
+ * `seq` is monotonic so two identical events still produce distinct slice writes.
45785
+ */
45786
+ var EventFireSchema = object({
45787
+ deviceId: number$1(),
45788
+ eventType: string(),
45789
+ sourceId: string().optional(),
45790
+ data: record(string(), unknown()).nullable(),
45791
+ timestamp: number$1().meta(readingMeta("none")),
45792
+ seq: number$1().meta(readingMeta("count"))
45793
+ });
45794
+ var EventEmitterStatusSchema = object({
45795
+ eventTypes: array(string()),
45796
+ /**
45797
+ * Required of a provider by the type. A status written before the field
45798
+ * existed still parses, as an empty vocabulary: read it through
45799
+ * `readEventVocabulary`, which then answers with the plain tokens.
45800
+ */
45801
+ vocabulary: array(EventVocabularyEntrySchema).default([]),
45802
+ lastEvent: EventFireSchema.nullable(),
45803
+ eventCountSinceStart: number$1().meta(readingMeta("count"))
45804
+ });
45805
+ DeviceType.EventEmitter;
45693
45806
  /**
45694
45807
  * Actions — named, runnable things an operator (or an automation) can start,
45695
45808
  * declared as LIST ENTRIES, never as devices.
@@ -45952,6 +46065,343 @@ function pruneDeletedEntities(selection, live, log, exporter) {
45952
46065
  dropped
45953
46066
  };
45954
46067
  }
46068
+ /**
46069
+ * `device-export` — collection cap for addons that export camstack
46070
+ * devices to external ecosystems (HomeAssistant via MQTT discovery,
46071
+ * HomeKit/HAP, Alexa Smart Home, …).
46072
+ *
46073
+ * No `ecosystem` enum — the addon id identifies the export target.
46074
+ * Each addon owns its mapping logic in its own settings UI. The cap
46075
+ * exposes only the COMMON surface: link state, supported device
46076
+ * kinds (so the UI can filter the device picker), and per-device
46077
+ * expose/unexpose.
46078
+ *
46079
+ * INSTANCES. One export addon can serve several independent targets (a
46080
+ * HomeKit bridge, a Home Assistant broker). `listInstances` names them.
46081
+ * `instanceId` on a READ is optional: absent = the whole addon (linked if any
46082
+ * enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
46083
+ * default instance's); present = that instance; an id the provider does not
46084
+ * serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
46085
+ * never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
46086
+ * change always names the target it changes. A single-instance provider
46087
+ * accepts an absent id on a read or its own id, and refuses any other.
46088
+ */
46089
+ /** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
46090
+ var InstanceIdSchema$1 = string().min(1);
46091
+ var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
46092
+ /** One independent export target of an addon. */
46093
+ var ExportInstanceSchema = object({
46094
+ instanceId: InstanceIdSchema$1,
46095
+ name: string(),
46096
+ enabled: boolean(),
46097
+ kind: string().optional(),
46098
+ /**
46099
+ * What this instance's platform accepts as a device name, in one operator-facing sentence
46100
+ * (D1049). The derived "Name on <instance>" field shows it; absent = the field says nothing
46101
+ * about the rule.
46102
+ */
46103
+ nameRule: string().optional()
46104
+ });
46105
+ var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
46106
+ /** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
46107
+ var ExportInstanceUnknownError = class extends Error {
46108
+ code = EXPORT_INSTANCE_UNKNOWN;
46109
+ instanceId;
46110
+ constructor(addon, instanceId) {
46111
+ super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
46112
+ this.name = "ExportInstanceUnknownError";
46113
+ this.instanceId = instanceId;
46114
+ }
46115
+ };
46116
+ /**
46117
+ * The instance a `getStatus` call names. The cap's `status` block injects a per-device
46118
+ * `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
46119
+ * both shapes; only the second names an instance (a per-device status read is addon-wide).
46120
+ */
46121
+ function statusInstanceOf(input) {
46122
+ return "instanceId" in input ? input.instanceId : void 0;
46123
+ }
46124
+ var LinkStateSchema = _enum([
46125
+ "unlinked",
46126
+ "linked",
46127
+ "error"
46128
+ ]);
46129
+ /**
46130
+ * A single label/value row surfaced in the export panel's "Setup"
46131
+ * section. Rendered with a copy-to-clipboard button. `secret: true`
46132
+ * rows are masked by default with a reveal toggle (client ids,
46133
+ * secrets, …).
46134
+ */
46135
+ var ExportSetupFieldSchema = object({
46136
+ label: string(),
46137
+ value: string(),
46138
+ /** Mask the value by default + render a reveal toggle (client id, secrets). */
46139
+ secret: boolean().optional()
46140
+ });
46141
+ /**
46142
+ * Generic, addon-agnostic pairing/account block. Any export addon can
46143
+ * surface a scannable QR, a set of copyable label/value rows, and a
46144
+ * free-form operator note — the `DeviceExportPanel` renders whatever
46145
+ * the provider supplies and skips the section entirely when `setup`
46146
+ * is unset.
46147
+ */
46148
+ var ExportSetupSchema = object({
46149
+ /** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
46150
+ qr: string().optional(),
46151
+ /** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
46152
+ fields: array(ExportSetupFieldSchema).readonly().optional(),
46153
+ /** Free-form operator instructions rendered above the fields. */
46154
+ note: string().optional()
46155
+ });
46156
+ var DeviceExportStatusSchema = object({
46157
+ linkState: LinkStateSchema,
46158
+ exposedDeviceCount: number$1(),
46159
+ error: string().optional(),
46160
+ /**
46161
+ * Optional pairing/account info the panel renders in a generic
46162
+ * "Setup" section. Addon-agnostic — the addon id identifies the
46163
+ * export target, never an `ecosystem` key here.
46164
+ */
46165
+ setup: ExportSetupSchema.optional()
46166
+ });
46167
+ var DeviceKindSchema = string();
46168
+ /**
46169
+ * EXPOSED NAME. What one instance calls a device on its platform, when it should not be the
46170
+ * device's own name. The exporter owns it: it is stored per instance in the exporter's per-device
46171
+ * store (D865), validated by the exporter against its platform's naming rules, and never reaches
46172
+ * the exported id — a rename updates the SAME device on the platform, never a second one.
46173
+ * Blank or `null` = the device's own name. A name the platform would refuse is refused with
46174
+ * `ExportNameRefusedError` (`export-name-refused`), whose message says why.
46175
+ */
46176
+ var ExposedDeviceSchema = object({
46177
+ deviceId: string(),
46178
+ exposedAs: string().optional(),
46179
+ /** The operator's name for this device on this instance; absent = the device's own name. */
46180
+ exposedName: string().optional(),
46181
+ capabilities: array(string()).optional()
46182
+ });
46183
+ var ExposeInputSchema = object({
46184
+ instanceId: InstanceIdSchema$1,
46185
+ deviceId: string(),
46186
+ capabilities: array(string()).optional(),
46187
+ /** Set the exposed name in the same call; absent = leave it as it is, blank/null = clear it. */
46188
+ exposedName: string().nullable().optional()
46189
+ });
46190
+ var SetExposedNameInputSchema = object({
46191
+ instanceId: InstanceIdSchema$1,
46192
+ deviceId: string(),
46193
+ /** Blank or null = the device's own name. */
46194
+ name: string().nullable(),
46195
+ /**
46196
+ * Validate only: refuse exactly as a real call would, write nothing. A caller saving several
46197
+ * names at once checks every one first, so one refusal writes none (D1049).
46198
+ */
46199
+ dryRun: boolean().optional()
46200
+ });
46201
+ var EXPORT_NAME_REFUSED = "export-name-refused";
46202
+ /** A name the instance's platform would refuse. The message starts with the code, then the reason. */
46203
+ var ExportNameRefusedError = class extends Error {
46204
+ code = EXPORT_NAME_REFUSED;
46205
+ instanceId;
46206
+ reason;
46207
+ constructor(instanceId, reason) {
46208
+ super(`${EXPORT_NAME_REFUSED}: ${reason}`);
46209
+ this.name = "ExportNameRefusedError";
46210
+ this.instanceId = instanceId;
46211
+ this.reason = reason;
46212
+ }
46213
+ };
46214
+ var UnexposeInputSchema = object({
46215
+ instanceId: InstanceIdSchema$1,
46216
+ deviceId: string()
46217
+ });
46218
+ /**
46219
+ * What an exporter may expose besides devices (D968). An action and a
46220
+ * notification target are LIST ENTRIES, never devices (D954): they enter an
46221
+ * exporter's own selection, not the device registry.
46222
+ */
46223
+ var ExportEntityKindSchema = _enum([
46224
+ "device",
46225
+ "action",
46226
+ "notifier"
46227
+ ]);
46228
+ var ExportEntityRefSchema = discriminatedUnion("kind", [
46229
+ object({
46230
+ kind: literal("device"),
46231
+ deviceId: string()
46232
+ }),
46233
+ object({
46234
+ kind: literal("action"),
46235
+ actionId: string().min(1)
46236
+ }),
46237
+ object({
46238
+ kind: literal("notifier"),
46239
+ targetId: string().min(1)
46240
+ })
46241
+ ]);
46242
+ var ExposedEntitySchema = object({
46243
+ entity: ExportEntityRefSchema,
46244
+ exposedAs: string().optional()
46245
+ });
46246
+ var ExposeEntityInputSchema = object({
46247
+ instanceId: InstanceIdSchema$1,
46248
+ entity: ExportEntityRefSchema
46249
+ });
46250
+ var UnexposeEntityInputSchema = object({
46251
+ instanceId: InstanceIdSchema$1,
46252
+ entity: ExportEntityRefSchema
46253
+ });
46254
+ var deviceExportCapability = {
46255
+ name: "device-export",
46256
+ scope: "system",
46257
+ mode: "collection",
46258
+ providerKind: "device-export",
46259
+ status: {
46260
+ schema: DeviceExportStatusSchema,
46261
+ kind: "poll"
46262
+ },
46263
+ /**
46264
+ * Each export provider MAY contribute its own per-device "Export" panel
46265
+ * (enabled toggle, preferred stream, addon-specific knobs). The three
46266
+ * framework methods are mounted on the cap router when present.
46267
+ * `IDeviceExportProvider` leaves them optional: an exporter with no
46268
+ * per-device panel omits them (a `deviceConfig` cap's UI is derived and
46269
+ * never hand-written — D14 — and an exporter is not one of those).
46270
+ */
46271
+ exposesDeviceSettings: true,
46272
+ methods: {
46273
+ getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
46274
+ listInstances: method(_void(), array(ExportInstanceSchema)),
46275
+ listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
46276
+ listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
46277
+ exposeDevice: method(ExposeInputSchema, _void(), {
46278
+ kind: "mutation",
46279
+ auth: "admin"
46280
+ }),
46281
+ unexposeDevice: method(UnexposeInputSchema, _void(), {
46282
+ kind: "mutation",
46283
+ auth: "admin"
46284
+ }),
46285
+ setExposedName: method(SetExposedNameInputSchema, _void(), {
46286
+ kind: "mutation",
46287
+ auth: "admin"
46288
+ }),
46289
+ listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
46290
+ listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
46291
+ exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
46292
+ kind: "mutation",
46293
+ auth: "admin"
46294
+ }),
46295
+ unexposeEntity: optionalMethod(UnexposeEntityInputSchema, _void(), {
46296
+ kind: "mutation",
46297
+ auth: "admin"
46298
+ })
46299
+ }
46300
+ };
46301
+ /**
46302
+ * The exposed name of a device on one export instance (`device-export`, D1049).
46303
+ *
46304
+ * Every exporter keeps its names the same way: in ITS per-device store (D865), under
46305
+ * {@link EXPOSED_NAMES_STORE_KEY}, one entry per instance id. The store is cleared centrally
46306
+ * when the device is deleted, so no removal hook is needed for it. Each exporter supplies the
46307
+ * validator of its own platform; the normalisation, the store shape and the refusal are here so
46308
+ * the four exporters cannot drift apart.
46309
+ *
46310
+ * The name is a label only: no exporter derives the exported id from it, so a rename updates
46311
+ * the same device on the platform.
46312
+ */
46313
+ /** The per-device store key holding `{ [instanceId]: name }`. */
46314
+ var EXPOSED_NAMES_STORE_KEY = "exposedNames";
46315
+ var ExposedNamesSchema = record(string(), string());
46316
+ /** Trim and collapse whitespace, then the platform rule. Blank or null clears (`name: null`). */
46317
+ function checkExposedName(raw, validate) {
46318
+ if (raw === null || raw === void 0) return {
46319
+ ok: true,
46320
+ name: null
46321
+ };
46322
+ if (typeof raw !== "string") return {
46323
+ ok: false,
46324
+ reason: "The name must be text."
46325
+ };
46326
+ const name = raw.trim().replace(/\s+/g, " ");
46327
+ if (name.length === 0) return {
46328
+ ok: true,
46329
+ name: null
46330
+ };
46331
+ return validate(name);
46332
+ }
46333
+ /** Every saved name of a device, by instance id. A malformed blob reads as none. */
46334
+ function readExposedNames(store) {
46335
+ const parsed = ExposedNamesSchema.safeParse(store[EXPOSED_NAMES_STORE_KEY]);
46336
+ return parsed.success ? parsed.data : {};
46337
+ }
46338
+ /**
46339
+ * The saved name of one instance, or null: never saved, or a stored value the platform would
46340
+ * now refuse (the device's own name is used rather than pushing a name the platform rejects).
46341
+ */
46342
+ function readExposedName(store, instanceId, validate) {
46343
+ const saved = readExposedNames(store)[instanceId];
46344
+ if (saved === void 0) return null;
46345
+ const check = checkExposedName(saved, validate);
46346
+ return check.ok ? check.name : null;
46347
+ }
46348
+ /** The store patch that sets (or, with null, clears) one instance's name and keeps the others. */
46349
+ function exposedNamePatch(store, instanceId, name) {
46350
+ const others = Object.fromEntries(Object.entries(readExposedNames(store)).filter(([id]) => id !== instanceId));
46351
+ return { [EXPOSED_NAMES_STORE_KEY]: name === null ? others : {
46352
+ ...others,
46353
+ [instanceId]: name
46354
+ } };
46355
+ }
46356
+ /**
46357
+ * Validate and save one instance's name. A name the platform would refuse throws
46358
+ * {@link ExportNameRefusedError} BEFORE anything is written, so the old name stays.
46359
+ */
46360
+ async function saveExposedName(input) {
46361
+ const check = checkExposedName(input.raw, input.validate);
46362
+ if (!check.ok) throw new ExportNameRefusedError(input.instanceId, check.reason);
46363
+ if (input.dryRun === true) return {
46364
+ changed: false,
46365
+ name: check.name
46366
+ };
46367
+ const store = await input.store.read(input.deviceId);
46368
+ if ((readExposedNames(store)[input.instanceId] ?? null) === check.name) return {
46369
+ changed: false,
46370
+ name: check.name
46371
+ };
46372
+ await input.store.write(input.deviceId, exposedNamePatch(store, input.instanceId, check.name));
46373
+ return {
46374
+ changed: true,
46375
+ name: check.name
46376
+ };
46377
+ }
46378
+ /** The exporter's per-device store as an {@link ExposedNameStore}; throws when settings are absent. */
46379
+ function exposedNameStoreOf(settings, owner) {
46380
+ const access = () => {
46381
+ if (settings === void 0) throw new Error(`${owner}: settings are not available`);
46382
+ return settings;
46383
+ };
46384
+ return {
46385
+ read: (deviceId) => access().readDeviceStore(deviceId),
46386
+ write: (deviceId, patch) => access().writeDeviceStore(deviceId, patch)
46387
+ };
46388
+ }
46389
+ /**
46390
+ * Remove every name saved for `instanceId` (the instance was deleted), so a later instance that
46391
+ * reuses the id does not inherit them. Returns the device ids that lost a name. A store that
46392
+ * cannot be read throws; nothing is written for the devices not reached.
46393
+ */
46394
+ async function pruneExposedNames(settings, instanceId) {
46395
+ const ids = await settings.listDeviceStoreIds();
46396
+ if (ids.length === 0) return [];
46397
+ const pruned = [];
46398
+ for (const [deviceId, store] of await settings.readDeviceStoreBatch(ids)) {
46399
+ if (readExposedNames(store)[instanceId] === void 0) continue;
46400
+ await settings.writeDeviceStore(deviceId, exposedNamePatch(store, instanceId, null));
46401
+ pruned.push(deviceId);
46402
+ }
46403
+ return pruned;
46404
+ }
45955
46405
  _enum([
45956
46406
  "automation",
45957
46407
  "action",
@@ -50238,11 +50688,13 @@ var IrCodecError = class extends Error {
50238
50688
  this.code = code;
50239
50689
  }
50240
50690
  };
50691
+ /** Maximum number of mark/space entries one pulse train may carry. */
50692
+ var IR_TIMINGS_MAX = 1024;
50241
50693
  /**
50242
50694
  * A pulse train in signed microseconds: mark (+) first, then space (-), strictly
50243
50695
  * alternating, no zeros, 2..1024 entries.
50244
50696
  */
50245
- var IrTimingsSchema = array(number$1().int()).min(2).max(1024).superRefine((timings, ctx) => {
50697
+ var IrTimingsSchema = array(number$1().int()).min(2).max(IR_TIMINGS_MAX).superRefine((timings, ctx) => {
50246
50698
  timings.forEach((value, index) => {
50247
50699
  const expectMark = index % 2 === 0;
50248
50700
  if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
@@ -50289,15 +50741,186 @@ function decodePronto(code) {
50289
50741
  carrierHz: Math.round(1e6 / unitUs)
50290
50742
  };
50291
50743
  }
50292
- /** What a remote command stores: a raw pulse train, or a learned Pronto code. */
50293
- var IrPayloadSchema = discriminatedUnion("kind", [object({
50294
- kind: literal("raw"),
50295
- timings: array(number$1().int()),
50296
- settings: TransmitSettingsSchema.optional()
50297
- }), object({
50298
- kind: literal("pronto"),
50299
- code: string()
50300
- })]);
50744
+ /**
50745
+ * FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
50746
+ * literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
50747
+ * is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
50748
+ * between the low 5 bits and the next byte.
50749
+ */
50750
+ var MAX_DISTANCE = 8192;
50751
+ var MAX_LITERAL_RUN = 32;
50752
+ var MIN_MATCH = 3;
50753
+ var MAX_MATCH = 264;
50754
+ /**
50755
+ * Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
50756
+ * can expand ~130x, so the decoder checks this bound before every write.
50757
+ */
50758
+ var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
50759
+ function fastlzDecompress(input) {
50760
+ const out = [];
50761
+ let ip = 0;
50762
+ const room = (count) => {
50763
+ if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
50764
+ };
50765
+ const next = () => {
50766
+ const byte = input[ip++];
50767
+ if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
50768
+ return byte;
50769
+ };
50770
+ while (ip < input.length) {
50771
+ const ctrl = next();
50772
+ if (ctrl < 32) {
50773
+ room(ctrl + 1);
50774
+ for (let i = 0; i <= ctrl; i++) out.push(next());
50775
+ continue;
50776
+ }
50777
+ let len = (ctrl >> 5) - 1;
50778
+ if (len === 6) len += next();
50779
+ const distance = ((ctrl & 31) << 8) + next() + 1;
50780
+ const start = out.length - distance;
50781
+ if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
50782
+ room(len + 3);
50783
+ for (let i = 0; i < len + 3; i++) {
50784
+ const byte = out[start + i];
50785
+ if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
50786
+ out.push(byte);
50787
+ }
50788
+ }
50789
+ return Uint8Array.from(out);
50790
+ }
50791
+ function fastlzCompress(input) {
50792
+ const out = [];
50793
+ const lastSeen = /* @__PURE__ */ new Map();
50794
+ let literalStart = 0;
50795
+ const flushLiterals = (end) => {
50796
+ for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
50797
+ const to = Math.min(from + MAX_LITERAL_RUN, end);
50798
+ out.push(to - from - 1);
50799
+ for (let i = from; i < to; i++) out.push(input[i] ?? 0);
50800
+ }
50801
+ };
50802
+ let pos = 0;
50803
+ while (pos < input.length) {
50804
+ let matchLen = 0;
50805
+ let matchDistance = 0;
50806
+ if (pos + MIN_MATCH <= input.length) {
50807
+ const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
50808
+ const candidate = lastSeen.get(key);
50809
+ lastSeen.set(key, pos);
50810
+ if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
50811
+ let len = 0;
50812
+ while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
50813
+ if (len >= MIN_MATCH) {
50814
+ matchLen = len;
50815
+ matchDistance = pos - candidate - 1;
50816
+ }
50817
+ }
50818
+ }
50819
+ if (matchLen === 0) {
50820
+ pos++;
50821
+ continue;
50822
+ }
50823
+ flushLiterals(pos);
50824
+ const enc = matchLen - 2;
50825
+ if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
50826
+ else out.push(224 | matchDistance >> 8, enc - 7);
50827
+ out.push(matchDistance & 255);
50828
+ pos += matchLen;
50829
+ literalStart = pos;
50830
+ }
50831
+ flushLiterals(input.length);
50832
+ return Uint8Array.from(out);
50833
+ }
50834
+ var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
50835
+ var MAX_DURATION_US = 65535;
50836
+ function toBase64(bytes) {
50837
+ let out = "";
50838
+ for (let i = 0; i < bytes.length; i += 3) {
50839
+ const a = bytes[i] ?? 0;
50840
+ const b = bytes[i + 1] ?? 0;
50841
+ const c = bytes[i + 2] ?? 0;
50842
+ const word = a << 16 | b << 8 | c;
50843
+ out += ALPHABET[word >> 18 & 63];
50844
+ out += ALPHABET[word >> 12 & 63];
50845
+ out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
50846
+ out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
50847
+ }
50848
+ return out;
50849
+ }
50850
+ function fromBase64(text) {
50851
+ const clean = text.trim().replace(/=+$/, "");
50852
+ if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
50853
+ const out = [];
50854
+ let bits = 0;
50855
+ let acc = 0;
50856
+ for (const ch of clean) {
50857
+ const value = ALPHABET.indexOf(ch);
50858
+ if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
50859
+ acc = acc << 6 | value;
50860
+ bits += 6;
50861
+ if (bits >= 8) {
50862
+ bits -= 8;
50863
+ out.push(acc >> bits & 255);
50864
+ }
50865
+ }
50866
+ return Uint8Array.from(out);
50867
+ }
50868
+ /** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
50869
+ function encodeTuya(timings) {
50870
+ const bytes = new Uint8Array(timings.length * 2);
50871
+ timings.forEach((value, index) => {
50872
+ const duration = Math.abs(value);
50873
+ if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
50874
+ bytes[index * 2] = duration & 255;
50875
+ bytes[index * 2 + 1] = duration >> 8;
50876
+ });
50877
+ return toBase64(fastlzCompress(bytes));
50878
+ }
50879
+ /** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
50880
+ function decodeTuya(code) {
50881
+ const bytes = fastlzDecompress(fromBase64(code));
50882
+ if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
50883
+ const timings = [];
50884
+ for (let i = 0; i < bytes.length; i += 2) {
50885
+ const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
50886
+ timings.push(i / 2 % 2 === 0 ? duration : -duration);
50887
+ }
50888
+ const checked = IrTimingsSchema.safeParse(timings);
50889
+ if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
50890
+ return checked.data;
50891
+ }
50892
+ /** Device-native IR code formats a transmitter can replay verbatim. */
50893
+ var IrNativeFormatSchema = _enum(["tuya"]);
50894
+ /**
50895
+ * Longest native code accepted: base64 of the worst-case compressed stream
50896
+ * (every decoded byte as a literal, plus one control byte per 32), with margin.
50897
+ */
50898
+ var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
50899
+ var IrNativeCodeSchema = object({
50900
+ format: IrNativeFormatSchema,
50901
+ code: string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
50902
+ });
50903
+ var IR_NATIVE_CODECS = { tuya: {
50904
+ encode: encodeTuya,
50905
+ decode: decodeTuya
50906
+ } };
50907
+ /** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
50908
+ var IrPayloadSchema = discriminatedUnion("kind", [
50909
+ object({
50910
+ kind: literal("raw"),
50911
+ timings: array(number$1().int()),
50912
+ settings: TransmitSettingsSchema.optional()
50913
+ }),
50914
+ object({
50915
+ kind: literal("pronto"),
50916
+ code: string()
50917
+ }),
50918
+ object({
50919
+ kind: literal("native"),
50920
+ format: IrNativeFormatSchema,
50921
+ code: string()
50922
+ })
50923
+ ]);
50301
50924
  /** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
50302
50925
  function toTimings(payload) {
50303
50926
  if (payload.kind === "pronto") {
@@ -50307,6 +50930,10 @@ function toTimings(payload) {
50307
50930
  settings: { carrierHz: decoded.carrierHz }
50308
50931
  };
50309
50932
  }
50933
+ if (payload.kind === "native") return {
50934
+ timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
50935
+ settings: {}
50936
+ };
50310
50937
  const checked = IrTimingsSchema.safeParse(payload.timings);
50311
50938
  if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
50312
50939
  return {
@@ -51115,8 +51742,8 @@ function actuator(input) {
51115
51742
  };
51116
51743
  }
51117
51744
  new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
51118
- DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
51119
51745
  DeviceType.Camera;
51746
+ DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
51120
51747
  var PowerSourceRefusalReasonSchema = _enum([
51121
51748
  "no-power-source",
51122
51749
  "switch-missing",
@@ -52391,193 +53018,6 @@ method(object({
52391
53018
  kind: "mutation",
52392
53019
  auth: "admin"
52393
53020
  });
52394
- /**
52395
- * `device-export` — collection cap for addons that export camstack
52396
- * devices to external ecosystems (HomeAssistant via MQTT discovery,
52397
- * HomeKit/HAP, Alexa Smart Home, …).
52398
- *
52399
- * No `ecosystem` enum — the addon id identifies the export target.
52400
- * Each addon owns its mapping logic in its own settings UI. The cap
52401
- * exposes only the COMMON surface: link state, supported device
52402
- * kinds (so the UI can filter the device picker), and per-device
52403
- * expose/unexpose.
52404
- *
52405
- * INSTANCES. One export addon can serve several independent targets (a
52406
- * HomeKit bridge, a Home Assistant broker). `listInstances` names them.
52407
- * `instanceId` on a READ is optional: absent = the whole addon (linked if any
52408
- * enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
52409
- * default instance's); present = that instance; an id the provider does not
52410
- * serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
52411
- * never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
52412
- * change always names the target it changes. A single-instance provider
52413
- * accepts an absent id on a read or its own id, and refuses any other.
52414
- */
52415
- /** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
52416
- var InstanceIdSchema$1 = string().min(1);
52417
- var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
52418
- /** One independent export target of an addon. */
52419
- var ExportInstanceSchema = object({
52420
- instanceId: InstanceIdSchema$1,
52421
- name: string(),
52422
- enabled: boolean(),
52423
- kind: string().optional()
52424
- });
52425
- var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
52426
- /** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
52427
- var ExportInstanceUnknownError = class extends Error {
52428
- code = EXPORT_INSTANCE_UNKNOWN;
52429
- instanceId;
52430
- constructor(addon, instanceId) {
52431
- super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
52432
- this.name = "ExportInstanceUnknownError";
52433
- this.instanceId = instanceId;
52434
- }
52435
- };
52436
- /**
52437
- * The instance a `getStatus` call names. The cap's `status` block injects a per-device
52438
- * `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
52439
- * both shapes; only the second names an instance (a per-device status read is addon-wide).
52440
- */
52441
- function statusInstanceOf(input) {
52442
- return "instanceId" in input ? input.instanceId : void 0;
52443
- }
52444
- var LinkStateSchema = _enum([
52445
- "unlinked",
52446
- "linked",
52447
- "error"
52448
- ]);
52449
- /**
52450
- * A single label/value row surfaced in the export panel's "Setup"
52451
- * section. Rendered with a copy-to-clipboard button. `secret: true`
52452
- * rows are masked by default with a reveal toggle (client ids,
52453
- * secrets, …).
52454
- */
52455
- var ExportSetupFieldSchema = object({
52456
- label: string(),
52457
- value: string(),
52458
- /** Mask the value by default + render a reveal toggle (client id, secrets). */
52459
- secret: boolean().optional()
52460
- });
52461
- /**
52462
- * Generic, addon-agnostic pairing/account block. Any export addon can
52463
- * surface a scannable QR, a set of copyable label/value rows, and a
52464
- * free-form operator note — the `DeviceExportPanel` renders whatever
52465
- * the provider supplies and skips the section entirely when `setup`
52466
- * is unset.
52467
- */
52468
- var ExportSetupSchema = object({
52469
- /** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
52470
- qr: string().optional(),
52471
- /** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
52472
- fields: array(ExportSetupFieldSchema).readonly().optional(),
52473
- /** Free-form operator instructions rendered above the fields. */
52474
- note: string().optional()
52475
- });
52476
- var DeviceExportStatusSchema = object({
52477
- linkState: LinkStateSchema,
52478
- exposedDeviceCount: number$1(),
52479
- error: string().optional(),
52480
- /**
52481
- * Optional pairing/account info the panel renders in a generic
52482
- * "Setup" section. Addon-agnostic — the addon id identifies the
52483
- * export target, never an `ecosystem` key here.
52484
- */
52485
- setup: ExportSetupSchema.optional()
52486
- });
52487
- var DeviceKindSchema = string();
52488
- var ExposedDeviceSchema = object({
52489
- deviceId: string(),
52490
- exposedAs: string().optional(),
52491
- capabilities: array(string()).optional()
52492
- });
52493
- var ExposeInputSchema = object({
52494
- instanceId: InstanceIdSchema$1,
52495
- deviceId: string(),
52496
- capabilities: array(string()).optional()
52497
- });
52498
- var UnexposeInputSchema = object({
52499
- instanceId: InstanceIdSchema$1,
52500
- deviceId: string()
52501
- });
52502
- /**
52503
- * What an exporter may expose besides devices (D968). An action and a
52504
- * notification target are LIST ENTRIES, never devices (D954): they enter an
52505
- * exporter's own selection, not the device registry.
52506
- */
52507
- var ExportEntityKindSchema = _enum([
52508
- "device",
52509
- "action",
52510
- "notifier"
52511
- ]);
52512
- var ExportEntityRefSchema = discriminatedUnion("kind", [
52513
- object({
52514
- kind: literal("device"),
52515
- deviceId: string()
52516
- }),
52517
- object({
52518
- kind: literal("action"),
52519
- actionId: string().min(1)
52520
- }),
52521
- object({
52522
- kind: literal("notifier"),
52523
- targetId: string().min(1)
52524
- })
52525
- ]);
52526
- var ExposedEntitySchema = object({
52527
- entity: ExportEntityRefSchema,
52528
- exposedAs: string().optional()
52529
- });
52530
- var ExposeEntityInputSchema = object({
52531
- instanceId: InstanceIdSchema$1,
52532
- entity: ExportEntityRefSchema
52533
- });
52534
- var UnexposeEntityInputSchema = object({
52535
- instanceId: InstanceIdSchema$1,
52536
- entity: ExportEntityRefSchema
52537
- });
52538
- var deviceExportCapability = {
52539
- name: "device-export",
52540
- scope: "system",
52541
- mode: "collection",
52542
- providerKind: "device-export",
52543
- status: {
52544
- schema: DeviceExportStatusSchema,
52545
- kind: "poll"
52546
- },
52547
- /**
52548
- * Each export provider MAY contribute its own per-device "Export" panel
52549
- * (enabled toggle, preferred stream, addon-specific knobs). The three
52550
- * framework methods are mounted on the cap router when present.
52551
- * `IDeviceExportProvider` leaves them optional: an exporter with no
52552
- * per-device panel omits them (a `deviceConfig` cap's UI is derived and
52553
- * never hand-written — D14 — and an exporter is not one of those).
52554
- */
52555
- exposesDeviceSettings: true,
52556
- methods: {
52557
- getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
52558
- listInstances: method(_void(), array(ExportInstanceSchema)),
52559
- listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
52560
- listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
52561
- exposeDevice: method(ExposeInputSchema, _void(), {
52562
- kind: "mutation",
52563
- auth: "admin"
52564
- }),
52565
- unexposeDevice: method(UnexposeInputSchema, _void(), {
52566
- kind: "mutation",
52567
- auth: "admin"
52568
- }),
52569
- listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
52570
- listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
52571
- exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
52572
- kind: "mutation",
52573
- auth: "admin"
52574
- }),
52575
- unexposeEntity: optionalMethod(UnexposeEntityInputSchema, _void(), {
52576
- kind: "mutation",
52577
- auth: "admin"
52578
- })
52579
- }
52580
- };
52581
53021
  var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
52582
53022
  var DeviceTemplateSchema = string().min(1).max(4096);
52583
53023
  /** One value a caller hands the renderer for `thisDevice`. */
@@ -56726,6 +57166,128 @@ var StateLookSchema = object({
56726
57166
  background: _enum(HERO_BACKGROUNDS),
56727
57167
  animation: HeroAnimationSchema
56728
57168
  });
57169
+ /** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
57170
+ var HeroTextSchema = object({
57171
+ en: string(),
57172
+ it: string()
57173
+ });
57174
+ /**
57175
+ * The ONE measurement a simple sensor shows (card wave, phase 1).
57176
+ *
57177
+ * A sensor that measures a single quantity (a temperature, a humidity, a power,
57178
+ * a contact, a text state) is drawn as that reading, once, big, inside a scene
57179
+ * whose motion says what the number means: heat rising when hot, flakes when
57180
+ * cold, a wire flowing at the speed of the power, a ring while a window is
57181
+ * open. Everything the card draws is decided here; a client only paints it.
57182
+ */
57183
+ var HERO_MEASUREMENT_QUANTITIES = [
57184
+ "temperature",
57185
+ "humidity",
57186
+ "power",
57187
+ "contact",
57188
+ "text"
57189
+ ];
57190
+ /** How a temperature reads to a person; drives the heat or the cold scene. */
57191
+ var HERO_MEASUREMENT_BANDS = [
57192
+ "hot",
57193
+ "mild",
57194
+ "cold"
57195
+ ];
57196
+ /** `updated` = the value was last read then ("2 min ago"); `changed` = it has held since then ("for 12 min"). */
57197
+ var HERO_MEASUREMENT_SINCE_KINDS = ["updated", "changed"];
57198
+ var HeroMeasurementReadingSchema = object({
57199
+ value: number$1(),
57200
+ quantity: ReadingQuantitySchema
57201
+ });
57202
+ var HeroMeasurementSchema = object({
57203
+ quantity: _enum(HERO_MEASUREMENT_QUANTITIES),
57204
+ reading: HeroMeasurementReadingSchema.nullable(),
57205
+ icon: IconKeySchema.nullable(),
57206
+ value: HeroTextSchema,
57207
+ unit: string().nullable(),
57208
+ band: _enum(HERO_MEASUREMENT_BANDS).nullable(),
57209
+ level: number$1().min(0).max(1).nullable(),
57210
+ word: HeroTextSchema,
57211
+ tone: _enum(HERO_TONES),
57212
+ since: number$1().nullable(),
57213
+ sinceKind: _enum(HERO_MEASUREMENT_SINCE_KINDS),
57214
+ historyKey: string().nullable()
57215
+ });
57216
+ var same$2 = (text) => t(text, text);
57217
+ var clamp01$1 = (n) => Math.min(1, Math.max(0, n));
57218
+ var trimmed = (n, digits) => String(Number(n.toFixed(digits)));
57219
+ function temperatureBand(celsius) {
57220
+ if (celsius < 12) return "cold";
57221
+ if (celsius > 28) return "hot";
57222
+ return "mild";
57223
+ }
57224
+ var BAND_WORD = {
57225
+ hot: t("Hot", "Caldo"),
57226
+ mild: t("Normal", "Normale"),
57227
+ cold: t("Cold", "Freddo")
57228
+ };
57229
+ var BAND_TONE = {
57230
+ hot: "warning",
57231
+ mild: "muted",
57232
+ cold: "info"
57233
+ };
57234
+ function temperatureMeasurement(celsius, since) {
57235
+ const band = temperatureBand(celsius);
57236
+ return {
57237
+ quantity: "temperature",
57238
+ reading: {
57239
+ value: celsius,
57240
+ quantity: "temperature"
57241
+ },
57242
+ icon: "thermometer",
57243
+ value: same$2(trimmed(celsius, 1)),
57244
+ unit: "°C",
57245
+ band,
57246
+ level: null,
57247
+ word: BAND_WORD[band],
57248
+ tone: BAND_TONE[band],
57249
+ since,
57250
+ sinceKind: "updated",
57251
+ historyKey: "cap:temperature-sensor.temperature"
57252
+ };
57253
+ }
57254
+ function humidityMeasurement(percent, since) {
57255
+ const dry = percent < 30;
57256
+ const humid = percent > 70;
57257
+ return {
57258
+ quantity: "humidity",
57259
+ reading: {
57260
+ value: percent,
57261
+ quantity: "humidity"
57262
+ },
57263
+ icon: "droplets",
57264
+ value: same$2(String(Math.round(percent))),
57265
+ unit: "%",
57266
+ band: null,
57267
+ level: clamp01$1(percent / 100),
57268
+ word: dry ? t("Dry", "Secco") : humid ? t("Humid", "Umido") : t("Normal", "Normale"),
57269
+ tone: dry || humid ? "warning" : "info",
57270
+ since,
57271
+ sinceKind: "updated",
57272
+ historyKey: "cap:humidity-sensor.humidity"
57273
+ };
57274
+ }
57275
+ function textMeasurement(text, since) {
57276
+ return {
57277
+ quantity: "text",
57278
+ reading: null,
57279
+ icon: null,
57280
+ value: same$2(text),
57281
+ unit: null,
57282
+ band: null,
57283
+ level: null,
57284
+ word: t("Changed", "Cambiato"),
57285
+ tone: "muted",
57286
+ since,
57287
+ sinceKind: "updated",
57288
+ historyKey: null
57289
+ };
57290
+ }
56729
57291
  /** The scene as the model carries it. `null` = the device did not say (never a guess). */
56730
57292
  var HeroSceneSchema = object({
56731
57293
  id: _enum([
@@ -56776,12 +57338,7 @@ var HeroSceneSchema = object({
56776
57338
  level: number$1().min(0).max(1).nullable()
56777
57339
  });
56778
57340
  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;
56779
- 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;
56780
- /** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
56781
- var HeroTextSchema = object({
56782
- en: string(),
56783
- it: string()
56784
- });
57341
+ 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.SwitchLight, 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;
56785
57342
  var HeroRowIdSchema = _enum([
56786
57343
  "progress",
56787
57344
  "run-for",
@@ -56887,6 +57444,25 @@ var HeroControlSchema = discriminatedUnion("kind", [
56887
57444
  optionLabels: record(string(), HeroTextSchema).optional(),
56888
57445
  call: HeroCallSchema,
56889
57446
  valueArg: string()
57447
+ }),
57448
+ object({
57449
+ kind: literal("number"),
57450
+ id: string(),
57451
+ label: HeroTextSchema,
57452
+ value: number$1().nullable(),
57453
+ /** `null` = any number; the device rounds what it does not accept. */
57454
+ step: number$1().nullable(),
57455
+ unit: string(),
57456
+ call: HeroCallSchema,
57457
+ valueArg: string()
57458
+ }),
57459
+ object({
57460
+ kind: literal("text"),
57461
+ id: string(),
57462
+ label: HeroTextSchema,
57463
+ value: string().nullable(),
57464
+ call: HeroCallSchema,
57465
+ valueArg: string()
56890
57466
  })
56891
57467
  ]);
56892
57468
  /** Declared by its interface: a `z.infer` of one more icon union pushes the cap's inferred type past what the compiler can print. */
@@ -57088,6 +57664,11 @@ var HeroModelSchema = object({
57088
57664
  timedRun: HeroTimedRunSlotSchema.nullable(),
57089
57665
  powerSupply: HeroPowerSupplySlotSchema.nullable(),
57090
57666
  rows: array(HeroRowSchema),
57667
+ /**
57668
+ * The ONE measurement of a simple sensor, drawn once inside the scene in place of
57669
+ * the caption, tiles and value chips. Absent = the card draws as before.
57670
+ */
57671
+ measurement: HeroMeasurementSchema.optional(),
57091
57672
  /** Ids of parts that actuate the device, hidden from a session that may not act on it. */
57092
57673
  gated: array(string()),
57093
57674
  provenance: array(HeroProvenanceSchema)
@@ -57159,8 +57740,23 @@ var HeroRowModelSchema = object({
57159
57740
  * the call. Absent or empty = `primary` alone.
57160
57741
  */
57161
57742
  extras: array(HeroControlSchema).max(2).optional(),
57162
- trailing: HeroFactSchema.nullable()
57743
+ trailing: HeroFactSchema.nullable(),
57744
+ /**
57745
+ * The simple sensor's one reading (the hero's `measurement`): the row draws its value
57746
+ * at the right, the unit small, the quantity's icon in the mini-scene. Absent = an
57747
+ * older server or a device that is not a simple sensor: draw `trailing`.
57748
+ */
57749
+ measurement: HeroMeasurementSchema.optional()
57163
57750
  });
57751
+ new Set([
57752
+ "temperature",
57753
+ "humidity",
57754
+ "pressure",
57755
+ "illuminance",
57756
+ "reading",
57757
+ "air-quality",
57758
+ "valve"
57759
+ ]);
57164
57760
  DeviceType.Climate;
57165
57761
  DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
57166
57762
  /**
@@ -57477,6 +58073,12 @@ var IntegrationLiteSchema = object({
57477
58073
  var AvailableIntegrationTypeSchema = object({
57478
58074
  addonId: string(),
57479
58075
  name: string(),
58076
+ /**
58077
+ * Product name a new integration is prefilled from (`<label> - Home`).
58078
+ * Absent: the client uses `name`. Set when the catalog title is not the
58079
+ * product (Bosch SHC, MQTT).
58080
+ */
58081
+ providerLabel: string().optional(),
57480
58082
  description: string(),
57481
58083
  iconUrl: string().nullable(),
57482
58084
  color: string(),
@@ -57988,13 +58590,32 @@ var IrSendResultSchema = object({
57988
58590
  var IrTransmitterInfoSchema = object({
57989
58591
  media: array(IrMediumSchema),
57990
58592
  settable: array(TransmitSettingKeySchema),
57991
- maxTimings: number$1().int().positive()
58593
+ maxTimings: number$1().int().positive(),
58594
+ /** The transmitter can learn a code (`learn`). */
58595
+ learn: boolean().default(false),
58596
+ /** Native code formats the transmitter replays verbatim (`send.native`). */
58597
+ formats: array(IrNativeFormatSchema).default([])
58598
+ });
58599
+ var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
58600
+ var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
58601
+ var IrLearnResultSchema = object({
58602
+ /** The code in the device's own format, when it reports one. */
58603
+ native: IrNativeCodeSchema.nullable(),
58604
+ timings: IrTimingsSchema,
58605
+ carrierHz: number$1().int().positive().nullable()
57992
58606
  });
57993
58607
  DeviceType.Generic, method(object({
57994
58608
  deviceId: number$1().int().nonnegative(),
57995
- timings: IrTimingsSchema,
58609
+ timings: IrTimingsSchema.optional(),
58610
+ native: IrNativeCodeSchema.optional(),
57996
58611
  settings: TransmitSettingsSchema.optional()
57997
- }), IrSendResultSchema, {
58612
+ }).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
58613
+ kind: "mutation",
58614
+ auth: "protected"
58615
+ }), method(object({
58616
+ deviceId: number$1().int().nonnegative(),
58617
+ timeoutMs: number$1().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
58618
+ }), IrLearnResultSchema, {
57998
58619
  kind: "mutation",
57999
58620
  auth: "protected"
58000
58621
  }), method(object({ deviceId: number$1().int().nonnegative() }), IrTransmitterInfoSchema, {
@@ -67217,6 +67838,7 @@ var NcSystemEventKindSchema = _enum([
67217
67838
  "recording-degraded",
67218
67839
  "device-attention-required",
67219
67840
  "device-attention-resolved",
67841
+ "device-command",
67220
67842
  "storage-location-low",
67221
67843
  "storage-location-critical",
67222
67844
  "storage-location-ok",
@@ -67279,11 +67901,6 @@ var NC_ALARM_SYSTEM_EVENT_KINDS = [
67279
67901
  "alarm-sensor-bypass",
67280
67902
  "alarm-disarmed"
67281
67903
  ];
67282
- /**
67283
- * One coherent system-event condition. `kinds` is the required opt-in safety
67284
- * gate; the remaining lists are optional narrowing filters relevant to the
67285
- * selected kinds.
67286
- */
67287
67904
  var NcSystemEventConditionSchema = object({
67288
67905
  kinds: array(NcSystemEventKindSchema).min(1),
67289
67906
  deviceIds: array(number$1().int()).min(1).optional(),
@@ -67315,6 +67932,28 @@ var NcSystemEventConditionSchema = object({
67315
67932
  nodeIds: array(string().min(1)).min(1).optional(),
67316
67933
  packageNames: array(string().min(1)).min(1).optional(),
67317
67934
  /**
67935
+ * `device-command` only: the vocabulary ACTION IDS (D983, `powerSource.forceRestart`)
67936
+ * this rule speaks about - the same dictionary the automation action blocks
67937
+ * pick from. The hub refuses an id the action index does not know.
67938
+ */
67939
+ commandActions: array(string().min(1)).min(1).optional(),
67940
+ /** `device-command` only: how the command settled. A device's own change is not a command. */
67941
+ commandOutcomes: array(_enum([
67942
+ "confirmed",
67943
+ "already",
67944
+ "unconfirmed",
67945
+ "failed"
67946
+ ])).min(1).optional(),
67947
+ /** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
67948
+ commandActorKinds: array(_enum([
67949
+ "user",
67950
+ "addon",
67951
+ "action",
67952
+ "scheduler",
67953
+ "composition",
67954
+ "node"
67955
+ ])).min(1).optional(),
67956
+ /**
67318
67957
  * At or below this remaining-life %, a consumable is LOW for THIS rule
67319
67958
  * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
67320
67959
  * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
@@ -68295,6 +68934,13 @@ var NcRuleInputSchema = object({
68295
68934
  */
68296
68935
  groupingSec: number$1().int().min(5).max(60).optional(),
68297
68936
  /**
68937
+ * Hold deliveries of this rule to one target and, when two or more arrive
68938
+ * before the window ends, send them as one summary. Absent = the kind's
68939
+ * default (`groupWithinSecOf`): 5 s for a system-event rule, 0 for every
68940
+ * other kind. `0` sends each delivery as it does today.
68941
+ */
68942
+ groupWithinSec: number$1().int().min(0).max(300).optional(),
68943
+ /**
68298
68944
  * ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
68299
68945
  * carries "Correct" / "Wrong" buttons (and, where the channel has room, a
68300
68946
  * "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
@@ -68731,7 +69377,12 @@ var NcHistoryEntrySchema = object({
68731
69377
  * Assistant export) must render as "no image right now", never as a
68732
69378
  * broken link.
68733
69379
  */
68734
- artifactIds: array(string().min(1)).optional()
69380
+ artifactIds: array(string().min(1)).optional(),
69381
+ /**
69382
+ * When this row was folded into a group-window summary, the outbox id of
69383
+ * that one notification. Absent on a row that was sent as itself.
69384
+ */
69385
+ groupedInto: string().min(1).optional()
68735
69386
  });
68736
69387
  /**
68737
69388
  * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
@@ -74194,10 +74845,15 @@ var RecordingSignalStatusSchema = object({
74194
74845
  });
74195
74846
  RecordingSignalStatusSchema.extend({ lastFetchedAt: number$1() });
74196
74847
  DeviceType.Camera, method(object({ deviceId: number$1() }), RecordingSignalStatusSchema);
74197
- var RemoteBindingSchema = object({ action: AutomationCapStepBaseSchema.omit({
74198
- target: true,
74199
- actionId: true
74200
- }).extend({ deviceId: number$1().int().nonnegative() }) });
74848
+ var RemoteBindingSchema = object({ action: object({
74849
+ kind: literal("cap"),
74850
+ deviceId: number$1().int().nonnegative(),
74851
+ cap: string().min(1),
74852
+ method: string().min(1),
74853
+ args: record(string(), unknown()).optional(),
74854
+ /** The unit the person picked per arg (display only); `args` always hold the cap's own unit. */
74855
+ argUnits: record(string(), string().min(1)).optional()
74856
+ }) });
74201
74857
  var RemoteCustomButtonSchema = object({
74202
74858
  /** The slug after `custom:` in the role. */
74203
74859
  key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
@@ -79617,8 +80273,6 @@ var AccessoryKind = {
79617
80273
  };
79618
80274
  AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
79619
80275
  DeviceType.HeatPump;
79620
- DeviceType.Climate;
79621
- DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
79622
80276
  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;
79623
80277
  new Set(Object.values(DeviceType));
79624
80278
  /** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
@@ -79631,6 +80285,13 @@ function contribution(cap, schema, build) {
79631
80285
  }
79632
80286
  };
79633
80287
  }
80288
+ /** The fragment, carrying the cap's single measurement when it has one. */
80289
+ function measured(fragment, measurement) {
80290
+ return measurement === void 0 ? fragment : {
80291
+ ...fragment,
80292
+ measurement
80293
+ };
80294
+ }
79634
80295
  function action(id, label, icon, cap, method, args = {}, emphasis = "normal", confirm = null) {
79635
80296
  return {
79636
80297
  id,
@@ -80905,10 +81566,26 @@ var controlContribution = contribution("control", ControlStatusSchema, (slice, c
80905
81566
  };
80906
81567
  });
80907
81568
  var CONTROL_LABEL = t("Value", "Valore");
80908
- /** A number with known bounds is a slider, a choice a picker; text and dates stay read-only. */
81569
+ /**
81570
+ * A number with known bounds is a slider, one without a number field, a choice a picker,
81571
+ * free text a text field; a date stays read-only.
81572
+ */
80909
81573
  function controlRows(slice) {
80910
81574
  if (slice.kind === "numeric" && typeof slice.value === "number") {
80911
- if (slice.min === void 0 || slice.max === void 0) return [];
81575
+ if (slice.min === void 0 || slice.max === void 0) return [row$1("control", "sliders-horizontal", null, [{
81576
+ kind: "number",
81577
+ id: "control.value",
81578
+ label: CONTROL_LABEL,
81579
+ value: slice.value,
81580
+ step: slice.step ?? null,
81581
+ unit: "",
81582
+ call: {
81583
+ cap: "control",
81584
+ method: "setValue",
81585
+ args: { control: { kind: "numeric" } }
81586
+ },
81587
+ valueArg: "control.value"
81588
+ }])];
80912
81589
  return [row$1("control", "sliders-horizontal", null, [{
80913
81590
  kind: "slider",
80914
81591
  id: "control.value",
@@ -80939,6 +81616,18 @@ function controlRows(slice) {
80939
81616
  },
80940
81617
  valueArg: "control.value"
80941
81618
  }])];
81619
+ if (slice.kind === "text") return [row$1("control", "sliders-horizontal", null, [{
81620
+ kind: "text",
81621
+ id: "control.value",
81622
+ label: CONTROL_LABEL,
81623
+ value: typeof slice.value === "string" ? slice.value : null,
81624
+ call: {
81625
+ cap: "control",
81626
+ method: "setValue",
81627
+ args: { control: { kind: "text" } }
81628
+ },
81629
+ valueArg: "control.value"
81630
+ }])];
80942
81631
  return [];
80943
81632
  }
80944
81633
  var SENSORS_FAMILY_CONTRIBUTIONS = {
@@ -81294,15 +81983,15 @@ function sensorFragment(value, id, icon, en, it, text) {
81294
81983
  tiles: { right: [tile$1(en, it, text)] }
81295
81984
  };
81296
81985
  }
81297
- var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)));
81298
- var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`));
81986
+ var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => measured(sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)), slice?.temperature == null ? void 0 : temperatureMeasurement(slice.temperature, slice.lastFetchedAt)));
81987
+ var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => measured(sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`), slice?.humidity == null ? void 0 : humidityMeasurement(slice.humidity, slice.lastFetchedAt)));
81299
81988
  var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
81300
81989
  var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
81301
81990
  var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
81302
81991
  var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
81303
81992
  if (slice === void 0 || slice.value === "") return { reading: reading("sensor", "unknown") };
81304
81993
  if (slice.timestamp === true) return { reading: reading("sensor", "on") };
81305
- return sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value);
81994
+ return measured(sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value), textMeasurement(slice.value, slice.lastFetchedAt));
81306
81995
  });
81307
81996
  /** Index bands: the headline of an air-quality sensor is a word, not a number. */
81308
81997
  function airQualityWord(aqi) {
@@ -82271,7 +82960,7 @@ lookOf({
82271
82960
  });
82272
82961
  DeviceType.Climate;
82273
82962
  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;
82274
- 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;
82963
+ 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.SwitchLight, 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;
82275
82964
  Object.freeze({
82276
82965
  "accessories.getStatus": {
82277
82966
  capName: "accessories",
@@ -84198,6 +84887,13 @@ Object.freeze({
84198
84887
  access: "view",
84199
84888
  role: "admin"
84200
84889
  },
84890
+ "deviceExport.setExposedName": {
84891
+ capName: "device-export",
84892
+ capScope: "system",
84893
+ addonId: null,
84894
+ access: "create",
84895
+ role: "admin"
84896
+ },
84201
84897
  "deviceExport.unexposeDevice": {
84202
84898
  capName: "device-export",
84203
84899
  capScope: "system",
@@ -86137,6 +86833,13 @@ Object.freeze({
86137
86833
  access: "view",
86138
86834
  role: "viewer"
86139
86835
  },
86836
+ "irTransmitter.learn": {
86837
+ capName: "ir-transmitter",
86838
+ capScope: "device",
86839
+ addonId: null,
86840
+ access: "create",
86841
+ role: "viewer"
86842
+ },
86140
86843
  "irTransmitter.send": {
86141
86844
  capName: "ir-transmitter",
86142
86845
  capScope: "device",
@@ -92655,48 +93358,6 @@ Object.freeze({
92655
93358
  role: "admin"
92656
93359
  }
92657
93360
  });
92658
- /**
92659
- * "Do" actions an operator can pick for a device — presentation-free.
92660
- *
92661
- * The wire shape stays `{ cap, method, args }`. Since D920 this module no
92662
- * longer HOLDS a catalogue: {@link DEVICE_DO_ACTIONS} is a projection of the
92663
- * cap vocabulary (`cap-vocabulary/`), the one cap-keyed map of every action
92664
- * and trigger — so a picker built on this module and one built on
92665
- * `actionsForDevice` (the vocabulary resolver) can never disagree about what
92666
- * a device can do. Ids, baked args and the matching of saved steps are the
92667
- * vocabulary's; labels here are its English labels.
92668
- *
92669
- * Shared by the admin NC Sequences / rule Do editor and Automations; the
92670
- * viewer can reuse the same catalogue once its step editor catches up.
92671
- */
92672
- function openArgKind(offer) {
92673
- if (offer.kind === "number") return "number";
92674
- if (offer.kind === "dynamic" && offer.valueKind === "number") return "number";
92675
- if (offer.kind === "enum" && offer.values.every((v) => typeof v.value === "number")) return "number";
92676
- return "string";
92677
- }
92678
- function projectOpenArg(arg) {
92679
- return {
92680
- key: arg.key,
92681
- label: arg.label.en,
92682
- kind: openArgKind(arg.offer),
92683
- offer: arg.offer,
92684
- ...arg.optional === true ? { optional: true } : {}
92685
- };
92686
- }
92687
- function projectAction(cap, action) {
92688
- const open = action.openArgs ?? [];
92689
- return {
92690
- id: action.id,
92691
- label: action.label.en,
92692
- cap,
92693
- method: action.method,
92694
- args: action.args ?? {},
92695
- ...open.length > 0 ? { openArgs: open.map(projectOpenArg) } : {}
92696
- };
92697
- }
92698
- Object.entries(CAP_VOCABULARY_BY_NAME).flatMap(([cap, entry]) => entry.scope === "device" ? (entry.actions ?? []).map((a) => projectAction(cap, a)) : []);
92699
- 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;
92700
93361
  DeviceFeature.BatteryOperated;
92701
93362
  function bound(cap, methods = [], authority = "reported") {
92702
93363
  return {
@@ -94013,6 +94674,11 @@ Object.freeze({
94013
94674
  form: "single",
94014
94675
  optional: false
94015
94676
  }],
94677
+ "irTransmitter.learn": [{
94678
+ name: "deviceId",
94679
+ form: "single",
94680
+ optional: false
94681
+ }],
94016
94682
  "irTransmitter.send": [{
94017
94683
  name: "deviceId",
94018
94684
  form: "single",
@@ -95952,7 +96618,10 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
95952
96618
  "deviceTypes",
95953
96619
  "nodeIds",
95954
96620
  "packageNames",
95955
- "consumableLowPercent"
96621
+ "consumableLowPercent",
96622
+ "commandActions",
96623
+ "commandOutcomes",
96624
+ "commandActorKinds"
95956
96625
  ];
95957
96626
  new Map(Object.entries({
95958
96627
  "device-online": "device-events",
@@ -95975,6 +96644,7 @@ new Map(Object.entries({
95975
96644
  "recording-degraded": "device-events",
95976
96645
  "device-attention-required": "device-events",
95977
96646
  "device-attention-resolved": "device-events",
96647
+ "device-command": "device-events",
95978
96648
  "node-online": "system",
95979
96649
  "node-offline": "system",
95980
96650
  "node-restarting": "system",
@@ -96075,6 +96745,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
96075
96745
  label: "Needs attention",
96076
96746
  kinds: ["device-attention-required", "device-attention-resolved"]
96077
96747
  },
96748
+ {
96749
+ id: "device-command",
96750
+ family: "device-events",
96751
+ label: "Commands given to devices",
96752
+ kinds: ["device-command"]
96753
+ },
96078
96754
  {
96079
96755
  id: "nodes",
96080
96756
  family: "system",
@@ -96152,6 +96828,15 @@ function systemEventKindsOfFamily(family) {
96152
96828
  return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
96153
96829
  }
96154
96830
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
96831
+ new Set([
96832
+ "alarm.trigger",
96833
+ "alarm.disarm",
96834
+ "alarm.arm.home",
96835
+ "alarm.arm.away",
96836
+ "alarm.arm.night",
96837
+ "alarm.arm.vacation",
96838
+ "alarm.arm.custom_bypass"
96839
+ ]);
96155
96840
  /**
96156
96841
  * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
96157
96842
  * persists (D640 "a sensor rule fires on the raise, the clear, or both").
@@ -96347,6 +97032,7 @@ var DEVICE_EVENTS = [
96347
97032
  "recording-healthy",
96348
97033
  "recording-degraded",
96349
97034
  ...DEVICE_ATTENTION,
97035
+ "device-command",
96350
97036
  ...ALARM
96351
97037
  ];
96352
97038
  /** Every kind a summary may speak about — the two summarisable families. */
@@ -96500,6 +97186,9 @@ var STATE_SUMMARY_VARS = [
96500
97186
  [...RULE_BODY_ONLY],
96501
97187
  [...RULE_TEXT],
96502
97188
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
97189
+ [...RULE_TEXT],
97190
+ [...RULE_TEXT],
97191
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
96503
97192
  ([...RULE_TEXT], [...COMBINED_ALARM]),
96504
97193
  ([...RULE_TEXT], [...COMBINED_ALARM]),
96505
97194
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
@@ -101248,10 +101937,24 @@ var BRIGHTNESS_DIRECTIVE = {
101248
101937
  needsReachableDevice: true,
101249
101938
  handle: (c) => handleSetBrightness(c.header, c.endpoint, c.payload, c.deps.brightnessController, c.identity)
101250
101939
  };
101251
- /** An outlet (D875: its source says so, e.g. HA `device_class: outlet`) is a
101252
- * smart plug; every other switch is a SWITCH. */
101940
+ /**
101941
+ * A switch's category comes from its sub-role, read only through the
101942
+ * `@camstack/types` accessors (operator decision 2026-11-12: every switch
101943
+ * sub-role is exported as its own category):
101944
+ * - an outlet (D875, e.g. HA `device_class: outlet`) is a SMARTPLUG;
101945
+ * - a relay driving a lamp (`switch-light`) is a LIGHT with power only;
101946
+ * - a plain fan behind a switch (`switch-fan`) is a FAN with power only;
101947
+ * - a plug-in heater (`switch-heater`) stays a SWITCH: Alexa has no heater
101948
+ * category with power only, and THERMOSTAT would promise a setpoint and a
101949
+ * temperature the device does not have;
101950
+ * - a helper boolean (`binary-helper`) and a role-less switch stay a SWITCH:
101951
+ * a helper is not a physical thing, SWITCH is exactly what it is.
101952
+ */
101253
101953
  function switchCategory(device) {
101254
- return device.role === DeviceRole.Outlet ? "SMARTPLUG" : "SWITCH";
101954
+ if (isSwitchLight(device.type, device.role)) return "LIGHT";
101955
+ if (isOutlet(device.type, device.role)) return "SMARTPLUG";
101956
+ if (isSwitchFan(device.type, device.role)) return "FAN";
101957
+ return "SWITCH";
101255
101958
  }
101256
101959
  //#endregion
101257
101960
  //#region src/endpoints/adapters/index.ts
@@ -102399,6 +103102,29 @@ function alarmArmModeForAlexa(armState, availableModes) {
102399
103102
  }
102400
103103
  //#endregion
102401
103104
  //#region src/endpoints/builder.ts
103105
+ /**
103106
+ * Build the Alexa Smart Home endpoint payload for a single camstack
103107
+ * device. The Discovery handler aggregates these into an
103108
+ * `Alexa.Discovery/Discover.Response`.
103109
+ *
103110
+ * Endpoint topology:
103111
+ * - Each exposed camera produces ONE parent endpoint with
103112
+ * `endpointId = String(deviceId)` carrying the streaming +
103113
+ * directive surfaces (CameraStream, RTCSession, Doorbell when the
103114
+ * camera has a doorbell, ModeController for PTZ presets when the
103115
+ * camera reports them).
103116
+ * - Each child accessory of the camera (siren / floodlight / PIR /
103117
+ * etc.) becomes a SEPARATE endpoint with
103118
+ * `endpointId = ${parentId}__${childId}` carrying PowerController +
103119
+ * BrightnessController (when applicable). The `__` separator lets
103120
+ * directive handlers decode the routing target cheaply.
103121
+ * - PTZ autotrack — when the parent camera exposes the
103122
+ * `ptz-autotrack` cap — becomes a synthetic child endpoint
103123
+ * `${parentId}__autotrack` with PowerController. We don't model it
103124
+ * as a true child device on the camstack side; the autotrack toggle
103125
+ * lives on the camera's own cap, so the Alexa endpoint id encodes
103126
+ * the routing.
103127
+ */
102402
103128
  var DEFAULT_RESOLUTIONS = [{
102403
103129
  width: 1920,
102404
103130
  height: 1080
@@ -102770,6 +103496,28 @@ function buildParentCameraEndpoint(input) {
102770
103496
  };
102771
103497
  }
102772
103498
  /**
103499
+ * Which endpoint a child switch becomes, from its type and role. A switch
103500
+ * sub-role is read only through the `@camstack/types` accessors; a heater
103501
+ * (`switch-heater`) and a helper boolean stay a plain switch for the reasons
103502
+ * written on `switchCategory` (`adapters/switch.ts`).
103503
+ */
103504
+ function classifyChildKind(deviceType, role) {
103505
+ if (role === "floodlight" || role === "spotlight" || role === "nightvision") return "light";
103506
+ if (role === "siren") return "siren";
103507
+ if (deviceType === "light" || isSwitchLight(deviceType, role)) return "light";
103508
+ if (deviceType === "siren") return "siren";
103509
+ if (isOutlet(deviceType, role)) return "outlet";
103510
+ if (isSwitchFan(deviceType, role)) return "fan";
103511
+ return "switch";
103512
+ }
103513
+ var CHILD_CATEGORY = {
103514
+ light: "LIGHT",
103515
+ switch: "SWITCH",
103516
+ siren: "SWITCH",
103517
+ outlet: "SMARTPLUG",
103518
+ fan: "FAN"
103519
+ };
103520
+ /**
102773
103521
  * Compose a child accessory's Alexa friendly name. camstack child devices
102774
103522
  * are usually already named with their parent prefix (e.g. parent
102775
103523
  * "Camera hall" → child "Camera hall Siren"), so blindly
@@ -102785,7 +103533,7 @@ function composeChildFriendlyName(parentName, childName, childDeviceId) {
102785
103533
  return `${parent} — ${child}`;
102786
103534
  }
102787
103535
  function buildChildAccessoryEndpoint(input) {
102788
- const displayCategories = input.kind === "light" ? ["LIGHT"] : ["SWITCH"];
103536
+ const displayCategories = [CHILD_CATEGORY[input.kind]];
102789
103537
  const capabilities = [ALEXA_BASE_CAPABILITY, POWER_CONTROLLER];
102790
103538
  if (input.hasBrightness) capabilities.push(BRIGHTNESS_CONTROLLER);
102791
103539
  const friendlyName = composeChildFriendlyName(input.parentName, input.childName, input.childDeviceId);
@@ -103688,13 +104436,6 @@ async function loadBoundDeviceInfo(device, api) {
103688
104436
  async function fetchPtzPresetNames(deviceId, api) {
103689
104437
  return (await api.ptz.getPresets.query({ deviceId })).filter(isAlexaRecallablePreset).map((p) => p.name).filter((n) => n.length > 0);
103690
104438
  }
103691
- function classifyChildKind(deviceType, role) {
103692
- if (role === "floodlight" || role === "spotlight" || role === "nightvision") return "light";
103693
- if (role === "siren") return "siren";
103694
- if (deviceType === "light") return "light";
103695
- if (deviceType === "siren") return "siren";
103696
- return "switch";
103697
- }
103698
104439
  function discoveryResponse(header, endpoints) {
103699
104440
  return { event: {
103700
104441
  header: {
@@ -105727,6 +106468,133 @@ function pickSkill(skills, lookup) {
105727
106468
  return skills.find((s) => s.id === "export-alexa" && s.enabled) ?? null;
105728
106469
  }
105729
106470
  //#endregion
106471
+ //#region src/endpoints/alexa-name.ts
106472
+ /**
106473
+ * The Alexa naming rule (D875, amended by D1049): what a device may be called in Alexa.
106474
+ *
106475
+ * The name itself is the generic `device-export` exposed name (D1049): stored per skill
106476
+ * instance in this addon's per-device store, saved through `setExposedName`, and used as the
106477
+ * endpoint `friendlyName`. It never reaches the endpoint id (`<deviceId>__dev`), so renaming
106478
+ * updates the SAME Alexa device on the next AddOrUpdateReport instead of creating a duplicate.
106479
+ * This module holds only Amazon's rule, and the key of the retired Alexa-only name the
106480
+ * migration reads.
106481
+ *
106482
+ * Amazon's friendlyName rule (Alexa.Discovery objects, endpoint object): "Up
106483
+ * to 256 alphanumeric characters and spaces. Don't include special characters
106484
+ * or punctuation." Letters of any script count as alphanumeric, so an Italian
106485
+ * name keeps its accents. The validator rejects what Amazon would reject, with
106486
+ * a message the operator can act on.
106487
+ */
106488
+ /**
106489
+ * Per-device store key of the RETIRED Alexa-only name (one per device, shared by every skill).
106490
+ * Only the migration `export-alexa/2026-11-12-alexa-name-to-exposed-name` reads it.
106491
+ */
106492
+ var LEGACY_ALEXA_NAME_KEY = "alexaName";
106493
+ /** Amazon's rule, as the derived "Name on <skill>" field states it (D1049). */
106494
+ var ALEXA_NAME_RULE = `Amazon accepts letters, digits and spaces only (no punctuation), up to 256 characters.`;
106495
+ /** Letters (any script, with their combining marks), digits and spaces. */
106496
+ var ALLOWED_PATTERN = /^[\p{L}\p{M}\p{N} ]+$/u;
106497
+ /** Amazon's rule over a normalised, non-blank name. */
106498
+ var alexaNameValidator = (name) => {
106499
+ if (name.length > 256) return {
106500
+ ok: false,
106501
+ reason: `The Alexa name is ${name.length} characters; Amazon allows at most 256.`
106502
+ };
106503
+ if (!ALLOWED_PATTERN.test(name)) return {
106504
+ ok: false,
106505
+ reason: "The Alexa name may contain only letters, digits and spaces (Amazon rejects punctuation and special characters)."
106506
+ };
106507
+ return {
106508
+ ok: true,
106509
+ name
106510
+ };
106511
+ };
106512
+ /** Validate an operator-typed Alexa name. Blank clears it (`name: null`, the device name is used). */
106513
+ function validateAlexaName(raw) {
106514
+ return checkExposedName(raw, alexaNameValidator);
106515
+ }
106516
+ //#endregion
106517
+ //#region src/migrations/alexa-name-to-exposed-name.ts
106518
+ /**
106519
+ * The Alexa-only device name becomes the generic exposed name (D1049, amending D875).
106520
+ *
106521
+ * Before: one `alexaName` per device in this addon's per-device store (`addon-device-settings`,
106522
+ * row `export-alexa:<deviceId>.alexaName`), and every skill of the addon (planning#422) showed
106523
+ * it. After: the `device-export` exposed name of EVERY skill that exists, row
106524
+ * `export-alexa:<deviceId>.exposedNames` = `{ <skillId>: name, … }` — so each skill keeps calling
106525
+ * the device what it called it. A skill id that has no `skills` record (the default one on a hub
106526
+ * that never configured Alexa) gets nothing: no running skill would read it.
106527
+ *
106528
+ * One plan, so the copy and the delete commit together. A name is copied as Alexa read it
106529
+ * (normalised; a stored value Alexa would have refused was never used and is not copied). A name
106530
+ * already saved for a skill through the new field was saved by the build that reads it, so it is
106531
+ * never overwritten; the other skills of that device still get the old name. The legacy key is
106532
+ * deleted in every case: nothing reads it any more. A rerun finds no legacy key and does nothing.
106533
+ * A read that fails throws, nothing written.
106534
+ */
106535
+ var OWNER = "export-alexa";
106536
+ /** The per-device settings table: one row per field, id `<addonId>:<deviceId>.<field>`. */
106537
+ var DEVICE_SETTINGS_TABLE = "addon-device-settings";
106538
+ var rowId$3 = (deviceId, field) => `${OWNER}:${deviceId}.${field}`;
106539
+ var rowOf = (deviceId, field, value) => ({
106540
+ addonId: OWNER,
106541
+ deviceId: String(deviceId),
106542
+ key: field,
106543
+ value
106544
+ });
106545
+ /** The held `exposedNames` blob as a record, or `{}` when it is not one. */
106546
+ function heldNames(value) {
106547
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
106548
+ return Object.fromEntries(Object.entries(value));
106549
+ }
106550
+ async function planAlexaNameToExposedName(ports) {
106551
+ const ids = await ports.listDeviceIds();
106552
+ if (ids.length === 0) return { edits: [] };
106553
+ const legacy = await ports.readDeviceField(ids, LEGACY_ALEXA_NAME_KEY);
106554
+ if (legacy.size === 0) return { edits: [] };
106555
+ const skills = await ports.listSkillIds();
106556
+ const held = await ports.readDeviceField([...legacy.keys()], EXPOSED_NAMES_STORE_KEY);
106557
+ const written = {};
106558
+ const expected = {};
106559
+ const retired = {};
106560
+ for (const [deviceId, stored] of legacy) {
106561
+ retired[rowId$3(deviceId, LEGACY_ALEXA_NAME_KEY)] = rowOf(deviceId, LEGACY_ALEXA_NAME_KEY, stored);
106562
+ const check = validateAlexaName(stored);
106563
+ if (!check.ok || check.name === null) continue;
106564
+ if (skills.length === 0) {
106565
+ ports.warn(`Alexa migration: device ${deviceId} had an Alexa name but no Alexa skill exists; it is not kept`);
106566
+ continue;
106567
+ }
106568
+ const before = held.has(deviceId) ? heldNames(held.get(deviceId)) : null;
106569
+ const merged = { ...before };
106570
+ for (const skillId of skills) {
106571
+ if (skillId in merged) {
106572
+ ports.warn(`Alexa migration: device ${deviceId} already has a name on skill ${skillId}; its old Alexa name is not copied there`);
106573
+ continue;
106574
+ }
106575
+ merged[skillId] = check.name;
106576
+ }
106577
+ if (before !== null && Object.keys(merged).length === Object.keys(before).length) continue;
106578
+ const id = rowId$3(deviceId, EXPOSED_NAMES_STORE_KEY);
106579
+ written[id] = rowOf(deviceId, EXPOSED_NAMES_STORE_KEY, merged);
106580
+ expected[id] = before === null ? null : rowOf(deviceId, EXPOSED_NAMES_STORE_KEY, held.get(deviceId));
106581
+ }
106582
+ const edits = [];
106583
+ if (Object.keys(written).length > 0) edits.push({
106584
+ op: "setKeys",
106585
+ scope: DEVICE_SETTINGS_TABLE,
106586
+ values: written,
106587
+ precondition: preconditionOf(expected)
106588
+ });
106589
+ edits.push({
106590
+ op: "deleteKeys",
106591
+ scope: DEVICE_SETTINGS_TABLE,
106592
+ keys: Object.keys(retired),
106593
+ precondition: preconditionOf(retired)
106594
+ });
106595
+ return { edits };
106596
+ }
106597
+ //#endregion
105730
106598
  //#region src/migrations/drop-public-hub-url.ts
105731
106599
  /**
105732
106600
  * The hub's public URL is no longer a setting of this addon (planning#378): Alexa reads the
@@ -106326,6 +107194,7 @@ var EXPOSURE_TO_RECORD_ID = "export-alexa/2026-11-04-exposure-to-record";
106326
107194
  var DROP_MOVED_EXPOSURE_ID = "export-alexa/2026-11-04-drop-moved-exposure";
106327
107195
  var STATE_TO_INSTANCE_ID = "export-alexa/2026-11-04-state-to-instance";
106328
107196
  var DROP_MOVED_STATE_ID = "export-alexa/2026-11-04-drop-moved-state";
107197
+ var ALEXA_NAME_TO_EXPOSED_NAME_ID = "export-alexa/2026-11-12-alexa-name-to-exposed-name";
106329
107198
  var FIXTURE_MARK = "the endpoint sync state the migration does not know";
106330
107199
  /**
106331
107200
  * The `export-alexa` catalogue (D987): offered to the engine when the addon initialises. Every
@@ -106459,6 +107328,22 @@ var ADDON_MIGRATIONS = [
106459
107328
  fixtureMark: FIXTURE_MARK
106460
107329
  },
106461
107330
  plan: planDropMovedState
107331
+ },
107332
+ {
107333
+ meta: {
107334
+ id: ALEXA_NAME_TO_EXPOSED_NAME_ID,
107335
+ owner: "export-alexa",
107336
+ level: "addon-state",
107337
+ seq: 9,
107338
+ dependsOn: [],
107339
+ store: "settings",
107340
+ scope: "cluster",
107341
+ onFailure: "tolerate",
107342
+ bodyKind: "plan",
107343
+ description: "Copy every device`s Alexa name to the exposed name of every Alexa skill and delete the alexaName key",
107344
+ fixtureMark: FIXTURE_MARK
107345
+ },
107346
+ plan: planAlexaNameToExposedName
106462
107347
  }
106463
107348
  ];
106464
107349
  //#endregion
@@ -107326,72 +108211,33 @@ var AlexaEgressPrewarm = class {
107326
108211
  }
107327
108212
  };
107328
108213
  //#endregion
107329
- //#region src/endpoints/alexa-name.ts
107330
- /**
107331
- * The per-device "Alexa name" (D875): what Alexa calls the device, when it
107332
- * should not be the device's own name.
107333
- *
107334
- * Stored under {@link ALEXA_NAME_KEY} in this addon's per-device settings store
107335
- * (D870) and used as the endpoint `friendlyName`. It never reaches the endpoint
107336
- * id (`<deviceId>__dev`), so renaming updates the SAME Alexa device on the next
107337
- * AddOrUpdateReport instead of creating a duplicate.
107338
- *
107339
- * Amazon's friendlyName rule (Alexa.Discovery objects, endpoint object): "Up
107340
- * to 256 alphanumeric characters and spaces. Don't include special characters
107341
- * or punctuation." Letters of any script count as alphanumeric, so an Italian
107342
- * name keeps its accents. The validator rejects what Amazon would reject, with
107343
- * a message the operator can act on.
107344
- */
107345
- /** Per-device store key of the saved Alexa name. */
107346
- var ALEXA_NAME_KEY = "alexaName";
107347
- /** The device-settings form field key, namespaced per exporter (see the addon). */
107348
- function alexaNameKey(deviceId) {
107349
- return `alexa:${deviceId}:alexaName`;
107350
- }
107351
- /** Letters (any script, with their combining marks), digits and spaces. */
107352
- var ALLOWED_PATTERN = /^[\p{L}\p{M}\p{N} ]+$/u;
107353
- /**
107354
- * Validate an operator-typed Alexa name. Blank clears the override
107355
- * (`name: null`, the device name is used).
107356
- */
107357
- function validateAlexaName(raw) {
107358
- if (raw === null || raw === void 0) return {
107359
- ok: true,
107360
- name: null
107361
- };
107362
- if (typeof raw !== "string") return {
107363
- ok: false,
107364
- error: "The Alexa name must be text."
107365
- };
107366
- const name = raw.trim().replace(/\s+/g, " ");
107367
- if (name.length === 0) return {
107368
- ok: true,
107369
- name: null
107370
- };
107371
- if (name.length > 256) return {
107372
- ok: false,
107373
- error: `The Alexa name is ${name.length} characters; Amazon allows at most 256.`
107374
- };
107375
- if (!ALLOWED_PATTERN.test(name)) return {
107376
- ok: false,
107377
- error: "The Alexa name may contain only letters, digits and spaces (Amazon rejects punctuation and special characters)."
107378
- };
107379
- return {
107380
- ok: true,
107381
- name
107382
- };
107383
- }
107384
- var StoredNameSchema = string();
107385
- /**
107386
- * The saved Alexa name in a per-device store blob, or null (never saved, or a
107387
- * stored value that no longer validates: the device name is used rather than
107388
- * pushing a name Amazon would refuse).
107389
- */
107390
- function readAlexaName(store) {
107391
- const parsed = StoredNameSchema.safeParse(store[ALEXA_NAME_KEY]);
107392
- if (!parsed.success) return null;
107393
- const check = validateAlexaName(parsed.data);
107394
- return check.ok ? check.name : null;
108214
+ //#region src/exposed-name-rename.ts
108215
+ async function renameOnSkill(deps, deviceIdRaw, raw, options = {}) {
108216
+ const deviceId = Number.parseInt(deviceIdRaw, 10);
108217
+ if (!Number.isFinite(deviceId)) throw new Error(`export-alexa: deviceId must be numeric — got "${deviceIdRaw}"`);
108218
+ const saved = await saveExposedName({
108219
+ store: deps.store,
108220
+ deviceId,
108221
+ instanceId: deps.instanceId,
108222
+ raw,
108223
+ validate: alexaNameValidator,
108224
+ ...options.dryRun === true ? { dryRun: true } : {}
108225
+ });
108226
+ if (!saved.changed) return;
108227
+ deps.logger.info("export-alexa: Alexa name saved", {
108228
+ tags: { deviceId },
108229
+ meta: {
108230
+ instanceId: deps.instanceId,
108231
+ name: saved.name
108232
+ }
108233
+ });
108234
+ if (!deps.isExposed(deviceId)) return;
108235
+ deps.push(deviceId).catch((err) => {
108236
+ deps.logger.warn("export-alexa: push after an Alexa name change failed", {
108237
+ tags: { deviceId },
108238
+ meta: { error: err instanceof Error ? err.message : String(err) }
108239
+ });
108240
+ });
107395
108241
  }
107396
108242
  //#endregion
107397
108243
  //#region src/stream-preference.ts
@@ -110446,7 +111292,7 @@ var SkillRuntime = class {
110446
111292
  logger: this.ctx.logger,
110447
111293
  snapshots: this.view.snapshots,
110448
111294
  ...this.view.detectionSensors ? { detectionClasses: async (id) => effectiveSensorClasses(await classesOf(id), parseSensorSelection(await vision.readPrefs(id))) } : {},
110449
- alexaName: async (id) => readAlexaName(await vision.readPrefs(id)),
111295
+ alexaName: async (id) => readExposedName(await vision.readPrefs(id), this.instanceId, alexaNameValidator),
110450
111296
  ...this.view.objectDetection ? { objectDetection: async (id) => vision.buildClasses(id, await classesOf(id)) } : {}
110451
111297
  });
110452
111298
  }
@@ -110892,27 +111738,11 @@ var SkillRuntime = class {
110892
111738
  value: enabled,
110893
111739
  immediate: true
110894
111740
  },
110895
- ...opts.shared ? [await this.alexaNameField(deviceId, enabledKey)] : [],
110896
111741
  ...kind === "camera" ? this.cameraOnlyExportFields(deviceId, settings, enabledKey) : [],
110897
111742
  ...kind === "camera" && opts.shared ? await this.cameraDetectionFields(deviceId, enabledKey) : []
110898
111743
  ]
110899
111744
  };
110900
111745
  }
110901
- /** D875: the "Alexa name" field, with the validation error of the saved value. */
110902
- async alexaNameField(deviceId, enabledKey) {
110903
- const saved = readAlexaName(await this.vision.readPrefs(deviceId));
110904
- return {
110905
- type: "text",
110906
- key: alexaNameKey(deviceId),
110907
- label: "Alexa name",
110908
- description: `What Alexa calls this device. Leave empty to use the device name. Letters, digits and spaces only (no punctuation), up to 256 characters. Renaming updates the same Alexa device; it does not create a duplicate.`,
110909
- value: saved ?? "",
110910
- showWhen: {
110911
- field: enabledKey,
110912
- equals: true
110913
- }
110914
- };
110915
- }
110916
111746
  /**
110917
111747
  * The camera's detection fields: which classes become Alexa sensors (D778;
110918
111748
  * only the classes its pipeline produces are offered) and its object
@@ -110934,24 +111764,6 @@ var SkillRuntime = class {
110934
111764
  })];
110935
111765
  }
110936
111766
  /**
110937
- * D875: save the Alexa name from a device-settings patch. A name Amazon would
110938
- * refuse throws BEFORE anything is written, so the form shows the reason and
110939
- * the old name stays. True when the saved name changed.
110940
- */
110941
- async applyAlexaNamePatch(deviceId, patch) {
110942
- const key = alexaNameKey(deviceId);
110943
- if (!(key in patch)) return false;
110944
- const check = validateAlexaName(patch[key]);
110945
- if (!check.ok) throw new Error(`export-alexa: ${check.error}`);
110946
- if (readAlexaName(await this.vision.readPrefs(deviceId)) === check.name) return false;
110947
- await this.vision.writePrefs(deviceId, { [ALEXA_NAME_KEY]: check.name ?? void 0 });
110948
- this.ctx.logger.info("export-alexa: Alexa name saved", {
110949
- tags: { deviceId },
110950
- meta: { name: check.name }
110951
- });
110952
- return true;
110953
- }
110954
- /**
110955
111767
  * Persist the camera's detection preferences from a device-settings patch
110956
111768
  * into this addon's per-device store. True when anything changed — the
110957
111769
  * camera's Alexa shape then needs a reconcile.
@@ -111002,15 +111814,32 @@ var SkillRuntime = class {
111002
111814
  }];
111003
111815
  }
111004
111816
  /**
111005
- * The device's own preferences in a patch (Alexa name, detection classes, object detection):
111006
- * shared by every skill, so they are saved ONCE, before any skill applies its own part (an
111007
- * expose in the same patch then builds with them).
111817
+ * The device's own preferences in a patch (detection classes, object detection): shared by
111818
+ * every skill, so they are saved ONCE, before any skill applies its own part (an expose in
111819
+ * the same patch then builds with them).
111008
111820
  */
111009
111821
  async applySharedPrefs(deviceId, patch) {
111010
- return {
111011
- prefsChanged: await this.applyDetectionPrefsPatch(deviceId, patch),
111012
- nameChanged: await this.applyAlexaNamePatch(deviceId, patch)
111013
- };
111822
+ return { prefsChanged: await this.applyDetectionPrefsPatch(deviceId, patch) };
111823
+ }
111824
+ /** D1049: this skill's exposed name for a device, or null (the device's own name). */
111825
+ async exposedNameOf(deviceId) {
111826
+ return readExposedName(await this.vision.readPrefs(deviceId), this.instanceId, alexaNameValidator);
111827
+ }
111828
+ /**
111829
+ * D1049: save this skill's name for a device (`device-export.setExposedName`); an exposed
111830
+ * device is pushed again under the same endpoint id. `renameOnSkill` holds the rule.
111831
+ */
111832
+ async setExposedName(deviceIdRaw, raw, dryRun = false) {
111833
+ await renameOnSkill({
111834
+ instanceId: this.instanceId,
111835
+ store: {
111836
+ read: (id) => exposedNameStoreOf(this.ctx.settings, "export-alexa").read(id),
111837
+ write: (id, patch) => this.vision.writePrefs(id, patch)
111838
+ },
111839
+ logger: this.ctx.logger,
111840
+ isExposed: (id) => this.findEntry(id) !== null,
111841
+ push: (id) => this.requireSyncEngine().pushDevice(id)
111842
+ }, deviceIdRaw, raw, { dryRun });
111014
111843
  }
111015
111844
  /**
111016
111845
  * Apply this skill's part of a patch produced by the device-details "Export" panel. Flips
@@ -111023,7 +111852,7 @@ var SkillRuntime = class {
111023
111852
  * the new preference. See remaining-work notes in CLAUDE.md.
111024
111853
  */
111025
111854
  async applyEntryPatch(deviceId, patch, shared) {
111026
- const { prefsChanged, nameChanged } = shared;
111855
+ const { prefsChanged } = shared;
111027
111856
  const idStr = String(deviceId);
111028
111857
  const current = this.findEntry(deviceId);
111029
111858
  const wasEnabled = current !== null;
@@ -111052,12 +111881,6 @@ var SkillRuntime = class {
111052
111881
  const currentAllow = current?.settings?.allowTranscode !== false;
111053
111882
  await this.patchEntrySettings(deviceId, nextSettings);
111054
111883
  const sourceChanged = currentPref !== streamPreference || currentAllow !== allowTranscode;
111055
- if (nameChanged && !sourceChanged) this.requireSyncEngine().pushDevice(deviceId).catch((err) => {
111056
- this.ctx.logger.warn("export-alexa: push after an Alexa name change failed", {
111057
- tags: { deviceId },
111058
- meta: { error: errMsg$1(err) }
111059
- });
111060
- });
111061
111884
  if (prefsChanged && !sourceChanged) this.requireSyncEngine().reconcileDevice(deviceId).catch((err) => {
111062
111885
  this.ctx.logger.warn("export-alexa: re-sync after a detection preference change failed", {
111063
111886
  tags: { deviceId },
@@ -111603,15 +112426,30 @@ var ExportAlexaAddon = class extends BaseAddon {
111603
112426
  instanceId: row.id,
111604
112427
  name: row.body.name,
111605
112428
  enabled: row.enabled,
111606
- kind: "alexa-skill"
112429
+ kind: "alexa-skill",
112430
+ nameRule: ALEXA_NAME_RULE
111607
112431
  }));
111608
112432
  },
111609
112433
  listSupportedDeviceKinds: async ({ instanceId }) => {
111610
112434
  ownInstance(instanceId);
111611
112435
  return [...SUPPORTED_KINDS];
111612
112436
  },
111613
- listExposedDevices: async ({ instanceId }) => ownInstance(instanceId).exposedDevices.map((e) => ({ deviceId: String(e.deviceId) })),
111614
- exposeDevice: async ({ instanceId, deviceId }) => ownInstance(instanceId).exposeDevice(deviceId),
112437
+ listExposedDevices: async ({ instanceId }) => {
112438
+ const runtime = ownInstance(instanceId);
112439
+ return Promise.all(runtime.exposedDevices.map(async (e) => {
112440
+ const exposedName = await runtime.exposedNameOf(e.deviceId);
112441
+ return {
112442
+ deviceId: String(e.deviceId),
112443
+ ...exposedName !== null ? { exposedName } : {}
112444
+ };
112445
+ }));
112446
+ },
112447
+ exposeDevice: async ({ instanceId, deviceId, exposedName }) => {
112448
+ const runtime = ownInstance(instanceId);
112449
+ if (exposedName !== void 0) await runtime.setExposedName(deviceId, exposedName);
112450
+ return runtime.exposeDevice(deviceId);
112451
+ },
112452
+ setExposedName: async ({ instanceId, deviceId, name, dryRun }) => ownInstance(instanceId).setExposedName(deviceId, name, dryRun === true),
111615
112453
  unexposeDevice: async ({ instanceId, deviceId }) => ownInstance(instanceId).unexposeDevice(deviceId),
111616
112454
  listSupportedEntityKinds: async () => ["device", "action"],
111617
112455
  listExposedEntities: async ({ instanceId }) => {
@@ -111739,6 +112577,7 @@ var ExportAlexaAddon = class extends BaseAddon {
111739
112577
  if (change === "deleted") {
111740
112578
  await this.stopRuntime(id);
111741
112579
  await this.deleteSkillRows(id);
112580
+ await this.pruneSkillNames(id);
111742
112581
  return;
111743
112582
  }
111744
112583
  const row = await this.requireInstances().readResolved(id);
@@ -111754,6 +112593,16 @@ var ExportAlexaAddon = class extends BaseAddon {
111754
112593
  await running.refreshRecords();
111755
112594
  await running.applyShapeSwitches();
111756
112595
  }
112596
+ /** A deleted skill's device names go too, so a skill that reuses the id inherits none (D1049). */
112597
+ async pruneSkillNames(id) {
112598
+ const settings = this.ctx.settings;
112599
+ if (settings === void 0) return;
112600
+ const pruned = await pruneExposedNames(settings, id);
112601
+ if (pruned.length > 0) this.ctx.logger.info("export-alexa: deleted skill names removed", { meta: {
112602
+ instanceId: id,
112603
+ devices: pruned.length
112604
+ } });
112605
+ }
111757
112606
  /** What a deleted skill leaves behind: its links, its exposure and its hidden state. */
111758
112607
  async deleteSkillRows(id) {
111759
112608
  await deleteSkillRows(this.requireHandles(), id);
@@ -111832,6 +112681,19 @@ var ExportAlexaAddon = class extends BaseAddon {
111832
112681
  readState: async () => (await stateHandle.getResolved("export-alexa"))?.data ?? null,
111833
112682
  clearIngressTokenSecret: async () => {
111834
112683
  await this.clearSecrets(["ingressToken"]);
112684
+ },
112685
+ listSkillIds: async () => (await this.requireInstances().listResolved()).map((r) => r.id),
112686
+ listDeviceIds: async () => {
112687
+ const settings = this.ctx.settings;
112688
+ if (settings === void 0) throw new Error("export-alexa: the settings store is unavailable");
112689
+ return settings.listDeviceStoreIds();
112690
+ },
112691
+ readDeviceField: async (deviceIds, field) => {
112692
+ const settings = this.ctx.settings;
112693
+ if (settings === void 0) throw new Error("export-alexa: the settings store is unavailable");
112694
+ const found = /* @__PURE__ */ new Map();
112695
+ for (const [deviceId, blob] of await settings.readDeviceStoreBatch(deviceIds)) if (field in blob) found.set(deviceId, blob[field]);
112696
+ return found;
111835
112697
  }
111836
112698
  };
111837
112699
  }