@camstack/addon-export-alexa 1.2.195 → 1.2.196

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
@@ -6079,7 +6088,7 @@ var ZodIssueCode = {
6079
6088
  var ZodFirstPartyTypeKind;
6080
6089
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6081
6090
  //#endregion
6082
- //#region ../types/dist/sleep-D0roI_CZ.mjs
6091
+ //#region ../types/dist/sleep-DyIxjZZt.mjs
6083
6092
  /**
6084
6093
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6085
6094
  * window to float samples (D455).
@@ -6762,6 +6771,13 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
6762
6771
  else skipped.push(id);
6763
6772
  };
6764
6773
  const selected = options.only === void 0 ? null : new Set(options.only);
6774
+ const deferred = /* @__PURE__ */ new Set();
6775
+ const deferredBy = (reason) => {
6776
+ if (selected === null || reason === null) return null;
6777
+ const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
6778
+ if (dep === void 0 || !byId.has(dep)) return null;
6779
+ return !selected.has(dep) || deferred.has(dep) ? dep : null;
6780
+ };
6765
6781
  for (const step of declaration.steps) {
6766
6782
  if (selected !== null && !selected.has(step.id)) continue;
6767
6783
  const bound = byId.get(step.id);
@@ -6773,6 +6789,19 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
6773
6789
  try {
6774
6790
  const gate = await host.startMigration({ id: step.id });
6775
6791
  if (!gate.proceed) {
6792
+ const waitsFor = deferredBy(gate.reason);
6793
+ if (waitsFor !== null) {
6794
+ log.info("migration deferred: its predecessor runs in another phase of this owner", {
6795
+ tags,
6796
+ meta: {
6797
+ waitsFor,
6798
+ reason: gate.reason
6799
+ }
6800
+ });
6801
+ deferred.add(step.id);
6802
+ skipped.push(step.id);
6803
+ continue;
6804
+ }
6776
6805
  log.warn("migration not run", {
6777
6806
  tags,
6778
6807
  meta: {
@@ -7817,7 +7846,7 @@ async function writeMembers(ctx, children, incoming, stored, pathOf) {
7817
7846
  for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
7818
7847
  return out;
7819
7848
  }
7820
- function rowId$3(row, idKey) {
7849
+ function rowId$4(row, idKey) {
7821
7850
  const raw = row[idKey];
7822
7851
  if (typeof raw === "string" && raw.length > 0) return raw;
7823
7852
  if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
@@ -7834,7 +7863,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
7834
7863
  }
7835
7864
  const storedById = /* @__PURE__ */ new Map();
7836
7865
  for (const row of storedRows) {
7837
- const id = rowId$3(row, node.idKey);
7866
+ const id = rowId$4(row, node.idKey);
7838
7867
  if (id !== null) storedById.set(id, row);
7839
7868
  }
7840
7869
  const kept = /* @__PURE__ */ new Set();
@@ -7844,13 +7873,13 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
7844
7873
  rows.push(row);
7845
7874
  continue;
7846
7875
  }
7847
- const id = rowId$3(row, node.idKey) ?? ctx.mintId();
7876
+ const id = rowId$4(row, node.idKey) ?? ctx.mintId();
7848
7877
  kept.add(id);
7849
7878
  const withId = {
7850
7879
  ...row,
7851
7880
  [node.idKey]: row[node.idKey] ?? id
7852
7881
  };
7853
- if (rowId$3(withId, node.idKey) === null) withId[node.idKey] = id;
7882
+ if (rowId$4(withId, node.idKey) === null) withId[node.idKey] = id;
7854
7883
  const storedRow = storedById.get(id) ?? {};
7855
7884
  rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
7856
7885
  }
@@ -10222,6 +10251,13 @@ var DeviceTransitionSchema = object({
10222
10251
  actor: TransitionActorSchema,
10223
10252
  command: TransitionCommandSchema.optional()
10224
10253
  });
10254
+ object({
10255
+ deviceId: number$1().int(),
10256
+ action: string(),
10257
+ outcome: TransitionOutcomeSchema,
10258
+ actor: TransitionActorSchema,
10259
+ at: number$1()
10260
+ });
10225
10261
  var READING_QUANTITIES = [
10226
10262
  "temperature",
10227
10263
  "pressure",
@@ -12245,7 +12281,10 @@ var ACTUATOR_CAP_VOCABULARY = {
12245
12281
  "ir-transmitter": {
12246
12282
  scope: "device",
12247
12283
  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" }
12284
+ notOperatorFacing: {
12285
+ send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it",
12286
+ learn: "an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal"
12287
+ }
12249
12288
  },
12250
12289
  control: {
12251
12290
  scope: "device",
@@ -15166,6 +15205,32 @@ var CAP_VOCABULARY_BY_NAME = {
15166
15205
  ...SYSTEM_CAP_VOCABULARY
15167
15206
  };
15168
15207
  /**
15208
+ * Vocabulary actions by id (D983). An action step names a vocabulary action
15209
+ * (`cover.open`), never a raw cap method; this is the one lookup that turns the
15210
+ * id into its cap, method and effect — and a persisted legacy `cap` + `method`
15211
+ * pair back into the action id when exactly one action matches.
15212
+ */
15213
+ function buildIndex() {
15214
+ const byId = /* @__PURE__ */ new Map();
15215
+ for (const [cap, entry] of Object.entries(CAP_VOCABULARY_BY_NAME)) {
15216
+ if (entry.scope !== "device") continue;
15217
+ for (const action of entry.actions ?? []) byId.set(action.id, {
15218
+ cap,
15219
+ action
15220
+ });
15221
+ }
15222
+ return byId;
15223
+ }
15224
+ var index;
15225
+ function actionIndex() {
15226
+ index ??= buildIndex();
15227
+ return index;
15228
+ }
15229
+ /** The vocabulary action with this id, or `undefined`. */
15230
+ function findVocabAction(actionId) {
15231
+ return actionIndex().get(actionId);
15232
+ }
15233
+ /**
15169
15234
  * `addon-pages-source` — collection cap exposing per-provider raw page
15170
15235
  * declarations. Every addon that contributes a UI page registers a
15171
15236
  * provider here. The hub-side singleton aggregator (`addon-pages` cap,
@@ -44837,21 +44902,23 @@ function convertLegacyWhen(half) {
44837
44902
  * (instants) and state leaves (durations). It replaces the flat trigger list
44838
44903
  * plus the separate condition tree; the firing rule is in that file and in
44839
44904
  * ADR "one tree".
44840
- * - **Actions** — the `wait` and `cap` steps, plus the `{kind:'code'}`
44905
+ * - **Actions** — the `wait` and device `command` steps, plus the `{kind:'code'}`
44841
44906
  * fragment of §3.2.2. See {@link AutomationActionSchema}.
44842
44907
  *
44843
44908
  * A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
44844
44909
  * {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
44845
44910
  */
44846
44911
  /**
44847
- * One action step: `wait`, or a `cap` call.
44912
+ * One action step: `wait`, or a device `command`.
44848
44913
  *
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).
44914
+ * A command step names a VOCABULARY action (`cover.open`) and who it acts on
44915
+ * (D983: `devices`, a `domain`, or a `{ $var }` resolved from the run's
44916
+ * variables). It never names a cap method: the step runner turns the action
44917
+ * id into its cap + method through the vocabulary index when the step runs
44918
+ * (`vocabCall`), the one place that mapping happens. The step runner
44919
+ * (`runSteps`) owns the device-scope check, the stop-at-first-failure and the
44920
+ * variable substitution, once, for every caller — automations, Actions, and
44921
+ * the notification centre, which runs only Actions (planning#473).
44855
44922
  */
44856
44923
  /** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
44857
44924
  var WAIT_MAX_SECONDS = 3600;
@@ -44860,39 +44927,22 @@ var AutomationWaitStepSchema = object({
44860
44927
  kind: literal("wait"),
44861
44928
  seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
44862
44929
  });
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
44930
  /**
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}.
44931
+ * The fields of a command step, before the vocabulary check. A step is
44932
+ * {@link AutomationCommandStepSchema}.
44873
44933
  */
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(),
44934
+ var AutomationCommandStepBaseSchema = object({
44935
+ kind: literal("command"),
44936
+ /** WHO the step acts on. */
44937
+ target: ActionTargetSchema,
44938
+ /** The vocabulary action this step performs (`cover.open`). */
44939
+ actionId: string().min(1),
44885
44940
  /**
44886
- * @deprecated The pre-D983 target: one device, several, or `{ $var }`.
44887
- * Still READ — {@link normalizeCapStep} maps it to `target` — and never
44888
- * written.
44941
+ * The values of the action's OPEN args (`position`, `presetId`); the args
44942
+ * the vocabulary bakes into the action are added when the step runs. Values
44943
+ * may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
44944
+ * SUBSTITUTE and do not evaluate (§3.2.3).
44889
44945
  */
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
44946
  args: record(string(), unknown()).optional(),
44897
44947
  /**
44898
44948
  * The unit the person picked per arg (display only). `args` always hold the
@@ -44901,18 +44951,20 @@ var AutomationCapStepBaseSchema = object({
44901
44951
  */
44902
44952
  argUnits: record(string(), string().min(1)).optional()
44903
44953
  });
44954
+ /** The vocabulary check every command step passes: the action exists. */
44955
+ function refineKnownAction(step, ctx) {
44956
+ if (findVocabAction(step.actionId) === void 0) ctx.addIssue({
44957
+ code: "custom",
44958
+ message: `"${step.actionId}" is not a vocabulary action id`,
44959
+ path: ["actionId"]
44960
+ });
44961
+ }
44904
44962
  /**
44905
- * The steps an internal Action may contain: cap and wait, and nothing that can
44963
+ * The steps an internal Action may contain: command and wait, and nothing that can
44906
44964
  * call back into an Action — so an Action can never reach itself (no cycles).
44907
44965
  * This is the LEAF shape: no condition of its own.
44908
44966
  */
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
- })]);
44967
+ var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCommandStepBaseSchema.superRefine(refineKnownAction)]);
44916
44968
  /**
44917
44969
  * The optional guard of a step (#472): `if` is the ONE `when` tree (D980), read
44918
44970
  * on the state mirror when the step is reached; `else` runs when it is false.
@@ -44933,13 +44985,7 @@ var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refi
44933
44985
  * same two step kinds an automation runs, minus a guard that reads the
44934
44986
  * automation's trigger, which such a list does not have.
44935
44987
  */
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) => {
44988
+ 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
44989
  if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
44944
44990
  code: "custom",
44945
44991
  message: TRIGGERED_BY_NEEDS_AUTOMATION,
@@ -44954,17 +45000,11 @@ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, Automa
44954
45000
  var continueOnErrorShape = {
44955
45001
  /** A failure of this step is traced `failed-continued` and the next step runs. */
44956
45002
  continueOnError: literal(true).optional() };
44957
- /** An automation's cap step: the shared guarded cap step, plus `continueOnError`. */
44958
- var AutomationGuardedCapStepSchema = AutomationCapStepBaseSchema.extend({
45003
+ /** An automation's command step: the shared guarded command step, plus `continueOnError`. */
45004
+ var AutomationGuardedCommandStepSchema = AutomationCommandStepBaseSchema.extend({
44959
45005
  ...stepGuardShape,
44960
45006
  ...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);
45007
+ }).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
44968
45008
  /** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
44969
45009
  var AutomationStopStepSchema = object({
44970
45010
  kind: literal("stop"),
@@ -45044,13 +45084,7 @@ function nestTooDeep(issue) {
45044
45084
  }
45045
45085
  var plainStepSchemas = [
45046
45086
  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
- }),
45087
+ AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
45054
45088
  AutomationStopStepSchema.omit({ if: true }).strict(),
45055
45089
  AutomationSetStepSchema.omit({ if: true }).strict(),
45056
45090
  AutomationRunActionStepSchema.strict()
@@ -45061,7 +45095,7 @@ var plainStepSchemas = [
45061
45095
  */
45062
45096
  var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
45063
45097
  /** 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");
45098
+ 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
45099
  /**
45066
45100
  * Several steps at once (#500): all are started together and all are awaited.
45067
45101
  * A failure fails the run once the others finished, as in a sequence; a member
@@ -45141,7 +45175,7 @@ var AutomationBodyStepSchema = discriminatedUnion("kind", [
45141
45175
  var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
45142
45176
  var AutomationActionSchema = discriminatedUnion("kind", [
45143
45177
  GuardedWaitStepSchema,
45144
- AutomationGuardedCapStepSchema,
45178
+ AutomationGuardedCommandStepSchema,
45145
45179
  AutomationStopStepSchema,
45146
45180
  AutomationSetStepSchema,
45147
45181
  chooseSchemaOf(AutomationBodyStepSchema),
@@ -45212,86 +45246,6 @@ function convertLegacyRecipe(legacy) {
45212
45246
  };
45213
45247
  }
45214
45248
  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
45249
  /**
45296
45250
  * Schedulers (D983) — an entity that performs actions over the day.
45297
45251
  *
@@ -45690,6 +45644,86 @@ var AutomationStateDocSchema = object({
45690
45644
  lastRunStartedAt: number$1().nullable(),
45691
45645
  traces: array(AutomationRunTraceSchema)
45692
45646
  });
45647
+ var DETECTION_DESCRIPTIONS = {
45648
+ deviceId: "the camera that saw it",
45649
+ className: "what it saw",
45650
+ trackId: "the track",
45651
+ score: "how sure the detector was",
45652
+ label: "the label it matched (a name, a plate), empty when none"
45653
+ };
45654
+ var STATIONARY_DESCRIPTIONS = {
45655
+ deviceId: "the camera that saw it",
45656
+ className: "what it saw",
45657
+ zones: "the zones it is in",
45658
+ phase: "appeared or departed",
45659
+ entryId: "the stopped object"
45660
+ };
45661
+ var BECOMES_DESCRIPTIONS = {
45662
+ deviceId: "the device that changed",
45663
+ from: "the value before the change, empty when it is not known",
45664
+ to: "the value it changed to"
45665
+ };
45666
+ /**
45667
+ * A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
45668
+ * those names depend on the device, so they are not in this list.
45669
+ */
45670
+ var FIRED_DESCRIPTIONS = {
45671
+ deviceId: "the device that fired",
45672
+ eventType: "the event, as the device names it",
45673
+ sourceId: "the part of the device that fired (a button), empty when it names none",
45674
+ eventKind: "the kind of press (press, long-press …), empty when the device declares none"
45675
+ };
45676
+ function describe$1(descriptions) {
45677
+ return Object.entries(descriptions).map(([name, description]) => ({
45678
+ name,
45679
+ description
45680
+ }));
45681
+ }
45682
+ describe$1(DETECTION_DESCRIPTIONS);
45683
+ describe$1(STATIONARY_DESCRIPTIONS);
45684
+ describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45685
+ ...v,
45686
+ hintKey: "firedDeviceId"
45687
+ } : v);
45688
+ describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45689
+ ...v,
45690
+ hintKey: "becomesDeviceId"
45691
+ } : v);
45692
+ new Set(Object.values(COCO_TO_MACRO.mapping));
45693
+ /**
45694
+ * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
45695
+ * device. Carries the device's EXACT declared event vocabulary verbatim
45696
+ * (NO normalization). Two shapes:
45697
+ * - structured source (HA `event.*` entity) → `vocabulary` is the fixed
45698
+ * declared set (e.g. press_short, press_long, …).
45699
+ * - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
45700
+ * is [] (open) and `lastEvent.data` carries the complex payload.
45701
+ * `vocabulary` (D1044) names each event for a person and types it for a
45702
+ * rule; `eventTypes` is its list of native tokens, kept for older readers.
45703
+ * A fire names the part of the device it came from in `sourceId` when the
45704
+ * vocabulary declares sources (a remote's buttons).
45705
+ * `seq` is monotonic so two identical events still produce distinct slice writes.
45706
+ */
45707
+ var EventFireSchema = object({
45708
+ deviceId: number$1(),
45709
+ eventType: string(),
45710
+ sourceId: string().optional(),
45711
+ data: record(string(), unknown()).nullable(),
45712
+ timestamp: number$1().meta(readingMeta("none")),
45713
+ seq: number$1().meta(readingMeta("count"))
45714
+ });
45715
+ var EventEmitterStatusSchema = object({
45716
+ eventTypes: array(string()),
45717
+ /**
45718
+ * Required of a provider by the type. A status written before the field
45719
+ * existed still parses, as an empty vocabulary: read it through
45720
+ * `readEventVocabulary`, which then answers with the plain tokens.
45721
+ */
45722
+ vocabulary: array(EventVocabularyEntrySchema).default([]),
45723
+ lastEvent: EventFireSchema.nullable(),
45724
+ eventCountSinceStart: number$1().meta(readingMeta("count"))
45725
+ });
45726
+ DeviceType.EventEmitter;
45693
45727
  /**
45694
45728
  * Actions — named, runnable things an operator (or an automation) can start,
45695
45729
  * declared as LIST ENTRIES, never as devices.
@@ -45952,6 +45986,343 @@ function pruneDeletedEntities(selection, live, log, exporter) {
45952
45986
  dropped
45953
45987
  };
45954
45988
  }
45989
+ /**
45990
+ * `device-export` — collection cap for addons that export camstack
45991
+ * devices to external ecosystems (HomeAssistant via MQTT discovery,
45992
+ * HomeKit/HAP, Alexa Smart Home, …).
45993
+ *
45994
+ * No `ecosystem` enum — the addon id identifies the export target.
45995
+ * Each addon owns its mapping logic in its own settings UI. The cap
45996
+ * exposes only the COMMON surface: link state, supported device
45997
+ * kinds (so the UI can filter the device picker), and per-device
45998
+ * expose/unexpose.
45999
+ *
46000
+ * INSTANCES. One export addon can serve several independent targets (a
46001
+ * HomeKit bridge, a Home Assistant broker). `listInstances` names them.
46002
+ * `instanceId` on a READ is optional: absent = the whole addon (linked if any
46003
+ * enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
46004
+ * default instance's); present = that instance; an id the provider does not
46005
+ * serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
46006
+ * never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
46007
+ * change always names the target it changes. A single-instance provider
46008
+ * accepts an absent id on a read or its own id, and refuses any other.
46009
+ */
46010
+ /** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
46011
+ var InstanceIdSchema$1 = string().min(1);
46012
+ var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
46013
+ /** One independent export target of an addon. */
46014
+ var ExportInstanceSchema = object({
46015
+ instanceId: InstanceIdSchema$1,
46016
+ name: string(),
46017
+ enabled: boolean(),
46018
+ kind: string().optional(),
46019
+ /**
46020
+ * What this instance's platform accepts as a device name, in one operator-facing sentence
46021
+ * (D1049). The derived "Name on <instance>" field shows it; absent = the field says nothing
46022
+ * about the rule.
46023
+ */
46024
+ nameRule: string().optional()
46025
+ });
46026
+ var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
46027
+ /** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
46028
+ var ExportInstanceUnknownError = class extends Error {
46029
+ code = EXPORT_INSTANCE_UNKNOWN;
46030
+ instanceId;
46031
+ constructor(addon, instanceId) {
46032
+ super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
46033
+ this.name = "ExportInstanceUnknownError";
46034
+ this.instanceId = instanceId;
46035
+ }
46036
+ };
46037
+ /**
46038
+ * The instance a `getStatus` call names. The cap's `status` block injects a per-device
46039
+ * `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
46040
+ * both shapes; only the second names an instance (a per-device status read is addon-wide).
46041
+ */
46042
+ function statusInstanceOf(input) {
46043
+ return "instanceId" in input ? input.instanceId : void 0;
46044
+ }
46045
+ var LinkStateSchema = _enum([
46046
+ "unlinked",
46047
+ "linked",
46048
+ "error"
46049
+ ]);
46050
+ /**
46051
+ * A single label/value row surfaced in the export panel's "Setup"
46052
+ * section. Rendered with a copy-to-clipboard button. `secret: true`
46053
+ * rows are masked by default with a reveal toggle (client ids,
46054
+ * secrets, …).
46055
+ */
46056
+ var ExportSetupFieldSchema = object({
46057
+ label: string(),
46058
+ value: string(),
46059
+ /** Mask the value by default + render a reveal toggle (client id, secrets). */
46060
+ secret: boolean().optional()
46061
+ });
46062
+ /**
46063
+ * Generic, addon-agnostic pairing/account block. Any export addon can
46064
+ * surface a scannable QR, a set of copyable label/value rows, and a
46065
+ * free-form operator note — the `DeviceExportPanel` renders whatever
46066
+ * the provider supplies and skips the section entirely when `setup`
46067
+ * is unset.
46068
+ */
46069
+ var ExportSetupSchema = object({
46070
+ /** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
46071
+ qr: string().optional(),
46072
+ /** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
46073
+ fields: array(ExportSetupFieldSchema).readonly().optional(),
46074
+ /** Free-form operator instructions rendered above the fields. */
46075
+ note: string().optional()
46076
+ });
46077
+ var DeviceExportStatusSchema = object({
46078
+ linkState: LinkStateSchema,
46079
+ exposedDeviceCount: number$1(),
46080
+ error: string().optional(),
46081
+ /**
46082
+ * Optional pairing/account info the panel renders in a generic
46083
+ * "Setup" section. Addon-agnostic — the addon id identifies the
46084
+ * export target, never an `ecosystem` key here.
46085
+ */
46086
+ setup: ExportSetupSchema.optional()
46087
+ });
46088
+ var DeviceKindSchema = string();
46089
+ /**
46090
+ * EXPOSED NAME. What one instance calls a device on its platform, when it should not be the
46091
+ * device's own name. The exporter owns it: it is stored per instance in the exporter's per-device
46092
+ * store (D865), validated by the exporter against its platform's naming rules, and never reaches
46093
+ * the exported id — a rename updates the SAME device on the platform, never a second one.
46094
+ * Blank or `null` = the device's own name. A name the platform would refuse is refused with
46095
+ * `ExportNameRefusedError` (`export-name-refused`), whose message says why.
46096
+ */
46097
+ var ExposedDeviceSchema = object({
46098
+ deviceId: string(),
46099
+ exposedAs: string().optional(),
46100
+ /** The operator's name for this device on this instance; absent = the device's own name. */
46101
+ exposedName: string().optional(),
46102
+ capabilities: array(string()).optional()
46103
+ });
46104
+ var ExposeInputSchema = object({
46105
+ instanceId: InstanceIdSchema$1,
46106
+ deviceId: string(),
46107
+ capabilities: array(string()).optional(),
46108
+ /** Set the exposed name in the same call; absent = leave it as it is, blank/null = clear it. */
46109
+ exposedName: string().nullable().optional()
46110
+ });
46111
+ var SetExposedNameInputSchema = object({
46112
+ instanceId: InstanceIdSchema$1,
46113
+ deviceId: string(),
46114
+ /** Blank or null = the device's own name. */
46115
+ name: string().nullable(),
46116
+ /**
46117
+ * Validate only: refuse exactly as a real call would, write nothing. A caller saving several
46118
+ * names at once checks every one first, so one refusal writes none (D1049).
46119
+ */
46120
+ dryRun: boolean().optional()
46121
+ });
46122
+ var EXPORT_NAME_REFUSED = "export-name-refused";
46123
+ /** A name the instance's platform would refuse. The message starts with the code, then the reason. */
46124
+ var ExportNameRefusedError = class extends Error {
46125
+ code = EXPORT_NAME_REFUSED;
46126
+ instanceId;
46127
+ reason;
46128
+ constructor(instanceId, reason) {
46129
+ super(`${EXPORT_NAME_REFUSED}: ${reason}`);
46130
+ this.name = "ExportNameRefusedError";
46131
+ this.instanceId = instanceId;
46132
+ this.reason = reason;
46133
+ }
46134
+ };
46135
+ var UnexposeInputSchema = object({
46136
+ instanceId: InstanceIdSchema$1,
46137
+ deviceId: string()
46138
+ });
46139
+ /**
46140
+ * What an exporter may expose besides devices (D968). An action and a
46141
+ * notification target are LIST ENTRIES, never devices (D954): they enter an
46142
+ * exporter's own selection, not the device registry.
46143
+ */
46144
+ var ExportEntityKindSchema = _enum([
46145
+ "device",
46146
+ "action",
46147
+ "notifier"
46148
+ ]);
46149
+ var ExportEntityRefSchema = discriminatedUnion("kind", [
46150
+ object({
46151
+ kind: literal("device"),
46152
+ deviceId: string()
46153
+ }),
46154
+ object({
46155
+ kind: literal("action"),
46156
+ actionId: string().min(1)
46157
+ }),
46158
+ object({
46159
+ kind: literal("notifier"),
46160
+ targetId: string().min(1)
46161
+ })
46162
+ ]);
46163
+ var ExposedEntitySchema = object({
46164
+ entity: ExportEntityRefSchema,
46165
+ exposedAs: string().optional()
46166
+ });
46167
+ var ExposeEntityInputSchema = object({
46168
+ instanceId: InstanceIdSchema$1,
46169
+ entity: ExportEntityRefSchema
46170
+ });
46171
+ var UnexposeEntityInputSchema = object({
46172
+ instanceId: InstanceIdSchema$1,
46173
+ entity: ExportEntityRefSchema
46174
+ });
46175
+ var deviceExportCapability = {
46176
+ name: "device-export",
46177
+ scope: "system",
46178
+ mode: "collection",
46179
+ providerKind: "device-export",
46180
+ status: {
46181
+ schema: DeviceExportStatusSchema,
46182
+ kind: "poll"
46183
+ },
46184
+ /**
46185
+ * Each export provider MAY contribute its own per-device "Export" panel
46186
+ * (enabled toggle, preferred stream, addon-specific knobs). The three
46187
+ * framework methods are mounted on the cap router when present.
46188
+ * `IDeviceExportProvider` leaves them optional: an exporter with no
46189
+ * per-device panel omits them (a `deviceConfig` cap's UI is derived and
46190
+ * never hand-written — D14 — and an exporter is not one of those).
46191
+ */
46192
+ exposesDeviceSettings: true,
46193
+ methods: {
46194
+ getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
46195
+ listInstances: method(_void(), array(ExportInstanceSchema)),
46196
+ listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
46197
+ listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
46198
+ exposeDevice: method(ExposeInputSchema, _void(), {
46199
+ kind: "mutation",
46200
+ auth: "admin"
46201
+ }),
46202
+ unexposeDevice: method(UnexposeInputSchema, _void(), {
46203
+ kind: "mutation",
46204
+ auth: "admin"
46205
+ }),
46206
+ setExposedName: method(SetExposedNameInputSchema, _void(), {
46207
+ kind: "mutation",
46208
+ auth: "admin"
46209
+ }),
46210
+ listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
46211
+ listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
46212
+ exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
46213
+ kind: "mutation",
46214
+ auth: "admin"
46215
+ }),
46216
+ unexposeEntity: optionalMethod(UnexposeEntityInputSchema, _void(), {
46217
+ kind: "mutation",
46218
+ auth: "admin"
46219
+ })
46220
+ }
46221
+ };
46222
+ /**
46223
+ * The exposed name of a device on one export instance (`device-export`, D1049).
46224
+ *
46225
+ * Every exporter keeps its names the same way: in ITS per-device store (D865), under
46226
+ * {@link EXPOSED_NAMES_STORE_KEY}, one entry per instance id. The store is cleared centrally
46227
+ * when the device is deleted, so no removal hook is needed for it. Each exporter supplies the
46228
+ * validator of its own platform; the normalisation, the store shape and the refusal are here so
46229
+ * the four exporters cannot drift apart.
46230
+ *
46231
+ * The name is a label only: no exporter derives the exported id from it, so a rename updates
46232
+ * the same device on the platform.
46233
+ */
46234
+ /** The per-device store key holding `{ [instanceId]: name }`. */
46235
+ var EXPOSED_NAMES_STORE_KEY = "exposedNames";
46236
+ var ExposedNamesSchema = record(string(), string());
46237
+ /** Trim and collapse whitespace, then the platform rule. Blank or null clears (`name: null`). */
46238
+ function checkExposedName(raw, validate) {
46239
+ if (raw === null || raw === void 0) return {
46240
+ ok: true,
46241
+ name: null
46242
+ };
46243
+ if (typeof raw !== "string") return {
46244
+ ok: false,
46245
+ reason: "The name must be text."
46246
+ };
46247
+ const name = raw.trim().replace(/\s+/g, " ");
46248
+ if (name.length === 0) return {
46249
+ ok: true,
46250
+ name: null
46251
+ };
46252
+ return validate(name);
46253
+ }
46254
+ /** Every saved name of a device, by instance id. A malformed blob reads as none. */
46255
+ function readExposedNames(store) {
46256
+ const parsed = ExposedNamesSchema.safeParse(store[EXPOSED_NAMES_STORE_KEY]);
46257
+ return parsed.success ? parsed.data : {};
46258
+ }
46259
+ /**
46260
+ * The saved name of one instance, or null: never saved, or a stored value the platform would
46261
+ * now refuse (the device's own name is used rather than pushing a name the platform rejects).
46262
+ */
46263
+ function readExposedName(store, instanceId, validate) {
46264
+ const saved = readExposedNames(store)[instanceId];
46265
+ if (saved === void 0) return null;
46266
+ const check = checkExposedName(saved, validate);
46267
+ return check.ok ? check.name : null;
46268
+ }
46269
+ /** The store patch that sets (or, with null, clears) one instance's name and keeps the others. */
46270
+ function exposedNamePatch(store, instanceId, name) {
46271
+ const others = Object.fromEntries(Object.entries(readExposedNames(store)).filter(([id]) => id !== instanceId));
46272
+ return { [EXPOSED_NAMES_STORE_KEY]: name === null ? others : {
46273
+ ...others,
46274
+ [instanceId]: name
46275
+ } };
46276
+ }
46277
+ /**
46278
+ * Validate and save one instance's name. A name the platform would refuse throws
46279
+ * {@link ExportNameRefusedError} BEFORE anything is written, so the old name stays.
46280
+ */
46281
+ async function saveExposedName(input) {
46282
+ const check = checkExposedName(input.raw, input.validate);
46283
+ if (!check.ok) throw new ExportNameRefusedError(input.instanceId, check.reason);
46284
+ if (input.dryRun === true) return {
46285
+ changed: false,
46286
+ name: check.name
46287
+ };
46288
+ const store = await input.store.read(input.deviceId);
46289
+ if ((readExposedNames(store)[input.instanceId] ?? null) === check.name) return {
46290
+ changed: false,
46291
+ name: check.name
46292
+ };
46293
+ await input.store.write(input.deviceId, exposedNamePatch(store, input.instanceId, check.name));
46294
+ return {
46295
+ changed: true,
46296
+ name: check.name
46297
+ };
46298
+ }
46299
+ /** The exporter's per-device store as an {@link ExposedNameStore}; throws when settings are absent. */
46300
+ function exposedNameStoreOf(settings, owner) {
46301
+ const access = () => {
46302
+ if (settings === void 0) throw new Error(`${owner}: settings are not available`);
46303
+ return settings;
46304
+ };
46305
+ return {
46306
+ read: (deviceId) => access().readDeviceStore(deviceId),
46307
+ write: (deviceId, patch) => access().writeDeviceStore(deviceId, patch)
46308
+ };
46309
+ }
46310
+ /**
46311
+ * Remove every name saved for `instanceId` (the instance was deleted), so a later instance that
46312
+ * reuses the id does not inherit them. Returns the device ids that lost a name. A store that
46313
+ * cannot be read throws; nothing is written for the devices not reached.
46314
+ */
46315
+ async function pruneExposedNames(settings, instanceId) {
46316
+ const ids = await settings.listDeviceStoreIds();
46317
+ if (ids.length === 0) return [];
46318
+ const pruned = [];
46319
+ for (const [deviceId, store] of await settings.readDeviceStoreBatch(ids)) {
46320
+ if (readExposedNames(store)[instanceId] === void 0) continue;
46321
+ await settings.writeDeviceStore(deviceId, exposedNamePatch(store, instanceId, null));
46322
+ pruned.push(deviceId);
46323
+ }
46324
+ return pruned;
46325
+ }
45955
46326
  _enum([
45956
46327
  "automation",
45957
46328
  "action",
@@ -50238,11 +50609,13 @@ var IrCodecError = class extends Error {
50238
50609
  this.code = code;
50239
50610
  }
50240
50611
  };
50612
+ /** Maximum number of mark/space entries one pulse train may carry. */
50613
+ var IR_TIMINGS_MAX = 1024;
50241
50614
  /**
50242
50615
  * A pulse train in signed microseconds: mark (+) first, then space (-), strictly
50243
50616
  * alternating, no zeros, 2..1024 entries.
50244
50617
  */
50245
- var IrTimingsSchema = array(number$1().int()).min(2).max(1024).superRefine((timings, ctx) => {
50618
+ var IrTimingsSchema = array(number$1().int()).min(2).max(IR_TIMINGS_MAX).superRefine((timings, ctx) => {
50246
50619
  timings.forEach((value, index) => {
50247
50620
  const expectMark = index % 2 === 0;
50248
50621
  if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
@@ -50289,15 +50662,186 @@ function decodePronto(code) {
50289
50662
  carrierHz: Math.round(1e6 / unitUs)
50290
50663
  };
50291
50664
  }
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
- })]);
50665
+ /**
50666
+ * FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
50667
+ * literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
50668
+ * is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
50669
+ * between the low 5 bits and the next byte.
50670
+ */
50671
+ var MAX_DISTANCE = 8192;
50672
+ var MAX_LITERAL_RUN = 32;
50673
+ var MIN_MATCH = 3;
50674
+ var MAX_MATCH = 264;
50675
+ /**
50676
+ * Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
50677
+ * can expand ~130x, so the decoder checks this bound before every write.
50678
+ */
50679
+ var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
50680
+ function fastlzDecompress(input) {
50681
+ const out = [];
50682
+ let ip = 0;
50683
+ const room = (count) => {
50684
+ if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
50685
+ };
50686
+ const next = () => {
50687
+ const byte = input[ip++];
50688
+ if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
50689
+ return byte;
50690
+ };
50691
+ while (ip < input.length) {
50692
+ const ctrl = next();
50693
+ if (ctrl < 32) {
50694
+ room(ctrl + 1);
50695
+ for (let i = 0; i <= ctrl; i++) out.push(next());
50696
+ continue;
50697
+ }
50698
+ let len = (ctrl >> 5) - 1;
50699
+ if (len === 6) len += next();
50700
+ const distance = ((ctrl & 31) << 8) + next() + 1;
50701
+ const start = out.length - distance;
50702
+ if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
50703
+ room(len + 3);
50704
+ for (let i = 0; i < len + 3; i++) {
50705
+ const byte = out[start + i];
50706
+ if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
50707
+ out.push(byte);
50708
+ }
50709
+ }
50710
+ return Uint8Array.from(out);
50711
+ }
50712
+ function fastlzCompress(input) {
50713
+ const out = [];
50714
+ const lastSeen = /* @__PURE__ */ new Map();
50715
+ let literalStart = 0;
50716
+ const flushLiterals = (end) => {
50717
+ for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
50718
+ const to = Math.min(from + MAX_LITERAL_RUN, end);
50719
+ out.push(to - from - 1);
50720
+ for (let i = from; i < to; i++) out.push(input[i] ?? 0);
50721
+ }
50722
+ };
50723
+ let pos = 0;
50724
+ while (pos < input.length) {
50725
+ let matchLen = 0;
50726
+ let matchDistance = 0;
50727
+ if (pos + MIN_MATCH <= input.length) {
50728
+ const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
50729
+ const candidate = lastSeen.get(key);
50730
+ lastSeen.set(key, pos);
50731
+ if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
50732
+ let len = 0;
50733
+ while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
50734
+ if (len >= MIN_MATCH) {
50735
+ matchLen = len;
50736
+ matchDistance = pos - candidate - 1;
50737
+ }
50738
+ }
50739
+ }
50740
+ if (matchLen === 0) {
50741
+ pos++;
50742
+ continue;
50743
+ }
50744
+ flushLiterals(pos);
50745
+ const enc = matchLen - 2;
50746
+ if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
50747
+ else out.push(224 | matchDistance >> 8, enc - 7);
50748
+ out.push(matchDistance & 255);
50749
+ pos += matchLen;
50750
+ literalStart = pos;
50751
+ }
50752
+ flushLiterals(input.length);
50753
+ return Uint8Array.from(out);
50754
+ }
50755
+ var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
50756
+ var MAX_DURATION_US = 65535;
50757
+ function toBase64(bytes) {
50758
+ let out = "";
50759
+ for (let i = 0; i < bytes.length; i += 3) {
50760
+ const a = bytes[i] ?? 0;
50761
+ const b = bytes[i + 1] ?? 0;
50762
+ const c = bytes[i + 2] ?? 0;
50763
+ const word = a << 16 | b << 8 | c;
50764
+ out += ALPHABET[word >> 18 & 63];
50765
+ out += ALPHABET[word >> 12 & 63];
50766
+ out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
50767
+ out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
50768
+ }
50769
+ return out;
50770
+ }
50771
+ function fromBase64(text) {
50772
+ const clean = text.trim().replace(/=+$/, "");
50773
+ if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
50774
+ const out = [];
50775
+ let bits = 0;
50776
+ let acc = 0;
50777
+ for (const ch of clean) {
50778
+ const value = ALPHABET.indexOf(ch);
50779
+ if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
50780
+ acc = acc << 6 | value;
50781
+ bits += 6;
50782
+ if (bits >= 8) {
50783
+ bits -= 8;
50784
+ out.push(acc >> bits & 255);
50785
+ }
50786
+ }
50787
+ return Uint8Array.from(out);
50788
+ }
50789
+ /** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
50790
+ function encodeTuya(timings) {
50791
+ const bytes = new Uint8Array(timings.length * 2);
50792
+ timings.forEach((value, index) => {
50793
+ const duration = Math.abs(value);
50794
+ if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
50795
+ bytes[index * 2] = duration & 255;
50796
+ bytes[index * 2 + 1] = duration >> 8;
50797
+ });
50798
+ return toBase64(fastlzCompress(bytes));
50799
+ }
50800
+ /** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
50801
+ function decodeTuya(code) {
50802
+ const bytes = fastlzDecompress(fromBase64(code));
50803
+ if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
50804
+ const timings = [];
50805
+ for (let i = 0; i < bytes.length; i += 2) {
50806
+ const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
50807
+ timings.push(i / 2 % 2 === 0 ? duration : -duration);
50808
+ }
50809
+ const checked = IrTimingsSchema.safeParse(timings);
50810
+ if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
50811
+ return checked.data;
50812
+ }
50813
+ /** Device-native IR code formats a transmitter can replay verbatim. */
50814
+ var IrNativeFormatSchema = _enum(["tuya"]);
50815
+ /**
50816
+ * Longest native code accepted: base64 of the worst-case compressed stream
50817
+ * (every decoded byte as a literal, plus one control byte per 32), with margin.
50818
+ */
50819
+ var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
50820
+ var IrNativeCodeSchema = object({
50821
+ format: IrNativeFormatSchema,
50822
+ code: string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
50823
+ });
50824
+ var IR_NATIVE_CODECS = { tuya: {
50825
+ encode: encodeTuya,
50826
+ decode: decodeTuya
50827
+ } };
50828
+ /** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
50829
+ var IrPayloadSchema = discriminatedUnion("kind", [
50830
+ object({
50831
+ kind: literal("raw"),
50832
+ timings: array(number$1().int()),
50833
+ settings: TransmitSettingsSchema.optional()
50834
+ }),
50835
+ object({
50836
+ kind: literal("pronto"),
50837
+ code: string()
50838
+ }),
50839
+ object({
50840
+ kind: literal("native"),
50841
+ format: IrNativeFormatSchema,
50842
+ code: string()
50843
+ })
50844
+ ]);
50301
50845
  /** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
50302
50846
  function toTimings(payload) {
50303
50847
  if (payload.kind === "pronto") {
@@ -50307,6 +50851,10 @@ function toTimings(payload) {
50307
50851
  settings: { carrierHz: decoded.carrierHz }
50308
50852
  };
50309
50853
  }
50854
+ if (payload.kind === "native") return {
50855
+ timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
50856
+ settings: {}
50857
+ };
50310
50858
  const checked = IrTimingsSchema.safeParse(payload.timings);
50311
50859
  if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
50312
50860
  return {
@@ -52391,193 +52939,6 @@ method(object({
52391
52939
  kind: "mutation",
52392
52940
  auth: "admin"
52393
52941
  });
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
52942
  var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
52582
52943
  var DeviceTemplateSchema = string().min(1).max(4096);
52583
52944
  /** One value a caller hands the renderer for `thisDevice`. */
@@ -56726,6 +57087,128 @@ var StateLookSchema = object({
56726
57087
  background: _enum(HERO_BACKGROUNDS),
56727
57088
  animation: HeroAnimationSchema
56728
57089
  });
57090
+ /** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
57091
+ var HeroTextSchema = object({
57092
+ en: string(),
57093
+ it: string()
57094
+ });
57095
+ /**
57096
+ * The ONE measurement a simple sensor shows (card wave, phase 1).
57097
+ *
57098
+ * A sensor that measures a single quantity (a temperature, a humidity, a power,
57099
+ * a contact, a text state) is drawn as that reading, once, big, inside a scene
57100
+ * whose motion says what the number means: heat rising when hot, flakes when
57101
+ * cold, a wire flowing at the speed of the power, a ring while a window is
57102
+ * open. Everything the card draws is decided here; a client only paints it.
57103
+ */
57104
+ var HERO_MEASUREMENT_QUANTITIES = [
57105
+ "temperature",
57106
+ "humidity",
57107
+ "power",
57108
+ "contact",
57109
+ "text"
57110
+ ];
57111
+ /** How a temperature reads to a person; drives the heat or the cold scene. */
57112
+ var HERO_MEASUREMENT_BANDS = [
57113
+ "hot",
57114
+ "mild",
57115
+ "cold"
57116
+ ];
57117
+ /** `updated` = the value was last read then ("2 min ago"); `changed` = it has held since then ("for 12 min"). */
57118
+ var HERO_MEASUREMENT_SINCE_KINDS = ["updated", "changed"];
57119
+ var HeroMeasurementReadingSchema = object({
57120
+ value: number$1(),
57121
+ quantity: ReadingQuantitySchema
57122
+ });
57123
+ var HeroMeasurementSchema = object({
57124
+ quantity: _enum(HERO_MEASUREMENT_QUANTITIES),
57125
+ reading: HeroMeasurementReadingSchema.nullable(),
57126
+ icon: IconKeySchema.nullable(),
57127
+ value: HeroTextSchema,
57128
+ unit: string().nullable(),
57129
+ band: _enum(HERO_MEASUREMENT_BANDS).nullable(),
57130
+ level: number$1().min(0).max(1).nullable(),
57131
+ word: HeroTextSchema,
57132
+ tone: _enum(HERO_TONES),
57133
+ since: number$1().nullable(),
57134
+ sinceKind: _enum(HERO_MEASUREMENT_SINCE_KINDS),
57135
+ historyKey: string().nullable()
57136
+ });
57137
+ var same$2 = (text) => t(text, text);
57138
+ var clamp01$1 = (n) => Math.min(1, Math.max(0, n));
57139
+ var trimmed = (n, digits) => String(Number(n.toFixed(digits)));
57140
+ function temperatureBand(celsius) {
57141
+ if (celsius < 12) return "cold";
57142
+ if (celsius > 28) return "hot";
57143
+ return "mild";
57144
+ }
57145
+ var BAND_WORD = {
57146
+ hot: t("Hot", "Caldo"),
57147
+ mild: t("Normal", "Normale"),
57148
+ cold: t("Cold", "Freddo")
57149
+ };
57150
+ var BAND_TONE = {
57151
+ hot: "warning",
57152
+ mild: "muted",
57153
+ cold: "info"
57154
+ };
57155
+ function temperatureMeasurement(celsius, since) {
57156
+ const band = temperatureBand(celsius);
57157
+ return {
57158
+ quantity: "temperature",
57159
+ reading: {
57160
+ value: celsius,
57161
+ quantity: "temperature"
57162
+ },
57163
+ icon: "thermometer",
57164
+ value: same$2(trimmed(celsius, 1)),
57165
+ unit: "°C",
57166
+ band,
57167
+ level: null,
57168
+ word: BAND_WORD[band],
57169
+ tone: BAND_TONE[band],
57170
+ since,
57171
+ sinceKind: "updated",
57172
+ historyKey: "cap:temperature-sensor.temperature"
57173
+ };
57174
+ }
57175
+ function humidityMeasurement(percent, since) {
57176
+ const dry = percent < 30;
57177
+ const humid = percent > 70;
57178
+ return {
57179
+ quantity: "humidity",
57180
+ reading: {
57181
+ value: percent,
57182
+ quantity: "humidity"
57183
+ },
57184
+ icon: "droplets",
57185
+ value: same$2(String(Math.round(percent))),
57186
+ unit: "%",
57187
+ band: null,
57188
+ level: clamp01$1(percent / 100),
57189
+ word: dry ? t("Dry", "Secco") : humid ? t("Humid", "Umido") : t("Normal", "Normale"),
57190
+ tone: dry || humid ? "warning" : "info",
57191
+ since,
57192
+ sinceKind: "updated",
57193
+ historyKey: "cap:humidity-sensor.humidity"
57194
+ };
57195
+ }
57196
+ function textMeasurement(text, since) {
57197
+ return {
57198
+ quantity: "text",
57199
+ reading: null,
57200
+ icon: null,
57201
+ value: same$2(text),
57202
+ unit: null,
57203
+ band: null,
57204
+ level: null,
57205
+ word: t("Changed", "Cambiato"),
57206
+ tone: "muted",
57207
+ since,
57208
+ sinceKind: "updated",
57209
+ historyKey: null
57210
+ };
57211
+ }
56729
57212
  /** The scene as the model carries it. `null` = the device did not say (never a guess). */
56730
57213
  var HeroSceneSchema = object({
56731
57214
  id: _enum([
@@ -56777,11 +57260,6 @@ var HeroSceneSchema = object({
56777
57260
  });
56778
57261
  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
57262
  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
- });
56785
57263
  var HeroRowIdSchema = _enum([
56786
57264
  "progress",
56787
57265
  "run-for",
@@ -56887,6 +57365,25 @@ var HeroControlSchema = discriminatedUnion("kind", [
56887
57365
  optionLabels: record(string(), HeroTextSchema).optional(),
56888
57366
  call: HeroCallSchema,
56889
57367
  valueArg: string()
57368
+ }),
57369
+ object({
57370
+ kind: literal("number"),
57371
+ id: string(),
57372
+ label: HeroTextSchema,
57373
+ value: number$1().nullable(),
57374
+ /** `null` = any number; the device rounds what it does not accept. */
57375
+ step: number$1().nullable(),
57376
+ unit: string(),
57377
+ call: HeroCallSchema,
57378
+ valueArg: string()
57379
+ }),
57380
+ object({
57381
+ kind: literal("text"),
57382
+ id: string(),
57383
+ label: HeroTextSchema,
57384
+ value: string().nullable(),
57385
+ call: HeroCallSchema,
57386
+ valueArg: string()
56890
57387
  })
56891
57388
  ]);
56892
57389
  /** 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 +57585,11 @@ var HeroModelSchema = object({
57088
57585
  timedRun: HeroTimedRunSlotSchema.nullable(),
57089
57586
  powerSupply: HeroPowerSupplySlotSchema.nullable(),
57090
57587
  rows: array(HeroRowSchema),
57588
+ /**
57589
+ * The ONE measurement of a simple sensor, drawn once inside the scene in place of
57590
+ * the caption, tiles and value chips. Absent = the card draws as before.
57591
+ */
57592
+ measurement: HeroMeasurementSchema.optional(),
57091
57593
  /** Ids of parts that actuate the device, hidden from a session that may not act on it. */
57092
57594
  gated: array(string()),
57093
57595
  provenance: array(HeroProvenanceSchema)
@@ -57159,8 +57661,23 @@ var HeroRowModelSchema = object({
57159
57661
  * the call. Absent or empty = `primary` alone.
57160
57662
  */
57161
57663
  extras: array(HeroControlSchema).max(2).optional(),
57162
- trailing: HeroFactSchema.nullable()
57664
+ trailing: HeroFactSchema.nullable(),
57665
+ /**
57666
+ * The simple sensor's one reading (the hero's `measurement`): the row draws its value
57667
+ * at the right, the unit small, the quantity's icon in the mini-scene. Absent = an
57668
+ * older server or a device that is not a simple sensor: draw `trailing`.
57669
+ */
57670
+ measurement: HeroMeasurementSchema.optional()
57163
57671
  });
57672
+ new Set([
57673
+ "temperature",
57674
+ "humidity",
57675
+ "pressure",
57676
+ "illuminance",
57677
+ "reading",
57678
+ "air-quality",
57679
+ "valve"
57680
+ ]);
57164
57681
  DeviceType.Climate;
57165
57682
  DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
57166
57683
  /**
@@ -57477,6 +57994,12 @@ var IntegrationLiteSchema = object({
57477
57994
  var AvailableIntegrationTypeSchema = object({
57478
57995
  addonId: string(),
57479
57996
  name: string(),
57997
+ /**
57998
+ * Product name a new integration is prefilled from (`<label> - Home`).
57999
+ * Absent: the client uses `name`. Set when the catalog title is not the
58000
+ * product (Bosch SHC, MQTT).
58001
+ */
58002
+ providerLabel: string().optional(),
57480
58003
  description: string(),
57481
58004
  iconUrl: string().nullable(),
57482
58005
  color: string(),
@@ -57988,13 +58511,32 @@ var IrSendResultSchema = object({
57988
58511
  var IrTransmitterInfoSchema = object({
57989
58512
  media: array(IrMediumSchema),
57990
58513
  settable: array(TransmitSettingKeySchema),
57991
- maxTimings: number$1().int().positive()
58514
+ maxTimings: number$1().int().positive(),
58515
+ /** The transmitter can learn a code (`learn`). */
58516
+ learn: boolean().default(false),
58517
+ /** Native code formats the transmitter replays verbatim (`send.native`). */
58518
+ formats: array(IrNativeFormatSchema).default([])
58519
+ });
58520
+ var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
58521
+ var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
58522
+ var IrLearnResultSchema = object({
58523
+ /** The code in the device's own format, when it reports one. */
58524
+ native: IrNativeCodeSchema.nullable(),
58525
+ timings: IrTimingsSchema,
58526
+ carrierHz: number$1().int().positive().nullable()
57992
58527
  });
57993
58528
  DeviceType.Generic, method(object({
57994
58529
  deviceId: number$1().int().nonnegative(),
57995
- timings: IrTimingsSchema,
58530
+ timings: IrTimingsSchema.optional(),
58531
+ native: IrNativeCodeSchema.optional(),
57996
58532
  settings: TransmitSettingsSchema.optional()
57997
- }), IrSendResultSchema, {
58533
+ }).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
58534
+ kind: "mutation",
58535
+ auth: "protected"
58536
+ }), method(object({
58537
+ deviceId: number$1().int().nonnegative(),
58538
+ timeoutMs: number$1().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
58539
+ }), IrLearnResultSchema, {
57998
58540
  kind: "mutation",
57999
58541
  auth: "protected"
58000
58542
  }), method(object({ deviceId: number$1().int().nonnegative() }), IrTransmitterInfoSchema, {
@@ -67217,6 +67759,7 @@ var NcSystemEventKindSchema = _enum([
67217
67759
  "recording-degraded",
67218
67760
  "device-attention-required",
67219
67761
  "device-attention-resolved",
67762
+ "device-command",
67220
67763
  "storage-location-low",
67221
67764
  "storage-location-critical",
67222
67765
  "storage-location-ok",
@@ -67279,11 +67822,6 @@ var NC_ALARM_SYSTEM_EVENT_KINDS = [
67279
67822
  "alarm-sensor-bypass",
67280
67823
  "alarm-disarmed"
67281
67824
  ];
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
67825
  var NcSystemEventConditionSchema = object({
67288
67826
  kinds: array(NcSystemEventKindSchema).min(1),
67289
67827
  deviceIds: array(number$1().int()).min(1).optional(),
@@ -67315,6 +67853,28 @@ var NcSystemEventConditionSchema = object({
67315
67853
  nodeIds: array(string().min(1)).min(1).optional(),
67316
67854
  packageNames: array(string().min(1)).min(1).optional(),
67317
67855
  /**
67856
+ * `device-command` only: the vocabulary ACTION IDS (D983, `powerSource.forceRestart`)
67857
+ * this rule speaks about - the same dictionary the automation action blocks
67858
+ * pick from. The hub refuses an id the action index does not know.
67859
+ */
67860
+ commandActions: array(string().min(1)).min(1).optional(),
67861
+ /** `device-command` only: how the command settled. A device's own change is not a command. */
67862
+ commandOutcomes: array(_enum([
67863
+ "confirmed",
67864
+ "already",
67865
+ "unconfirmed",
67866
+ "failed"
67867
+ ])).min(1).optional(),
67868
+ /** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
67869
+ commandActorKinds: array(_enum([
67870
+ "user",
67871
+ "addon",
67872
+ "action",
67873
+ "scheduler",
67874
+ "composition",
67875
+ "node"
67876
+ ])).min(1).optional(),
67877
+ /**
67318
67878
  * At or below this remaining-life %, a consumable is LOW for THIS rule
67319
67879
  * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
67320
67880
  * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
@@ -68295,6 +68855,13 @@ var NcRuleInputSchema = object({
68295
68855
  */
68296
68856
  groupingSec: number$1().int().min(5).max(60).optional(),
68297
68857
  /**
68858
+ * Hold deliveries of this rule to one target and, when two or more arrive
68859
+ * before the window ends, send them as one summary. Absent = the kind's
68860
+ * default (`groupWithinSecOf`): 5 s for a system-event rule, 0 for every
68861
+ * other kind. `0` sends each delivery as it does today.
68862
+ */
68863
+ groupWithinSec: number$1().int().min(0).max(300).optional(),
68864
+ /**
68298
68865
  * ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
68299
68866
  * carries "Correct" / "Wrong" buttons (and, where the channel has room, a
68300
68867
  * "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
@@ -68731,7 +69298,12 @@ var NcHistoryEntrySchema = object({
68731
69298
  * Assistant export) must render as "no image right now", never as a
68732
69299
  * broken link.
68733
69300
  */
68734
- artifactIds: array(string().min(1)).optional()
69301
+ artifactIds: array(string().min(1)).optional(),
69302
+ /**
69303
+ * When this row was folded into a group-window summary, the outbox id of
69304
+ * that one notification. Absent on a row that was sent as itself.
69305
+ */
69306
+ groupedInto: string().min(1).optional()
68735
69307
  });
68736
69308
  /**
68737
69309
  * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
@@ -74194,10 +74766,15 @@ var RecordingSignalStatusSchema = object({
74194
74766
  });
74195
74767
  RecordingSignalStatusSchema.extend({ lastFetchedAt: number$1() });
74196
74768
  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() }) });
74769
+ var RemoteBindingSchema = object({ action: object({
74770
+ kind: literal("cap"),
74771
+ deviceId: number$1().int().nonnegative(),
74772
+ cap: string().min(1),
74773
+ method: string().min(1),
74774
+ args: record(string(), unknown()).optional(),
74775
+ /** The unit the person picked per arg (display only); `args` always hold the cap's own unit. */
74776
+ argUnits: record(string(), string().min(1)).optional()
74777
+ }) });
74201
74778
  var RemoteCustomButtonSchema = object({
74202
74779
  /** The slug after `custom:` in the role. */
74203
74780
  key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
@@ -79631,6 +80208,13 @@ function contribution(cap, schema, build) {
79631
80208
  }
79632
80209
  };
79633
80210
  }
80211
+ /** The fragment, carrying the cap's single measurement when it has one. */
80212
+ function measured(fragment, measurement) {
80213
+ return measurement === void 0 ? fragment : {
80214
+ ...fragment,
80215
+ measurement
80216
+ };
80217
+ }
79634
80218
  function action(id, label, icon, cap, method, args = {}, emphasis = "normal", confirm = null) {
79635
80219
  return {
79636
80220
  id,
@@ -80905,10 +81489,26 @@ var controlContribution = contribution("control", ControlStatusSchema, (slice, c
80905
81489
  };
80906
81490
  });
80907
81491
  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. */
81492
+ /**
81493
+ * A number with known bounds is a slider, one without a number field, a choice a picker,
81494
+ * free text a text field; a date stays read-only.
81495
+ */
80909
81496
  function controlRows(slice) {
80910
81497
  if (slice.kind === "numeric" && typeof slice.value === "number") {
80911
- if (slice.min === void 0 || slice.max === void 0) return [];
81498
+ if (slice.min === void 0 || slice.max === void 0) return [row$1("control", "sliders-horizontal", null, [{
81499
+ kind: "number",
81500
+ id: "control.value",
81501
+ label: CONTROL_LABEL,
81502
+ value: slice.value,
81503
+ step: slice.step ?? null,
81504
+ unit: "",
81505
+ call: {
81506
+ cap: "control",
81507
+ method: "setValue",
81508
+ args: { control: { kind: "numeric" } }
81509
+ },
81510
+ valueArg: "control.value"
81511
+ }])];
80912
81512
  return [row$1("control", "sliders-horizontal", null, [{
80913
81513
  kind: "slider",
80914
81514
  id: "control.value",
@@ -80939,6 +81539,18 @@ function controlRows(slice) {
80939
81539
  },
80940
81540
  valueArg: "control.value"
80941
81541
  }])];
81542
+ if (slice.kind === "text") return [row$1("control", "sliders-horizontal", null, [{
81543
+ kind: "text",
81544
+ id: "control.value",
81545
+ label: CONTROL_LABEL,
81546
+ value: typeof slice.value === "string" ? slice.value : null,
81547
+ call: {
81548
+ cap: "control",
81549
+ method: "setValue",
81550
+ args: { control: { kind: "text" } }
81551
+ },
81552
+ valueArg: "control.value"
81553
+ }])];
80942
81554
  return [];
80943
81555
  }
80944
81556
  var SENSORS_FAMILY_CONTRIBUTIONS = {
@@ -81294,15 +81906,15 @@ function sensorFragment(value, id, icon, en, it, text) {
81294
81906
  tiles: { right: [tile$1(en, it, text)] }
81295
81907
  };
81296
81908
  }
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)}%`));
81909
+ 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)));
81910
+ 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
81911
  var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
81300
81912
  var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
81301
81913
  var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
81302
81914
  var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
81303
81915
  if (slice === void 0 || slice.value === "") return { reading: reading("sensor", "unknown") };
81304
81916
  if (slice.timestamp === true) return { reading: reading("sensor", "on") };
81305
- return sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value);
81917
+ return measured(sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value), textMeasurement(slice.value, slice.lastFetchedAt));
81306
81918
  });
81307
81919
  /** Index bands: the headline of an air-quality sensor is a word, not a number. */
81308
81920
  function airQualityWord(aqi) {
@@ -84198,6 +84810,13 @@ Object.freeze({
84198
84810
  access: "view",
84199
84811
  role: "admin"
84200
84812
  },
84813
+ "deviceExport.setExposedName": {
84814
+ capName: "device-export",
84815
+ capScope: "system",
84816
+ addonId: null,
84817
+ access: "create",
84818
+ role: "admin"
84819
+ },
84201
84820
  "deviceExport.unexposeDevice": {
84202
84821
  capName: "device-export",
84203
84822
  capScope: "system",
@@ -86137,6 +86756,13 @@ Object.freeze({
86137
86756
  access: "view",
86138
86757
  role: "viewer"
86139
86758
  },
86759
+ "irTransmitter.learn": {
86760
+ capName: "ir-transmitter",
86761
+ capScope: "device",
86762
+ addonId: null,
86763
+ access: "create",
86764
+ role: "viewer"
86765
+ },
86140
86766
  "irTransmitter.send": {
86141
86767
  capName: "ir-transmitter",
86142
86768
  capScope: "device",
@@ -92655,48 +93281,6 @@ Object.freeze({
92655
93281
  role: "admin"
92656
93282
  }
92657
93283
  });
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
93284
  DeviceFeature.BatteryOperated;
92701
93285
  function bound(cap, methods = [], authority = "reported") {
92702
93286
  return {
@@ -94013,6 +94597,11 @@ Object.freeze({
94013
94597
  form: "single",
94014
94598
  optional: false
94015
94599
  }],
94600
+ "irTransmitter.learn": [{
94601
+ name: "deviceId",
94602
+ form: "single",
94603
+ optional: false
94604
+ }],
94016
94605
  "irTransmitter.send": [{
94017
94606
  name: "deviceId",
94018
94607
  form: "single",
@@ -95952,7 +96541,10 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
95952
96541
  "deviceTypes",
95953
96542
  "nodeIds",
95954
96543
  "packageNames",
95955
- "consumableLowPercent"
96544
+ "consumableLowPercent",
96545
+ "commandActions",
96546
+ "commandOutcomes",
96547
+ "commandActorKinds"
95956
96548
  ];
95957
96549
  new Map(Object.entries({
95958
96550
  "device-online": "device-events",
@@ -95975,6 +96567,7 @@ new Map(Object.entries({
95975
96567
  "recording-degraded": "device-events",
95976
96568
  "device-attention-required": "device-events",
95977
96569
  "device-attention-resolved": "device-events",
96570
+ "device-command": "device-events",
95978
96571
  "node-online": "system",
95979
96572
  "node-offline": "system",
95980
96573
  "node-restarting": "system",
@@ -96075,6 +96668,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
96075
96668
  label: "Needs attention",
96076
96669
  kinds: ["device-attention-required", "device-attention-resolved"]
96077
96670
  },
96671
+ {
96672
+ id: "device-command",
96673
+ family: "device-events",
96674
+ label: "Commands given to devices",
96675
+ kinds: ["device-command"]
96676
+ },
96078
96677
  {
96079
96678
  id: "nodes",
96080
96679
  family: "system",
@@ -96152,6 +96751,15 @@ function systemEventKindsOfFamily(family) {
96152
96751
  return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
96153
96752
  }
96154
96753
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
96754
+ new Set([
96755
+ "alarm.trigger",
96756
+ "alarm.disarm",
96757
+ "alarm.arm.home",
96758
+ "alarm.arm.away",
96759
+ "alarm.arm.night",
96760
+ "alarm.arm.vacation",
96761
+ "alarm.arm.custom_bypass"
96762
+ ]);
96155
96763
  /**
96156
96764
  * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
96157
96765
  * persists (D640 "a sensor rule fires on the raise, the clear, or both").
@@ -96347,6 +96955,7 @@ var DEVICE_EVENTS = [
96347
96955
  "recording-healthy",
96348
96956
  "recording-degraded",
96349
96957
  ...DEVICE_ATTENTION,
96958
+ "device-command",
96350
96959
  ...ALARM
96351
96960
  ];
96352
96961
  /** Every kind a summary may speak about — the two summarisable families. */
@@ -96500,6 +97109,9 @@ var STATE_SUMMARY_VARS = [
96500
97109
  [...RULE_BODY_ONLY],
96501
97110
  [...RULE_TEXT],
96502
97111
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
97112
+ [...RULE_TEXT],
97113
+ [...RULE_TEXT],
97114
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
96503
97115
  ([...RULE_TEXT], [...COMBINED_ALARM]),
96504
97116
  ([...RULE_TEXT], [...COMBINED_ALARM]),
96505
97117
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
@@ -105727,6 +106339,133 @@ function pickSkill(skills, lookup) {
105727
106339
  return skills.find((s) => s.id === "export-alexa" && s.enabled) ?? null;
105728
106340
  }
105729
106341
  //#endregion
106342
+ //#region src/endpoints/alexa-name.ts
106343
+ /**
106344
+ * The Alexa naming rule (D875, amended by D1049): what a device may be called in Alexa.
106345
+ *
106346
+ * The name itself is the generic `device-export` exposed name (D1049): stored per skill
106347
+ * instance in this addon's per-device store, saved through `setExposedName`, and used as the
106348
+ * endpoint `friendlyName`. It never reaches the endpoint id (`<deviceId>__dev`), so renaming
106349
+ * updates the SAME Alexa device on the next AddOrUpdateReport instead of creating a duplicate.
106350
+ * This module holds only Amazon's rule, and the key of the retired Alexa-only name the
106351
+ * migration reads.
106352
+ *
106353
+ * Amazon's friendlyName rule (Alexa.Discovery objects, endpoint object): "Up
106354
+ * to 256 alphanumeric characters and spaces. Don't include special characters
106355
+ * or punctuation." Letters of any script count as alphanumeric, so an Italian
106356
+ * name keeps its accents. The validator rejects what Amazon would reject, with
106357
+ * a message the operator can act on.
106358
+ */
106359
+ /**
106360
+ * Per-device store key of the RETIRED Alexa-only name (one per device, shared by every skill).
106361
+ * Only the migration `export-alexa/2026-11-12-alexa-name-to-exposed-name` reads it.
106362
+ */
106363
+ var LEGACY_ALEXA_NAME_KEY = "alexaName";
106364
+ /** Amazon's rule, as the derived "Name on <skill>" field states it (D1049). */
106365
+ var ALEXA_NAME_RULE = `Amazon accepts letters, digits and spaces only (no punctuation), up to 256 characters.`;
106366
+ /** Letters (any script, with their combining marks), digits and spaces. */
106367
+ var ALLOWED_PATTERN = /^[\p{L}\p{M}\p{N} ]+$/u;
106368
+ /** Amazon's rule over a normalised, non-blank name. */
106369
+ var alexaNameValidator = (name) => {
106370
+ if (name.length > 256) return {
106371
+ ok: false,
106372
+ reason: `The Alexa name is ${name.length} characters; Amazon allows at most 256.`
106373
+ };
106374
+ if (!ALLOWED_PATTERN.test(name)) return {
106375
+ ok: false,
106376
+ reason: "The Alexa name may contain only letters, digits and spaces (Amazon rejects punctuation and special characters)."
106377
+ };
106378
+ return {
106379
+ ok: true,
106380
+ name
106381
+ };
106382
+ };
106383
+ /** Validate an operator-typed Alexa name. Blank clears it (`name: null`, the device name is used). */
106384
+ function validateAlexaName(raw) {
106385
+ return checkExposedName(raw, alexaNameValidator);
106386
+ }
106387
+ //#endregion
106388
+ //#region src/migrations/alexa-name-to-exposed-name.ts
106389
+ /**
106390
+ * The Alexa-only device name becomes the generic exposed name (D1049, amending D875).
106391
+ *
106392
+ * Before: one `alexaName` per device in this addon's per-device store (`addon-device-settings`,
106393
+ * row `export-alexa:<deviceId>.alexaName`), and every skill of the addon (planning#422) showed
106394
+ * it. After: the `device-export` exposed name of EVERY skill that exists, row
106395
+ * `export-alexa:<deviceId>.exposedNames` = `{ <skillId>: name, … }` — so each skill keeps calling
106396
+ * the device what it called it. A skill id that has no `skills` record (the default one on a hub
106397
+ * that never configured Alexa) gets nothing: no running skill would read it.
106398
+ *
106399
+ * One plan, so the copy and the delete commit together. A name is copied as Alexa read it
106400
+ * (normalised; a stored value Alexa would have refused was never used and is not copied). A name
106401
+ * already saved for a skill through the new field was saved by the build that reads it, so it is
106402
+ * never overwritten; the other skills of that device still get the old name. The legacy key is
106403
+ * deleted in every case: nothing reads it any more. A rerun finds no legacy key and does nothing.
106404
+ * A read that fails throws, nothing written.
106405
+ */
106406
+ var OWNER = "export-alexa";
106407
+ /** The per-device settings table: one row per field, id `<addonId>:<deviceId>.<field>`. */
106408
+ var DEVICE_SETTINGS_TABLE = "addon-device-settings";
106409
+ var rowId$3 = (deviceId, field) => `${OWNER}:${deviceId}.${field}`;
106410
+ var rowOf = (deviceId, field, value) => ({
106411
+ addonId: OWNER,
106412
+ deviceId: String(deviceId),
106413
+ key: field,
106414
+ value
106415
+ });
106416
+ /** The held `exposedNames` blob as a record, or `{}` when it is not one. */
106417
+ function heldNames(value) {
106418
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
106419
+ return Object.fromEntries(Object.entries(value));
106420
+ }
106421
+ async function planAlexaNameToExposedName(ports) {
106422
+ const ids = await ports.listDeviceIds();
106423
+ if (ids.length === 0) return { edits: [] };
106424
+ const legacy = await ports.readDeviceField(ids, LEGACY_ALEXA_NAME_KEY);
106425
+ if (legacy.size === 0) return { edits: [] };
106426
+ const skills = await ports.listSkillIds();
106427
+ const held = await ports.readDeviceField([...legacy.keys()], EXPOSED_NAMES_STORE_KEY);
106428
+ const written = {};
106429
+ const expected = {};
106430
+ const retired = {};
106431
+ for (const [deviceId, stored] of legacy) {
106432
+ retired[rowId$3(deviceId, LEGACY_ALEXA_NAME_KEY)] = rowOf(deviceId, LEGACY_ALEXA_NAME_KEY, stored);
106433
+ const check = validateAlexaName(stored);
106434
+ if (!check.ok || check.name === null) continue;
106435
+ if (skills.length === 0) {
106436
+ ports.warn(`Alexa migration: device ${deviceId} had an Alexa name but no Alexa skill exists; it is not kept`);
106437
+ continue;
106438
+ }
106439
+ const before = held.has(deviceId) ? heldNames(held.get(deviceId)) : null;
106440
+ const merged = { ...before };
106441
+ for (const skillId of skills) {
106442
+ if (skillId in merged) {
106443
+ ports.warn(`Alexa migration: device ${deviceId} already has a name on skill ${skillId}; its old Alexa name is not copied there`);
106444
+ continue;
106445
+ }
106446
+ merged[skillId] = check.name;
106447
+ }
106448
+ if (before !== null && Object.keys(merged).length === Object.keys(before).length) continue;
106449
+ const id = rowId$3(deviceId, EXPOSED_NAMES_STORE_KEY);
106450
+ written[id] = rowOf(deviceId, EXPOSED_NAMES_STORE_KEY, merged);
106451
+ expected[id] = before === null ? null : rowOf(deviceId, EXPOSED_NAMES_STORE_KEY, held.get(deviceId));
106452
+ }
106453
+ const edits = [];
106454
+ if (Object.keys(written).length > 0) edits.push({
106455
+ op: "setKeys",
106456
+ scope: DEVICE_SETTINGS_TABLE,
106457
+ values: written,
106458
+ precondition: preconditionOf(expected)
106459
+ });
106460
+ edits.push({
106461
+ op: "deleteKeys",
106462
+ scope: DEVICE_SETTINGS_TABLE,
106463
+ keys: Object.keys(retired),
106464
+ precondition: preconditionOf(retired)
106465
+ });
106466
+ return { edits };
106467
+ }
106468
+ //#endregion
105730
106469
  //#region src/migrations/drop-public-hub-url.ts
105731
106470
  /**
105732
106471
  * The hub's public URL is no longer a setting of this addon (planning#378): Alexa reads the
@@ -106326,6 +107065,7 @@ var EXPOSURE_TO_RECORD_ID = "export-alexa/2026-11-04-exposure-to-record";
106326
107065
  var DROP_MOVED_EXPOSURE_ID = "export-alexa/2026-11-04-drop-moved-exposure";
106327
107066
  var STATE_TO_INSTANCE_ID = "export-alexa/2026-11-04-state-to-instance";
106328
107067
  var DROP_MOVED_STATE_ID = "export-alexa/2026-11-04-drop-moved-state";
107068
+ var ALEXA_NAME_TO_EXPOSED_NAME_ID = "export-alexa/2026-11-12-alexa-name-to-exposed-name";
106329
107069
  var FIXTURE_MARK = "the endpoint sync state the migration does not know";
106330
107070
  /**
106331
107071
  * The `export-alexa` catalogue (D987): offered to the engine when the addon initialises. Every
@@ -106459,6 +107199,22 @@ var ADDON_MIGRATIONS = [
106459
107199
  fixtureMark: FIXTURE_MARK
106460
107200
  },
106461
107201
  plan: planDropMovedState
107202
+ },
107203
+ {
107204
+ meta: {
107205
+ id: ALEXA_NAME_TO_EXPOSED_NAME_ID,
107206
+ owner: "export-alexa",
107207
+ level: "addon-state",
107208
+ seq: 9,
107209
+ dependsOn: [],
107210
+ store: "settings",
107211
+ scope: "cluster",
107212
+ onFailure: "tolerate",
107213
+ bodyKind: "plan",
107214
+ description: "Copy every device`s Alexa name to the exposed name of every Alexa skill and delete the alexaName key",
107215
+ fixtureMark: FIXTURE_MARK
107216
+ },
107217
+ plan: planAlexaNameToExposedName
106462
107218
  }
106463
107219
  ];
106464
107220
  //#endregion
@@ -107326,72 +108082,33 @@ var AlexaEgressPrewarm = class {
107326
108082
  }
107327
108083
  };
107328
108084
  //#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;
108085
+ //#region src/exposed-name-rename.ts
108086
+ async function renameOnSkill(deps, deviceIdRaw, raw, options = {}) {
108087
+ const deviceId = Number.parseInt(deviceIdRaw, 10);
108088
+ if (!Number.isFinite(deviceId)) throw new Error(`export-alexa: deviceId must be numeric — got "${deviceIdRaw}"`);
108089
+ const saved = await saveExposedName({
108090
+ store: deps.store,
108091
+ deviceId,
108092
+ instanceId: deps.instanceId,
108093
+ raw,
108094
+ validate: alexaNameValidator,
108095
+ ...options.dryRun === true ? { dryRun: true } : {}
108096
+ });
108097
+ if (!saved.changed) return;
108098
+ deps.logger.info("export-alexa: Alexa name saved", {
108099
+ tags: { deviceId },
108100
+ meta: {
108101
+ instanceId: deps.instanceId,
108102
+ name: saved.name
108103
+ }
108104
+ });
108105
+ if (!deps.isExposed(deviceId)) return;
108106
+ deps.push(deviceId).catch((err) => {
108107
+ deps.logger.warn("export-alexa: push after an Alexa name change failed", {
108108
+ tags: { deviceId },
108109
+ meta: { error: err instanceof Error ? err.message : String(err) }
108110
+ });
108111
+ });
107395
108112
  }
107396
108113
  //#endregion
107397
108114
  //#region src/stream-preference.ts
@@ -110446,7 +111163,7 @@ var SkillRuntime = class {
110446
111163
  logger: this.ctx.logger,
110447
111164
  snapshots: this.view.snapshots,
110448
111165
  ...this.view.detectionSensors ? { detectionClasses: async (id) => effectiveSensorClasses(await classesOf(id), parseSensorSelection(await vision.readPrefs(id))) } : {},
110449
- alexaName: async (id) => readAlexaName(await vision.readPrefs(id)),
111166
+ alexaName: async (id) => readExposedName(await vision.readPrefs(id), this.instanceId, alexaNameValidator),
110450
111167
  ...this.view.objectDetection ? { objectDetection: async (id) => vision.buildClasses(id, await classesOf(id)) } : {}
110451
111168
  });
110452
111169
  }
@@ -110892,27 +111609,11 @@ var SkillRuntime = class {
110892
111609
  value: enabled,
110893
111610
  immediate: true
110894
111611
  },
110895
- ...opts.shared ? [await this.alexaNameField(deviceId, enabledKey)] : [],
110896
111612
  ...kind === "camera" ? this.cameraOnlyExportFields(deviceId, settings, enabledKey) : [],
110897
111613
  ...kind === "camera" && opts.shared ? await this.cameraDetectionFields(deviceId, enabledKey) : []
110898
111614
  ]
110899
111615
  };
110900
111616
  }
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
111617
  /**
110917
111618
  * The camera's detection fields: which classes become Alexa sensors (D778;
110918
111619
  * only the classes its pipeline produces are offered) and its object
@@ -110934,24 +111635,6 @@ var SkillRuntime = class {
110934
111635
  })];
110935
111636
  }
110936
111637
  /**
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
111638
  * Persist the camera's detection preferences from a device-settings patch
110956
111639
  * into this addon's per-device store. True when anything changed — the
110957
111640
  * camera's Alexa shape then needs a reconcile.
@@ -111002,15 +111685,32 @@ var SkillRuntime = class {
111002
111685
  }];
111003
111686
  }
111004
111687
  /**
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).
111688
+ * The device's own preferences in a patch (detection classes, object detection): shared by
111689
+ * every skill, so they are saved ONCE, before any skill applies its own part (an expose in
111690
+ * the same patch then builds with them).
111008
111691
  */
111009
111692
  async applySharedPrefs(deviceId, patch) {
111010
- return {
111011
- prefsChanged: await this.applyDetectionPrefsPatch(deviceId, patch),
111012
- nameChanged: await this.applyAlexaNamePatch(deviceId, patch)
111013
- };
111693
+ return { prefsChanged: await this.applyDetectionPrefsPatch(deviceId, patch) };
111694
+ }
111695
+ /** D1049: this skill's exposed name for a device, or null (the device's own name). */
111696
+ async exposedNameOf(deviceId) {
111697
+ return readExposedName(await this.vision.readPrefs(deviceId), this.instanceId, alexaNameValidator);
111698
+ }
111699
+ /**
111700
+ * D1049: save this skill's name for a device (`device-export.setExposedName`); an exposed
111701
+ * device is pushed again under the same endpoint id. `renameOnSkill` holds the rule.
111702
+ */
111703
+ async setExposedName(deviceIdRaw, raw, dryRun = false) {
111704
+ await renameOnSkill({
111705
+ instanceId: this.instanceId,
111706
+ store: {
111707
+ read: (id) => exposedNameStoreOf(this.ctx.settings, "export-alexa").read(id),
111708
+ write: (id, patch) => this.vision.writePrefs(id, patch)
111709
+ },
111710
+ logger: this.ctx.logger,
111711
+ isExposed: (id) => this.findEntry(id) !== null,
111712
+ push: (id) => this.requireSyncEngine().pushDevice(id)
111713
+ }, deviceIdRaw, raw, { dryRun });
111014
111714
  }
111015
111715
  /**
111016
111716
  * Apply this skill's part of a patch produced by the device-details "Export" panel. Flips
@@ -111023,7 +111723,7 @@ var SkillRuntime = class {
111023
111723
  * the new preference. See remaining-work notes in CLAUDE.md.
111024
111724
  */
111025
111725
  async applyEntryPatch(deviceId, patch, shared) {
111026
- const { prefsChanged, nameChanged } = shared;
111726
+ const { prefsChanged } = shared;
111027
111727
  const idStr = String(deviceId);
111028
111728
  const current = this.findEntry(deviceId);
111029
111729
  const wasEnabled = current !== null;
@@ -111052,12 +111752,6 @@ var SkillRuntime = class {
111052
111752
  const currentAllow = current?.settings?.allowTranscode !== false;
111053
111753
  await this.patchEntrySettings(deviceId, nextSettings);
111054
111754
  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
111755
  if (prefsChanged && !sourceChanged) this.requireSyncEngine().reconcileDevice(deviceId).catch((err) => {
111062
111756
  this.ctx.logger.warn("export-alexa: re-sync after a detection preference change failed", {
111063
111757
  tags: { deviceId },
@@ -111603,15 +112297,30 @@ var ExportAlexaAddon = class extends BaseAddon {
111603
112297
  instanceId: row.id,
111604
112298
  name: row.body.name,
111605
112299
  enabled: row.enabled,
111606
- kind: "alexa-skill"
112300
+ kind: "alexa-skill",
112301
+ nameRule: ALEXA_NAME_RULE
111607
112302
  }));
111608
112303
  },
111609
112304
  listSupportedDeviceKinds: async ({ instanceId }) => {
111610
112305
  ownInstance(instanceId);
111611
112306
  return [...SUPPORTED_KINDS];
111612
112307
  },
111613
- listExposedDevices: async ({ instanceId }) => ownInstance(instanceId).exposedDevices.map((e) => ({ deviceId: String(e.deviceId) })),
111614
- exposeDevice: async ({ instanceId, deviceId }) => ownInstance(instanceId).exposeDevice(deviceId),
112308
+ listExposedDevices: async ({ instanceId }) => {
112309
+ const runtime = ownInstance(instanceId);
112310
+ return Promise.all(runtime.exposedDevices.map(async (e) => {
112311
+ const exposedName = await runtime.exposedNameOf(e.deviceId);
112312
+ return {
112313
+ deviceId: String(e.deviceId),
112314
+ ...exposedName !== null ? { exposedName } : {}
112315
+ };
112316
+ }));
112317
+ },
112318
+ exposeDevice: async ({ instanceId, deviceId, exposedName }) => {
112319
+ const runtime = ownInstance(instanceId);
112320
+ if (exposedName !== void 0) await runtime.setExposedName(deviceId, exposedName);
112321
+ return runtime.exposeDevice(deviceId);
112322
+ },
112323
+ setExposedName: async ({ instanceId, deviceId, name, dryRun }) => ownInstance(instanceId).setExposedName(deviceId, name, dryRun === true),
111615
112324
  unexposeDevice: async ({ instanceId, deviceId }) => ownInstance(instanceId).unexposeDevice(deviceId),
111616
112325
  listSupportedEntityKinds: async () => ["device", "action"],
111617
112326
  listExposedEntities: async ({ instanceId }) => {
@@ -111739,6 +112448,7 @@ var ExportAlexaAddon = class extends BaseAddon {
111739
112448
  if (change === "deleted") {
111740
112449
  await this.stopRuntime(id);
111741
112450
  await this.deleteSkillRows(id);
112451
+ await this.pruneSkillNames(id);
111742
112452
  return;
111743
112453
  }
111744
112454
  const row = await this.requireInstances().readResolved(id);
@@ -111754,6 +112464,16 @@ var ExportAlexaAddon = class extends BaseAddon {
111754
112464
  await running.refreshRecords();
111755
112465
  await running.applyShapeSwitches();
111756
112466
  }
112467
+ /** A deleted skill's device names go too, so a skill that reuses the id inherits none (D1049). */
112468
+ async pruneSkillNames(id) {
112469
+ const settings = this.ctx.settings;
112470
+ if (settings === void 0) return;
112471
+ const pruned = await pruneExposedNames(settings, id);
112472
+ if (pruned.length > 0) this.ctx.logger.info("export-alexa: deleted skill names removed", { meta: {
112473
+ instanceId: id,
112474
+ devices: pruned.length
112475
+ } });
112476
+ }
111757
112477
  /** What a deleted skill leaves behind: its links, its exposure and its hidden state. */
111758
112478
  async deleteSkillRows(id) {
111759
112479
  await deleteSkillRows(this.requireHandles(), id);
@@ -111832,6 +112552,19 @@ var ExportAlexaAddon = class extends BaseAddon {
111832
112552
  readState: async () => (await stateHandle.getResolved("export-alexa"))?.data ?? null,
111833
112553
  clearIngressTokenSecret: async () => {
111834
112554
  await this.clearSecrets(["ingressToken"]);
112555
+ },
112556
+ listSkillIds: async () => (await this.requireInstances().listResolved()).map((r) => r.id),
112557
+ listDeviceIds: async () => {
112558
+ const settings = this.ctx.settings;
112559
+ if (settings === void 0) throw new Error("export-alexa: the settings store is unavailable");
112560
+ return settings.listDeviceStoreIds();
112561
+ },
112562
+ readDeviceField: async (deviceIds, field) => {
112563
+ const settings = this.ctx.settings;
112564
+ if (settings === void 0) throw new Error("export-alexa: the settings store is unavailable");
112565
+ const found = /* @__PURE__ */ new Map();
112566
+ for (const [deviceId, blob] of await settings.readDeviceStoreBatch(deviceIds)) if (field in blob) found.set(deviceId, blob[field]);
112567
+ return found;
111835
112568
  }
111836
112569
  };
111837
112570
  }