@camstack/addon-provider-homematic 1.2.181 → 1.2.183

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.mjs CHANGED
@@ -795,7 +795,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
795
795
  return EventCategory;
796
796
  }({});
797
797
  //#endregion
798
- //#region ../types/dist/device-type-CfHw_quR.mjs
798
+ //#region ../types/dist/device-type-D1fH5kaC.mjs
799
799
  /**
800
800
  import { errMsg } from '@camstack/types'
801
801
  * Extract a human-readable message from an unknown error value.
@@ -1026,6 +1026,12 @@ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
1026
1026
  DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
1027
1027
  /** Media player exposes stop distinct from pause. */
1028
1028
  DeviceFeature["MediaPlayerStop"] = "media-player-stop";
1029
+ /** Media player exposes volume up / down in steps (an infrared TV has no level). */
1030
+ DeviceFeature["MediaPlayerVolumeStep"] = "media-player-volume-step";
1031
+ /** Media player exposes channel up / down in steps. */
1032
+ DeviceFeature["MediaPlayerChannelStep"] = "media-player-channel-step";
1033
+ /** Media player exposes power on / off. */
1034
+ DeviceFeature["MediaPlayerPower"] = "media-player-power";
1029
1035
  /** Alarm panel requires a PIN code on arm/disarm. */
1030
1036
  DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
1031
1037
  /** Presence device carries GPS coordinates (lat/lng/accuracy) in
@@ -4562,6 +4568,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
4562
4568
  var booleanProcessor = (_schema, _ctx, json, _params) => {
4563
4569
  json.type = "boolean";
4564
4570
  };
4571
+ var bigintProcessor = (_schema, ctx, _json, _params) => {
4572
+ if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
4573
+ };
4574
+ var symbolProcessor = (_schema, ctx, _json, _params) => {
4575
+ if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
4576
+ };
4565
4577
  var nullProcessor = (_schema, ctx, json, _params) => {
4566
4578
  if (ctx.target === "openapi-3.0") {
4567
4579
  json.type = "string";
@@ -4569,12 +4581,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
4569
4581
  json.enum = [null];
4570
4582
  } else json.type = "null";
4571
4583
  };
4584
+ var undefinedProcessor = (_schema, ctx, _json, _params) => {
4585
+ if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
4586
+ };
4572
4587
  var voidProcessor = (_schema, ctx, _json, _params) => {
4573
4588
  if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
4574
4589
  };
4575
4590
  var neverProcessor = (_schema, _ctx, json, _params) => {
4576
4591
  json.not = {};
4577
4592
  };
4593
+ var anyProcessor = (_schema, _ctx, _json, _params) => {};
4594
+ var unknownProcessor = (_schema, _ctx, _json, _params) => {};
4578
4595
  var dateProcessor = (_schema, ctx, _json, _params) => {
4579
4596
  if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
4580
4597
  };
@@ -4606,12 +4623,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
4606
4623
  json.enum = vals;
4607
4624
  }
4608
4625
  };
4626
+ var nanProcessor = (_schema, ctx, _json, _params) => {
4627
+ if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
4628
+ };
4629
+ var templateLiteralProcessor = (schema, _ctx, json, _params) => {
4630
+ const _json = json;
4631
+ const pattern = schema._zod.pattern;
4632
+ if (!pattern) throw new Error("Pattern not found in template literal");
4633
+ _json.type = "string";
4634
+ _json.pattern = pattern.source;
4635
+ };
4636
+ var fileProcessor = (schema, _ctx, json, _params) => {
4637
+ const _json = json;
4638
+ const file = {
4639
+ type: "string",
4640
+ format: "binary",
4641
+ contentEncoding: "binary"
4642
+ };
4643
+ const { minimum, maximum, mime } = schema._zod.bag;
4644
+ if (minimum !== void 0) file.minLength = minimum;
4645
+ if (maximum !== void 0) file.maxLength = maximum;
4646
+ if (mime) if (mime.length === 1) {
4647
+ file.contentMediaType = mime[0];
4648
+ Object.assign(_json, file);
4649
+ } else {
4650
+ Object.assign(_json, file);
4651
+ _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
4652
+ }
4653
+ else Object.assign(_json, file);
4654
+ };
4655
+ var successProcessor = (_schema, _ctx, json, _params) => {
4656
+ json.type = "boolean";
4657
+ };
4609
4658
  var customProcessor = (_schema, ctx, _json, _params) => {
4610
4659
  if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4611
4660
  };
4661
+ var functionProcessor = (_schema, ctx, _json, _params) => {
4662
+ if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
4663
+ };
4612
4664
  var transformProcessor = (_schema, ctx, _json, _params) => {
4613
4665
  if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4614
4666
  };
4667
+ var mapProcessor = (_schema, ctx, _json, _params) => {
4668
+ if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
4669
+ };
4670
+ var setProcessor = (_schema, ctx, _json, _params) => {
4671
+ if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
4672
+ };
4615
4673
  var arrayProcessor = (schema, ctx, _json, params) => {
4616
4674
  const json = _json;
4617
4675
  const def = schema._zod.def;
@@ -4816,6 +4874,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
4816
4874
  seen.ref = def.innerType;
4817
4875
  json.readOnly = true;
4818
4876
  };
4877
+ var promiseProcessor = (schema, ctx, _json, params) => {
4878
+ const def = schema._zod.def;
4879
+ process$1(def.innerType, ctx, params);
4880
+ const seen = ctx.seen.get(schema);
4881
+ seen.ref = def.innerType;
4882
+ };
4819
4883
  var optionalProcessor = (schema, ctx, _json, params) => {
4820
4884
  const def = schema._zod.def;
4821
4885
  process$1(def.innerType, ctx, params);
@@ -4828,6 +4892,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
4828
4892
  const seen = ctx.seen.get(schema);
4829
4893
  seen.ref = innerType;
4830
4894
  };
4895
+ var allProcessors = {
4896
+ string: stringProcessor,
4897
+ number: numberProcessor,
4898
+ boolean: booleanProcessor,
4899
+ bigint: bigintProcessor,
4900
+ symbol: symbolProcessor,
4901
+ null: nullProcessor,
4902
+ undefined: undefinedProcessor,
4903
+ void: voidProcessor,
4904
+ never: neverProcessor,
4905
+ any: anyProcessor,
4906
+ unknown: unknownProcessor,
4907
+ date: dateProcessor,
4908
+ enum: enumProcessor,
4909
+ literal: literalProcessor,
4910
+ nan: nanProcessor,
4911
+ template_literal: templateLiteralProcessor,
4912
+ file: fileProcessor,
4913
+ success: successProcessor,
4914
+ custom: customProcessor,
4915
+ function: functionProcessor,
4916
+ transform: transformProcessor,
4917
+ map: mapProcessor,
4918
+ set: setProcessor,
4919
+ array: arrayProcessor,
4920
+ object: objectProcessor,
4921
+ union: unionProcessor,
4922
+ intersection: intersectionProcessor,
4923
+ tuple: tupleProcessor,
4924
+ record: recordProcessor,
4925
+ nullable: nullableProcessor,
4926
+ nonoptional: nonoptionalProcessor,
4927
+ default: defaultProcessor,
4928
+ prefault: prefaultProcessor,
4929
+ catch: catchProcessor,
4930
+ pipe: pipeProcessor,
4931
+ readonly: readonlyProcessor,
4932
+ promise: promiseProcessor,
4933
+ optional: optionalProcessor,
4934
+ lazy: lazyProcessor
4935
+ };
4936
+ function toJSONSchema(input, params) {
4937
+ if ("_idmap" in input) {
4938
+ const registry = input;
4939
+ const ctx = initializeContext({
4940
+ ...params,
4941
+ processors: allProcessors
4942
+ });
4943
+ const defs = {};
4944
+ for (const entry of registry._idmap.entries()) {
4945
+ const [_, schema] = entry;
4946
+ process$1(schema, ctx);
4947
+ }
4948
+ const schemas = {};
4949
+ ctx.external = {
4950
+ registry,
4951
+ uri: params?.uri,
4952
+ defs
4953
+ };
4954
+ for (const entry of registry._idmap.entries()) {
4955
+ const [key, schema] = entry;
4956
+ extractDefs(ctx, schema);
4957
+ schemas[key] = finalize(ctx, schema);
4958
+ }
4959
+ if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
4960
+ return { schemas };
4961
+ }
4962
+ const ctx = initializeContext({
4963
+ ...params,
4964
+ processors: allProcessors
4965
+ });
4966
+ process$1(input, ctx);
4967
+ extractDefs(ctx, input);
4968
+ return finalize(ctx, input);
4969
+ }
4831
4970
  //#endregion
4832
4971
  //#region ../../node_modules/zod/v4/classic/iso.js
4833
4972
  var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
@@ -5852,7 +5991,7 @@ var ZodIssueCode = {
5852
5991
  var ZodFirstPartyTypeKind;
5853
5992
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5854
5993
  //#endregion
5855
- //#region ../types/dist/sleep-QsoHs66J.mjs
5994
+ //#region ../types/dist/sleep-9TIHFj1w.mjs
5856
5995
  /**
5857
5996
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5858
5997
  * window to float samples (D455).
@@ -5931,6 +6070,22 @@ function buildAlawTable() {
5931
6070
  }
5932
6071
  buildUlawTable();
5933
6072
  buildAlawTable();
6073
+ /**
6074
+ * An addon whose own migrations did not apply refuses to initialise (D987). The error is typed
6075
+ * so a runner hosting several addons can tell "this addon is blocked" from a crash and keep its
6076
+ * co-located siblings running. Recognised by NAME and shape, never `instanceof`: a forked addon
6077
+ * bundles its own copy of this module, so the class the runner sees is not the one that threw.
6078
+ */
6079
+ var MIGRATIONS_BLOCKED_ERROR_NAME = "AddonMigrationsBlockedError";
6080
+ var AddonMigrationsBlockedError = class extends Error {
6081
+ /** The ledger ids that did not apply and block the owner. */
6082
+ migrationIds;
6083
+ constructor(migrationIds) {
6084
+ super(`migration(s) ${migrationIds.join(", ")} did not apply and block this addon — fix or retry them (migrations.retry), then restart it`);
6085
+ this.name = MIGRATIONS_BLOCKED_ERROR_NAME;
6086
+ this.migrationIds = migrationIds;
6087
+ }
6088
+ };
5934
6089
  /** Is this field's stored value a credential? */
5935
6090
  function isSecretConfigField(field) {
5936
6091
  if (field.type === "password") return true;
@@ -5984,9 +6139,16 @@ function isSecretMarker(value) {
5984
6139
  const ref = value["$secret"];
5985
6140
  return typeof ref === "string" && ref.length > 0;
5986
6141
  }
6142
+ /** Anything carrying a `$secret` key — a stored marker or a UI view of one. */
6143
+ function isSecretMarkerLike(value) {
6144
+ return isRecord$7(value) && Object.prototype.hasOwnProperty.call(value, "$secret");
6145
+ }
5987
6146
  function isSecretClear(value) {
5988
6147
  return isRecord$7(value) && value["$secretClear"] === true;
5989
6148
  }
6149
+ function isSecretFieldView(value) {
6150
+ return isRecord$7(value) && value["set"] === true && isSecretMarkerLike(value);
6151
+ }
5990
6152
  /**
5991
6153
  * The UI view of a stored secret field value: a marker becomes "set", inline
5992
6154
  * plaintext becomes "set (inline)", nothing becomes `null`. A value never
@@ -6368,6 +6530,53 @@ function emitReadiness(bus, params) {
6368
6530
  ts
6369
6531
  }));
6370
6532
  }
6533
+ /** Why a catalogue entry is not a runnable body of its declared kind. */
6534
+ var AddonMigrationDefinitionError = class extends Error {
6535
+ id;
6536
+ constructor(id, message) {
6537
+ super(`${id}: ${message}`);
6538
+ this.id = id;
6539
+ this.name = "AddonMigrationDefinitionError";
6540
+ }
6541
+ };
6542
+ /**
6543
+ * Bind a catalogue to the addon's ports. Throws {@link AddonMigrationDefinitionError} when
6544
+ * an entry's `bodyKind` does not match the body it carries, or is `sql` (a hub-only
6545
+ * body). A throwing body never escapes `execute`: it is reported as a failed result.
6546
+ */
6547
+ function defineAddonMigrations(catalogue, ports) {
6548
+ return catalogue.map((entry) => {
6549
+ const { meta } = entry;
6550
+ if ("plan" in entry) {
6551
+ if (meta.bodyKind !== "plan") throw new AddonMigrationDefinitionError(meta.id, `carries a plan body but declares "${meta.bodyKind}"`);
6552
+ return {
6553
+ meta,
6554
+ execute: () => guarded(async () => ({
6555
+ kind: "plan",
6556
+ plan: await entry.plan(ports)
6557
+ }))
6558
+ };
6559
+ }
6560
+ if (meta.bodyKind !== "procedure") throw new AddonMigrationDefinitionError(meta.id, `carries a procedure body but declares "${meta.bodyKind}"`);
6561
+ return {
6562
+ meta,
6563
+ execute: () => guarded(async () => ({
6564
+ kind: "procedure",
6565
+ result: await entry.procedure(ports)
6566
+ }))
6567
+ };
6568
+ });
6569
+ }
6570
+ async function guarded(work) {
6571
+ try {
6572
+ return await work();
6573
+ } catch (err) {
6574
+ return {
6575
+ kind: "failed",
6576
+ error: errMsg(err)
6577
+ };
6578
+ }
6579
+ }
6371
6580
  var NOT_RUN = {
6372
6581
  declared: false,
6373
6582
  snapshot: null,
@@ -6382,7 +6591,7 @@ var NOT_RUN = {
6382
6591
  * throws: an unreachable or refusing engine is logged and reported `declared: false`,
6383
6592
  * because the hub (and this addon's boot) must not hang on a migration.
6384
6593
  */
6385
- async function runAddonMigrations(host, migrations, logger) {
6594
+ async function runAddonMigrations(host, migrations, logger, options = {}) {
6386
6595
  const first = migrations[0];
6387
6596
  if (first === void 0) return NOT_RUN;
6388
6597
  const owner = first.meta.owner;
@@ -6411,7 +6620,9 @@ async function runAddonMigrations(host, migrations, logger) {
6411
6620
  else if (status === "blocked") blocked.push(id);
6412
6621
  else skipped.push(id);
6413
6622
  };
6623
+ const selected = options.only === void 0 ? null : new Set(options.only);
6414
6624
  for (const step of declaration.steps) {
6625
+ if (selected !== null && !selected.has(step.id)) continue;
6415
6626
  const bound = byId.get(step.id);
6416
6627
  if (bound === void 0 || step.action === "skip") {
6417
6628
  skipped.push(step.id);
@@ -6589,11 +6800,36 @@ function projectStore(store, perNodeKeys, nodeId) {
6589
6800
  }
6590
6801
  return out;
6591
6802
  }
6803
+ /**
6804
+ * The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
6805
+ *
6806
+ * A ref is DETERMINISTIC from where the value lives — the owner addon, the
6807
+ * scope (global, one node, one device, one integration, one row of a business
6808
+ * collection) and the field path inside that scope — so saving the same field
6809
+ * twice updates the same ref, and the ref itself says which settings blob
6810
+ * points at it. It is also the AAD of the value's ciphertext: a ciphertext
6811
+ * copied onto another ref does not decrypt.
6812
+ *
6813
+ * Array items are addressed by ITEM ID, never by index
6814
+ * (`providers[authentik].clientSecret`), so reordering a list keeps every ref.
6815
+ *
6816
+ * Pure and browser-safe: no node builtins, no I/O.
6817
+ */
6818
+ /** The URI scheme of every keychain ref. */
6819
+ var SECRET_REF_SCHEME = "secret://";
6592
6820
  var GLOBAL_SCOPE = { kind: "global" };
6593
6821
  /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6594
6822
  function globalSecretScope() {
6595
6823
  return GLOBAL_SCOPE;
6596
6824
  }
6825
+ /**
6826
+ * An addon id as a ref owner. A hub in-process builtin's context id is
6827
+ * `addon:<id>`; the owner of its secrets is `<id>`, exactly as for the same
6828
+ * addon running forked.
6829
+ */
6830
+ function normalizeSecretOwner(addonId) {
6831
+ return addonId.startsWith("addon:") ? addonId.slice(6) : addonId;
6832
+ }
6597
6833
  function encodeSegment(value) {
6598
6834
  return encodeURIComponent(value);
6599
6835
  }
@@ -6604,6 +6840,16 @@ function decodeSegment(value) {
6604
6840
  return null;
6605
6841
  }
6606
6842
  }
6843
+ /** The scope as it appears inside a ref (`global`, `node/<id>`, …). */
6844
+ function formatSecretScope(scope) {
6845
+ switch (scope.kind) {
6846
+ case "global": return "global";
6847
+ case "node": return `node/${encodeSegment(scope.nodeId)}`;
6848
+ case "device": return `device/${scope.deviceId}`;
6849
+ case "integration": return `integration/${encodeSegment(scope.integrationId)}`;
6850
+ case "row": return `row/${encodeSegment(scope.collection)}/${encodeSegment(scope.rowId)}`;
6851
+ }
6852
+ }
6607
6853
  /**
6608
6854
  * The field path of a value inside an array item, addressed by the item's id:
6609
6855
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6612,6 +6858,13 @@ function decodeSegment(value) {
6612
6858
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6613
6859
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6614
6860
  }
6861
+ /** Build a ref. Throws on an empty owner or field path — both are bugs. */
6862
+ function buildSecretRef(parts) {
6863
+ const owner = normalizeSecretOwner(parts.owner);
6864
+ if (owner.length === 0) throw new Error("buildSecretRef: owner is empty");
6865
+ if (parts.fieldPath.length === 0) throw new Error("buildSecretRef: fieldPath is empty");
6866
+ return `${SECRET_REF_SCHEME}${encodeSegment(owner)}/${formatSecretScope(parts.scope)}/${parts.fieldPath}`;
6867
+ }
6615
6868
  function parseScope(segments) {
6616
6869
  switch (segments[0]) {
6617
6870
  case "global": return {
@@ -7529,15 +7782,19 @@ var BaseAddon = class {
7529
7782
  * nothing; the boot continues. A migration that FAILED (or was blocked by one)
7530
7783
  * and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
7531
7784
  * serve data whose shape it cannot trust; `tolerate` migrations never do.
7785
+ *
7786
+ * ALWAYS pass the whole catalogue; a phase that must run only some of it passes
7787
+ * `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
7788
+ * omitted applied ids "newer").
7532
7789
  */
7533
- async runMigrations(migrations) {
7790
+ async runMigrations(migrations, options) {
7534
7791
  const api = this.ctx.api.migrations;
7535
7792
  const report = await runAddonMigrations({
7536
7793
  declareOwner: (input) => api.declareOwner.mutate(input),
7537
7794
  startMigration: (input) => api.startMigration.mutate(input),
7538
7795
  finishMigration: (input) => api.finishMigration.mutate(input)
7539
- }, migrations, this.ctx.logger);
7540
- if (report.blockOwner.length > 0) throw new Error(`migration(s) ${report.blockOwner.join(", ")} did not apply and block this addon — fix or retry them (migrations.retry), then restart it`);
7796
+ }, migrations, this.ctx.logger, options);
7797
+ if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
7541
7798
  return report;
7542
7799
  }
7543
7800
  /**
@@ -7678,10 +7935,9 @@ var BaseAddon = class {
7678
7935
  *
7679
7936
  * Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
7680
7937
  * needs its connection fields, the default integration the addon's own sections. It is the
7681
- * SHAPE of the form only — the values live in `integrations.getSettings`, and the write path is
7682
- * unchanged (`integrations.setSettings` for an account integration).
7938
+ * SHAPE of the form only — the values live on the instance record.
7683
7939
  */
7684
- async integrationSettingsSchema(_instance) {
7940
+ async integrationFormSchema(_instance) {
7685
7941
  return null;
7686
7942
  }
7687
7943
  /**
@@ -7727,7 +7983,7 @@ var BaseAddon = class {
7727
7983
  * per-instance schema when it declares one, else its global schema (what they always showed).
7728
7984
  */
7729
7985
  async getIntegrationFormSchema(instance, nodeId) {
7730
- const scoped = await this.integrationSettingsSchema(instance);
7986
+ const scoped = await this.integrationFormSchema(instance);
7731
7987
  if (scoped === null) return this.getGlobalSettings(void 0, void 0, nodeId);
7732
7988
  return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
7733
7989
  }
@@ -7877,6 +8133,10 @@ var BaseAddon = class {
7877
8133
  const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7878
8134
  const patch = {};
7879
8135
  for (const key of keys) {
8136
+ if (tree.get(key)?.kind === "array") {
8137
+ patch[key] = [];
8138
+ continue;
8139
+ }
7880
8140
  const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7881
8141
  patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7882
8142
  }
@@ -8516,6 +8776,45 @@ function normalizeAddonInitResult(result) {
8516
8776
  if (Array.isArray(result)) return { providers: result };
8517
8777
  return result;
8518
8778
  }
8779
+ var PREFIX = "records/";
8780
+ /** The base of every records failure. `detail` is the human part of the message. */
8781
+ var RecordsError = class extends Error {
8782
+ code;
8783
+ detail;
8784
+ constructor(code, detail) {
8785
+ super(`${PREFIX}${code}: ${detail}`);
8786
+ this.name = "RecordsError";
8787
+ this.code = code;
8788
+ this.detail = detail;
8789
+ }
8790
+ };
8791
+ /** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
8792
+ var RevConflictError = class extends RecordsError {
8793
+ constructor(detail) {
8794
+ super("rev-conflict", detail);
8795
+ this.name = "RevConflictError";
8796
+ }
8797
+ };
8798
+ /** The keychain could not store or serve a value: explicit, never an empty string. */
8799
+ var RecordSecretUnavailableError = class extends RecordsError {
8800
+ constructor(detail) {
8801
+ super("secret-unavailable", detail);
8802
+ this.name = "RecordSecretUnavailableError";
8803
+ }
8804
+ };
8805
+ var InvalidRecordError = class extends RecordsError {
8806
+ constructor(detail) {
8807
+ super("invalid-record", detail);
8808
+ this.name = "InvalidRecordError";
8809
+ }
8810
+ };
8811
+ /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
8812
+ var DeclarationRefusedError = class extends RecordsError {
8813
+ constructor(detail) {
8814
+ super("declaration-refused", detail);
8815
+ this.name = "DeclarationRefusedError";
8816
+ }
8817
+ };
8519
8818
  /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
8520
8819
  /** The files a kind may live in. `history` is device-history's (D850), never records. */
8521
8820
  var RECORD_DATABASES = ["settings", "events"];
@@ -8531,6 +8830,183 @@ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
8531
8830
  var RECORD_MAX_DATA_BYTES = 1024 * 1024;
8532
8831
  var RECORD_BATCH_MAX = 1e3;
8533
8832
  var RECORD_QUERY_MAX = 1e3;
8833
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
8834
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
8835
+ /** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
8836
+ var RECORD_SECRET_COLLECTION_PREFIX = "records:";
8837
+ /**
8838
+ * Secret fields of a record, addressed the way a Zod schema declares them
8839
+ * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
8840
+ * (`auth.accessToken`, `headers[].value`).
8841
+ *
8842
+ * `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
8843
+ * names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
8844
+ * key releases exactly that key's secret.
8845
+ *
8846
+ * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
8847
+ * `{ headers: 'name' }`), never by index, so reordering a list keeps every
8848
+ * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
8849
+ * leaf names its element: `headers[X-Api].value`.
8850
+ *
8851
+ * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
8852
+ */
8853
+ /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
8854
+ function parseSecretPath(path) {
8855
+ if (path.length === 0) throw new InvalidRecordError("an empty secret path");
8856
+ return path.split(".").map((raw) => {
8857
+ const each = raw.endsWith("[]");
8858
+ const map = raw.endsWith("{}");
8859
+ const key = each || map ? raw.slice(0, -2) : raw;
8860
+ if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
8861
+ return {
8862
+ key,
8863
+ each,
8864
+ map
8865
+ };
8866
+ });
8867
+ }
8868
+ /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
8869
+ function secretArrayPrefixes(path) {
8870
+ const segments = parseSecretPath(path);
8871
+ const prefixes = [];
8872
+ const walked = [];
8873
+ for (const segment of segments) {
8874
+ walked.push(segment.key);
8875
+ if (segment.each) prefixes.push(walked.join("."));
8876
+ }
8877
+ return prefixes;
8878
+ }
8879
+ function isRecord$4(value) {
8880
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8881
+ }
8882
+ function elementId(element, idKey, declared, prefix) {
8883
+ const id = isRecord$4(element) ? element[idKey] : void 0;
8884
+ if (typeof id !== "string" || id.length === 0) throw new InvalidRecordError(`"${declared}": every element of "${prefix}" needs a non-empty string "${idKey}" to carry a secret`);
8885
+ return id;
8886
+ }
8887
+ /**
8888
+ * Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
8889
+ * visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
8890
+ * result is a new body, `data` is untouched.
8891
+ */
8892
+ var REMOVE_LEAF = Symbol("remove-leaf");
8893
+ function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
8894
+ if (!isRecord$4(node)) return node;
8895
+ const segment = segments[index];
8896
+ if (segment === void 0) return node;
8897
+ if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
8898
+ const child = node[segment.key];
8899
+ const keys = [...walkedKeys, segment.key];
8900
+ const last = index === segments.length - 1;
8901
+ if (segment.each) {
8902
+ if (!Array.isArray(child)) return node;
8903
+ const prefix = keys.join(".");
8904
+ const idKey = arrayKeys[prefix];
8905
+ if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
8906
+ const mapped = child.map((element) => {
8907
+ const id = elementId(element, idKey, declared, prefix);
8908
+ const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
8909
+ return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
8910
+ });
8911
+ return {
8912
+ ...node,
8913
+ [segment.key]: mapped
8914
+ };
8915
+ }
8916
+ if (segment.map) {
8917
+ if (!isRecord$4(child)) return node;
8918
+ const kept = Object.entries(child).map(([mapKey, value]) => {
8919
+ const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
8920
+ if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
8921
+ return [mapKey, visit({
8922
+ declared,
8923
+ concrete,
8924
+ value
8925
+ })];
8926
+ }).filter(([, value]) => value !== REMOVE_LEAF);
8927
+ return {
8928
+ ...node,
8929
+ [segment.key]: Object.fromEntries(kept)
8930
+ };
8931
+ }
8932
+ const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
8933
+ if (last) {
8934
+ const replacement = visit({
8935
+ declared,
8936
+ concrete,
8937
+ value: child
8938
+ });
8939
+ if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
8940
+ return {
8941
+ ...node,
8942
+ [segment.key]: replacement
8943
+ };
8944
+ }
8945
+ return {
8946
+ ...node,
8947
+ [segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
8948
+ };
8949
+ }
8950
+ /** Replace/remove every present secret leaf; returns a NEW body. */
8951
+ function mapSecretLeaves(data, paths, arrayKeys, visit) {
8952
+ let current = data;
8953
+ for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
8954
+ return current;
8955
+ }
8956
+ /** Every present secret leaf, read-only. */
8957
+ function collectSecretLeaves(data, paths, arrayKeys) {
8958
+ const found = [];
8959
+ mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
8960
+ found.push(leaf);
8961
+ return leaf.value;
8962
+ });
8963
+ return found;
8964
+ }
8965
+ /**
8966
+ * The keychain collection name a kind's secrets live under. Prefixed so a
8967
+ * record's refs never collide with the refs a legacy collection of the same name
8968
+ * already holds during an adoption.
8969
+ */
8970
+ function recordSecretCollection(kind) {
8971
+ return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
8972
+ }
8973
+ /** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
8974
+ function recordSecretRef(owner, kind, rowId, concretePath) {
8975
+ return buildSecretRef({
8976
+ owner,
8977
+ scope: {
8978
+ kind: "row",
8979
+ collection: recordSecretCollection(kind),
8980
+ rowId
8981
+ },
8982
+ fieldPath: concretePath
8983
+ });
8984
+ }
8985
+ /**
8986
+ * A stored secret, as an admin read shows it: a VIEW naming the row's own
8987
+ * keychain ref (`set: true`), never the value and no longer the bare redaction
8988
+ * token. The form hands it to the secret field, which reveals the value by ref
8989
+ * through the audited `keychain-admin.reveal`; sent back untouched it keeps the
8990
+ * stored secret (the records door reads a view as KEEP).
8991
+ *
8992
+ * ONE implementation for the entries service and for every addon that serves
8993
+ * its own instances (`RecordIntegrationInstances`).
8994
+ */
8995
+ function isRecord$3(value) {
8996
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8997
+ }
8998
+ function secretViewsOf(owner, kind, id, decl, data) {
8999
+ if (decl.secretPaths.length === 0) return data;
9000
+ const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
9001
+ if (leaf.value !== "__camstack_redacted__") return leaf.value;
9002
+ return {
9003
+ $secret: recordSecretRef(owner, kind, id, leaf.concrete),
9004
+ v: 1,
9005
+ set: true
9006
+ };
9007
+ });
9008
+ return isRecord$3(shown) ? shown : data;
9009
+ }
8534
9010
  /**
8535
9011
  * The share-view scope kinds a share-link token can carry. The hub mints
8536
9012
  * and validates them (`ShareViewGrantSchema` builds its
@@ -8603,7 +9079,8 @@ function isZodSecret(schema) {
8603
9079
  }
8604
9080
  /**
8605
9081
  * Every declared secret path in a config schema: dotted keys, `[]` for "each
8606
- * element of this array" (`connection.password`, `rows[].token`). A declared
9082
+ * element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
9083
+ * map" (`applianceSecrets{}`). A declared
8607
9084
  * object or array is reported as one path and not descended into — everything
8608
9085
  * under it is secret.
8609
9086
  */
@@ -8614,6 +9091,7 @@ function collectZodSecretPaths(schema, prefix = "") {
8614
9091
  const def = defOf(layer);
8615
9092
  if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8616
9093
  else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
9094
+ else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
8617
9095
  else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8618
9096
  else if (def.type === "intersection") {
8619
9097
  if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
@@ -8688,6 +9166,126 @@ var RecordKindDeclarationSchema = object({
8688
9166
  }).strict();
8689
9167
  /** The kind names: lower-case, dash separated, short enough for an index name. */
8690
9168
  var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
9169
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
9170
+ function assertValidDeclaration(name, decl) {
9171
+ const refuse = (why) => {
9172
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
9173
+ };
9174
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
9175
+ const seen = /* @__PURE__ */ new Set();
9176
+ for (const index of decl.indexes) {
9177
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
9178
+ seen.add(index.name);
9179
+ }
9180
+ const { retention } = decl;
9181
+ const hasSecrets = decl.secretPaths.length > 0;
9182
+ if ("ttlMs" in retention) {
9183
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
9184
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
9185
+ }
9186
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
9187
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
9188
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
9189
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
9190
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
9191
+ if (decl.database === "settings" && bound > 5e4) refuse(`a row bound above ${RECORD_SETTINGS_MAX_ROWS} belongs in database: "events" (a big delete on the settings thread stalls every configuration read)`);
9192
+ }
9193
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
9194
+ for (const path of decl.secretPaths) for (const prefix of secretArrayPrefixes(path)) if (decl.secretArrayKeys[prefix] === void 0) refuse(`secret path "${path}" crosses the array "${prefix}": declare its id key in secretArrayKeys`);
9195
+ }
9196
+ function bodyFieldsOf(schema) {
9197
+ return { ...toJSONSchema(schema, {
9198
+ unrepresentable: "any",
9199
+ io: "input"
9200
+ }) };
9201
+ }
9202
+ function isRecordLike(value) {
9203
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9204
+ }
9205
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
9206
+ function hasNameField(json, field) {
9207
+ const branches = json["oneOf"] ?? json["anyOf"];
9208
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
9209
+ const properties = json["properties"];
9210
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
9211
+ }
9212
+ /**
9213
+ * Declare the kinds of a package. The keys are the kind names. The result is
9214
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
9215
+ * types its handle from.
9216
+ */
9217
+ function defineRecordKinds(specs) {
9218
+ const out = {};
9219
+ for (const [name, spec] of Object.entries(specs)) {
9220
+ const secretPaths = collectZodSecretPaths(spec.schema);
9221
+ const nameField = spec.entry?.nameField ?? "name";
9222
+ const fields = bodyFieldsOf(spec.schema);
9223
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
9224
+ const parsed = RecordKindDeclarationSchema.parse({
9225
+ database: spec.database,
9226
+ class: spec.class,
9227
+ writeTrigger: spec.writeTrigger,
9228
+ device: spec.device,
9229
+ at: spec.at,
9230
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
9231
+ retention: spec.retention,
9232
+ deviceRemoval: spec.deviceRemoval,
9233
+ maxDataBytes: spec.maxDataBytes,
9234
+ secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
9235
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
9236
+ transactFamily: spec.transactFamily,
9237
+ entry: spec.entry === void 0 ? void 0 : {
9238
+ title: spec.entry.title,
9239
+ nameField,
9240
+ fields
9241
+ }
9242
+ });
9243
+ assertValidDeclaration(name, parsed);
9244
+ out[name] = {
9245
+ name,
9246
+ schema: spec.schema,
9247
+ declaration: parsed
9248
+ };
9249
+ }
9250
+ return out;
9251
+ }
9252
+ /**
9253
+ * Entry kinds (D881): every list of user-created entries (notification
9254
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
9255
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
9256
+ * through the `record-entries` capability with password fields derived from
9257
+ * the schema (`.meta({ secret: true })`).
9258
+ */
9259
+ /** The body of a plain entry: a name and the fields the kind adds. */
9260
+ function entryBody(shape) {
9261
+ return object({
9262
+ name: string().min(1),
9263
+ ...shape
9264
+ });
9265
+ }
9266
+ /**
9267
+ * Declare one entry kind. An entry is configuration: never trimmed by the
9268
+ * engine, never aged, belonging to no device.
9269
+ */
9270
+ function defineEntryKind(name, spec) {
9271
+ const defined = defineRecordKinds({ [name]: {
9272
+ schema: spec.schema,
9273
+ class: "config",
9274
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
9275
+ retention: { none: "an entry goes only when the operator deletes it" },
9276
+ ...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
9277
+ ...spec.database === void 0 ? {} : { database: spec.database },
9278
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
9279
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
9280
+ ...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
9281
+ entry: {
9282
+ title: spec.title,
9283
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
9284
+ }
9285
+ } })[name];
9286
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
9287
+ return defined;
9288
+ }
8691
9289
  object({
8692
9290
  field: string().min(1),
8693
9291
  on: literal("advance")
@@ -9383,6 +9981,7 @@ var CAP_NAMES = Object.freeze([
9383
9981
  "backup",
9384
9982
  "battery",
9385
9983
  "binary",
9984
+ "board-key-source",
9386
9985
  "brightness",
9387
9986
  "broker",
9388
9987
  "button",
@@ -9504,6 +10103,7 @@ var CAP_NAMES = Object.freeze([
9504
10103
  "privacy-mask",
9505
10104
  "ptz",
9506
10105
  "ptz-autotrack",
10106
+ "pump-cycle",
9507
10107
  "reboot",
9508
10108
  "record-entries",
9509
10109
  "recording",
@@ -10796,18 +11396,6 @@ Object.freeze({
10796
11396
  "path": "pumpRunning",
10797
11397
  "valueType": "boolean"
10798
11398
  },
10799
- {
10800
- "path": "pumpIntervalEnabled",
10801
- "valueType": "boolean"
10802
- },
10803
- {
10804
- "path": "pumpOnTime",
10805
- "valueType": "number"
10806
- },
10807
- {
10808
- "path": "pumpOffTime",
10809
- "valueType": "number"
10810
- },
10811
11399
  {
10812
11400
  "path": "lastDrink",
10813
11401
  "valueType": "number"
@@ -10931,6 +11519,20 @@ Object.freeze({
10931
11519
  "valueType": "number"
10932
11520
  }
10933
11521
  ],
11522
+ "pump-cycle": [
11523
+ {
11524
+ "path": "enabled",
11525
+ "valueType": "boolean"
11526
+ },
11527
+ {
11528
+ "path": "onTime",
11529
+ "valueType": "number"
11530
+ },
11531
+ {
11532
+ "path": "offTime",
11533
+ "valueType": "number"
11534
+ }
11535
+ ],
10934
11536
  "recording-archive": [
10935
11537
  {
10936
11538
  "path": "deviceId",
@@ -11380,7 +11982,7 @@ object({
11380
11982
  params: record(string(), union([string(), number()])).optional()
11381
11983
  });
11382
11984
  //#endregion
11383
- //#region ../types/dist/composition-Dh3RfMx5.mjs
11985
+ //#region ../types/dist/composition-pOHbTzRB.mjs
11384
11986
  /**
11385
11987
  * The ffmpeg build every CamStack node downloads, per platform and arch.
11386
11988
  *
@@ -12143,38 +12745,6 @@ function validateExpressionSource(src) {
12143
12745
  return null;
12144
12746
  }
12145
12747
  /**
12146
- * One power reading becomes a washer, dryer or dishwasher (D944 helper).
12147
- *
12148
- * Standby of the control board is under 5 W; a motor or a heater is far
12149
- * above that, so 5 W is the line. A door lock or a short pump spike is not
12150
- * a cycle, so running starts only after 30 s above the line.
12151
- *
12152
- * A wash, dry or dishwasher pause (soak, heat-wait, heater off between
12153
- * bursts) lasts several minutes. Ending the cycle on the first dip would
12154
- * report "finished" in the middle of the program, so the stop dwell is
12155
- * 10 minutes on every type. The number is stored per type so one machine
12156
- * can move later without moving the others.
12157
- */
12158
- var APPLIANCE_TEMPLATE_ID = "appliance";
12159
- var APPLIANCE_KINDS = [
12160
- "washer",
12161
- "dryer",
12162
- "dishwasher"
12163
- ];
12164
- DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher;
12165
- /**
12166
- * A dumb plug-in stove or heater, built from a smart plug (a `Heater`).
12167
- *
12168
- * The plug is the actuator: `switch.setState` is a FORWARD to the plug's own
12169
- * (D967), so the heater switches exactly as the plug does. Running is the
12170
- * plug being on; when a power reading is also named, running is the draw
12171
- * staying above the line instead (a plug left on with the stove's own
12172
- * thermostat open is not heating). 50 W is far above any standby and below
12173
- * the smallest radiator.
12174
- */
12175
- var HEATER_TEMPLATE_ID = "heater";
12176
- DeviceType.Heater;
12177
- /**
12178
12748
  * Statistics and integrals over a history read (D944).
12179
12749
  *
12180
12750
  * Pure: the same points always give the same answer, so a restart recomputes
@@ -12318,34 +12888,6 @@ var HelperSpecSchema = discriminatedUnion("kind", [
12318
12888
  /** Actuator groups only. Readings leave this unset. */
12319
12889
  active: ActiveCriterionSchema.optional()
12320
12890
  }),
12321
- object({
12322
- kind: literal("appliance"),
12323
- templateId: literal(APPLIANCE_TEMPLATE_ID),
12324
- appliance: _enum(APPLIANCE_KINDS),
12325
- thresholdWatts: number().positive(),
12326
- startDwellMs: number().int().nonnegative(),
12327
- stopDwellMs: number().int().nonnegative(),
12328
- member: HelperMemberSchema,
12329
- /**
12330
- * The plug that powers the appliance (`switch.on`). Optional: when set, the
12331
- * composition carries a `power-source` feature, so the hub can cut and restore
12332
- * that plug (power-source link of a NEW-target composition).
12333
- */
12334
- powerSwitch: HelperMemberSchema.optional(),
12335
- /** How long a forced restart keeps the plug off; the cap's default when unset. */
12336
- offSeconds: number().optional()
12337
- }),
12338
- object({
12339
- kind: literal("heater"),
12340
- templateId: literal(HEATER_TEMPLATE_ID),
12341
- /** The plug, read and commanded at `switch.on`. */
12342
- plug: HelperMemberSchema,
12343
- /** The plug's power reading, when it has one: running is then the draw, not the switch. */
12344
- meter: HelperMemberSchema.optional(),
12345
- thresholdWatts: number().positive(),
12346
- startDwellMs: number().int().nonnegative(),
12347
- stopDwellMs: number().int().nonnegative()
12348
- }),
12349
12891
  object({
12350
12892
  kind: literal("statistic"),
12351
12893
  stat: _enum(STATISTIC_STATS),
@@ -12517,7 +13059,14 @@ var CompositionForwardCommandSchema = object({
12517
13059
  method: string().min(1),
12518
13060
  args: record(string().min(1), CompositionForwardArgSchema).optional()
12519
13061
  });
12520
- var CompositionCommandTargetSchema = discriminatedUnion("kind", [CompositionForwardCommandSchema, CompositionCodeSourceSchema]);
13062
+ var CompositionCommandTargetSchema = discriminatedUnion("kind", [
13063
+ CompositionForwardCommandSchema,
13064
+ CompositionCodeSourceSchema,
13065
+ object({
13066
+ kind: literal("extension"),
13067
+ target: literal("remote")
13068
+ })
13069
+ ]);
12521
13070
  /** An item key inside an item-array cap (`consumables.items[<key>]`). */
12522
13071
  var COMPOSITION_ITEM_KEY_RE = /^[a-z0-9][a-z0-9-]{0,47}$/;
12523
13072
  /**
@@ -12562,7 +13111,7 @@ var CompositionSchema = object({
12562
13111
  kind: literal("existing"),
12563
13112
  device: CompositionSourceRefSchema
12564
13113
  })]),
12565
- features: array(CompositionFeatureSchema).min(1).max(16),
13114
+ features: array(CompositionFeatureSchema).min(0).max(16),
12566
13115
  /**
12567
13116
  * Present when the block is a helper template. Absent on a free
12568
13117
  * composition (the room example, device 4603). The editor reads this,
@@ -12594,6 +13143,73 @@ var NodeColorIdSchema = _enum([
12594
13143
  "node-g",
12595
13144
  "node-h"
12596
13145
  ]);
13146
+ //#endregion
13147
+ //#region ../types/dist/index.mjs
13148
+ var SMTP_INBOUND_DEFAULT_PORT = 2525;
13149
+ var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
13150
+ var SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
13151
+ /** The text excerpt a message carries on the bus. */
13152
+ var SMTP_INBOUND_TEXT_MAX_CHARS = 4096;
13153
+ var PortSchema = number().int().min(1).max(65535);
13154
+ /** A recipient local-part: what stands before the `@`. */
13155
+ var SmtpRecipientSchema = string().min(1).max(64).regex(/^[A-Za-z0-9._+-]+$/);
13156
+ object({
13157
+ port: PortSchema.default(SMTP_INBOUND_DEFAULT_PORT),
13158
+ bindHost: string().min(1).default("0.0.0.0"),
13159
+ domain: string().min(1).default(SMTP_INBOUND_DEFAULT_DOMAIN),
13160
+ requireAuth: boolean().default(true),
13161
+ username: string().default(""),
13162
+ password: string().default("").meta({ secret: true }),
13163
+ starttls: boolean().default(false),
13164
+ maxMessageBytes: number().int().positive().default(SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES)
13165
+ });
13166
+ object({
13167
+ host: string().min(1).nullable(),
13168
+ hostReason: string().nullable(),
13169
+ port: PortSchema,
13170
+ domain: string().min(1),
13171
+ requireAuth: boolean(),
13172
+ username: string(),
13173
+ password: string(),
13174
+ starttls: boolean()
13175
+ });
13176
+ object({
13177
+ recipients: array(SmtpRecipientSchema).min(1),
13178
+ /**
13179
+ * Who is subscribing. A second `subscribe` with the same id REPLACES that subscriber's
13180
+ * recipients (the way a consumer that restarted, or lost a device, declares its set again);
13181
+ * a recipient held by another subscriber is refused with `smtp-inbound/recipient-claimed`.
13182
+ * Absent, the subscriber is anonymous and unique.
13183
+ */
13184
+ subscriberId: string().min(1).max(64).optional()
13185
+ });
13186
+ var SmtpInboundAttachmentSchema = object({
13187
+ filename: string(),
13188
+ contentType: string(),
13189
+ bytes: number().int().nonnegative()
13190
+ });
13191
+ /** The payload of one `broker.message` (the key is the recipient local-part). */
13192
+ var SmtpInboundMessageSchema = object({
13193
+ /** Monotonic per mailbox; a gap tells a consumer it missed an event. */
13194
+ seq: number().int().positive(),
13195
+ messageId: string(),
13196
+ receivedAt: number().int().nonnegative(),
13197
+ from: string(),
13198
+ to: string(),
13199
+ subject: string(),
13200
+ text: string().max(SMTP_INBOUND_TEXT_MAX_CHARS),
13201
+ attachments: array(SmtpInboundAttachmentSchema)
13202
+ });
13203
+ object({
13204
+ /** The newest seq issued so far (0 before any mail). */
13205
+ lastSeq: number().int().nonnegative(),
13206
+ /** The oldest seq still retained; messages below it are gone. */
13207
+ oldestSeq: number().int().nonnegative(),
13208
+ messages: array(object({
13209
+ key: string(),
13210
+ message: SmtpInboundMessageSchema
13211
+ }))
13212
+ });
12597
13213
  new Set([
12598
13214
  "track",
12599
13215
  "face",
@@ -12713,6 +13329,205 @@ var IntegrationInstanceRefSchema = object({
12713
13329
  ]),
12714
13330
  candidateStableId: string().optional()
12715
13331
  });
13332
+ /**
13333
+ * `RecordIntegrationInstances` - the `integration-instances` provider over ONE
13334
+ * entry kind, so an addon that holds a connection serves it in ~30 lines.
13335
+ *
13336
+ * Every instance is one record of the addon's own kind, keyed by the
13337
+ * `integrations` registry id. The records door does the secret work: a field the
13338
+ * kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
13339
+ * deleting the row deletes the secret, and one row's value is never another's.
13340
+ *
13341
+ * Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
13342
+ * token or the view the form was given KEEP the stored secret;
13343
+ * `{ $secretClear: true }` clears it; any other string replaces it.
13344
+ */
13345
+ /** The most instances one addon lists (an integrations page, not a table). */
13346
+ var INSTANCES_LIST_MAX = 1e3;
13347
+ /** The keys of the kind's secret fields that sit at the top level of the body. */
13348
+ function topLevelSecretKeys(paths) {
13349
+ return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
13350
+ }
13351
+ /** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
13352
+ function secretMapKeys(paths) {
13353
+ return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
13354
+ }
13355
+ /**
13356
+ * A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
13357
+ * view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
13358
+ * or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
13359
+ */
13360
+ function secretMapPatch(value) {
13361
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
13362
+ const out = {};
13363
+ for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
13364
+ else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
13365
+ return Object.keys(out).length > 0 ? out : null;
13366
+ }
13367
+ /** Does the kind's body schema carry an `enabled` field? */
13368
+ function declaresEnabled(kind) {
13369
+ const json = toJSONSchema(kind.schema, {
13370
+ unrepresentable: "any",
13371
+ io: "input"
13372
+ });
13373
+ const properties = Reflect.get(json, "properties");
13374
+ return typeof properties === "object" && properties !== null && "enabled" in properties;
13375
+ }
13376
+ var RecordIntegrationInstances = class {
13377
+ records;
13378
+ kind;
13379
+ hooks;
13380
+ handle;
13381
+ secretKeys;
13382
+ secretMaps;
13383
+ nameField;
13384
+ /** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
13385
+ registryOwnsEnabled;
13386
+ constructor(records, kind, hooks) {
13387
+ this.records = records;
13388
+ this.kind = kind;
13389
+ this.hooks = hooks;
13390
+ this.handle = records.kind(kind);
13391
+ this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
13392
+ this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
13393
+ this.nameField = kind.declaration.entry?.nameField ?? "name";
13394
+ this.registryOwnsEnabled = hooks.description.role === "devices";
13395
+ if (this.registryOwnsEnabled && declaresEnabled(kind)) throw new Error(`kind "${kind.name}": the integrations registry owns the on/off switch of a role "devices" addon, so the body must not declare "enabled"`);
13396
+ }
13397
+ /**
13398
+ * One instance read for the addon's own runtime; null when absent. When the keychain is
13399
+ * locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
13400
+ * caller can keep what it had instead of reconfiguring with an empty secret (D49).
13401
+ */
13402
+ async readResolved(id) {
13403
+ try {
13404
+ const record = await this.handle.getResolved(id);
13405
+ return record === null ? null : {
13406
+ id,
13407
+ body: record.data,
13408
+ enabled: record.data.enabled !== false,
13409
+ secrets: "resolved"
13410
+ };
13411
+ } catch (err) {
13412
+ if (!(err instanceof RecordSecretUnavailableError)) throw err;
13413
+ const stored = await this.handle.get(id);
13414
+ if (stored === null) return null;
13415
+ return {
13416
+ id,
13417
+ body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
13418
+ enabled: stored.data.enabled !== false,
13419
+ secrets: "unavailable"
13420
+ };
13421
+ }
13422
+ }
13423
+ /** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
13424
+ async getResolved(id) {
13425
+ return (await this.readResolved(id))?.body ?? null;
13426
+ }
13427
+ /** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
13428
+ async listResolved() {
13429
+ const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
13430
+ const out = [];
13431
+ for (const record of page.records) {
13432
+ const read = await this.readResolved(record.id);
13433
+ if (read !== null) out.push(read);
13434
+ }
13435
+ return out;
13436
+ }
13437
+ viewOf(record) {
13438
+ const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
13439
+ const rawName = record.data[this.nameField];
13440
+ const kind = this.hooks.kindOf?.(record.data);
13441
+ const health = this.hooks.health?.(record.data, record.id);
13442
+ return {
13443
+ id: record.id,
13444
+ name: typeof rawName === "string" ? rawName : record.id,
13445
+ configured: this.hooks.configured(record.data),
13446
+ ...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
13447
+ formValues: shown,
13448
+ ...kind !== void 0 ? { kind } : {},
13449
+ ...health?.status !== void 0 ? { status: health.status } : {},
13450
+ ...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
13451
+ };
13452
+ }
13453
+ describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
13454
+ ...this.hooks.description,
13455
+ mintsId: true
13456
+ };
13457
+ instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
13458
+ listInstances = async () => {
13459
+ return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
13460
+ };
13461
+ getInstance = async ({ id }) => {
13462
+ const record = await this.handle.get(id);
13463
+ return record === null ? null : this.viewOf(record);
13464
+ };
13465
+ /** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
13466
+ createInstance = async ({ id, name, kind }) => {
13467
+ const minted = id ?? this.hooks.mintId?.({
13468
+ name,
13469
+ ...kind !== void 0 ? { kind } : {}
13470
+ });
13471
+ if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
13472
+ await this.handle.put({
13473
+ id: minted,
13474
+ data: this.hooks.initialBody(name, kind)
13475
+ }, { ifRev: 0 });
13476
+ await this.hooks.onChanged?.(minted, "created");
13477
+ return { id: minted };
13478
+ };
13479
+ updateInstance = async ({ id, name, values }) => {
13480
+ const patch = {};
13481
+ for (const [key, value] of Object.entries(values)) {
13482
+ if (value === void 0) continue;
13483
+ if (this.secretMaps.has(key)) {
13484
+ const entries = secretMapPatch(value);
13485
+ if (entries !== null) patch[key] = entries;
13486
+ } else if (!this.secretKeys.has(key)) patch[key] = value;
13487
+ else if (isSecretClear(value)) patch[key] = null;
13488
+ else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
13489
+ }
13490
+ if (name !== void 0) patch[this.nameField] = name;
13491
+ await this.handle.patch(id, patch);
13492
+ await this.hooks.onChanged?.(id, "updated");
13493
+ return { ok: true };
13494
+ };
13495
+ /** The switch lives in the record body; the addon is told so it applies it (D996). */
13496
+ setInstanceEnabled = async ({ id, enabled }) => {
13497
+ if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
13498
+ await this.handle.patch(id, { enabled });
13499
+ await this.hooks.onChanged?.(id, "enabled");
13500
+ return { ok: true };
13501
+ };
13502
+ /** The row and its keychain refs go together (the records door). */
13503
+ deleteInstance = async ({ id }) => {
13504
+ await this.handle.delete(id);
13505
+ await this.hooks.onChanged?.(id, "deleted");
13506
+ return { ok: true };
13507
+ };
13508
+ testInstance = async (input) => {
13509
+ if (this.hooks.test === void 0) return {
13510
+ success: false,
13511
+ status: "unsupported",
13512
+ error: "This integration declares no connection test"
13513
+ };
13514
+ return this.hooks.test(input);
13515
+ };
13516
+ /** The flat provider object to hand to `registerProvider`. */
13517
+ toProvider() {
13518
+ return {
13519
+ describe: this.describe,
13520
+ instanceFormSchema: this.instanceFormSchema,
13521
+ listInstances: this.listInstances,
13522
+ getInstance: this.getInstance,
13523
+ createInstance: this.createInstance,
13524
+ updateInstance: this.updateInstance,
13525
+ setInstanceEnabled: this.setInstanceEnabled,
13526
+ deleteInstance: this.deleteInstance,
13527
+ testInstance: this.testInstance
13528
+ };
13529
+ }
13530
+ };
12716
13531
  var EncodeProfileSchema = object({
12717
13532
  video: object({
12718
13533
  codec: _enum([
@@ -13748,7 +14563,13 @@ var MigrationLedgerEntrySchema = object({
13748
14563
  * joined by the engine from the catalogues it knows this boot. Absent when no
13749
14564
  * catalogue lists the id (a newer database).
13750
14565
  */
13751
- meta: MigrationMetaSchema.optional()
14566
+ meta: MigrationMetaSchema.optional(),
14567
+ /**
14568
+ * Set when this is an applied row of an addon owner whose catalogue the answering
14569
+ * process has not loaded (the owner has not declared yet): the row is applied, the
14570
+ * process just cannot judge it. Never `skipped-newer` — that needs the owner loaded.
14571
+ */
14572
+ ownerNotLoaded: boolean().optional()
13752
14573
  });
13753
14574
  /** A catalogued migration that is not applied, with where it stands. */
13754
14575
  var MigrationPendingEntrySchema = object({
@@ -13782,6 +14603,159 @@ var MigrationOwnerStepSchema = object({
13782
14603
  state: union([literal("pending"), MigrationStatusSchema])
13783
14604
  });
13784
14605
  /**
14606
+ * Move an integration's legacy `integration_settings` rows into a typed record of the addon's own
14607
+ * kind (planning#416, the one store). The record is keyed by the `integrations` registry id, so
14608
+ * the integration id, the devices stamped with it and the automations that name it do not change.
14609
+ *
14610
+ * Order, so a crash or a locked keychain is safe at every point:
14611
+ *
14612
+ * 1. Phase A, read only: every row of every integration of the addon is read with its secrets
14613
+ * resolved. One that cannot be read (a locked keychain) throws, naming the integration, before
14614
+ * anything is written; `block-owner` then holds the addon.
14615
+ * 2. Phase B, per integration: the addon's `bodyFrom` builds the body; the record is put with
14616
+ * `ifRev: 0` (an existing record is never overwritten). A record this pass CREATED is read back
14617
+ * and every secret leaf must equal what the rows held, else the record is deleted and the pass
14618
+ * throws; an EXISTING record must hold every secret the rows carry, else the rows are kept and
14619
+ * a warning names the path. Only then are the rows (and their keychain values) cleared.
14620
+ *
14621
+ * Idempotent: an integration whose rows are gone and whose record exists is skipped, so a rerun is
14622
+ * a no-op. A default integration with no rows still gets its record (an empty body, D985).
14623
+ * Never logs or throws a secret value; messages name integration ids and secret PATHS only.
14624
+ */
14625
+ function secretLeavesOf(body, spec) {
14626
+ const out = /* @__PURE__ */ new Map();
14627
+ for (const leaf of collectSecretLeaves(body, spec.secretPaths, spec.secretArrayKeys ?? {})) if (typeof leaf.value === "string" && leaf.value.length > 0) out.set(leaf.concrete, leaf.value);
14628
+ return out;
14629
+ }
14630
+ function why(err) {
14631
+ return err instanceof Error ? err.message : String(err);
14632
+ }
14633
+ async function moveIntegrationRowsToRecords(ports, spec) {
14634
+ const integrations = await ports.listIntegrations(spec.addonId);
14635
+ if (integrations.length === 0) return {
14636
+ outcome: "already-done",
14637
+ summary: { integrations: 0 }
14638
+ };
14639
+ const rowsOf = /* @__PURE__ */ new Map();
14640
+ for (const integration of integrations) try {
14641
+ rowsOf.set(integration.id, await ports.readRows(integration.id));
14642
+ } catch (err) {
14643
+ throw new Error(`integration '${integration.id}': the legacy settings cannot be read with their secrets (${why(err)}) - nothing moved`, { cause: err });
14644
+ }
14645
+ let created = 0;
14646
+ let cleared = 0;
14647
+ let kept = 0;
14648
+ for (const integration of integrations) {
14649
+ const values = rowsOf.get(integration.id) ?? {};
14650
+ const hasRows = Object.keys(values).length > 0;
14651
+ const body = spec.bodyFrom(values, ports, integration);
14652
+ const put = await ports.putRecord(integration.id, body);
14653
+ if (put === "created") created += 1;
14654
+ if (!hasRows) continue;
14655
+ const wanted = secretLeavesOf(body, spec);
14656
+ const back = await ports.readRecord(integration.id);
14657
+ if (back === null) throw new Error(`integration '${integration.id}': the record is gone after it was put`);
14658
+ const held = secretLeavesOf(back, spec);
14659
+ if (put === "created") {
14660
+ const wrong = [...wanted].filter(([path, value]) => held.get(path) !== value).map(([p]) => p);
14661
+ if (wrong.length > 0) {
14662
+ await ports.deleteRecord(integration.id);
14663
+ throw new Error(`integration '${integration.id}': ${wrong.join(", ")} did not read back from the record - the record was removed and the legacy settings are kept`);
14664
+ }
14665
+ } else {
14666
+ const missing = [...wanted].filter(([path]) => !held.has(path)).map(([p]) => p);
14667
+ if (missing.length > 0) {
14668
+ ports.warn(`integration '${integration.id}': the existing record holds no ${missing.join(", ")}; the legacy settings are kept, not cleared`);
14669
+ kept += 1;
14670
+ continue;
14671
+ }
14672
+ }
14673
+ await ports.clearRows(integration.id);
14674
+ cleared += 1;
14675
+ }
14676
+ return created === 0 && cleared === 0 ? {
14677
+ outcome: "already-done",
14678
+ summary: {
14679
+ integrations: integrations.length,
14680
+ kept
14681
+ }
14682
+ } : {
14683
+ outcome: "done",
14684
+ summary: {
14685
+ integrations: integrations.length,
14686
+ created,
14687
+ cleared,
14688
+ kept
14689
+ }
14690
+ };
14691
+ }
14692
+ /**
14693
+ * The addon-side ports of `moveIntegrationRowsToRecords` (planning#416). An addon runs the move
14694
+ * from its own process, so the leftover rows are reached through the migration-only door
14695
+ * (`migrations.readLegacyIntegrationRows` / `clearLegacyIntegrationRows`) on the hub's connection.
14696
+ * The door returns markers. This process is the owner, so it resolves and releases them with
14697
+ * `resolveSecretMarkers` — the same call the old settings door used — and only then asks the
14698
+ * door to delete the rows. The addon's own record kind is its records handle.
14699
+ */
14700
+ async function resolvedRows(stored, secrets) {
14701
+ if (secrets === null) return stored;
14702
+ const { value, unresolved } = await resolveSecretMarkers(stored, secrets);
14703
+ if (unresolved.length > 0) throw new Error(`${unresolved.length} secret(s) cannot be read from the keychain`);
14704
+ return value;
14705
+ }
14706
+ function integrationRowsPortsOverApi(deps) {
14707
+ const secrets = deps.secrets ?? null;
14708
+ return {
14709
+ warn: (message) => deps.log.warn(message),
14710
+ listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
14711
+ id: i.id,
14712
+ name: i.name
14713
+ })),
14714
+ readRows: async (integrationId) => resolvedRows(await deps.api.readLegacyIntegrationRows({ integrationId }), secrets),
14715
+ putRecord: async (id, body) => {
14716
+ if (await deps.records.get(id) !== null) return "exists";
14717
+ try {
14718
+ await deps.records.put({
14719
+ id,
14720
+ data: body
14721
+ }, { ifRev: 0 });
14722
+ } catch (err) {
14723
+ if (err instanceof RevConflictError) return "exists";
14724
+ throw err;
14725
+ }
14726
+ return "created";
14727
+ },
14728
+ readRecord: async (id) => (await deps.records.getResolved(id))?.data ?? null,
14729
+ deleteRecord: async (id) => {
14730
+ await deps.records.delete(id);
14731
+ },
14732
+ clearRows: async (integrationId) => {
14733
+ const refs = collectSecretMarkerRefs(await deps.api.readLegacyIntegrationRows({ integrationId }));
14734
+ if (refs.length > 0 && secrets !== null) await secrets.delete(refs);
14735
+ await deps.api.clearLegacyIntegrationRows({ integrationId });
14736
+ }
14737
+ };
14738
+ }
14739
+ function defaultIntegrationApiOver(api) {
14740
+ return {
14741
+ list: () => api.integrations.list.query(),
14742
+ readLegacyIntegrationRows: (input) => api.migrations.readLegacyIntegrationRows.query(input),
14743
+ clearLegacyIntegrationRows: (input) => api.migrations.clearLegacyIntegrationRows.mutate(input),
14744
+ listDevices: (addonId) => api.deviceManager.listAll.query({
14745
+ addonId,
14746
+ projection: "slim"
14747
+ }),
14748
+ setDeviceIntegrationId: async (deviceId, integrationId) => {
14749
+ await api.deviceManager.setIntegrationId.mutate({
14750
+ deviceId,
14751
+ integrationId
14752
+ });
14753
+ },
14754
+ readDeviceHasConfig: async (deviceId) => Object.keys((await api.deviceManager.getDevice.query({ deviceId }))?.config ?? {}).length > 0,
14755
+ readDeviceIntegrationId: async (deviceId) => (await api.deviceManager.getDevice.query({ deviceId }))?.integrationId ?? null
14756
+ };
14757
+ }
14758
+ /**
13785
14759
  * The trainer contract — what the hub hands the cloud trainer and what it
13786
14760
  * gets back (cloud training, D805+).
13787
14761
  *
@@ -18866,24 +19840,52 @@ var APPLIANCE_CAP_VOCABULARY = {
18866
19840
  args: { on: false }
18867
19841
  },
18868
19842
  {
18869
- id: "petFountain.intervalOn",
18870
- method: "setPumpInterval",
19843
+ id: "petFountain.resetDailyConsumption",
19844
+ method: "resetDailyConsumption",
19845
+ label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
19846
+ phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
19847
+ icon: "rotate-ccw"
19848
+ }
19849
+ ],
19850
+ state: [{
19851
+ kind: "boolean",
19852
+ field: "empty",
19853
+ label: t("Tank empty", "Serbatoio vuoto"),
19854
+ whenTrue: t("When the tank of {device} is empty", "Quando il serbatoio di {device} è vuoto"),
19855
+ whenFalse: t("When the tank of {device} is refilled", "Quando il serbatoio di {device} viene riempito"),
19856
+ icon: "droplet"
19857
+ }, {
19858
+ kind: "numeric",
19859
+ field: "waterLevel",
19860
+ quantity: t("the water level", "il livello dell’acqua"),
19861
+ label: t("Water level", "Livello dell’acqua"),
19862
+ unit: "%",
19863
+ icon: "droplets"
19864
+ }]
19865
+ },
19866
+ "pump-cycle": {
19867
+ scope: "device",
19868
+ noun: t("Pump cycle", "Ciclo della pompa"),
19869
+ actions: [
19870
+ {
19871
+ id: "pumpCycle.on",
19872
+ method: "setEnabled",
18871
19873
  label: t("Pump cycle on", "Ciclo pompa attivo"),
18872
19874
  phrase: t("Run the pump of {device} on its on/off cycle", "Fai lavorare la pompa di {device} a ciclo acceso/spento"),
18873
19875
  icon: "timer",
18874
19876
  args: { on: true }
18875
19877
  },
18876
19878
  {
18877
- id: "petFountain.intervalOff",
18878
- method: "setPumpInterval",
19879
+ id: "pumpCycle.off",
19880
+ method: "setEnabled",
18879
19881
  label: t("Pump cycle off", "Ciclo pompa spento"),
18880
19882
  phrase: t("Run the pump of {device} continuously", "Fai lavorare la pompa di {device} in continuo"),
18881
19883
  icon: "timer-off",
18882
19884
  args: { on: false }
18883
19885
  },
18884
19886
  {
18885
- id: "petFountain.pumpOnMinutes",
18886
- method: "setPumpOnMinutes",
19887
+ id: "pumpCycle.onMinutes",
19888
+ method: "setOnMinutes",
18887
19889
  label: t("Set pump run time", "Imposta il tempo di lavoro della pompa"),
18888
19890
  phrase: t("Set the pump of {device} to run {minutes} minutes per cycle", "Imposta la pompa di {device} a lavorare {minutes} minuti per ciclo"),
18889
19891
  icon: "timer",
@@ -18899,8 +19901,8 @@ var APPLIANCE_CAP_VOCABULARY = {
18899
19901
  }]
18900
19902
  },
18901
19903
  {
18902
- id: "petFountain.pumpOffMinutes",
18903
- method: "setPumpOffMinutes",
19904
+ id: "pumpCycle.offMinutes",
19905
+ method: "setOffMinutes",
18904
19906
  label: t("Set pump rest time", "Imposta il tempo di riposo della pompa"),
18905
19907
  phrase: t("Set the pump of {device} to rest {minutes} minutes per cycle", "Imposta la pompa di {device} a riposare {minutes} minuti per ciclo"),
18906
19908
  icon: "timer-off",
@@ -18914,35 +19916,63 @@ var APPLIANCE_CAP_VOCABULARY = {
18914
19916
  unit: "min"
18915
19917
  }
18916
19918
  }]
18917
- },
18918
- {
18919
- id: "petFountain.resetDailyConsumption",
18920
- method: "resetDailyConsumption",
18921
- label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
18922
- phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
18923
- icon: "rotate-ccw"
18924
19919
  }
18925
19920
  ],
18926
19921
  state: [{
18927
19922
  kind: "boolean",
18928
- field: "empty",
18929
- label: t("Tank empty", "Serbatoio vuoto"),
18930
- whenTrue: t("When the tank of {device} is empty", "Quando il serbatoio di {device} è vuoto"),
18931
- whenFalse: t("When the tank of {device} is refilled", "Quando il serbatoio di {device} viene riempito"),
18932
- icon: "droplet"
18933
- }, {
18934
- kind: "numeric",
18935
- field: "waterLevel",
18936
- quantity: t("the water level", "il livello dell’acqua"),
18937
- label: t("Water level", "Livello dell’acqua"),
18938
- unit: "%",
18939
- icon: "droplets"
19923
+ field: "enabled",
19924
+ label: t("Pump cycle", "Ciclo pompa"),
19925
+ whenTrue: t("When {device} starts running its pump on a cycle", "Quando {device} inizia a far lavorare la pompa a ciclo"),
19926
+ whenFalse: t("When {device} runs its pump continuously", "Quando {device} fa lavorare la pompa in continuo"),
19927
+ icon: "timer"
18940
19928
  }]
18941
19929
  },
18942
19930
  "media-player": {
18943
19931
  scope: "device",
18944
19932
  noun: t("Media player", "Lettore multimediale"),
18945
19933
  actions: [
19934
+ {
19935
+ id: "media.turnOn",
19936
+ method: "turnOn",
19937
+ label: t("Turn on", "Accendi"),
19938
+ phrase: t("Turn on {device}", "Accendi {device}"),
19939
+ icon: "power"
19940
+ },
19941
+ {
19942
+ id: "media.turnOff",
19943
+ method: "turnOff",
19944
+ label: t("Turn off", "Spegni"),
19945
+ phrase: t("Turn off {device}", "Spegni {device}"),
19946
+ icon: "power"
19947
+ },
19948
+ {
19949
+ id: "media.volumeUp",
19950
+ method: "volumeUp",
19951
+ label: t("Volume up", "Alza il volume"),
19952
+ phrase: t("Raise the volume of {device}", "Alza il volume di {device}"),
19953
+ icon: "volume-2"
19954
+ },
19955
+ {
19956
+ id: "media.volumeDown",
19957
+ method: "volumeDown",
19958
+ label: t("Volume down", "Abbassa il volume"),
19959
+ phrase: t("Lower the volume of {device}", "Abbassa il volume di {device}"),
19960
+ icon: "volume-2"
19961
+ },
19962
+ {
19963
+ id: "media.channelUp",
19964
+ method: "channelUp",
19965
+ label: t("Channel up", "Canale successivo"),
19966
+ phrase: t("Go to the next channel on {device}", "Passa al canale successivo su {device}"),
19967
+ icon: "skip-forward"
19968
+ },
19969
+ {
19970
+ id: "media.channelDown",
19971
+ method: "channelDown",
19972
+ label: t("Channel down", "Canale precedente"),
19973
+ phrase: t("Go to the previous channel on {device}", "Torna al canale precedente su {device}"),
19974
+ icon: "skip-back"
19975
+ },
18946
19976
  {
18947
19977
  id: "media.play",
18948
19978
  method: "play",
@@ -20829,6 +21859,7 @@ var SYSTEM_CAP_VOCABULARY = {
20829
21859
  "audio-analyzer": system(PIPELINE),
20830
21860
  "audio-codec": system(INTERNAL),
20831
21861
  "auth-provider": system(IDENTITY),
21862
+ "board-key-source": system(INTERNAL),
20832
21863
  backup: system("system backups — run and restored from the Backups page"),
20833
21864
  broker: system("message-broker connections — configured, not actuated"),
20834
21865
  "calendar-source": system(INTERNAL),
@@ -45817,6 +46848,49 @@ var binaryCapability = {
45817
46848
  volatileStateFields: ["lastChangedAt"]
45818
46849
  };
45819
46850
  /**
46851
+ * Why a board key could not be read. Typed so a caller reports the cause and
46852
+ * never treats "could not read" as "has no key" (D49).
46853
+ */
46854
+ var BoardKeyFailureReasonSchema = _enum([
46855
+ "unknown-source",
46856
+ "not-admin",
46857
+ "no-builder",
46858
+ "no-ingress-url",
46859
+ "unreachable",
46860
+ "unknown-board",
46861
+ "no-encryption-key",
46862
+ "unreadable-config"
46863
+ ]);
46864
+ var BoardKeySourceSchema = object({
46865
+ sourceId: string(),
46866
+ name: string()
46867
+ });
46868
+ var BoardKeyBoardSchema = object({
46869
+ /** The builder's file name, e.g. `kitchen.yaml`: the handle `getBoardKey` takes. */
46870
+ configuration: string(),
46871
+ /** The node name the builder gives the board. */
46872
+ name: string(),
46873
+ /** The address the builder knows the board by, when it has one. */
46874
+ address: string().nullable()
46875
+ });
46876
+ var BoardKeyFailureSchema = object({
46877
+ ok: literal(false),
46878
+ reason: BoardKeyFailureReasonSchema,
46879
+ detail: string().optional()
46880
+ });
46881
+ var ListBoardsResultSchema = discriminatedUnion("ok", [object({
46882
+ ok: literal(true),
46883
+ boards: array(BoardKeyBoardSchema).readonly()
46884
+ }), BoardKeyFailureSchema]);
46885
+ var GetBoardKeyResultSchema = discriminatedUnion("ok", [object({
46886
+ ok: literal(true),
46887
+ key: string()
46888
+ }), BoardKeyFailureSchema]);
46889
+ method(_void(), array(BoardKeySourceSchema).readonly(), { auth: "admin" }), method(object({ sourceId: string().min(1) }), ListBoardsResultSchema, { auth: "admin" }), method(object({
46890
+ sourceId: string().min(1),
46891
+ configuration: string().min(1)
46892
+ }), GetBoardKeyResultSchema, { auth: "admin" });
46893
+ /**
45820
46894
  * Dimmable-light brightness control. Co-exists with `switch` on the
45821
46895
  * same device — the switch toggles on/off, this cap sets the level
45822
46896
  * applied when the light is on. Drivers map their per-vendor dim
@@ -48506,6 +49580,244 @@ var controlCapability = {
48506
49580
  */
48507
49581
  history: "none"
48508
49582
  };
49583
+ /**
49584
+ * Media-player cap. Models HA `media_player.*` (Sonos, Chromecast,
49585
+ * Apple TV, Spotify, Roku, generic OTT receivers, …) on
49586
+ * `DeviceType.MediaPlayer`. Disjoint from the camera streaming
49587
+ * surface — those use `DeviceType.Camera` + the broker pipeline.
49588
+ *
49589
+ * The cap declares a wide method surface; not every backend supports
49590
+ * every method. Drivers signal sub-capability via the
49591
+ * `DeviceFeature.MediaPlayerXxx` flags (paired one-to-one with the
49592
+ * corresponding method) so the UI gates buttons without a slice
49593
+ * fetch — same pattern as `PanTiltZoom` for cameras.
49594
+ */
49595
+ var MediaPlayerStateSchema = _enum([
49596
+ "off",
49597
+ "on",
49598
+ "idle",
49599
+ "playing",
49600
+ "paused",
49601
+ "buffering",
49602
+ "standby"
49603
+ ]);
49604
+ var MediaPlayerRepeatSchema = _enum([
49605
+ "off",
49606
+ "all",
49607
+ "one"
49608
+ ]);
49609
+ var MediaInfoSchema = object({
49610
+ /** Free-form media kind (`music`, `tvshow`, `movie`, `app`, `channel`,
49611
+ * `podcast`, …). */
49612
+ type: string(),
49613
+ /** Human-readable title. */
49614
+ title: string(),
49615
+ /** Optional artist / channel / station label. */
49616
+ artist: string().optional(),
49617
+ /** Optional album / season / show name. */
49618
+ album: string().optional(),
49619
+ /** Optional cover-art / thumbnail URL. */
49620
+ imageUrl: string().optional()
49621
+ });
49622
+ /**
49623
+ * Where `state`, `volumeLevel`, `isMuted` and `source` come from. `reported`:
49624
+ * the device said so. `assumed`: the driver has no feedback (infrared) and
49625
+ * tracks what it last SENT; it moves only after a send was accepted, and a
49626
+ * human at the real remote makes it wrong. A UI shows an assumed value as a
49627
+ * guess, never as a reading.
49628
+ */
49629
+ var MediaPlayerStateSourceSchema = _enum(["reported", "assumed"]);
49630
+ /** The fields of a media-player status a driver can only guess. */
49631
+ var MediaPlayerAssumedFieldSchema = _enum([
49632
+ "state",
49633
+ "volumeLevel",
49634
+ "isMuted",
49635
+ "source"
49636
+ ]);
49637
+ var MediaPlayerStatusSchema = object({
49638
+ /** Playback lifecycle state. */
49639
+ state: MediaPlayerStateSchema,
49640
+ /**
49641
+ * Whether the state fields are readings or the driver's own bookkeeping.
49642
+ * A slice written before this field existed parses as `reported`.
49643
+ */
49644
+ stateSource: MediaPlayerStateSourceSchema.default("reported"),
49645
+ /**
49646
+ * Which fields are the driver's own guess. `stateSource` is `assumed` when
49647
+ * this is not empty; a field not listed here is a reading even then (power
49648
+ * from a running-state source, mute guessed from the last send).
49649
+ */
49650
+ assumedFields: array(MediaPlayerAssumedFieldSchema).default([]),
49651
+ /** Volume as 0..100 inclusive. Null when the device has no volume
49652
+ * surface. Pair with `DeviceFeature.MediaPlayerVolume`. */
49653
+ volumeLevel: number().min(0).max(100).nullable().meta(readingMeta("percentage")),
49654
+ /** Mute toggle distinct from volume=0. Null when no mute surface.
49655
+ * Pair with `DeviceFeature.MediaPlayerMute`. */
49656
+ isMuted: boolean().nullable(),
49657
+ /** Active source / input. Empty when no source surface. */
49658
+ source: string(),
49659
+ /** Selectable sources. Empty when no source surface.
49660
+ * Pair with `DeviceFeature.MediaPlayerSelectSource`. */
49661
+ availableSources: array(string()),
49662
+ /** Currently-playing media info. Null when nothing is playing. */
49663
+ currentMedia: MediaInfoSchema.nullable(),
49664
+ /** Current playback position in ms. Null when not seekable or
49665
+ * nothing is playing. Pair with `DeviceFeature.MediaPlayerSeek`. */
49666
+ position: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
49667
+ /** Total duration of the current media in ms. Null when unknown
49668
+ * (live stream) or nothing is playing. */
49669
+ duration: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
49670
+ /** Shuffle toggle. Null when no shuffle surface.
49671
+ * Pair with `DeviceFeature.MediaPlayerShuffle`. */
49672
+ shuffle: boolean().nullable(),
49673
+ /** Repeat mode. Null when no repeat surface.
49674
+ * Pair with `DeviceFeature.MediaPlayerRepeat`. */
49675
+ repeat: MediaPlayerRepeatSchema.nullable(),
49676
+ /** Ms epoch when the slice was last updated. */
49677
+ lastChangedAt: number()
49678
+ });
49679
+ var stepInput = object({
49680
+ deviceId: number().int().nonnegative(),
49681
+ /** How many presses: the caller's count (Alexa `volumeSteps`, `channelCount`). */
49682
+ steps: number().int().min(1).max(50).default(1)
49683
+ });
49684
+ var deviceOnly = object({ deviceId: number().int().nonnegative() });
49685
+ var mediaPlayerCapability = {
49686
+ name: "media-player",
49687
+ scope: "device",
49688
+ deviceNative: true,
49689
+ mode: "singleton",
49690
+ deviceTypes: [DeviceType.MediaPlayer],
49691
+ methods: {
49692
+ turnOn: method(deviceOnly, _void(), {
49693
+ kind: "mutation",
49694
+ auth: "protected"
49695
+ }),
49696
+ turnOff: method(deviceOnly, _void(), {
49697
+ kind: "mutation",
49698
+ auth: "protected"
49699
+ }),
49700
+ volumeUp: method(stepInput, _void(), {
49701
+ kind: "mutation",
49702
+ auth: "protected"
49703
+ }),
49704
+ volumeDown: method(stepInput, _void(), {
49705
+ kind: "mutation",
49706
+ auth: "protected"
49707
+ }),
49708
+ channelUp: method(stepInput, _void(), {
49709
+ kind: "mutation",
49710
+ auth: "protected"
49711
+ }),
49712
+ channelDown: method(stepInput, _void(), {
49713
+ kind: "mutation",
49714
+ auth: "protected"
49715
+ }),
49716
+ play: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49717
+ kind: "mutation",
49718
+ auth: "protected"
49719
+ }),
49720
+ pause: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49721
+ kind: "mutation",
49722
+ auth: "protected"
49723
+ }),
49724
+ stop: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49725
+ kind: "mutation",
49726
+ auth: "protected"
49727
+ }),
49728
+ next: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49729
+ kind: "mutation",
49730
+ auth: "protected"
49731
+ }),
49732
+ previous: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49733
+ kind: "mutation",
49734
+ auth: "protected"
49735
+ }),
49736
+ seek: method(object({
49737
+ deviceId: number().int().nonnegative(),
49738
+ position: number().int().nonnegative()
49739
+ }), _void(), {
49740
+ kind: "mutation",
49741
+ auth: "protected"
49742
+ }),
49743
+ setVolume: method(object({
49744
+ deviceId: number().int().nonnegative(),
49745
+ volumeLevel: number().min(0).max(100)
49746
+ }), _void(), {
49747
+ kind: "mutation",
49748
+ auth: "protected"
49749
+ }),
49750
+ setMute: method(object({
49751
+ deviceId: number().int().nonnegative(),
49752
+ muted: boolean()
49753
+ }), _void(), {
49754
+ kind: "mutation",
49755
+ auth: "protected"
49756
+ }),
49757
+ setShuffle: method(object({
49758
+ deviceId: number().int().nonnegative(),
49759
+ shuffle: boolean()
49760
+ }), _void(), {
49761
+ kind: "mutation",
49762
+ auth: "protected"
49763
+ }),
49764
+ setRepeat: method(object({
49765
+ deviceId: number().int().nonnegative(),
49766
+ repeat: MediaPlayerRepeatSchema
49767
+ }), _void(), {
49768
+ kind: "mutation",
49769
+ auth: "protected"
49770
+ }),
49771
+ selectSource: method(object({
49772
+ deviceId: number().int().nonnegative(),
49773
+ source: string().min(1)
49774
+ }), _void(), {
49775
+ kind: "mutation",
49776
+ auth: "protected"
49777
+ }),
49778
+ playMedia: method(object({
49779
+ deviceId: number().int().nonnegative(),
49780
+ /** Media identifier / URL. */
49781
+ mediaId: string().min(1),
49782
+ /** Media kind (`music`, `tvshow`, `movie`, `app`, …) — provider
49783
+ * passes it through to the upstream service. */
49784
+ mediaType: string().min(1)
49785
+ }), _void(), {
49786
+ kind: "mutation",
49787
+ auth: "protected"
49788
+ })
49789
+ },
49790
+ status: {
49791
+ schema: MediaPlayerStatusSchema,
49792
+ kind: "push"
49793
+ },
49794
+ /**
49795
+ * Runtime-state slice — mirrored by the kernel. UI players read the
49796
+ * full slice for live now-playing, volume, and progress updates
49797
+ * without polling.
49798
+ */
49799
+ runtimeState: MediaPlayerStatusSchema,
49800
+ /**
49801
+ * Runtime-state durability: **session** — a restored transport position describes a playback that stopped when the hub did.
49802
+ *
49803
+ * See `RuntimeStateDurability`. Enforced by
49804
+ * `scripts/check-runtime-state-durability.ts`.
49805
+ */
49806
+ durability: "session",
49807
+ /**
49808
+ * History (D850): volume (a level an operator or an automation sets; the
49809
+ * default 10 s floor folds a slider drag into its end value) and mute.
49810
+ * `position` is not recorded: it moves continuously while playing.
49811
+ */
49812
+ history: { fields: {
49813
+ volumeLevel: {
49814
+ kind: "gauge",
49815
+ unit: "%",
49816
+ deadband: 1
49817
+ },
49818
+ isMuted: { kind: "boolean" }
49819
+ } }
49820
+ };
48509
49821
  DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Heater, DeviceType.Dryer, DeviceType.Gateway, DeviceType.Camera, DeviceType.Fan, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Gateway, DeviceType.Hub, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.PetFeeder, DeviceType.Heater;
48510
49822
  var NUMBER = {
48511
49823
  kind: "fixed",
@@ -48953,117 +50265,6 @@ function actuator(input) {
48953
50265
  };
48954
50266
  }
48955
50267
  new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
48956
- var PowerSourceRefusalReasonSchema = _enum([
48957
- "no-power-source",
48958
- "switch-missing",
48959
- "switch-offline",
48960
- "switch-unknown",
48961
- "restart-in-progress",
48962
- "switch-call-failed"
48963
- ]);
48964
- var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
48965
- accepted: literal(false),
48966
- reason: PowerSourceRefusalReasonSchema,
48967
- /** One line for the operator, naming the switch. */
48968
- message: string()
48969
- })]);
48970
- var PowerSourceInfoSchema = object({
48971
- /** False when the device has no power source linked; the rest is then empty. */
48972
- linked: boolean(),
48973
- switchDeviceId: number().nullable(),
48974
- switchName: string().nullable(),
48975
- /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
48976
- switchOn: boolean().nullable(),
48977
- switchOnline: boolean().nullable(),
48978
- restartInProgress: boolean(),
48979
- offSeconds: number().int()
48980
- });
48981
- /** The composed slice: the switch state the link mirrors, plus the stored off time. */
48982
- var PowerSourceStateSchema = object({
48983
- /** Null while the switch has not reported: unknown is never `false` (D393). */
48984
- switchOn: boolean().nullable(),
48985
- offSeconds: number().int(),
48986
- lastFetchedAt: number()
48987
- });
48988
- var POWER_SOURCE_DEVICE_TYPES = [
48989
- DeviceType.Gateway,
48990
- DeviceType.Hub,
48991
- DeviceType.Camera,
48992
- DeviceType.Sensor,
48993
- DeviceType.MediaPlayer,
48994
- DeviceType.Vacuum,
48995
- DeviceType.Generic,
48996
- DeviceType.Washer,
48997
- DeviceType.Dryer,
48998
- DeviceType.Dishwasher,
48999
- DeviceType.PetFountain,
49000
- DeviceType.Fan,
49001
- DeviceType.Humidifier,
49002
- DeviceType.Climate,
49003
- DeviceType.WaterHeater
49004
- ];
49005
- var powerSourceCustomize = {
49006
- version: 1,
49007
- targets: [{
49008
- id: "switch",
49009
- cardinality: "scalar",
49010
- vocabulary: {
49011
- cap: "power-source",
49012
- stateField: "switchOn"
49013
- },
49014
- deviceTypes: POWER_SOURCE_DEVICE_TYPES,
49015
- apply: "add",
49016
- path: "switchOn",
49017
- sources: [{
49018
- kind: "switch",
49019
- transforms: [{ kind: "identity" }]
49020
- }],
49021
- companions: [{
49022
- kind: "constant",
49023
- path: "offSeconds",
49024
- value: 10,
49025
- when: "add"
49026
- }, {
49027
- kind: "clock",
49028
- path: "lastFetchedAt",
49029
- when: "always"
49030
- }],
49031
- sourceReport: { status: "assignment-status" }
49032
- }]
49033
- };
49034
- var deviceInput$2 = object({ deviceId: number().int().nonnegative() });
49035
- var powerSourceCapability = {
49036
- name: "power-source",
49037
- scope: "device",
49038
- mode: "singleton",
49039
- deviceTypes: POWER_SOURCE_DEVICE_TYPES,
49040
- methods: {
49041
- getStatus: systemMethod(deviceInput$2, PowerSourceInfoSchema, { auth: "admin" }),
49042
- powerOn: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
49043
- kind: "mutation",
49044
- auth: "admin"
49045
- }),
49046
- powerOff: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
49047
- kind: "mutation",
49048
- auth: "admin"
49049
- }),
49050
- forceRestart: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
49051
- kind: "mutation",
49052
- auth: "admin"
49053
- })
49054
- },
49055
- runtimeState: PowerSourceStateSchema,
49056
- customize: powerSourceCustomize,
49057
- /**
49058
- * Runtime-state durability: **session** — mirrored from the linked switch on
49059
- * its next report; a restored value would outlive the reading it names.
49060
- *
49061
- * See `RuntimeStateDurability`. Enforced by
49062
- * `scripts/check-runtime-state-durability.ts`.
49063
- */
49064
- durability: "session",
49065
- history: "none"
49066
- };
49067
50268
  DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
49068
50269
  DeviceType.Camera;
49069
50270
  `${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
@@ -49091,6 +50292,168 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
49091
50292
  }).optional()
49092
50293
  })) });
49093
50294
  /**
50295
+ * A saved Customize assignment (D936). The schema is the type: callers use
50296
+ * `z.infer`, they do not restate the shape.
50297
+ */
50298
+ var OverrideSourceSchema = object({
50299
+ addonId: string().min(1),
50300
+ stableId: string().min(1),
50301
+ cap: string().min(1),
50302
+ fieldPath: string().min(1)
50303
+ });
50304
+ var IdentityTransformDraftSchema = object({ kind: literal("identity") });
50305
+ var InvertTransformDraftSchema = object({ kind: literal("invert") });
50306
+ var ThresholdTransformDraftSchema = object({
50307
+ kind: literal("threshold"),
50308
+ comparison: _enum(["gte", "lte"]),
50309
+ threshold: number(),
50310
+ startDwellMs: number().nonnegative(),
50311
+ stopDwellMs: number().nonnegative()
50312
+ });
50313
+ var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
50314
+ IdentityTransformDraftSchema,
50315
+ InvertTransformDraftSchema,
50316
+ ThresholdTransformDraftSchema,
50317
+ object({
50318
+ kind: literal("linear"),
50319
+ scale: number(),
50320
+ offset: number(),
50321
+ clampMin: number().optional(),
50322
+ clampMax: number().optional()
50323
+ }),
50324
+ object({
50325
+ kind: literal("enum-map"),
50326
+ mapping: record(string(), string().nullable())
50327
+ }),
50328
+ object({ kind: literal("number") })
50329
+ ]);
50330
+ var ScalarOverrideDraftSchema = object({
50331
+ kind: literal("scalar"),
50332
+ cap: string().min(1),
50333
+ targetId: string().min(1),
50334
+ source: OverrideSourceSchema,
50335
+ transform: CustomizeTransformDraftSchema
50336
+ });
50337
+ var KeyedArrayOverrideDraftSchema = object({
50338
+ kind: literal("keyedArray"),
50339
+ cap: string().min(1),
50340
+ targetId: string().min(1),
50341
+ key: string().min(1),
50342
+ label: string().min(1),
50343
+ fieldPath: string().min(1),
50344
+ source: OverrideSourceSchema,
50345
+ transform: CustomizeTransformDraftSchema
50346
+ });
50347
+ var PulseOverrideDraftSchema = object({
50348
+ kind: literal("pulse"),
50349
+ cap: string().min(1),
50350
+ targetId: string().min(1),
50351
+ enabled: boolean(),
50352
+ debounceMs: number().nonnegative(),
50353
+ edges: array(_enum([
50354
+ "rising",
50355
+ "button",
50356
+ "native-event"
50357
+ ])).min(1).optional(),
50358
+ sources: array(OverrideSourceSchema).min(1)
50359
+ });
50360
+ var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: _enum([
50361
+ "in-addition",
50362
+ "confirm",
50363
+ "replace"
50364
+ ]).optional() });
50365
+ discriminatedUnion("kind", [
50366
+ ScalarOverrideDraftSchema,
50367
+ KeyedArrayOverrideDraftSchema,
50368
+ PulseOverrideDraftSchema,
50369
+ object({
50370
+ kind: literal("span"),
50371
+ cap: string().min(1),
50372
+ targetId: string().min(1),
50373
+ timeoutMs: number().nonnegative(),
50374
+ cooldownMs: number().nonnegative().optional(),
50375
+ sources: array(SpanSourceDraftSchema)
50376
+ })
50377
+ ]);
50378
+ object({
50379
+ targetId: string().min(1),
50380
+ configured: boolean(),
50381
+ source: _enum(["native", "assigned"]),
50382
+ state: _enum([
50383
+ "active",
50384
+ "stale",
50385
+ "released",
50386
+ "unavailable"
50387
+ ]),
50388
+ reason: string().nullable()
50389
+ });
50390
+ /**
50391
+ * What a running-threshold proposal says (planning#405). The schema is the
50392
+ * type: the algorithm, the capability method and the UI all read `z.infer`.
50393
+ *
50394
+ * A proposal is read-only advice: it carries the numbers it was derived from
50395
+ * (`evidence`) so the operator can judge it, and an `insufficient` answer names
50396
+ * WHY with a typed reason and the catalog defaults, never an invented number.
50397
+ */
50398
+ var RunningProposalTierSchema = _enum(["raw", "5m"]);
50399
+ var RunningProposalConfidenceSchema = _enum([
50400
+ "high",
50401
+ "medium",
50402
+ "low"
50403
+ ]);
50404
+ var RunningProposalInsufficientReasonSchema = _enum([
50405
+ "no-history",
50406
+ "span-too-short",
50407
+ "truncated",
50408
+ "no-idle-floor",
50409
+ "no-runs",
50410
+ "no-separation"
50411
+ ]);
50412
+ var RunningProposalReplaySchema = object({
50413
+ /** Intervals the real dwell expression held true over the window. */
50414
+ intervals: number().int().nonnegative(),
50415
+ /** Intervals outside every run, or a second interval inside one. */
50416
+ extra: number().int().nonnegative(),
50417
+ /** Runs without an interval of their own (none, or merged into a neighbour). */
50418
+ missed: number().int().nonnegative()
50419
+ });
50420
+ var RunningProposalEvidenceSchema = object({
50421
+ tier: RunningProposalTierSchema,
50422
+ spanMs: number().nonnegative(),
50423
+ from: number(),
50424
+ to: number(),
50425
+ points: number().int().nonnegative(),
50426
+ runsFound: number().int().nonnegative(),
50427
+ pausesFound: number().int().nonnegative(),
50428
+ longestPauseMs: number().nonnegative(),
50429
+ /** Episodes shorter than ~90 s (an anti-crease pulse, a display waking): never a run, never a pause. */
50430
+ pulsesFound: number().int().nonnegative(),
50431
+ longestPulseMs: number().nonnegative(),
50432
+ idleFloorW: number(),
50433
+ noiseCeilingW: number(),
50434
+ plateauW: number(),
50435
+ replay: RunningProposalReplaySchema
50436
+ });
50437
+ var RunningProposalInsufficientEvidenceSchema = object({
50438
+ spanMs: number().nonnegative(),
50439
+ points: number().int().nonnegative(),
50440
+ runsFound: number().int().nonnegative()
50441
+ });
50442
+ var RunningThresholdProposalSchema = discriminatedUnion("state", [object({
50443
+ state: literal("proposal"),
50444
+ transform: ThresholdTransformDraftSchema,
50445
+ evidence: RunningProposalEvidenceSchema,
50446
+ confidence: RunningProposalConfidenceSchema,
50447
+ /** Why the confidence is not higher; empty when nothing held it back. */
50448
+ notes: array(string())
50449
+ }), object({
50450
+ state: literal("insufficient"),
50451
+ reason: RunningProposalInsufficientReasonSchema,
50452
+ evidence: RunningProposalInsufficientEvidenceSchema,
50453
+ /** The catalog defaults, offered as what stands when nothing better is known. */
50454
+ fallback: ThresholdTransformDraftSchema
50455
+ })]);
50456
+ /**
49094
50457
  * The report of a one-shot "move this owner's plaintext secrets into the
49095
50458
  * keychain" run (D878). COUNTS only - never a value, never a ref.
49096
50459
  *
@@ -49380,6 +50743,14 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
49380
50743
  kind: "mutation",
49381
50744
  auth: "admin",
49382
50745
  access: "view"
50746
+ }), method(object({
50747
+ deviceId: number().int(),
50748
+ cap: string().min(1),
50749
+ fieldPath: string().min(1),
50750
+ deviceType: _enum(DeviceType).optional()
50751
+ }), RunningThresholdProposalSchema, {
50752
+ auth: "admin",
50753
+ access: "view"
49383
50754
  }), method(object({
49384
50755
  blockId: string().min(1),
49385
50756
  trace: AutomationRunTraceSchema.optional(),
@@ -50356,7 +51727,27 @@ method(object({
50356
51727
  * exposes only the COMMON surface: link state, supported device
50357
51728
  * kinds (so the UI can filter the device picker), and per-device
50358
51729
  * expose/unexpose.
50359
- */
51730
+ *
51731
+ * INSTANCES. One export addon can serve several independent targets (a
51732
+ * HomeKit bridge, a Home Assistant broker). `listInstances` names them.
51733
+ * `instanceId` on a READ is optional: absent = the whole addon (linked if any
51734
+ * enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
51735
+ * default instance's); present = that instance; an id the provider does not
51736
+ * serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
51737
+ * never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
51738
+ * change always names the target it changes. A single-instance provider
51739
+ * accepts an absent id on a read or its own id, and refuses any other.
51740
+ */
51741
+ /** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
51742
+ var InstanceIdSchema$1 = string().min(1);
51743
+ var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
51744
+ /** One independent export target of an addon. */
51745
+ var ExportInstanceSchema = object({
51746
+ instanceId: InstanceIdSchema$1,
51747
+ name: string(),
51748
+ enabled: boolean(),
51749
+ kind: string().optional()
51750
+ });
50360
51751
  var LinkStateSchema = _enum([
50361
51752
  "unlinked",
50362
51753
  "linked",
@@ -50407,10 +51798,14 @@ var ExposedDeviceSchema = object({
50407
51798
  capabilities: array(string()).optional()
50408
51799
  });
50409
51800
  var ExposeInputSchema = object({
51801
+ instanceId: InstanceIdSchema$1,
50410
51802
  deviceId: string(),
50411
51803
  capabilities: array(string()).optional()
50412
51804
  });
50413
- var UnexposeInputSchema = object({ deviceId: string() });
51805
+ var UnexposeInputSchema = object({
51806
+ instanceId: InstanceIdSchema$1,
51807
+ deviceId: string()
51808
+ });
50414
51809
  /**
50415
51810
  * What an exporter may expose besides devices (D968). An action and a
50416
51811
  * notification target are LIST ENTRIES, never devices (D954): they enter an
@@ -50439,15 +51834,21 @@ var ExposedEntitySchema = object({
50439
51834
  entity: ExportEntityRefSchema,
50440
51835
  exposedAs: string().optional()
50441
51836
  });
50442
- var ExposeEntityInputSchema = object({ entity: ExportEntityRefSchema });
50443
- var UnexposeEntityInputSchema = object({ entity: ExportEntityRefSchema });
50444
- method(_void(), DeviceExportStatusSchema), method(_void(), array(DeviceKindSchema)), method(_void(), array(ExposedDeviceSchema)), method(ExposeInputSchema, _void(), {
51837
+ var ExposeEntityInputSchema = object({
51838
+ instanceId: InstanceIdSchema$1,
51839
+ entity: ExportEntityRefSchema
51840
+ });
51841
+ var UnexposeEntityInputSchema = object({
51842
+ instanceId: InstanceIdSchema$1,
51843
+ entity: ExportEntityRefSchema
51844
+ });
51845
+ method(InstancePinSchema, DeviceExportStatusSchema), method(_void(), array(ExportInstanceSchema)), method(InstancePinSchema, array(DeviceKindSchema)), method(InstancePinSchema, array(ExposedDeviceSchema)), method(ExposeInputSchema, _void(), {
50445
51846
  kind: "mutation",
50446
51847
  auth: "admin"
50447
51848
  }), method(UnexposeInputSchema, _void(), {
50448
51849
  kind: "mutation",
50449
51850
  auth: "admin"
50450
- }), optionalMethod(_void(), array(ExportEntityKindSchema)), optionalMethod(_void(), array(ExposedEntitySchema)), optionalMethod(ExposeEntityInputSchema, _void(), {
51851
+ }), optionalMethod(_void(), array(ExportEntityKindSchema)), optionalMethod(InstancePinSchema, array(ExposedEntitySchema)), optionalMethod(ExposeEntityInputSchema, _void(), {
50451
51852
  kind: "mutation",
50452
51853
  auth: "admin"
50453
51854
  }), optionalMethod(UnexposeEntityInputSchema, _void(), {
@@ -52449,7 +53850,7 @@ var DishwasherStatusSchema = object({
52449
53850
  /** Ms epoch of the last value received from the appliance; 0 = never. */
52450
53851
  lastFetchedAt: number()
52451
53852
  });
52452
- var DeviceIdSchema$1 = number().int().nonnegative();
53853
+ var DeviceIdSchema$2 = number().int().nonnegative();
52453
53854
  /** A value a program option or setting can take. */
52454
53855
  var DishwasherValueSchema = union([
52455
53856
  boolean(),
@@ -52524,77 +53925,77 @@ var dishwasherCapability = {
52524
53925
  * option feature keys; each is checked against the program's constraints.
52525
53926
  */
52526
53927
  start: method(object({
52527
- deviceId: DeviceIdSchema$1,
53928
+ deviceId: DeviceIdSchema$2,
52528
53929
  program: string().min(1).optional(),
52529
53930
  options: record(string(), DishwasherValueSchema).optional()
52530
53931
  }), _void(), {
52531
53932
  kind: "mutation",
52532
53933
  auth: "protected"
52533
53934
  }),
52534
- pause: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
53935
+ pause: method(object({ deviceId: DeviceIdSchema$2 }), _void(), {
52535
53936
  kind: "mutation",
52536
53937
  auth: "protected"
52537
53938
  }),
52538
- resume: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
53939
+ resume: method(object({ deviceId: DeviceIdSchema$2 }), _void(), {
52539
53940
  kind: "mutation",
52540
53941
  auth: "protected"
52541
53942
  }),
52542
- stop: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
53943
+ stop: method(object({ deviceId: DeviceIdSchema$2 }), _void(), {
52543
53944
  kind: "mutation",
52544
53945
  auth: "protected"
52545
53946
  }),
52546
53947
  /** Select (not start) a program; refused when the appliance does not offer it. */
52547
53948
  setProgram: method(object({
52548
- deviceId: DeviceIdSchema$1,
53949
+ deviceId: DeviceIdSchema$2,
52549
53950
  program: string().min(1)
52550
53951
  }), _void(), {
52551
53952
  kind: "mutation",
52552
53953
  auth: "protected"
52553
53954
  }),
52554
53955
  setPower: method(object({
52555
- deviceId: DeviceIdSchema$1,
53956
+ deviceId: DeviceIdSchema$2,
52556
53957
  on: boolean()
52557
53958
  }), _void(), {
52558
53959
  kind: "mutation",
52559
53960
  auth: "protected"
52560
53961
  }),
52561
53962
  setHalfLoad: method(object({
52562
- deviceId: DeviceIdSchema$1,
53963
+ deviceId: DeviceIdSchema$2,
52563
53964
  on: boolean()
52564
53965
  }), _void(), {
52565
53966
  kind: "mutation",
52566
53967
  auth: "protected"
52567
53968
  }),
52568
53969
  setHygienePlus: method(object({
52569
- deviceId: DeviceIdSchema$1,
53970
+ deviceId: DeviceIdSchema$2,
52570
53971
  on: boolean()
52571
53972
  }), _void(), {
52572
53973
  kind: "mutation",
52573
53974
  auth: "protected"
52574
53975
  }),
52575
53976
  setExtraDry: method(object({
52576
- deviceId: DeviceIdSchema$1,
53977
+ deviceId: DeviceIdSchema$2,
52577
53978
  on: boolean()
52578
53979
  }), _void(), {
52579
53980
  kind: "mutation",
52580
53981
  auth: "protected"
52581
53982
  }),
52582
53983
  setIntensiveZone: method(object({
52583
- deviceId: DeviceIdSchema$1,
53984
+ deviceId: DeviceIdSchema$2,
52584
53985
  on: boolean()
52585
53986
  }), _void(), {
52586
53987
  kind: "mutation",
52587
53988
  auth: "protected"
52588
53989
  }),
52589
53990
  setVarioSpeedPlus: method(object({
52590
- deviceId: DeviceIdSchema$1,
53991
+ deviceId: DeviceIdSchema$2,
52591
53992
  on: boolean()
52592
53993
  }), _void(), {
52593
53994
  kind: "mutation",
52594
53995
  auth: "protected"
52595
53996
  }),
52596
53997
  setChildLock: method(object({
52597
- deviceId: DeviceIdSchema$1,
53998
+ deviceId: DeviceIdSchema$2,
52598
53999
  on: boolean()
52599
54000
  }), _void(), {
52600
54001
  kind: "mutation",
@@ -52606,7 +54007,7 @@ var dishwasherCapability = {
52606
54007
  * its declared range / members.
52607
54008
  */
52608
54009
  setOption: method(object({
52609
- deviceId: DeviceIdSchema$1,
54010
+ deviceId: DeviceIdSchema$2,
52610
54011
  key: string().min(1),
52611
54012
  value: DishwasherValueSchema
52612
54013
  }), _void(), {
@@ -52614,7 +54015,7 @@ var dishwasherCapability = {
52614
54015
  auth: "protected"
52615
54016
  }),
52616
54017
  /** What this appliance can do, from its own description — the UI is derived from it. */
52617
- getOptions: method(object({ deviceId: DeviceIdSchema$1 }), DishwasherOptionsSchema, { auth: "protected" })
54018
+ getOptions: method(object({ deviceId: DeviceIdSchema$2 }), DishwasherOptionsSchema, { auth: "protected" })
52618
54019
  },
52619
54020
  status: {
52620
54021
  schema: DishwasherStatusSchema,
@@ -54038,15 +55439,15 @@ var FanPresetCaptureResultSchema = object({
54038
55439
  items: array(FanCaptureItemSchema),
54039
55440
  omitted: array(FanCaptureOmissionSchema)
54040
55441
  });
54041
- var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
55442
+ var deviceInput$2 = object({ deviceId: number().int().nonnegative() });
54042
55443
  DeviceType.Fan;
54043
- method(deviceInput$1, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$1.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
55444
+ method(deviceInput$2, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$2.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
54044
55445
  kind: "mutation",
54045
55446
  auth: "admin"
54046
- }), method(deviceInput$1.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
55447
+ }), method(deviceInput$2.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
54047
55448
  kind: "mutation",
54048
55449
  auth: "protected"
54049
- }), method(deviceInput$1.extend({
55450
+ }), method(deviceInput$2.extend({
54050
55451
  fields: array(FanCaptureFieldSchema).optional(),
54051
55452
  steps: array(ActionStepSchema).max(20).default([])
54052
55453
  }), FanPresetCaptureResultSchema, { auth: "protected" });
@@ -54894,11 +56295,7 @@ var CreateIntegrationInputSchema = object({
54894
56295
  info: record(string(), unknown()).optional(),
54895
56296
  /** `stableId` of the discovery candidate the form was seeded from (D984). */
54896
56297
  originStableId: string().optional(),
54897
- settings: record(string(), unknown()).optional(),
54898
- /** Keys of `settings` the form's schema declares secret (by type) — kept in
54899
- * the keychain, not the table (D787). */
54900
- secretKeys: array(string()).optional(),
54901
- skipRestart: boolean().optional()
56298
+ settings: record(string(), unknown()).optional()
54902
56299
  });
54903
56300
  var UpdateIntegrationInputSchema = object({
54904
56301
  id: string(),
@@ -54919,16 +56316,6 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
54919
56316
  }), method(object({ id: string() }), DeleteIntegrationResultSchema, {
54920
56317
  kind: "mutation",
54921
56318
  auth: "admin"
54922
- }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
54923
- id: string(),
54924
- settings: record(string(), unknown()),
54925
- /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
54926
- secretKeys: array(string()).optional(),
54927
- /** The integration's own addon applies the change in-process and asks the hub not to respawn it. */
54928
- skipRestart: boolean().optional()
54929
- }), object({ success: boolean() }), {
54930
- kind: "mutation",
54931
- auth: "admin"
54932
56319
  }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
54933
56320
  addonId: string(),
54934
56321
  settings: record(string(), unknown())
@@ -54957,13 +56344,65 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
54957
56344
  */
54958
56345
  var ConfigSchemaPassthrough$3 = custom();
54959
56346
  var IntegrationInstanceIdSchema = string().min(1);
56347
+ var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
56348
+ /**
56349
+ * One kind of instance a provider can create (an adapter, an account type). The sign-in and
56350
+ * connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
56351
+ * hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
56352
+ * interactive account link (popup) and may carry `{{brokerId}}`, which the UI replaces with the
56353
+ * instance id.
56354
+ */
56355
+ var IntegrationInstanceKindSchema = object({
56356
+ /** Stable id of the kind, sent back as `createInstance.kind`. */
56357
+ id: string().min(1),
56358
+ label: string().min(1),
56359
+ /** The kind signs in through a server-held interactive session. */
56360
+ signIn: object({
56361
+ basePath: string().min(1),
56362
+ methods: array(_enum(["device-code", "proxy"])).optional()
56363
+ }).optional(),
56364
+ /** Relative hub path to start an interactive account link of an instance of this kind. */
56365
+ connectPath: string().min(1).optional(),
56366
+ /** Relative hub path to disconnect that account. */
56367
+ disconnectPath: string().min(1).optional()
56368
+ });
54960
56369
  var IntegrationInstanceDescriptionSchema = object({
56370
+ /** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
56371
+ role: _enum([
56372
+ "devices",
56373
+ "services",
56374
+ "both"
56375
+ ]),
56376
+ /** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
56377
+ discovery: object({
56378
+ mode: _enum([
56379
+ "none",
56380
+ "lan",
56381
+ "account"
56382
+ ]),
56383
+ scopedToInstance: boolean()
56384
+ }).optional(),
54961
56385
  /** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
54962
- instanceMode: _enum(["single", "multiple"]),
56386
+ instanceMode: IntegrationInstanceModeSchema,
54963
56387
  /** What the instance is, for the UI (`destination`, `relay`, `account`). */
54964
56388
  kind: string(),
54965
56389
  /** True when `testInstance` really probes the remote. */
54966
- canTest: boolean()
56390
+ canTest: boolean(),
56391
+ /**
56392
+ * The kinds an instance can be of. Absent or one entry: nothing to choose; more than one: the
56393
+ * Add flow asks which first and sends it as `createInstance.kind`.
56394
+ */
56395
+ kinds: array(IntegrationInstanceKindSchema).optional(),
56396
+ /**
56397
+ * The provider accepts `createInstance.id` for an id that once existed (an adopted id, because
56398
+ * devices carry it). The UI then offers "restore under its old id" on Add. Absent means no.
56399
+ */
56400
+ allowRestoreId: boolean().optional(),
56401
+ /**
56402
+ * `createInstance` without an `id` works: the provider mints it. Absent means the caller must
56403
+ * send an id (the UI then mints an opaque one).
56404
+ */
56405
+ mintsId: boolean().optional()
54967
56406
  });
54968
56407
  var IntegrationInstanceStatusSchema = object({
54969
56408
  state: _enum([
@@ -54972,16 +56411,28 @@ var IntegrationInstanceStatusSchema = object({
54972
56411
  "error",
54973
56412
  "unknown"
54974
56413
  ]),
54975
- detail: string().optional()
56414
+ detail: string().optional(),
56415
+ /** A short human word for the state ("Signed in", "Token expired"); shown instead of `state`. */
56416
+ label: string().optional()
54976
56417
  });
54977
56418
  var IntegrationInstanceSchema = object({
54978
56419
  id: IntegrationInstanceIdSchema,
54979
56420
  name: string(),
54980
56421
  /** The addon's own rule (an URL is present, a client id is present...). */
54981
56422
  configured: boolean(),
56423
+ /**
56424
+ * The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
56425
+ * so a row written before the field existed is on). Absent when the `integrations` registry
56426
+ * owns the switch (`describe().role` is `devices`): read it from the registry row.
56427
+ */
56428
+ enabled: boolean().optional(),
56429
+ /** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
56430
+ kind: string().optional(),
54982
56431
  /** Values for the instance form; a secret is a `SecretFieldView`, never text. */
54983
56432
  formValues: record(string(), unknown()),
54984
- status: IntegrationInstanceStatusSchema.optional()
56433
+ status: IntegrationInstanceStatusSchema.optional(),
56434
+ /** Epoch ms of the last probe of the remote that produced `status`; absent when never checked. */
56435
+ lastCheckedAt: number().optional()
54985
56436
  });
54986
56437
  var IntegrationInstancePatchSchema = object({
54987
56438
  id: IntegrationInstanceIdSchema,
@@ -54989,25 +56440,57 @@ var IntegrationInstancePatchSchema = object({
54989
56440
  /** Omitted / '' / redaction token keeps a secret; `{ $secretClear: true }` clears it. */
54990
56441
  values: record(string(), unknown())
54991
56442
  });
54992
- method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }), method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3, { auth: "admin" }), method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }), method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }), method(object({
54993
- id: IntegrationInstanceIdSchema,
54994
- name: string().min(1)
54995
- }), object({ id: string() }), {
54996
- kind: "mutation",
54997
- auth: "admin"
54998
- }), method(IntegrationInstancePatchSchema, object({ ok: literal(true) }), {
54999
- kind: "mutation",
55000
- auth: "admin"
55001
- }), method(object({ id: IntegrationInstanceIdSchema }), object({ ok: literal(true) }), {
55002
- kind: "mutation",
55003
- auth: "admin"
55004
- }), optionalMethod(object({
55005
- id: IntegrationInstanceIdSchema.nullable(),
55006
- values: record(string(), unknown())
55007
- }), TestConnectionResultSchema$1, {
55008
- kind: "mutation",
55009
- auth: "admin"
55010
- });
56443
+ var integrationInstancesCapability = {
56444
+ name: "integration-instances",
56445
+ scope: "system",
56446
+ mode: "collection",
56447
+ methods: {
56448
+ describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
56449
+ /** The form; `id: null` is the create form. */
56450
+ instanceFormSchema: method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3, { auth: "admin" }),
56451
+ listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
56452
+ getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
56453
+ /**
56454
+ * Insert the typed record. With `id` it is stored under that id (a duplicate id is refused);
56455
+ * without one the PROVIDER mints it and answers it. `kind` picks one of `describe().kinds`.
56456
+ */
56457
+ createInstance: method(object({
56458
+ id: IntegrationInstanceIdSchema.optional(),
56459
+ name: string().min(1),
56460
+ kind: string().min(1).optional()
56461
+ }), object({ id: string() }), {
56462
+ kind: "mutation",
56463
+ auth: "admin"
56464
+ }),
56465
+ updateInstance: method(IntegrationInstancePatchSchema, object({ ok: literal(true) }), {
56466
+ kind: "mutation",
56467
+ auth: "admin"
56468
+ }),
56469
+ /**
56470
+ * Switch ONE instance on or off. A row control, not a form field: `updateInstance.values` is the
56471
+ * form patch (D62, D996). An off instance keeps its record and secrets and does no work.
56472
+ */
56473
+ setInstanceEnabled: method(object({
56474
+ id: IntegrationInstanceIdSchema,
56475
+ enabled: boolean()
56476
+ }), object({ ok: literal(true) }), {
56477
+ kind: "mutation",
56478
+ auth: "admin"
56479
+ }),
56480
+ /** Delete the record and its keychain refs together. */
56481
+ deleteInstance: method(object({ id: IntegrationInstanceIdSchema }), object({ ok: literal(true) }), {
56482
+ kind: "mutation",
56483
+ auth: "admin"
56484
+ }),
56485
+ testInstance: optionalMethod(object({
56486
+ id: IntegrationInstanceIdSchema.nullable(),
56487
+ values: record(string(), unknown())
56488
+ }), TestConnectionResultSchema$1, {
56489
+ kind: "mutation",
56490
+ auth: "admin"
56491
+ })
56492
+ }
56493
+ };
55011
56494
  /**
55012
56495
  * Two-way audio / talk-back cap. Clients open a WebRTC audio-only
55013
56496
  * session (server-initiated offer pattern, identical to the main
@@ -57025,6 +58508,11 @@ var LogEntrySchema = object({
57025
58508
  * flight, and not asking for the next slice ends the scan.
57026
58509
  */
57027
58510
  var LogReadQuerySchema = object({
58511
+ /**
58512
+ * Which destination INSTANCE answers (a destination addon may hold several records). Absent ⇒
58513
+ * the provider's first readable one, so a caller written before instances existed is unchanged.
58514
+ */
58515
+ instanceId: string().min(1).max(200).optional(),
57028
58516
  /** Correlates `cancelRead`. Caller-chosen, unique per in-flight read. */
57029
58517
  requestId: string().min(1).max(64).optional(),
57030
58518
  /** The device the line is about (`tags.deviceId`, numeric). */
@@ -57087,6 +58575,8 @@ var LogReadResultSchema = object({
57087
58575
  /** True when `cancelRead` ended this slice early. */
57088
58576
  cancelled: boolean().optional()
57089
58577
  });
58578
+ /** Names one destination instance; absent ⇒ the provider's first readable one. */
58579
+ var LogInstanceSelectorSchema = object({ instanceId: string().min(1).max(200).optional() });
57090
58580
  var LogReadCapabilitiesSchema = object({
57091
58581
  /** False ⇒ this destination only ships lines (console, forwarder, an unconfigured Loki). */
57092
58582
  readable: boolean(),
@@ -57105,7 +58595,7 @@ var LogReadCapabilitiesSchema = object({
57105
58595
  /** How far back the store reaches, when the provider knows (days). */
57106
58596
  retentionDays: number().nullable()
57107
58597
  });
57108
- method(LogEntrySchema, _void(), { kind: "mutation" }), optionalMethod(_void(), LogReadCapabilitiesSchema, { auth: "admin" }), optionalMethod(LogReadQuerySchema, LogReadResultSchema, { auth: "admin" }), optionalMethod(object({ requestId: string().min(1).max(64) }), object({ cancelled: boolean() }), {
58598
+ method(LogEntrySchema, _void(), { kind: "mutation" }), optionalMethod(LogInstanceSelectorSchema, LogReadCapabilitiesSchema, { auth: "admin" }), optionalMethod(LogReadQuerySchema, LogReadResultSchema, { auth: "admin" }), optionalMethod(object({ requestId: string().min(1).max(64) }), object({ cancelled: boolean() }), {
57109
58599
  kind: "mutation",
57110
58600
  auth: "admin"
57111
58601
  });
@@ -57209,214 +58699,6 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
57209
58699
  ]);
57210
58700
  method(_void(), array(LoginMethodContributionSchema).readonly());
57211
58701
  /**
57212
- * Media-player cap. Models HA `media_player.*` (Sonos, Chromecast,
57213
- * Apple TV, Spotify, Roku, generic OTT receivers, …) on
57214
- * `DeviceType.MediaPlayer`. Disjoint from the camera streaming
57215
- * surface — those use `DeviceType.Camera` + the broker pipeline.
57216
- *
57217
- * The cap declares a wide method surface; not every backend supports
57218
- * every method. Drivers signal sub-capability via the
57219
- * `DeviceFeature.MediaPlayerXxx` flags (paired one-to-one with the
57220
- * corresponding method) so the UI gates buttons without a slice
57221
- * fetch — same pattern as `PanTiltZoom` for cameras.
57222
- */
57223
- var MediaPlayerStateSchema = _enum([
57224
- "off",
57225
- "on",
57226
- "idle",
57227
- "playing",
57228
- "paused",
57229
- "buffering",
57230
- "standby"
57231
- ]);
57232
- var MediaPlayerRepeatSchema = _enum([
57233
- "off",
57234
- "all",
57235
- "one"
57236
- ]);
57237
- var MediaInfoSchema = object({
57238
- /** Free-form media kind (`music`, `tvshow`, `movie`, `app`, `channel`,
57239
- * `podcast`, …). */
57240
- type: string(),
57241
- /** Human-readable title. */
57242
- title: string(),
57243
- /** Optional artist / channel / station label. */
57244
- artist: string().optional(),
57245
- /** Optional album / season / show name. */
57246
- album: string().optional(),
57247
- /** Optional cover-art / thumbnail URL. */
57248
- imageUrl: string().optional()
57249
- });
57250
- /**
57251
- * Where `state`, `volumeLevel`, `isMuted` and `source` come from. `reported`:
57252
- * the device said so. `assumed`: the driver has no feedback (infrared) and
57253
- * tracks what it last SENT; it moves only after a send was accepted, and a
57254
- * human at the real remote makes it wrong. A UI shows an assumed value as a
57255
- * guess, never as a reading.
57256
- */
57257
- var MediaPlayerStateSourceSchema = _enum(["reported", "assumed"]);
57258
- /** The fields of a media-player status a driver can only guess. */
57259
- var MediaPlayerAssumedFieldSchema = _enum([
57260
- "state",
57261
- "volumeLevel",
57262
- "isMuted",
57263
- "source"
57264
- ]);
57265
- var MediaPlayerStatusSchema = object({
57266
- /** Playback lifecycle state. */
57267
- state: MediaPlayerStateSchema,
57268
- /**
57269
- * Whether the state fields are readings or the driver's own bookkeeping.
57270
- * A slice written before this field existed parses as `reported`.
57271
- */
57272
- stateSource: MediaPlayerStateSourceSchema.default("reported"),
57273
- /**
57274
- * Which fields are the driver's own guess. `stateSource` is `assumed` when
57275
- * this is not empty; a field not listed here is a reading even then (power
57276
- * from a running-state source, mute guessed from the last send).
57277
- */
57278
- assumedFields: array(MediaPlayerAssumedFieldSchema).default([]),
57279
- /** Volume as 0..100 inclusive. Null when the device has no volume
57280
- * surface. Pair with `DeviceFeature.MediaPlayerVolume`. */
57281
- volumeLevel: number().min(0).max(100).nullable().meta(readingMeta("percentage")),
57282
- /** Mute toggle distinct from volume=0. Null when no mute surface.
57283
- * Pair with `DeviceFeature.MediaPlayerMute`. */
57284
- isMuted: boolean().nullable(),
57285
- /** Active source / input. Empty when no source surface. */
57286
- source: string(),
57287
- /** Selectable sources. Empty when no source surface.
57288
- * Pair with `DeviceFeature.MediaPlayerSelectSource`. */
57289
- availableSources: array(string()),
57290
- /** Currently-playing media info. Null when nothing is playing. */
57291
- currentMedia: MediaInfoSchema.nullable(),
57292
- /** Current playback position in ms. Null when not seekable or
57293
- * nothing is playing. Pair with `DeviceFeature.MediaPlayerSeek`. */
57294
- position: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
57295
- /** Total duration of the current media in ms. Null when unknown
57296
- * (live stream) or nothing is playing. */
57297
- duration: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
57298
- /** Shuffle toggle. Null when no shuffle surface.
57299
- * Pair with `DeviceFeature.MediaPlayerShuffle`. */
57300
- shuffle: boolean().nullable(),
57301
- /** Repeat mode. Null when no repeat surface.
57302
- * Pair with `DeviceFeature.MediaPlayerRepeat`. */
57303
- repeat: MediaPlayerRepeatSchema.nullable(),
57304
- /** Ms epoch when the slice was last updated. */
57305
- lastChangedAt: number()
57306
- });
57307
- var mediaPlayerCapability = {
57308
- name: "media-player",
57309
- scope: "device",
57310
- deviceNative: true,
57311
- mode: "singleton",
57312
- deviceTypes: [DeviceType.MediaPlayer],
57313
- methods: {
57314
- play: method(object({ deviceId: number().int().nonnegative() }), _void(), {
57315
- kind: "mutation",
57316
- auth: "protected"
57317
- }),
57318
- pause: method(object({ deviceId: number().int().nonnegative() }), _void(), {
57319
- kind: "mutation",
57320
- auth: "protected"
57321
- }),
57322
- stop: method(object({ deviceId: number().int().nonnegative() }), _void(), {
57323
- kind: "mutation",
57324
- auth: "protected"
57325
- }),
57326
- next: method(object({ deviceId: number().int().nonnegative() }), _void(), {
57327
- kind: "mutation",
57328
- auth: "protected"
57329
- }),
57330
- previous: method(object({ deviceId: number().int().nonnegative() }), _void(), {
57331
- kind: "mutation",
57332
- auth: "protected"
57333
- }),
57334
- seek: method(object({
57335
- deviceId: number().int().nonnegative(),
57336
- position: number().int().nonnegative()
57337
- }), _void(), {
57338
- kind: "mutation",
57339
- auth: "protected"
57340
- }),
57341
- setVolume: method(object({
57342
- deviceId: number().int().nonnegative(),
57343
- volumeLevel: number().min(0).max(100)
57344
- }), _void(), {
57345
- kind: "mutation",
57346
- auth: "protected"
57347
- }),
57348
- setMute: method(object({
57349
- deviceId: number().int().nonnegative(),
57350
- muted: boolean()
57351
- }), _void(), {
57352
- kind: "mutation",
57353
- auth: "protected"
57354
- }),
57355
- setShuffle: method(object({
57356
- deviceId: number().int().nonnegative(),
57357
- shuffle: boolean()
57358
- }), _void(), {
57359
- kind: "mutation",
57360
- auth: "protected"
57361
- }),
57362
- setRepeat: method(object({
57363
- deviceId: number().int().nonnegative(),
57364
- repeat: MediaPlayerRepeatSchema
57365
- }), _void(), {
57366
- kind: "mutation",
57367
- auth: "protected"
57368
- }),
57369
- selectSource: method(object({
57370
- deviceId: number().int().nonnegative(),
57371
- source: string().min(1)
57372
- }), _void(), {
57373
- kind: "mutation",
57374
- auth: "protected"
57375
- }),
57376
- playMedia: method(object({
57377
- deviceId: number().int().nonnegative(),
57378
- /** Media identifier / URL. */
57379
- mediaId: string().min(1),
57380
- /** Media kind (`music`, `tvshow`, `movie`, `app`, …) — provider
57381
- * passes it through to the upstream service. */
57382
- mediaType: string().min(1)
57383
- }), _void(), {
57384
- kind: "mutation",
57385
- auth: "protected"
57386
- })
57387
- },
57388
- status: {
57389
- schema: MediaPlayerStatusSchema,
57390
- kind: "push"
57391
- },
57392
- /**
57393
- * Runtime-state slice — mirrored by the kernel. UI players read the
57394
- * full slice for live now-playing, volume, and progress updates
57395
- * without polling.
57396
- */
57397
- runtimeState: MediaPlayerStatusSchema,
57398
- /**
57399
- * Runtime-state durability: **session** — a restored transport position describes a playback that stopped when the hub did.
57400
- *
57401
- * See `RuntimeStateDurability`. Enforced by
57402
- * `scripts/check-runtime-state-durability.ts`.
57403
- */
57404
- durability: "session",
57405
- /**
57406
- * History (D850): volume (a level an operator or an automation sets; the
57407
- * default 10 s floor folds a slider drag into its end value) and mute.
57408
- * `position` is not recorded: it moves continuously while playing.
57409
- */
57410
- history: { fields: {
57411
- volumeLevel: {
57412
- kind: "gauge",
57413
- unit: "%",
57414
- deadband: 1
57415
- },
57416
- isMuted: { kind: "boolean" }
57417
- } }
57418
- };
57419
- /**
57420
58702
  * mesh-network — collection cap for mesh-VPN providers.
57421
58703
  *
57422
58704
  * Different shape from `network-access` (public tunnels):
@@ -58010,6 +59292,27 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
58010
59292
  }), {
58011
59293
  kind: "mutation",
58012
59294
  auth: "admin"
59295
+ }), method(object({ integrationId: string().min(1) }), record(string(), unknown()), { auth: "admin" }), method(object({ integrationId: string().min(1) }), object({
59296
+ rows: number().int().nonnegative(),
59297
+ secrets: number().int().nonnegative()
59298
+ }), {
59299
+ kind: "mutation",
59300
+ auth: "admin"
59301
+ }), method(object({
59302
+ integrationId: string().min(1),
59303
+ patch: record(string(), unknown())
59304
+ }), object({ written: boolean() }), {
59305
+ kind: "mutation",
59306
+ auth: "admin"
59307
+ }), method(object({
59308
+ integrationId: string().min(1),
59309
+ keys: array(string().min(1))
59310
+ }), object({
59311
+ present: boolean(),
59312
+ removed: record(string(), unknown())
59313
+ }), {
59314
+ kind: "mutation",
59315
+ auth: "admin"
58013
59316
  });
58014
59317
  method(object({
58015
59318
  sourceUrl: string(),
@@ -66175,6 +67478,21 @@ var NcTemplateVarKindSchema = _enum([
66175
67478
  "sound",
66176
67479
  "system"
66177
67480
  ]);
67481
+ /**
67482
+ * The default title/body a rule of one SITUATION is delivered with when the
67483
+ * operator wrote no template — served so an editor can pre-fill it (and the
67484
+ * operator can rebuild it from placeholders) instead of starting from a blank
67485
+ * box that, once saved, silently replaces it. `id` names the situation inside
67486
+ * a rule `kind`: `appliance-cycle` is a `sensor` rule whose device is an
67487
+ * appliance finishing a cycle. Texts are raw templates (`{{var}}` intact), in
67488
+ * the hub's current language and with its overrides applied.
67489
+ */
67490
+ var NcTemplateDefaultSchema = object({
67491
+ id: _enum(["appliance-cycle"]),
67492
+ kind: NcRuleKindSchema,
67493
+ title: string(),
67494
+ body: string()
67495
+ });
66178
67496
  /** Which producer renders a template: an ordinary rule, a timelapse, a digest. */
66179
67497
  var NcTemplateFamilySchema = _enum([
66180
67498
  "rule",
@@ -67030,7 +68348,11 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
67030
68348
  }), method(object({}), object({
67031
68349
  catalog: array(NcConditionDescriptorSchema),
67032
68350
  taxonomy: NcTaxonomySchema.optional()
67033
- })), method(object({}), object({ vars: array(NcTemplateVarDescriptorSchema) })), method(NcTemplatePreviewInputSchema, NcTemplatePreviewSchema, {
68351
+ })), method(object({}), object({
68352
+ vars: array(NcTemplateVarDescriptorSchema),
68353
+ /** Per-situation default texts; absent on a hub that predates them. */
68354
+ defaults: array(NcTemplateDefaultSchema)
68355
+ })), method(NcTemplatePreviewInputSchema, NcTemplatePreviewSchema, {
67034
68356
  kind: "mutation",
67035
68357
  access: "view"
67036
68358
  }), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({}), NcRuleLastRunsSchema, { auth: "admin" }), method(object({ artifactId: string().min(1) }), object({ url: string().nullable() }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
@@ -67926,7 +69248,7 @@ var petFeederCapability = {
67926
69248
  /**
67927
69249
  * Pet water-fountain cap. Models the telemetry and the control surface of a
67928
69250
  * circulating drinking fountain: how much water is in the tank, how much the
67929
- * pet drank, whether the pump runs and on what duty cycle.
69251
+ * pet drank, whether the pump runs.
67930
69252
  *
67931
69253
  * It has no native vendor provider of its own: a fountain reaches CamStack as
67932
69254
  * a container of loose entities (a pump switch, two number boxes, a "filter
@@ -67942,8 +69264,10 @@ var petFeederCapability = {
67942
69264
  * never here. Every reading may be `null`: a source that is offline or does
67943
69265
  * not report is unknown, never zero.
67944
69266
  *
67945
- * The filter is not a field of this cap: it is an item of the `consumables`
67946
- * cap on the same device (kind `wear`), reset by the same forward mechanism.
69267
+ * The pump's on/off duty cycle is model-specific and lives in the optional
69268
+ * `pump-cycle` cap. The filter, the cleaning and the water change are not
69269
+ * fields of this cap: they are items of the `consumables` cap on the same
69270
+ * device (kind `wear`), reset by the same forward mechanism.
67947
69271
  */
67948
69272
  var PetFountainStatusSchema = object({
67949
69273
  /** Water in the tank, 0..100 (%). Null while the source has not reported. */
@@ -67954,27 +69278,20 @@ var PetFountainStatusSchema = object({
67954
69278
  empty: boolean().nullable(),
67955
69279
  /** True while the pump is running. Null while unknown. */
67956
69280
  pumpRunning: boolean().nullable(),
67957
- /** True when the pump works on an on/off duty cycle rather than continuously. */
67958
- pumpIntervalEnabled: boolean().nullable(),
67959
- /** How long the pump runs per cycle, in seconds. */
67960
- pumpOnTime: number().min(0).nullable().meta(readingMeta("duration")),
67961
- /** How long the pump rests per cycle, in seconds. */
67962
- pumpOffTime: number().min(0).nullable().meta(readingMeta("duration")),
67963
69281
  /** Water drunk in the last drink, in litres. */
67964
69282
  lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
67965
69283
  /** Water drunk in the current hour, in litres. */
67966
69284
  currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
67967
69285
  /** Water drunk over the last 24 hours (rolling), in litres. */
67968
69286
  last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
67969
- /** Water drunk since local midnight, in litres. */
69287
+ /** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
67970
69288
  todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
67971
69289
  /** Decoded fault message. Null means healthy; a non-null string is an active fault. */
67972
69290
  error: string().nullable(),
67973
69291
  /** Ms epoch when the slice was last refreshed. */
67974
69292
  lastFetchedAt: number()
67975
69293
  });
67976
- var DeviceIdSchema = number().int().nonnegative();
67977
- var MinutesSchema = number().int().min(0);
69294
+ var DeviceIdSchema$1 = number().int().nonnegative();
67978
69295
  var petFountainCapability = {
67979
69296
  name: "pet-fountain",
67980
69297
  scope: "device",
@@ -67984,38 +69301,14 @@ var petFountainCapability = {
67984
69301
  methods: {
67985
69302
  /** Start or stop the pump. */
67986
69303
  setPump: method(object({
67987
- deviceId: DeviceIdSchema,
67988
- on: boolean()
67989
- }), _void(), {
67990
- kind: "mutation",
67991
- auth: "protected"
67992
- }),
67993
- /** Switch the on/off duty cycle on or off (off = the pump runs continuously). */
67994
- setPumpInterval: method(object({
67995
- deviceId: DeviceIdSchema,
69304
+ deviceId: DeviceIdSchema$1,
67996
69305
  on: boolean()
67997
69306
  }), _void(), {
67998
69307
  kind: "mutation",
67999
69308
  auth: "protected"
68000
69309
  }),
68001
- /** Set how many minutes the pump runs per cycle. */
68002
- setPumpOnMinutes: method(object({
68003
- deviceId: DeviceIdSchema,
68004
- minutes: MinutesSchema
68005
- }), _void(), {
68006
- kind: "mutation",
68007
- auth: "protected"
68008
- }),
68009
- /** Set how many minutes the pump rests per cycle. */
68010
- setPumpOffMinutes: method(object({
68011
- deviceId: DeviceIdSchema,
68012
- minutes: MinutesSchema
68013
- }), _void(), {
68014
- kind: "mutation",
68015
- auth: "protected"
68016
- }),
68017
69310
  /** Clear the rolling daily consumption counters on the device. */
68018
- resetDailyConsumption: method(object({ deviceId: DeviceIdSchema }), _void(), {
69311
+ resetDailyConsumption: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
68019
69312
  kind: "mutation",
68020
69313
  auth: "protected"
68021
69314
  })
@@ -69650,6 +70943,14 @@ var powerMeterCapability = {
69650
70943
  deviceNative: true,
69651
70944
  mode: "singleton",
69652
70945
  deviceTypes: POWER_METER_DEVICE_TYPES,
70946
+ deviceConfig: { ui: {
70947
+ kind: "widget",
70948
+ widgetId: "host/power-meter-line",
70949
+ tab: "power",
70950
+ placement: "hero",
70951
+ label: "Power",
70952
+ order: 4
70953
+ } },
69653
70954
  methods: {},
69654
70955
  status: {
69655
70956
  schema: PowerMeterStatusSchema,
@@ -69709,6 +71010,117 @@ var powerMeterCapability = {
69709
71010
  volatileStateFields: ["lastFetchedAt"],
69710
71011
  customize: powerMeterCustomize
69711
71012
  };
71013
+ var PowerSourceRefusalReasonSchema = _enum([
71014
+ "no-power-source",
71015
+ "switch-missing",
71016
+ "switch-offline",
71017
+ "switch-unknown",
71018
+ "restart-in-progress",
71019
+ "switch-call-failed"
71020
+ ]);
71021
+ var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
71022
+ accepted: literal(false),
71023
+ reason: PowerSourceRefusalReasonSchema,
71024
+ /** One line for the operator, naming the switch. */
71025
+ message: string()
71026
+ })]);
71027
+ var PowerSourceInfoSchema = object({
71028
+ /** False when the device has no power source linked; the rest is then empty. */
71029
+ linked: boolean(),
71030
+ switchDeviceId: number().nullable(),
71031
+ switchName: string().nullable(),
71032
+ /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
71033
+ switchOn: boolean().nullable(),
71034
+ switchOnline: boolean().nullable(),
71035
+ restartInProgress: boolean(),
71036
+ offSeconds: number().int()
71037
+ });
71038
+ /** The composed slice: the switch state the link mirrors, plus the stored off time. */
71039
+ var PowerSourceStateSchema = object({
71040
+ /** Null while the switch has not reported: unknown is never `false` (D393). */
71041
+ switchOn: boolean().nullable(),
71042
+ offSeconds: number().int(),
71043
+ lastFetchedAt: number()
71044
+ });
71045
+ var POWER_SOURCE_DEVICE_TYPES = [
71046
+ DeviceType.Gateway,
71047
+ DeviceType.Hub,
71048
+ DeviceType.Camera,
71049
+ DeviceType.Sensor,
71050
+ DeviceType.MediaPlayer,
71051
+ DeviceType.Vacuum,
71052
+ DeviceType.Generic,
71053
+ DeviceType.Washer,
71054
+ DeviceType.Dryer,
71055
+ DeviceType.Dishwasher,
71056
+ DeviceType.PetFountain,
71057
+ DeviceType.Fan,
71058
+ DeviceType.Humidifier,
71059
+ DeviceType.Climate,
71060
+ DeviceType.WaterHeater
71061
+ ];
71062
+ var powerSourceCustomize = {
71063
+ version: 1,
71064
+ targets: [{
71065
+ id: "switch",
71066
+ cardinality: "scalar",
71067
+ vocabulary: {
71068
+ cap: "power-source",
71069
+ stateField: "switchOn"
71070
+ },
71071
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
71072
+ apply: "add",
71073
+ path: "switchOn",
71074
+ sources: [{
71075
+ kind: "switch",
71076
+ transforms: [{ kind: "identity" }]
71077
+ }],
71078
+ companions: [{
71079
+ kind: "constant",
71080
+ path: "offSeconds",
71081
+ value: 10,
71082
+ when: "add"
71083
+ }, {
71084
+ kind: "clock",
71085
+ path: "lastFetchedAt",
71086
+ when: "always"
71087
+ }],
71088
+ sourceReport: { status: "assignment-status" }
71089
+ }]
71090
+ };
71091
+ var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
71092
+ var powerSourceCapability = {
71093
+ name: "power-source",
71094
+ scope: "device",
71095
+ mode: "singleton",
71096
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
71097
+ methods: {
71098
+ getStatus: systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "admin" }),
71099
+ powerOn: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
71100
+ kind: "mutation",
71101
+ auth: "admin"
71102
+ }),
71103
+ powerOff: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
71104
+ kind: "mutation",
71105
+ auth: "admin"
71106
+ }),
71107
+ forceRestart: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
71108
+ kind: "mutation",
71109
+ auth: "admin"
71110
+ })
71111
+ },
71112
+ runtimeState: PowerSourceStateSchema,
71113
+ customize: powerSourceCustomize,
71114
+ /**
71115
+ * Runtime-state durability: **session** — mirrored from the linked switch on
71116
+ * its next report; a restored value would outlive the reading it names.
71117
+ *
71118
+ * See `RuntimeStateDurability`. Enforced by
71119
+ * `scripts/check-runtime-state-durability.ts`.
71120
+ */
71121
+ durability: "session",
71122
+ history: "none"
71123
+ };
69712
71124
  /**
69713
71125
  * Presence cap. Models HA `person.*` and `device_tracker.*` entities
69714
71126
  * on `DeviceType.Presence`. Read-only — no setters: presence is
@@ -70348,6 +71760,79 @@ var ptzAutotrackCapability = {
70348
71760
  */
70349
71761
  history: "none"
70350
71762
  };
71763
+ /**
71764
+ * The on/off duty cycle of a pet fountain's pump. Some models run the pump
71765
+ * continuously and have nothing to configure; others can alternate a run time
71766
+ * and a rest time. That is model-specific, so it is its own optional cap on the
71767
+ * fountain device: a fountain without cycle entities simply never composes it
71768
+ * (planning#366), and the `pet-fountain` cap stays the model-independent core.
71769
+ *
71770
+ * Like `pet-fountain` it has no native vendor provider: an operator BUILDS the
71771
+ * cycle from loose entities (a cycle switch and two number boxes) and every
71772
+ * method is a forward to one source entity (D659, D967). Durations are stored
71773
+ * in SECONDS (D944); a number box that cannot be read back leaves them `null`
71774
+ * — unknown, never zero (D393).
71775
+ */
71776
+ var PumpCycleStatusSchema = object({
71777
+ /** True when the pump works on the on/off cycle, false when it runs continuously. Null while unknown. */
71778
+ enabled: boolean().nullable(),
71779
+ /** How long the pump runs per cycle, in seconds. Null while unknown. */
71780
+ onTime: number().min(0).nullable().meta(readingMeta("duration")),
71781
+ /** How long the pump rests per cycle, in seconds. Null while unknown. */
71782
+ offTime: number().min(0).nullable().meta(readingMeta("duration")),
71783
+ /** Ms epoch when the slice was last refreshed. */
71784
+ lastFetchedAt: number()
71785
+ });
71786
+ var DeviceIdSchema = number().int().nonnegative();
71787
+ var MinutesSchema = number().int().min(0);
71788
+ var pumpCycleCapability = {
71789
+ name: "pump-cycle",
71790
+ scope: "device",
71791
+ deviceNative: true,
71792
+ mode: "singleton",
71793
+ deviceTypes: [DeviceType.PetFountain],
71794
+ methods: {
71795
+ /** Switch the on/off duty cycle on or off (off = the pump runs continuously). */
71796
+ setEnabled: method(object({
71797
+ deviceId: DeviceIdSchema,
71798
+ on: boolean()
71799
+ }), _void(), {
71800
+ kind: "mutation",
71801
+ auth: "protected"
71802
+ }),
71803
+ /** Set how many minutes the pump runs per cycle. */
71804
+ setOnMinutes: method(object({
71805
+ deviceId: DeviceIdSchema,
71806
+ minutes: MinutesSchema
71807
+ }), _void(), {
71808
+ kind: "mutation",
71809
+ auth: "protected"
71810
+ }),
71811
+ /** Set how many minutes the pump rests per cycle. */
71812
+ setOffMinutes: method(object({
71813
+ deviceId: DeviceIdSchema,
71814
+ minutes: MinutesSchema
71815
+ }), _void(), {
71816
+ kind: "mutation",
71817
+ auth: "protected"
71818
+ })
71819
+ },
71820
+ status: {
71821
+ schema: PumpCycleStatusSchema,
71822
+ kind: "push"
71823
+ },
71824
+ /** Runtime-state slice — mirrored by the kernel; the hero card reads it whole. */
71825
+ runtimeState: PumpCycleStatusSchema,
71826
+ /**
71827
+ * Runtime-state durability: **session** — live appliance state re-published on connect.
71828
+ *
71829
+ * See `RuntimeStateDurability`. Enforced by
71830
+ * `scripts/check-runtime-state-durability.ts`.
71831
+ */
71832
+ durability: "session",
71833
+ /** History (D850): a duty-cycle setting is not a series worth recording. */
71834
+ history: "none"
71835
+ };
70351
71836
  DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, method(object({ deviceId: number().int().nonnegative() }), object({ success: literal(true) }), {
70352
71837
  kind: "mutation",
70353
71838
  auth: "admin"
@@ -73138,7 +74623,13 @@ var RemoteMediaCommandSchema = _enum([
73138
74623
  "next",
73139
74624
  "previous",
73140
74625
  "setMute",
73141
- "selectSource"
74626
+ "selectSource",
74627
+ "turnOn",
74628
+ "turnOff",
74629
+ "volumeUp",
74630
+ "volumeDown",
74631
+ "channelUp",
74632
+ "channelDown"
73142
74633
  ]);
73143
74634
  /** A send result, or `not-routed`: the role is not bound, so the native cap answers. */
73144
74635
  var RemoteMediaCommandResultSchema = discriminatedUnion("status", [...RemoteSendResultSchema.options, object({ status: literal("not-routed") })]);
@@ -73159,7 +74650,7 @@ method(deviceInput, RemoteConfigSchema, { auth: "admin" }), method(deviceInput.e
73159
74650
  }), RemoteSendResultSchema, {
73160
74651
  kind: "mutation",
73161
74652
  auth: "protected"
73162
- }), method(deviceInput.extend({
74653
+ }), method(deviceInput, MediaPlayerStatusSchema.nullable(), { auth: "protected" }), method(deviceInput.extend({
73163
74654
  command: RemoteMediaCommandSchema,
73164
74655
  muted: boolean().optional(),
73165
74656
  source: string().optional(),
@@ -75405,7 +76896,11 @@ listSignals: method(_void(), array(StreamSignalSchema).readonly()) }
75405
76896
  * `getSettingsUISchema()` surface.
75406
76897
  */
75407
76898
  var SwitchStatusSchema = object({
75408
- on: boolean().meta({ label: "On" }),
76899
+ /**
76900
+ * `null` = the device has never reported its state (a measurement that
76901
+ * has not happened is unknown, never `false`).
76902
+ */
76903
+ on: boolean().nullable().meta({ label: "On" }),
75409
76904
  /** Ms epoch of the last state change. Useful for UI "X minutes ago". */
75410
76905
  lastChangedAt: number()
75411
76906
  });
@@ -75430,7 +76925,7 @@ var switchCapability = {
75430
76925
  }) },
75431
76926
  events: { onStateChanged: { data: object({
75432
76927
  deviceId: number(),
75433
- on: boolean(),
76928
+ on: boolean().nullable(),
75434
76929
  lastChangedAt: number()
75435
76930
  }) } },
75436
76931
  status: {
@@ -79079,6 +80574,26 @@ function buildDescriptor(capName, kind) {
79079
80574
  * contributes one entry per bound cap present in this map.
79080
80575
  */
79081
80576
  var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
80577
+ /**
80578
+ * What a remote key is CALLED and what it LOOKS like, for every role (D963),
80579
+ * shared by the admin UI and the viewer. A role is data on the wire; each
80580
+ * client resolves its name from `label` (English and Italian side by side) and
80581
+ * its glyph from `icon`, a lucide id from the shared icon catalogue — the
80582
+ * server sends an id, a client maps it to its own icon set.
80583
+ *
80584
+ * `legend` is text printed on the key INSTEAD of a glyph (a digit has no
80585
+ * pictogram): a client that can draw text shows it, one that cannot falls back
80586
+ * to `icon`.
80587
+ */
80588
+ function digit(n) {
80589
+ return {
80590
+ label: t(n, n),
80591
+ icon: "hash",
80592
+ legend: n
80593
+ };
80594
+ }
80595
+ digit("0"), digit("1"), digit("2"), digit("3"), digit("4"), digit("5"), digit("6"), digit("7"), digit("8"), digit("9");
80596
+ DeviceFeature.MediaPlayerPower, DeviceFeature.MediaPlayerVolumeStep, DeviceFeature.MediaPlayerChannelStep, DeviceFeature.MediaPlayerMute, DeviceFeature.MediaPlayerStop, DeviceFeature.MediaPlayerNext, DeviceFeature.MediaPlayerPrevious;
79082
80597
  var btn = (idSuffix, row, col, init) => ({
79083
80598
  idSuffix,
79084
80599
  row,
@@ -79205,6 +80720,42 @@ discriminatedUnion("kind", [object({
79205
80720
  kind: literal("pronto"),
79206
80721
  code: string()
79207
80722
  })]);
80723
+ /**
80724
+ * Propose a running threshold from a device's own power history (planning#405).
80725
+ *
80726
+ * Pure and deterministic: the same series gives the same answer. The series is
80727
+ * a HELD-VALUE step series — a point's value stands until the next point — which
80728
+ * is how device-history stores a gauge, so "time at a level" is exact, not a
80729
+ * count of samples.
80730
+ *
80731
+ * 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
80732
+ * near F. A device that is not near one level most of the time has no floor.
80733
+ * 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
80734
+ * 3. an episode shorter than `PULSE_MAX_MS` is a PULSE (an anti-crease tumble, a
80735
+ * display waking): it is neither a run nor a pause. Among the remaining
80736
+ * episodes, gaps over `PAUSE_MAX_MS` always separate runs; the rest split in
80737
+ * two by the largest log-scale jump (>= 3x): the short ones are pauses INSIDE
80738
+ * a run (a soak), the long ones separate runs. A stretch under `MIN_RUN_MS`
80739
+ * is no run.
80740
+ * 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
80741
+ * grid a person would type; stop dwell covers the longest pause and the
80742
+ * kind's floor; start dwell covers the longest pulse and standby blip above T.
80743
+ * 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
80744
+ * run must hold exactly one true interval and nothing may flap outside.
80745
+ */
80746
+ var SECOND_MS = 1e3;
80747
+ var MINUTE_MS$1 = 60 * SECOND_MS;
80748
+ 24 * (60 * MINUTE_MS$1);
80749
+ 10 * MINUTE_MS$1;
80750
+ 30 * SECOND_MS;
80751
+ 60 * SECOND_MS;
80752
+ 20 * MINUTE_MS$1;
80753
+ 90 * SECOND_MS;
80754
+ 30 * MINUTE_MS$1;
80755
+ 10 * MINUTE_MS$1;
80756
+ DeviceType.Dryer, 3 * MINUTE_MS$1, DeviceType.Dishwasher, 3 * MINUTE_MS$1, DeviceType.Washer, 10 * MINUTE_MS$1;
80757
+ 10 * SECOND_MS;
80758
+ 10 * SECOND_MS;
79208
80759
  DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverStoppable, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
79209
80760
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
79210
80761
  String.raw`rose\(active(\d+), changed(\d+), (\d+(?:\.\d+)?)\)`;
@@ -79565,6 +81116,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
79565
81116
  pressureSensor: pressureSensorCapability,
79566
81117
  privacyMask: privacyMaskCapability,
79567
81118
  ptzAutotrack: ptzAutotrackCapability,
81119
+ pumpCycle: pumpCycleCapability,
79568
81120
  recordingOnboard: recordingOnboardCapability,
79569
81121
  recordingSignal: recordingSignalCapability,
79570
81122
  runningState: runningStateCapability,
@@ -81749,6 +83301,27 @@ Object.freeze({
81749
83301
  access: "view",
81750
83302
  role: "viewer"
81751
83303
  },
83304
+ "boardKeySource.getBoardKey": {
83305
+ capName: "board-key-source",
83306
+ capScope: "system",
83307
+ addonId: null,
83308
+ access: "view",
83309
+ role: "admin"
83310
+ },
83311
+ "boardKeySource.listBoards": {
83312
+ capName: "board-key-source",
83313
+ capScope: "system",
83314
+ addonId: null,
83315
+ access: "view",
83316
+ role: "admin"
83317
+ },
83318
+ "boardKeySource.listSources": {
83319
+ capName: "board-key-source",
83320
+ capScope: "system",
83321
+ addonId: null,
83322
+ access: "view",
83323
+ role: "admin"
83324
+ },
81752
83325
  "brightness.getStatus": {
81753
83326
  capName: "brightness",
81754
83327
  capScope: "device",
@@ -82288,6 +83861,13 @@ Object.freeze({
82288
83861
  access: "create",
82289
83862
  role: "admin"
82290
83863
  },
83864
+ "coreBlocks.proposeRunningThreshold": {
83865
+ capName: "core-blocks",
83866
+ capScope: "system",
83867
+ addonId: null,
83868
+ access: "view",
83869
+ role: "admin"
83870
+ },
82291
83871
  "coreBlocks.reportAutomationRun": {
82292
83872
  capName: "core-blocks",
82293
83873
  capScope: "system",
@@ -82799,6 +84379,13 @@ Object.freeze({
82799
84379
  access: "view",
82800
84380
  role: "admin"
82801
84381
  },
84382
+ "deviceExport.listInstances": {
84383
+ capName: "device-export",
84384
+ capScope: "system",
84385
+ addonId: null,
84386
+ access: "view",
84387
+ role: "admin"
84388
+ },
82802
84389
  "deviceExport.listSupportedDeviceKinds": {
82803
84390
  capName: "device-export",
82804
84391
  capScope: "system",
@@ -84430,6 +86017,13 @@ Object.freeze({
84430
86017
  access: "view",
84431
86018
  role: "admin"
84432
86019
  },
86020
+ "integrationInstances.setInstanceEnabled": {
86021
+ capName: "integration-instances",
86022
+ capScope: "system",
86023
+ addonId: null,
86024
+ access: "create",
86025
+ role: "admin"
86026
+ },
84433
86027
  "integrationInstances.testInstance": {
84434
86028
  capName: "integration-instances",
84435
86029
  capScope: "system",
@@ -84479,13 +86073,6 @@ Object.freeze({
84479
86073
  access: "view",
84480
86074
  role: "admin"
84481
86075
  },
84482
- "integrations.getSettings": {
84483
- capName: "integrations",
84484
- capScope: "system",
84485
- addonId: null,
84486
- access: "view",
84487
- role: "admin"
84488
- },
84489
86076
  "integrations.list": {
84490
86077
  capName: "integrations",
84491
86078
  capScope: "system",
@@ -84493,13 +86080,6 @@ Object.freeze({
84493
86080
  access: "view",
84494
86081
  role: "admin"
84495
86082
  },
84496
- "integrations.setSettings": {
84497
- capName: "integrations",
84498
- capScope: "system",
84499
- addonId: null,
84500
- access: "create",
84501
- role: "admin"
84502
- },
84503
86083
  "integrations.testConnection": {
84504
86084
  capName: "integrations",
84505
86085
  capScope: "system",
@@ -85228,6 +86808,20 @@ Object.freeze({
85228
86808
  access: "view",
85229
86809
  role: "admin"
85230
86810
  },
86811
+ "mediaPlayer.channelDown": {
86812
+ capName: "media-player",
86813
+ capScope: "device",
86814
+ addonId: null,
86815
+ access: "create",
86816
+ role: "viewer"
86817
+ },
86818
+ "mediaPlayer.channelUp": {
86819
+ capName: "media-player",
86820
+ capScope: "device",
86821
+ addonId: null,
86822
+ access: "create",
86823
+ role: "viewer"
86824
+ },
85231
86825
  "mediaPlayer.getStatus": {
85232
86826
  capName: "media-player",
85233
86827
  capScope: "device",
@@ -85319,6 +86913,34 @@ Object.freeze({
85319
86913
  access: "create",
85320
86914
  role: "viewer"
85321
86915
  },
86916
+ "mediaPlayer.turnOff": {
86917
+ capName: "media-player",
86918
+ capScope: "device",
86919
+ addonId: null,
86920
+ access: "create",
86921
+ role: "viewer"
86922
+ },
86923
+ "mediaPlayer.turnOn": {
86924
+ capName: "media-player",
86925
+ capScope: "device",
86926
+ addonId: null,
86927
+ access: "create",
86928
+ role: "viewer"
86929
+ },
86930
+ "mediaPlayer.volumeDown": {
86931
+ capName: "media-player",
86932
+ capScope: "device",
86933
+ addonId: null,
86934
+ access: "create",
86935
+ role: "viewer"
86936
+ },
86937
+ "mediaPlayer.volumeUp": {
86938
+ capName: "media-player",
86939
+ capScope: "device",
86940
+ addonId: null,
86941
+ access: "create",
86942
+ role: "viewer"
86943
+ },
85322
86944
  "meshNetwork.getStatus": {
85323
86945
  capName: "mesh-network",
85324
86946
  capScope: "system",
@@ -85452,6 +87074,13 @@ Object.freeze({
85452
87074
  access: "view",
85453
87075
  role: "admin"
85454
87076
  },
87077
+ "migrations.clearLegacyIntegrationRows": {
87078
+ capName: "migrations",
87079
+ capScope: "system",
87080
+ addonId: null,
87081
+ access: "delete",
87082
+ role: "admin"
87083
+ },
85455
87084
  "migrations.declareOwner": {
85456
87085
  capName: "migrations",
85457
87086
  capScope: "system",
@@ -85459,6 +87088,13 @@ Object.freeze({
85459
87088
  access: "create",
85460
87089
  role: "admin"
85461
87090
  },
87091
+ "migrations.deleteLegacyIntegrationRowKeys": {
87092
+ capName: "migrations",
87093
+ capScope: "system",
87094
+ addonId: null,
87095
+ access: "delete",
87096
+ role: "admin"
87097
+ },
85462
87098
  "migrations.dryRun": {
85463
87099
  capName: "migrations",
85464
87100
  capScope: "system",
@@ -85494,6 +87130,20 @@ Object.freeze({
85494
87130
  access: "create",
85495
87131
  role: "admin"
85496
87132
  },
87133
+ "migrations.patchLegacyIntegrationRows": {
87134
+ capName: "migrations",
87135
+ capScope: "system",
87136
+ addonId: null,
87137
+ access: "create",
87138
+ role: "admin"
87139
+ },
87140
+ "migrations.readLegacyIntegrationRows": {
87141
+ capName: "migrations",
87142
+ capScope: "system",
87143
+ addonId: null,
87144
+ access: "view",
87145
+ role: "admin"
87146
+ },
85497
87147
  "migrations.restorePreMigration": {
85498
87148
  capName: "migrations",
85499
87149
  capScope: "system",
@@ -86565,27 +88215,6 @@ Object.freeze({
86565
88215
  access: "create",
86566
88216
  role: "viewer"
86567
88217
  },
86568
- "petFountain.setPumpInterval": {
86569
- capName: "pet-fountain",
86570
- capScope: "device",
86571
- addonId: null,
86572
- access: "create",
86573
- role: "viewer"
86574
- },
86575
- "petFountain.setPumpOffMinutes": {
86576
- capName: "pet-fountain",
86577
- capScope: "device",
86578
- addonId: null,
86579
- access: "create",
86580
- role: "viewer"
86581
- },
86582
- "petFountain.setPumpOnMinutes": {
86583
- capName: "pet-fountain",
86584
- capScope: "device",
86585
- addonId: null,
86586
- access: "create",
86587
- role: "viewer"
86588
- },
86589
88218
  "pipelineAnalytics.addRetrainFrameFromRecording": {
86590
88219
  capName: "pipeline-analytics",
86591
88220
  capScope: "device",
@@ -88364,6 +89993,34 @@ Object.freeze({
88364
89993
  access: "create",
88365
89994
  role: "admin"
88366
89995
  },
89996
+ "pumpCycle.getStatus": {
89997
+ capName: "pump-cycle",
89998
+ capScope: "device",
89999
+ addonId: null,
90000
+ access: "view",
90001
+ role: "viewer"
90002
+ },
90003
+ "pumpCycle.setEnabled": {
90004
+ capName: "pump-cycle",
90005
+ capScope: "device",
90006
+ addonId: null,
90007
+ access: "create",
90008
+ role: "viewer"
90009
+ },
90010
+ "pumpCycle.setOffMinutes": {
90011
+ capName: "pump-cycle",
90012
+ capScope: "device",
90013
+ addonId: null,
90014
+ access: "create",
90015
+ role: "viewer"
90016
+ },
90017
+ "pumpCycle.setOnMinutes": {
90018
+ capName: "pump-cycle",
90019
+ capScope: "device",
90020
+ addonId: null,
90021
+ access: "create",
90022
+ role: "viewer"
90023
+ },
88367
90024
  "reboot.reboot": {
88368
90025
  capName: "reboot",
88369
90026
  capScope: "device",
@@ -88868,6 +90525,13 @@ Object.freeze({
88868
90525
  access: "create",
88869
90526
  role: "admin"
88870
90527
  },
90528
+ "remote.getAssumedStatus": {
90529
+ capName: "remote",
90530
+ capScope: "system",
90531
+ addonId: null,
90532
+ access: "view",
90533
+ role: "admin"
90534
+ },
88871
90535
  "remote.getConfig": {
88872
90536
  capName: "remote",
88873
90537
  capScope: "system",
@@ -91683,6 +93347,11 @@ Object.freeze({
91683
93347
  form: "single",
91684
93348
  optional: false
91685
93349
  }],
93350
+ "coreBlocks.proposeRunningThreshold": [{
93351
+ name: "deviceId",
93352
+ form: "single",
93353
+ optional: false
93354
+ }],
91686
93355
  "cover.close": [{
91687
93356
  name: "deviceId",
91688
93357
  form: "single",
@@ -92534,6 +94203,16 @@ Object.freeze({
92534
94203
  form: "single",
92535
94204
  optional: true
92536
94205
  }],
94206
+ "mediaPlayer.channelDown": [{
94207
+ name: "deviceId",
94208
+ form: "single",
94209
+ optional: false
94210
+ }],
94211
+ "mediaPlayer.channelUp": [{
94212
+ name: "deviceId",
94213
+ form: "single",
94214
+ optional: false
94215
+ }],
92537
94216
  "mediaPlayer.getStatus": [{
92538
94217
  name: "deviceId",
92539
94218
  form: "single",
@@ -92599,6 +94278,26 @@ Object.freeze({
92599
94278
  form: "single",
92600
94279
  optional: false
92601
94280
  }],
94281
+ "mediaPlayer.turnOff": [{
94282
+ name: "deviceId",
94283
+ form: "single",
94284
+ optional: false
94285
+ }],
94286
+ "mediaPlayer.turnOn": [{
94287
+ name: "deviceId",
94288
+ form: "single",
94289
+ optional: false
94290
+ }],
94291
+ "mediaPlayer.volumeDown": [{
94292
+ name: "deviceId",
94293
+ form: "single",
94294
+ optional: false
94295
+ }],
94296
+ "mediaPlayer.volumeUp": [{
94297
+ name: "deviceId",
94298
+ form: "single",
94299
+ optional: false
94300
+ }],
92602
94301
  "meter.getStatus": [{
92603
94302
  name: "deviceId",
92604
94303
  form: "single",
@@ -92908,21 +94607,6 @@ Object.freeze({
92908
94607
  form: "single",
92909
94608
  optional: false
92910
94609
  }],
92911
- "petFountain.setPumpInterval": [{
92912
- name: "deviceId",
92913
- form: "single",
92914
- optional: false
92915
- }],
92916
- "petFountain.setPumpOffMinutes": [{
92917
- name: "deviceId",
92918
- form: "single",
92919
- optional: false
92920
- }],
92921
- "petFountain.setPumpOnMinutes": [{
92922
- name: "deviceId",
92923
- form: "single",
92924
- optional: false
92925
- }],
92926
94610
  "pipelineAnalytics.addRetrainFrameFromRecording": [{
92927
94611
  name: "deviceId",
92928
94612
  form: "single",
@@ -93558,6 +95242,26 @@ Object.freeze({
93558
95242
  form: "single",
93559
95243
  optional: false
93560
95244
  }],
95245
+ "pumpCycle.getStatus": [{
95246
+ name: "deviceId",
95247
+ form: "single",
95248
+ optional: false
95249
+ }],
95250
+ "pumpCycle.setEnabled": [{
95251
+ name: "deviceId",
95252
+ form: "single",
95253
+ optional: false
95254
+ }],
95255
+ "pumpCycle.setOffMinutes": [{
95256
+ name: "deviceId",
95257
+ form: "single",
95258
+ optional: false
95259
+ }],
95260
+ "pumpCycle.setOnMinutes": [{
95261
+ name: "deviceId",
95262
+ form: "single",
95263
+ optional: false
95264
+ }],
93561
95265
  "reboot.reboot": [{
93562
95266
  name: "deviceId",
93563
95267
  form: "single",
@@ -93759,6 +95463,11 @@ Object.freeze({
93759
95463
  form: "single",
93760
95464
  optional: true
93761
95465
  }],
95466
+ "remote.getAssumedStatus": [{
95467
+ name: "deviceId",
95468
+ form: "single",
95469
+ optional: false
95470
+ }],
93762
95471
  "remote.getConfig": [{
93763
95472
  name: "deviceId",
93764
95473
  form: "single",
@@ -94306,99 +96015,6 @@ Object.freeze({
94306
96015
  "network-access": "ingress",
94307
96016
  "smtp-provider": "email"
94308
96017
  });
94309
- /**
94310
- * A saved Customize assignment (D936). The schema is the type: callers use
94311
- * `z.infer`, they do not restate the shape.
94312
- */
94313
- var OverrideSourceSchema = object({
94314
- addonId: string().min(1),
94315
- stableId: string().min(1),
94316
- cap: string().min(1),
94317
- fieldPath: string().min(1)
94318
- });
94319
- var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
94320
- object({ kind: literal("identity") }),
94321
- object({ kind: literal("invert") }),
94322
- object({
94323
- kind: literal("threshold"),
94324
- comparison: _enum(["gte", "lte"]),
94325
- threshold: number(),
94326
- startDwellMs: number().nonnegative(),
94327
- stopDwellMs: number().nonnegative()
94328
- }),
94329
- object({
94330
- kind: literal("linear"),
94331
- scale: number(),
94332
- offset: number(),
94333
- clampMin: number().optional(),
94334
- clampMax: number().optional()
94335
- }),
94336
- object({
94337
- kind: literal("enum-map"),
94338
- mapping: record(string(), string().nullable())
94339
- }),
94340
- object({ kind: literal("number") })
94341
- ]);
94342
- var ScalarOverrideDraftSchema = object({
94343
- kind: literal("scalar"),
94344
- cap: string().min(1),
94345
- targetId: string().min(1),
94346
- source: OverrideSourceSchema,
94347
- transform: CustomizeTransformDraftSchema
94348
- });
94349
- var KeyedArrayOverrideDraftSchema = object({
94350
- kind: literal("keyedArray"),
94351
- cap: string().min(1),
94352
- targetId: string().min(1),
94353
- key: string().min(1),
94354
- label: string().min(1),
94355
- fieldPath: string().min(1),
94356
- source: OverrideSourceSchema,
94357
- transform: CustomizeTransformDraftSchema
94358
- });
94359
- var PulseOverrideDraftSchema = object({
94360
- kind: literal("pulse"),
94361
- cap: string().min(1),
94362
- targetId: string().min(1),
94363
- enabled: boolean(),
94364
- debounceMs: number().nonnegative(),
94365
- edges: array(_enum([
94366
- "rising",
94367
- "button",
94368
- "native-event"
94369
- ])).min(1).optional(),
94370
- sources: array(OverrideSourceSchema).min(1)
94371
- });
94372
- var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: _enum([
94373
- "in-addition",
94374
- "confirm",
94375
- "replace"
94376
- ]).optional() });
94377
- discriminatedUnion("kind", [
94378
- ScalarOverrideDraftSchema,
94379
- KeyedArrayOverrideDraftSchema,
94380
- PulseOverrideDraftSchema,
94381
- object({
94382
- kind: literal("span"),
94383
- cap: string().min(1),
94384
- targetId: string().min(1),
94385
- timeoutMs: number().nonnegative(),
94386
- cooldownMs: number().nonnegative().optional(),
94387
- sources: array(SpanSourceDraftSchema)
94388
- })
94389
- ]);
94390
- object({
94391
- targetId: string().min(1),
94392
- configured: boolean(),
94393
- source: _enum(["native", "assigned"]),
94394
- state: _enum([
94395
- "active",
94396
- "stale",
94397
- "released",
94398
- "unavailable"
94399
- ]),
94400
- reason: string().nullable()
94401
- });
94402
96018
  var G711_SCALE_CORRECTION_DB = {
94403
96019
  PCMU: 20 * Math.log10(4),
94404
96020
  PCMA: 20 * Math.log10(8)
@@ -95014,6 +96630,7 @@ var STATE_SUMMARY_VARS = [
95014
96630
  [...RULE_TEXT],
95015
96631
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
95016
96632
  ([...RULE_TEXT], [...COMBINED_ALARM]),
96633
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
95017
96634
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
95018
96635
  ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
95019
96636
  ([...RULE_TEXT], [...CONSUMABLE]),
@@ -119910,6 +121527,83 @@ function buildCcuOverviewHandlers(deps) {
119910
121527
  };
119911
121528
  }
119912
121529
  //#endregion
121530
+ //#region src/custom-actions.ts
121531
+ /**
121532
+ * Custom actions of the Homematic addon: the LAN scan behind the integration
121533
+ * form's CCU picker, and the CCU management page (`provider-homematic` admin
121534
+ * page). Reads are `query`; every CCU write is a `mutation` whose input carries
121535
+ * the operator's `confirmed` flag.
121536
+ */
121537
+ var homematicActions = defineCustomActions({
121538
+ discoverCcu: customAction(object({}), object({
121539
+ hosts: array(object({
121540
+ host: string(),
121541
+ name: string(),
121542
+ id: string()
121543
+ })),
121544
+ summary: string()
121545
+ }), {
121546
+ kind: "mutation",
121547
+ auth: "admin"
121548
+ }),
121549
+ listCcus: customAction(object({}), array(CcuListItemSchema), {
121550
+ kind: "query",
121551
+ auth: "admin"
121552
+ }),
121553
+ ccuOverview: customAction(IntegrationRefSchema, CcuOverviewSchema, {
121554
+ kind: "query",
121555
+ auth: "admin"
121556
+ }),
121557
+ listServiceMessages: customAction(IntegrationRefSchema, ServiceMessagesResultSchema, {
121558
+ kind: "query",
121559
+ auth: "admin"
121560
+ }),
121561
+ listCcuDevices: customAction(IntegrationRefSchema, CcuDevicesResultSchema, {
121562
+ kind: "query",
121563
+ auth: "admin"
121564
+ }),
121565
+ listHeatingGroups: customAction(IntegrationRefSchema, HeatingOverviewSchema, {
121566
+ kind: "query",
121567
+ auth: "admin"
121568
+ }),
121569
+ createHeatingGroup: customAction(CreateGroupInputSchema, HeatingGroupSchema, {
121570
+ kind: "mutation",
121571
+ auth: "admin"
121572
+ }),
121573
+ updateHeatingGroup: customAction(UpdateGroupInputSchema, HeatingGroupSchema, {
121574
+ kind: "mutation",
121575
+ auth: "admin"
121576
+ }),
121577
+ deleteHeatingGroup: customAction(DeleteGroupInputSchema, OkResultSchema, {
121578
+ kind: "mutation",
121579
+ auth: "admin"
121580
+ }),
121581
+ ccuPairingStatus: customAction(IntegrationRefSchema, PairingStatusSchema, {
121582
+ kind: "query",
121583
+ auth: "admin"
121584
+ }),
121585
+ setCcuInstallMode: customAction(SetInstallModeInputSchema, OkResultSchema, {
121586
+ kind: "mutation",
121587
+ auth: "admin"
121588
+ }),
121589
+ deleteCcuDevice: customAction(DeleteCcuDeviceInputSchema, OkResultSchema, {
121590
+ kind: "mutation",
121591
+ auth: "admin"
121592
+ }),
121593
+ getCcuDeviceConfig: customAction(DeviceRefSchema, DeviceConfigSchema, {
121594
+ kind: "query",
121595
+ auth: "admin"
121596
+ }),
121597
+ setCcuChannelConfig: customAction(SetChannelConfigInputSchema, OkResultSchema, {
121598
+ kind: "mutation",
121599
+ auth: "admin"
121600
+ }),
121601
+ acknowledgeServiceMessage: customAction(AcknowledgeInputSchema, OkResultSchema, {
121602
+ kind: "mutation",
121603
+ auth: "admin"
121604
+ })
121605
+ });
121606
+ //#endregion
119913
121607
  //#region src/callback-host.ts
119914
121608
  /**
119915
121609
  * Pick the hub LAN IPv4 a CCU at `ccuHost` can call back to. Prefers an
@@ -120176,83 +121870,170 @@ function buildConnectionFormSchema() {
120176
121870
  }
120177
121871
  ] };
120178
121872
  }
121873
+ var homematicConnectionsEntryKind = defineEntryKind("connections", {
121874
+ title: "Homematic CCUs",
121875
+ schema: entryBody({
121876
+ host: string().nullish(),
121877
+ enableHmipRf: boolean().nullish(),
121878
+ enableBidcosRf: boolean().nullish(),
121879
+ enableGroups: boolean().nullish(),
121880
+ enableBidcosWired: boolean().nullish(),
121881
+ username: string().nullish(),
121882
+ password: string().optional().meta({ secret: true }),
121883
+ callbackHost: string().nullish(),
121884
+ callbackPort: number().int().min(1).max(65535).nullish(),
121885
+ tls: boolean().nullish()
121886
+ }),
121887
+ writeTrigger: "an operator adds, edits or removes a Homematic CCU"
121888
+ });
121889
+ /** Every kind this addon declares, keyed by its name. */
121890
+ var homematicRecordKinds = { connections: homematicConnectionsEntryKind };
121891
+ /** The record body as the flat settings the connection schema parses: no name, no unset keys. */
121892
+ function connectionSettingsOf(body) {
121893
+ const out = {};
121894
+ for (const [key, value] of Object.entries(body)) {
121895
+ if (key === "name" || value === null || value === void 0) continue;
121896
+ out[key] = value;
121897
+ }
121898
+ return out;
121899
+ }
121900
+ function settingsReadOf(resolved) {
121901
+ return resolved === null ? {
121902
+ values: {},
121903
+ secretsLocked: false
121904
+ } : {
121905
+ values: connectionSettingsOf(resolved.body),
121906
+ secretsLocked: resolved.secrets === "unavailable"
121907
+ };
121908
+ }
121909
+ function buildHomematicInstances(records, deps) {
121910
+ return new RecordIntegrationInstances(records, homematicConnectionsEntryKind, {
121911
+ description: {
121912
+ role: "devices",
121913
+ discovery: {
121914
+ mode: "lan",
121915
+ scopedToInstance: false
121916
+ },
121917
+ instanceMode: "multiple",
121918
+ kind: "connection",
121919
+ canTest: false
121920
+ },
121921
+ formSchema: () => buildConnectionFormSchema(),
121922
+ initialBody: (name) => ({ name }),
121923
+ configured: (body) => (body.host ?? "").trim().length > 0,
121924
+ onChanged: () => deps.onChanged()
121925
+ });
121926
+ }
121927
+ /** The ONE reader of a CCU's connection: the integration's record, never the legacy rows. */
121928
+ async function readCcuConnection(instances, integrationId) {
121929
+ const read = settingsReadOf(await instances.readResolved(integrationId));
121930
+ return {
121931
+ connection: connectionFromSettings(read.values),
121932
+ secretsLocked: read.secretsLocked
121933
+ };
121934
+ }
121935
+ /** The hosts of the CCUs already set up, for discovery to leave out; an unreadable one is skipped. */
121936
+ async function knownCcuHostsOf(deps) {
121937
+ const hosts = [];
121938
+ for (const id of deps.integrationIds) try {
121939
+ const { connection } = await readCcuConnection(deps.instances, id);
121940
+ if (connection !== null) hosts.push(connection.host);
121941
+ } catch (err) {
121942
+ deps.onUnreadable(id, err);
121943
+ }
121944
+ return hosts;
121945
+ }
120179
121946
  //#endregion
120180
- //#region src/custom-actions.ts
121947
+ //#region src/migrations/integration-rows-to-record.ts
120181
121948
  /**
120182
- * Custom actions of the Homematic addon: the LAN scan behind the integration
120183
- * form's CCU picker, and the CCU management page (`provider-homematic` admin
120184
- * page). Reads are `query`; every CCU write is a `mutation` whose input carries
120185
- * the operator's `confirmed` flag.
121949
+ * Every Homematic integration moves from legacy `integration_settings` rows into its own
121950
+ * `connections` record under the registry id (planning#416, D1007): the CCU connection the live
121951
+ * session dials, the WebUI password a keychain secret declared by the kind. Each integration's
121952
+ * record is built from ITS OWN rows, never from another's. Only the integration configuration
121953
+ * moves: adopted devices, their stable ids and their history are not touched.
121954
+ *
121955
+ * Keys nothing reads any more are named in a warning, by key, and dropped with the rows once the
121956
+ * record has been read back; a value of the wrong type is left out and named by key as well.
120186
121957
  */
120187
- var homematicActions = defineCustomActions({
120188
- discoverCcu: customAction(object({}), object({
120189
- hosts: array(object({
120190
- host: string(),
120191
- name: string(),
120192
- id: string()
120193
- })),
120194
- summary: string()
120195
- }), {
120196
- kind: "mutation",
120197
- auth: "admin"
120198
- }),
120199
- listCcus: customAction(object({}), array(CcuListItemSchema), {
120200
- kind: "query",
120201
- auth: "admin"
120202
- }),
120203
- ccuOverview: customAction(IntegrationRefSchema, CcuOverviewSchema, {
120204
- kind: "query",
120205
- auth: "admin"
120206
- }),
120207
- listServiceMessages: customAction(IntegrationRefSchema, ServiceMessagesResultSchema, {
120208
- kind: "query",
120209
- auth: "admin"
120210
- }),
120211
- listCcuDevices: customAction(IntegrationRefSchema, CcuDevicesResultSchema, {
120212
- kind: "query",
120213
- auth: "admin"
120214
- }),
120215
- listHeatingGroups: customAction(IntegrationRefSchema, HeatingOverviewSchema, {
120216
- kind: "query",
120217
- auth: "admin"
120218
- }),
120219
- createHeatingGroup: customAction(CreateGroupInputSchema, HeatingGroupSchema, {
120220
- kind: "mutation",
120221
- auth: "admin"
120222
- }),
120223
- updateHeatingGroup: customAction(UpdateGroupInputSchema, HeatingGroupSchema, {
120224
- kind: "mutation",
120225
- auth: "admin"
120226
- }),
120227
- deleteHeatingGroup: customAction(DeleteGroupInputSchema, OkResultSchema, {
120228
- kind: "mutation",
120229
- auth: "admin"
120230
- }),
120231
- ccuPairingStatus: customAction(IntegrationRefSchema, PairingStatusSchema, {
120232
- kind: "query",
120233
- auth: "admin"
120234
- }),
120235
- setCcuInstallMode: customAction(SetInstallModeInputSchema, OkResultSchema, {
120236
- kind: "mutation",
120237
- auth: "admin"
120238
- }),
120239
- deleteCcuDevice: customAction(DeleteCcuDeviceInputSchema, OkResultSchema, {
120240
- kind: "mutation",
120241
- auth: "admin"
120242
- }),
120243
- getCcuDeviceConfig: customAction(DeviceRefSchema, DeviceConfigSchema, {
120244
- kind: "query",
120245
- auth: "admin"
120246
- }),
120247
- setCcuChannelConfig: customAction(SetChannelConfigInputSchema, OkResultSchema, {
120248
- kind: "mutation",
120249
- auth: "admin"
120250
- }),
120251
- acknowledgeServiceMessage: customAction(AcknowledgeInputSchema, OkResultSchema, {
120252
- kind: "mutation",
120253
- auth: "admin"
121958
+ var HOMEMATIC_ROWS_TO_RECORD_ID = "provider-homematic/2026-11-05-integration-rows-to-record";
121959
+ var TEXT_KEYS = [
121960
+ "host",
121961
+ "username",
121962
+ "callbackHost"
121963
+ ];
121964
+ var FLAG_KEYS = [
121965
+ "enableHmipRf",
121966
+ "enableBidcosRf",
121967
+ "enableGroups",
121968
+ "enableBidcosWired",
121969
+ "tls"
121970
+ ];
121971
+ function portOf(value) {
121972
+ const n = typeof value === "string" && value.trim() !== "" ? Number(value) : value;
121973
+ return typeof n === "number" && Number.isInteger(n) && n >= 1 && n <= 65535 ? n : null;
121974
+ }
121975
+ /** The record body of one integration, from its resolved legacy rows. Never logs a value. */
121976
+ function homematicBodyFromRows(values, log, integration) {
121977
+ const body = { name: integration.name };
121978
+ const unusable = [];
121979
+ const known = new Set([
121980
+ "password",
121981
+ "callbackPort",
121982
+ ...TEXT_KEYS,
121983
+ ...FLAG_KEYS
121984
+ ]);
121985
+ for (const key of TEXT_KEYS) {
121986
+ if (!(key in values)) continue;
121987
+ const raw = values[key];
121988
+ if (typeof raw === "string") {
121989
+ if (raw.trim() !== "") body[key] = raw.trim();
121990
+ } else unusable.push(key);
121991
+ }
121992
+ for (const key of FLAG_KEYS) {
121993
+ if (!(key in values)) continue;
121994
+ const raw = values[key];
121995
+ if (typeof raw === "boolean") body[key] = raw;
121996
+ else unusable.push(key);
121997
+ }
121998
+ if ("callbackPort" in values) {
121999
+ const raw = values["callbackPort"];
122000
+ if (raw !== "" && raw !== null) {
122001
+ const port = portOf(raw);
122002
+ if (port === null) unusable.push("callbackPort");
122003
+ else body["callbackPort"] = port;
122004
+ }
122005
+ }
122006
+ if ("password" in values) {
122007
+ const password = values["password"];
122008
+ if (typeof password === "string") {
122009
+ if (password.length > 0) body["password"] = password;
122010
+ } else unusable.push("password");
122011
+ }
122012
+ const unknown = Object.keys(values).filter((key) => !known.has(key));
122013
+ if (unknown.length > 0) log.warn(`integration '${integration.id}': legacy settings nothing reads any more are dropped: ${unknown.join(", ")}`);
122014
+ if (unusable.length > 0) log.warn(`integration '${integration.id}': legacy settings with an unusable value are left out: ${unusable.join(", ")}`);
122015
+ return homematicConnectionsEntryKind.schema.parse(body);
122016
+ }
122017
+ var HOMEMATIC_ROWS_TO_RECORD_MIGRATION = {
122018
+ meta: {
122019
+ id: HOMEMATIC_ROWS_TO_RECORD_ID,
122020
+ owner: "provider-homematic",
122021
+ level: "addon-state",
122022
+ seq: 1,
122023
+ dependsOn: [],
122024
+ store: "settings",
122025
+ scope: "cluster",
122026
+ onFailure: "block-owner",
122027
+ bodyKind: "procedure",
122028
+ description: "Move every Homematic CCU integration into its own connection record keyed by its registry id, the WebUI password as a keychain secret, then clear its legacy integration settings rows; adopted devices are not touched",
122029
+ fixtureMark: "a legacy setting key the migration does not know"
122030
+ },
122031
+ procedure: (ports) => moveIntegrationRowsToRecords(ports, {
122032
+ addonId: "provider-homematic",
122033
+ secretPaths: homematicConnectionsEntryKind.declaration.secretPaths,
122034
+ bodyFrom: homematicBodyFromRows
120254
122035
  })
120255
- });
122036
+ };
120256
122037
  //#endregion
120257
122038
  //#region src/homematic-facade-resolver.ts
120258
122039
  /**
@@ -123783,11 +125564,27 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123783
125564
  /** Live per-integration CCU sessions, or null before init / after shutdown. */
123784
125565
  integrationReconciler = null;
123785
125566
  clients = null;
125567
+ instances = null;
123786
125568
  constructor() {
123787
125569
  super({});
123788
125570
  }
123789
125571
  async onInitialize() {
123790
125572
  const regs = this.providerRegistrationsFromSuper(await super.onInitialize());
125573
+ const records = this.ctx.records;
125574
+ if (records === void 0) throw new Error("provider-homematic: ctx.records is required (hub-only addon)");
125575
+ await records.declare(homematicRecordKinds);
125576
+ const instances = buildHomematicInstances(records, { onChanged: () => this.reconcileIntegrations() });
125577
+ this.instances = instances;
125578
+ await this.runMigrations(defineAddonMigrations([HOMEMATIC_ROWS_TO_RECORD_MIGRATION], integrationRowsPortsOverApi({
125579
+ api: defaultIntegrationApiOver(this.ctx.api),
125580
+ secrets: this.ctx.secrets ?? null,
125581
+ records: records.kind({
125582
+ name: homematicConnectionsEntryKind.name,
125583
+ declaration: homematicConnectionsEntryKind.declaration,
125584
+ schema: record(string(), unknown())
125585
+ }),
125586
+ log: { warn: (message) => this.ctx.logger.warn(message) }
125587
+ })));
123791
125588
  this.clients = new HmClientRegistry(this.ctx.logger);
123792
125589
  this.clients.setOnConnected((integrationId) => {
123793
125590
  this.ctx.logger.info("Homematic: CCU connected", { meta: { integrationId } });
@@ -123803,6 +125600,10 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123803
125600
  return {
123804
125601
  providers: [
123805
125602
  ...regs,
125603
+ {
125604
+ capability: integrationInstancesCapability,
125605
+ provider: instances.toProvider()
125606
+ },
123806
125607
  {
123807
125608
  capability: deviceAdoptionCapability,
123808
125609
  provider: this.buildAdoptionProvider()
@@ -123876,8 +125677,9 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123876
125677
  homematicFacades.clear();
123877
125678
  await super.onShutdown();
123878
125679
  }
123879
- globalSettingsSchema() {
123880
- return buildConnectionFormSchema();
125680
+ requireInstances() {
125681
+ if (!this.instances) throw new Error("Homematic provider not initialised");
125682
+ return this.instances;
123881
125683
  }
123882
125684
  /**
123883
125685
  * Stable id, integration-scoped so two CCUs exposing the same device address
@@ -123924,20 +125726,14 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123924
125726
  async knownCcuHosts() {
123925
125727
  try {
123926
125728
  const all = await this.ctx.api.integrations.list.query();
123927
- const hosts = [];
123928
- for (const integration of all) {
123929
- if (integration.addonId !== this.ctx.id) continue;
123930
- try {
123931
- const connection = connectionFromSettings(await this.ctx.api.integrations.getSettings.query({ id: integration.id }));
123932
- if (connection) hosts.push(connection.host);
123933
- } catch (err) {
123934
- this.ctx.logger.warn("Homematic discovery: settings read failed", {
123935
- tags: { integrationId: integration.id },
123936
- meta: { error: errMsg(err) }
123937
- });
123938
- }
123939
- }
123940
- return hosts;
125729
+ return await knownCcuHostsOf({
125730
+ instances: this.requireInstances(),
125731
+ integrationIds: all.filter((i) => i.addonId === this.ctx.id).map((i) => i.id),
125732
+ onUnreadable: (integrationId, err) => this.ctx.logger.warn("Homematic discovery: settings read failed", {
125733
+ tags: { integrationId },
125734
+ meta: { error: errMsg(err) }
125735
+ })
125736
+ });
123941
125737
  } catch (err) {
123942
125738
  this.ctx.logger.warn("Homematic discovery: integration list failed", { meta: { error: errMsg(err) } });
123943
125739
  return [];
@@ -123992,8 +125788,8 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123992
125788
  },
123993
125789
  listIntegrations: () => this.ctx.api.integrations.list.query(),
123994
125790
  applySettings: async (integration) => {
123995
- const connection = connectionFromSettings(await this.ctx.api.integrations.getSettings.query({ id: integration.id }));
123996
- if (!connection) return false;
125791
+ const { connection, secretsLocked } = await readCcuConnection(this.requireInstances(), integration.id);
125792
+ if (secretsLocked || !connection) return false;
123997
125793
  await this.requireClients().upsert(integration.id, integration.name, connection);
123998
125794
  return true;
123999
125795
  },