@camstack/addon-provider-homematic 1.2.181 → 1.2.182

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-D1jjWAr8.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
  /**
@@ -7877,6 +8134,10 @@ var BaseAddon = class {
7877
8134
  const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7878
8135
  const patch = {};
7879
8136
  for (const key of keys) {
8137
+ if (tree.get(key)?.kind === "array") {
8138
+ patch[key] = [];
8139
+ continue;
8140
+ }
7880
8141
  const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7881
8142
  patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7882
8143
  }
@@ -8516,6 +8777,45 @@ function normalizeAddonInitResult(result) {
8516
8777
  if (Array.isArray(result)) return { providers: result };
8517
8778
  return result;
8518
8779
  }
8780
+ var PREFIX = "records/";
8781
+ /** The base of every records failure. `detail` is the human part of the message. */
8782
+ var RecordsError = class extends Error {
8783
+ code;
8784
+ detail;
8785
+ constructor(code, detail) {
8786
+ super(`${PREFIX}${code}: ${detail}`);
8787
+ this.name = "RecordsError";
8788
+ this.code = code;
8789
+ this.detail = detail;
8790
+ }
8791
+ };
8792
+ /** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
8793
+ var RevConflictError = class extends RecordsError {
8794
+ constructor(detail) {
8795
+ super("rev-conflict", detail);
8796
+ this.name = "RevConflictError";
8797
+ }
8798
+ };
8799
+ /** The keychain could not store or serve a value: explicit, never an empty string. */
8800
+ var RecordSecretUnavailableError = class extends RecordsError {
8801
+ constructor(detail) {
8802
+ super("secret-unavailable", detail);
8803
+ this.name = "RecordSecretUnavailableError";
8804
+ }
8805
+ };
8806
+ var InvalidRecordError = class extends RecordsError {
8807
+ constructor(detail) {
8808
+ super("invalid-record", detail);
8809
+ this.name = "InvalidRecordError";
8810
+ }
8811
+ };
8812
+ /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
8813
+ var DeclarationRefusedError = class extends RecordsError {
8814
+ constructor(detail) {
8815
+ super("declaration-refused", detail);
8816
+ this.name = "DeclarationRefusedError";
8817
+ }
8818
+ };
8519
8819
  /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
8520
8820
  /** The files a kind may live in. `history` is device-history's (D850), never records. */
8521
8821
  var RECORD_DATABASES = ["settings", "events"];
@@ -8531,6 +8831,183 @@ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
8531
8831
  var RECORD_MAX_DATA_BYTES = 1024 * 1024;
8532
8832
  var RECORD_BATCH_MAX = 1e3;
8533
8833
  var RECORD_QUERY_MAX = 1e3;
8834
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
8835
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
8836
+ /** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
8837
+ var RECORD_SECRET_COLLECTION_PREFIX = "records:";
8838
+ /**
8839
+ * Secret fields of a record, addressed the way a Zod schema declares them
8840
+ * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
8841
+ * (`auth.accessToken`, `headers[].value`).
8842
+ *
8843
+ * `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
8844
+ * names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
8845
+ * key releases exactly that key's secret.
8846
+ *
8847
+ * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
8848
+ * `{ headers: 'name' }`), never by index, so reordering a list keeps every
8849
+ * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
8850
+ * leaf names its element: `headers[X-Api].value`.
8851
+ *
8852
+ * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
8853
+ */
8854
+ /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
8855
+ function parseSecretPath(path) {
8856
+ if (path.length === 0) throw new InvalidRecordError("an empty secret path");
8857
+ return path.split(".").map((raw) => {
8858
+ const each = raw.endsWith("[]");
8859
+ const map = raw.endsWith("{}");
8860
+ const key = each || map ? raw.slice(0, -2) : raw;
8861
+ if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
8862
+ return {
8863
+ key,
8864
+ each,
8865
+ map
8866
+ };
8867
+ });
8868
+ }
8869
+ /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
8870
+ function secretArrayPrefixes(path) {
8871
+ const segments = parseSecretPath(path);
8872
+ const prefixes = [];
8873
+ const walked = [];
8874
+ for (const segment of segments) {
8875
+ walked.push(segment.key);
8876
+ if (segment.each) prefixes.push(walked.join("."));
8877
+ }
8878
+ return prefixes;
8879
+ }
8880
+ function isRecord$4(value) {
8881
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8882
+ }
8883
+ function elementId(element, idKey, declared, prefix) {
8884
+ const id = isRecord$4(element) ? element[idKey] : void 0;
8885
+ 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`);
8886
+ return id;
8887
+ }
8888
+ /**
8889
+ * Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
8890
+ * visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
8891
+ * result is a new body, `data` is untouched.
8892
+ */
8893
+ var REMOVE_LEAF = Symbol("remove-leaf");
8894
+ function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
8895
+ if (!isRecord$4(node)) return node;
8896
+ const segment = segments[index];
8897
+ if (segment === void 0) return node;
8898
+ if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
8899
+ const child = node[segment.key];
8900
+ const keys = [...walkedKeys, segment.key];
8901
+ const last = index === segments.length - 1;
8902
+ if (segment.each) {
8903
+ if (!Array.isArray(child)) return node;
8904
+ const prefix = keys.join(".");
8905
+ const idKey = arrayKeys[prefix];
8906
+ if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
8907
+ const mapped = child.map((element) => {
8908
+ const id = elementId(element, idKey, declared, prefix);
8909
+ const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
8910
+ return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
8911
+ });
8912
+ return {
8913
+ ...node,
8914
+ [segment.key]: mapped
8915
+ };
8916
+ }
8917
+ if (segment.map) {
8918
+ if (!isRecord$4(child)) return node;
8919
+ const kept = Object.entries(child).map(([mapKey, value]) => {
8920
+ const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
8921
+ if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
8922
+ return [mapKey, visit({
8923
+ declared,
8924
+ concrete,
8925
+ value
8926
+ })];
8927
+ }).filter(([, value]) => value !== REMOVE_LEAF);
8928
+ return {
8929
+ ...node,
8930
+ [segment.key]: Object.fromEntries(kept)
8931
+ };
8932
+ }
8933
+ const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
8934
+ if (last) {
8935
+ const replacement = visit({
8936
+ declared,
8937
+ concrete,
8938
+ value: child
8939
+ });
8940
+ if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
8941
+ return {
8942
+ ...node,
8943
+ [segment.key]: replacement
8944
+ };
8945
+ }
8946
+ return {
8947
+ ...node,
8948
+ [segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
8949
+ };
8950
+ }
8951
+ /** Replace/remove every present secret leaf; returns a NEW body. */
8952
+ function mapSecretLeaves(data, paths, arrayKeys, visit) {
8953
+ let current = data;
8954
+ for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
8955
+ return current;
8956
+ }
8957
+ /** Every present secret leaf, read-only. */
8958
+ function collectSecretLeaves(data, paths, arrayKeys) {
8959
+ const found = [];
8960
+ mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
8961
+ found.push(leaf);
8962
+ return leaf.value;
8963
+ });
8964
+ return found;
8965
+ }
8966
+ /**
8967
+ * The keychain collection name a kind's secrets live under. Prefixed so a
8968
+ * record's refs never collide with the refs a legacy collection of the same name
8969
+ * already holds during an adoption.
8970
+ */
8971
+ function recordSecretCollection(kind) {
8972
+ return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
8973
+ }
8974
+ /** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
8975
+ function recordSecretRef(owner, kind, rowId, concretePath) {
8976
+ return buildSecretRef({
8977
+ owner,
8978
+ scope: {
8979
+ kind: "row",
8980
+ collection: recordSecretCollection(kind),
8981
+ rowId
8982
+ },
8983
+ fieldPath: concretePath
8984
+ });
8985
+ }
8986
+ /**
8987
+ * A stored secret, as an admin read shows it: a VIEW naming the row's own
8988
+ * keychain ref (`set: true`), never the value and no longer the bare redaction
8989
+ * token. The form hands it to the secret field, which reveals the value by ref
8990
+ * through the audited `keychain-admin.reveal`; sent back untouched it keeps the
8991
+ * stored secret (the records door reads a view as KEEP).
8992
+ *
8993
+ * ONE implementation for the entries service and for every addon that serves
8994
+ * its own instances (`RecordIntegrationInstances`).
8995
+ */
8996
+ function isRecord$3(value) {
8997
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8998
+ }
8999
+ function secretViewsOf(owner, kind, id, decl, data) {
9000
+ if (decl.secretPaths.length === 0) return data;
9001
+ const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
9002
+ if (leaf.value !== "__camstack_redacted__") return leaf.value;
9003
+ return {
9004
+ $secret: recordSecretRef(owner, kind, id, leaf.concrete),
9005
+ v: 1,
9006
+ set: true
9007
+ };
9008
+ });
9009
+ return isRecord$3(shown) ? shown : data;
9010
+ }
8534
9011
  /**
8535
9012
  * The share-view scope kinds a share-link token can carry. The hub mints
8536
9013
  * and validates them (`ShareViewGrantSchema` builds its
@@ -8603,7 +9080,8 @@ function isZodSecret(schema) {
8603
9080
  }
8604
9081
  /**
8605
9082
  * Every declared secret path in a config schema: dotted keys, `[]` for "each
8606
- * element of this array" (`connection.password`, `rows[].token`). A declared
9083
+ * element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
9084
+ * map" (`applianceSecrets{}`). A declared
8607
9085
  * object or array is reported as one path and not descended into — everything
8608
9086
  * under it is secret.
8609
9087
  */
@@ -8614,6 +9092,7 @@ function collectZodSecretPaths(schema, prefix = "") {
8614
9092
  const def = defOf(layer);
8615
9093
  if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8616
9094
  else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
9095
+ else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
8617
9096
  else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8618
9097
  else if (def.type === "intersection") {
8619
9098
  if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
@@ -8688,6 +9167,126 @@ var RecordKindDeclarationSchema = object({
8688
9167
  }).strict();
8689
9168
  /** The kind names: lower-case, dash separated, short enough for an index name. */
8690
9169
  var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
9170
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
9171
+ function assertValidDeclaration(name, decl) {
9172
+ const refuse = (why) => {
9173
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
9174
+ };
9175
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
9176
+ const seen = /* @__PURE__ */ new Set();
9177
+ for (const index of decl.indexes) {
9178
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
9179
+ seen.add(index.name);
9180
+ }
9181
+ const { retention } = decl;
9182
+ const hasSecrets = decl.secretPaths.length > 0;
9183
+ if ("ttlMs" in retention) {
9184
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
9185
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
9186
+ }
9187
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
9188
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
9189
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
9190
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
9191
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
9192
+ 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)`);
9193
+ }
9194
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
9195
+ 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`);
9196
+ }
9197
+ function bodyFieldsOf(schema) {
9198
+ return { ...toJSONSchema(schema, {
9199
+ unrepresentable: "any",
9200
+ io: "input"
9201
+ }) };
9202
+ }
9203
+ function isRecordLike(value) {
9204
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9205
+ }
9206
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
9207
+ function hasNameField(json, field) {
9208
+ const branches = json["oneOf"] ?? json["anyOf"];
9209
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
9210
+ const properties = json["properties"];
9211
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
9212
+ }
9213
+ /**
9214
+ * Declare the kinds of a package. The keys are the kind names. The result is
9215
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
9216
+ * types its handle from.
9217
+ */
9218
+ function defineRecordKinds(specs) {
9219
+ const out = {};
9220
+ for (const [name, spec] of Object.entries(specs)) {
9221
+ const secretPaths = collectZodSecretPaths(spec.schema);
9222
+ const nameField = spec.entry?.nameField ?? "name";
9223
+ const fields = bodyFieldsOf(spec.schema);
9224
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
9225
+ const parsed = RecordKindDeclarationSchema.parse({
9226
+ database: spec.database,
9227
+ class: spec.class,
9228
+ writeTrigger: spec.writeTrigger,
9229
+ device: spec.device,
9230
+ at: spec.at,
9231
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
9232
+ retention: spec.retention,
9233
+ deviceRemoval: spec.deviceRemoval,
9234
+ maxDataBytes: spec.maxDataBytes,
9235
+ secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
9236
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
9237
+ transactFamily: spec.transactFamily,
9238
+ entry: spec.entry === void 0 ? void 0 : {
9239
+ title: spec.entry.title,
9240
+ nameField,
9241
+ fields
9242
+ }
9243
+ });
9244
+ assertValidDeclaration(name, parsed);
9245
+ out[name] = {
9246
+ name,
9247
+ schema: spec.schema,
9248
+ declaration: parsed
9249
+ };
9250
+ }
9251
+ return out;
9252
+ }
9253
+ /**
9254
+ * Entry kinds (D881): every list of user-created entries (notification
9255
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
9256
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
9257
+ * through the `record-entries` capability with password fields derived from
9258
+ * the schema (`.meta({ secret: true })`).
9259
+ */
9260
+ /** The body of a plain entry: a name and the fields the kind adds. */
9261
+ function entryBody(shape) {
9262
+ return object({
9263
+ name: string().min(1),
9264
+ ...shape
9265
+ });
9266
+ }
9267
+ /**
9268
+ * Declare one entry kind. An entry is configuration: never trimmed by the
9269
+ * engine, never aged, belonging to no device.
9270
+ */
9271
+ function defineEntryKind(name, spec) {
9272
+ const defined = defineRecordKinds({ [name]: {
9273
+ schema: spec.schema,
9274
+ class: "config",
9275
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
9276
+ retention: { none: "an entry goes only when the operator deletes it" },
9277
+ ...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
9278
+ ...spec.database === void 0 ? {} : { database: spec.database },
9279
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
9280
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
9281
+ ...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
9282
+ entry: {
9283
+ title: spec.title,
9284
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
9285
+ }
9286
+ } })[name];
9287
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
9288
+ return defined;
9289
+ }
8691
9290
  object({
8692
9291
  field: string().min(1),
8693
9292
  on: literal("advance")
@@ -9383,6 +9982,7 @@ var CAP_NAMES = Object.freeze([
9383
9982
  "backup",
9384
9983
  "battery",
9385
9984
  "binary",
9985
+ "board-key-source",
9386
9986
  "brightness",
9387
9987
  "broker",
9388
9988
  "button",
@@ -9504,6 +10104,7 @@ var CAP_NAMES = Object.freeze([
9504
10104
  "privacy-mask",
9505
10105
  "ptz",
9506
10106
  "ptz-autotrack",
10107
+ "pump-cycle",
9507
10108
  "reboot",
9508
10109
  "record-entries",
9509
10110
  "recording",
@@ -10796,18 +11397,6 @@ Object.freeze({
10796
11397
  "path": "pumpRunning",
10797
11398
  "valueType": "boolean"
10798
11399
  },
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
11400
  {
10812
11401
  "path": "lastDrink",
10813
11402
  "valueType": "number"
@@ -10931,6 +11520,20 @@ Object.freeze({
10931
11520
  "valueType": "number"
10932
11521
  }
10933
11522
  ],
11523
+ "pump-cycle": [
11524
+ {
11525
+ "path": "enabled",
11526
+ "valueType": "boolean"
11527
+ },
11528
+ {
11529
+ "path": "onTime",
11530
+ "valueType": "number"
11531
+ },
11532
+ {
11533
+ "path": "offTime",
11534
+ "valueType": "number"
11535
+ }
11536
+ ],
10934
11537
  "recording-archive": [
10935
11538
  {
10936
11539
  "path": "deviceId",
@@ -11380,7 +11983,7 @@ object({
11380
11983
  params: record(string(), union([string(), number()])).optional()
11381
11984
  });
11382
11985
  //#endregion
11383
- //#region ../types/dist/composition-Dh3RfMx5.mjs
11986
+ //#region ../types/dist/composition-CRNwcFYY.mjs
11384
11987
  /**
11385
11988
  * The ffmpeg build every CamStack node downloads, per platform and arch.
11386
11989
  *
@@ -12143,38 +12746,6 @@ function validateExpressionSource(src) {
12143
12746
  return null;
12144
12747
  }
12145
12748
  /**
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
12749
  * Statistics and integrals over a history read (D944).
12179
12750
  *
12180
12751
  * Pure: the same points always give the same answer, so a restart recomputes
@@ -12318,34 +12889,6 @@ var HelperSpecSchema = discriminatedUnion("kind", [
12318
12889
  /** Actuator groups only. Readings leave this unset. */
12319
12890
  active: ActiveCriterionSchema.optional()
12320
12891
  }),
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
12892
  object({
12350
12893
  kind: literal("statistic"),
12351
12894
  stat: _enum(STATISTIC_STATS),
@@ -12517,7 +13060,14 @@ var CompositionForwardCommandSchema = object({
12517
13060
  method: string().min(1),
12518
13061
  args: record(string().min(1), CompositionForwardArgSchema).optional()
12519
13062
  });
12520
- var CompositionCommandTargetSchema = discriminatedUnion("kind", [CompositionForwardCommandSchema, CompositionCodeSourceSchema]);
13063
+ var CompositionCommandTargetSchema = discriminatedUnion("kind", [
13064
+ CompositionForwardCommandSchema,
13065
+ CompositionCodeSourceSchema,
13066
+ object({
13067
+ kind: literal("extension"),
13068
+ target: literal("remote")
13069
+ })
13070
+ ]);
12521
13071
  /** An item key inside an item-array cap (`consumables.items[<key>]`). */
12522
13072
  var COMPOSITION_ITEM_KEY_RE = /^[a-z0-9][a-z0-9-]{0,47}$/;
12523
13073
  /**
@@ -12562,7 +13112,7 @@ var CompositionSchema = object({
12562
13112
  kind: literal("existing"),
12563
13113
  device: CompositionSourceRefSchema
12564
13114
  })]),
12565
- features: array(CompositionFeatureSchema).min(1).max(16),
13115
+ features: array(CompositionFeatureSchema).min(0).max(16),
12566
13116
  /**
12567
13117
  * Present when the block is a helper template. Absent on a free
12568
13118
  * composition (the room example, device 4603). The editor reads this,
@@ -12594,6 +13144,73 @@ var NodeColorIdSchema = _enum([
12594
13144
  "node-g",
12595
13145
  "node-h"
12596
13146
  ]);
13147
+ //#endregion
13148
+ //#region ../types/dist/index.mjs
13149
+ var SMTP_INBOUND_DEFAULT_PORT = 2525;
13150
+ var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
13151
+ var SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
13152
+ /** The text excerpt a message carries on the bus. */
13153
+ var SMTP_INBOUND_TEXT_MAX_CHARS = 4096;
13154
+ var PortSchema = number().int().min(1).max(65535);
13155
+ /** A recipient local-part: what stands before the `@`. */
13156
+ var SmtpRecipientSchema = string().min(1).max(64).regex(/^[A-Za-z0-9._+-]+$/);
13157
+ object({
13158
+ port: PortSchema.default(SMTP_INBOUND_DEFAULT_PORT),
13159
+ bindHost: string().min(1).default("0.0.0.0"),
13160
+ domain: string().min(1).default(SMTP_INBOUND_DEFAULT_DOMAIN),
13161
+ requireAuth: boolean().default(true),
13162
+ username: string().default(""),
13163
+ password: string().default("").meta({ secret: true }),
13164
+ starttls: boolean().default(false),
13165
+ maxMessageBytes: number().int().positive().default(SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES)
13166
+ });
13167
+ object({
13168
+ host: string().min(1).nullable(),
13169
+ hostReason: string().nullable(),
13170
+ port: PortSchema,
13171
+ domain: string().min(1),
13172
+ requireAuth: boolean(),
13173
+ username: string(),
13174
+ password: string(),
13175
+ starttls: boolean()
13176
+ });
13177
+ object({
13178
+ recipients: array(SmtpRecipientSchema).min(1),
13179
+ /**
13180
+ * Who is subscribing. A second `subscribe` with the same id REPLACES that subscriber's
13181
+ * recipients (the way a consumer that restarted, or lost a device, declares its set again);
13182
+ * a recipient held by another subscriber is refused with `smtp-inbound/recipient-claimed`.
13183
+ * Absent, the subscriber is anonymous and unique.
13184
+ */
13185
+ subscriberId: string().min(1).max(64).optional()
13186
+ });
13187
+ var SmtpInboundAttachmentSchema = object({
13188
+ filename: string(),
13189
+ contentType: string(),
13190
+ bytes: number().int().nonnegative()
13191
+ });
13192
+ /** The payload of one `broker.message` (the key is the recipient local-part). */
13193
+ var SmtpInboundMessageSchema = object({
13194
+ /** Monotonic per mailbox; a gap tells a consumer it missed an event. */
13195
+ seq: number().int().positive(),
13196
+ messageId: string(),
13197
+ receivedAt: number().int().nonnegative(),
13198
+ from: string(),
13199
+ to: string(),
13200
+ subject: string(),
13201
+ text: string().max(SMTP_INBOUND_TEXT_MAX_CHARS),
13202
+ attachments: array(SmtpInboundAttachmentSchema)
13203
+ });
13204
+ object({
13205
+ /** The newest seq issued so far (0 before any mail). */
13206
+ lastSeq: number().int().nonnegative(),
13207
+ /** The oldest seq still retained; messages below it are gone. */
13208
+ oldestSeq: number().int().nonnegative(),
13209
+ messages: array(object({
13210
+ key: string(),
13211
+ message: SmtpInboundMessageSchema
13212
+ }))
13213
+ });
12597
13214
  new Set([
12598
13215
  "track",
12599
13216
  "face",
@@ -12713,6 +13330,205 @@ var IntegrationInstanceRefSchema = object({
12713
13330
  ]),
12714
13331
  candidateStableId: string().optional()
12715
13332
  });
13333
+ /**
13334
+ * `RecordIntegrationInstances` - the `integration-instances` provider over ONE
13335
+ * entry kind, so an addon that holds a connection serves it in ~30 lines.
13336
+ *
13337
+ * Every instance is one record of the addon's own kind, keyed by the
13338
+ * `integrations` registry id. The records door does the secret work: a field the
13339
+ * kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
13340
+ * deleting the row deletes the secret, and one row's value is never another's.
13341
+ *
13342
+ * Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
13343
+ * token or the view the form was given KEEP the stored secret;
13344
+ * `{ $secretClear: true }` clears it; any other string replaces it.
13345
+ */
13346
+ /** The most instances one addon lists (an integrations page, not a table). */
13347
+ var INSTANCES_LIST_MAX = 1e3;
13348
+ /** The keys of the kind's secret fields that sit at the top level of the body. */
13349
+ function topLevelSecretKeys(paths) {
13350
+ return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
13351
+ }
13352
+ /** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
13353
+ function secretMapKeys(paths) {
13354
+ return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
13355
+ }
13356
+ /**
13357
+ * A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
13358
+ * view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
13359
+ * or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
13360
+ */
13361
+ function secretMapPatch(value) {
13362
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
13363
+ const out = {};
13364
+ for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
13365
+ else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
13366
+ return Object.keys(out).length > 0 ? out : null;
13367
+ }
13368
+ /** Does the kind's body schema carry an `enabled` field? */
13369
+ function declaresEnabled(kind) {
13370
+ const json = toJSONSchema(kind.schema, {
13371
+ unrepresentable: "any",
13372
+ io: "input"
13373
+ });
13374
+ const properties = Reflect.get(json, "properties");
13375
+ return typeof properties === "object" && properties !== null && "enabled" in properties;
13376
+ }
13377
+ var RecordIntegrationInstances = class {
13378
+ records;
13379
+ kind;
13380
+ hooks;
13381
+ handle;
13382
+ secretKeys;
13383
+ secretMaps;
13384
+ nameField;
13385
+ /** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
13386
+ registryOwnsEnabled;
13387
+ constructor(records, kind, hooks) {
13388
+ this.records = records;
13389
+ this.kind = kind;
13390
+ this.hooks = hooks;
13391
+ this.handle = records.kind(kind);
13392
+ this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
13393
+ this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
13394
+ this.nameField = kind.declaration.entry?.nameField ?? "name";
13395
+ this.registryOwnsEnabled = hooks.description.role === "devices";
13396
+ 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"`);
13397
+ }
13398
+ /**
13399
+ * One instance read for the addon's own runtime; null when absent. When the keychain is
13400
+ * locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
13401
+ * caller can keep what it had instead of reconfiguring with an empty secret (D49).
13402
+ */
13403
+ async readResolved(id) {
13404
+ try {
13405
+ const record = await this.handle.getResolved(id);
13406
+ return record === null ? null : {
13407
+ id,
13408
+ body: record.data,
13409
+ enabled: record.data.enabled !== false,
13410
+ secrets: "resolved"
13411
+ };
13412
+ } catch (err) {
13413
+ if (!(err instanceof RecordSecretUnavailableError)) throw err;
13414
+ const stored = await this.handle.get(id);
13415
+ if (stored === null) return null;
13416
+ return {
13417
+ id,
13418
+ body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
13419
+ enabled: stored.data.enabled !== false,
13420
+ secrets: "unavailable"
13421
+ };
13422
+ }
13423
+ }
13424
+ /** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
13425
+ async getResolved(id) {
13426
+ return (await this.readResolved(id))?.body ?? null;
13427
+ }
13428
+ /** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
13429
+ async listResolved() {
13430
+ const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
13431
+ const out = [];
13432
+ for (const record of page.records) {
13433
+ const read = await this.readResolved(record.id);
13434
+ if (read !== null) out.push(read);
13435
+ }
13436
+ return out;
13437
+ }
13438
+ viewOf(record) {
13439
+ const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
13440
+ const rawName = record.data[this.nameField];
13441
+ const kind = this.hooks.kindOf?.(record.data);
13442
+ const health = this.hooks.health?.(record.data, record.id);
13443
+ return {
13444
+ id: record.id,
13445
+ name: typeof rawName === "string" ? rawName : record.id,
13446
+ configured: this.hooks.configured(record.data),
13447
+ ...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
13448
+ formValues: shown,
13449
+ ...kind !== void 0 ? { kind } : {},
13450
+ ...health?.status !== void 0 ? { status: health.status } : {},
13451
+ ...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
13452
+ };
13453
+ }
13454
+ describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
13455
+ ...this.hooks.description,
13456
+ mintsId: true
13457
+ };
13458
+ instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
13459
+ listInstances = async () => {
13460
+ return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
13461
+ };
13462
+ getInstance = async ({ id }) => {
13463
+ const record = await this.handle.get(id);
13464
+ return record === null ? null : this.viewOf(record);
13465
+ };
13466
+ /** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
13467
+ createInstance = async ({ id, name, kind }) => {
13468
+ const minted = id ?? this.hooks.mintId?.({
13469
+ name,
13470
+ ...kind !== void 0 ? { kind } : {}
13471
+ });
13472
+ if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
13473
+ await this.handle.put({
13474
+ id: minted,
13475
+ data: this.hooks.initialBody(name, kind)
13476
+ }, { ifRev: 0 });
13477
+ await this.hooks.onChanged?.(minted, "created");
13478
+ return { id: minted };
13479
+ };
13480
+ updateInstance = async ({ id, name, values }) => {
13481
+ const patch = {};
13482
+ for (const [key, value] of Object.entries(values)) {
13483
+ if (value === void 0) continue;
13484
+ if (this.secretMaps.has(key)) {
13485
+ const entries = secretMapPatch(value);
13486
+ if (entries !== null) patch[key] = entries;
13487
+ } else if (!this.secretKeys.has(key)) patch[key] = value;
13488
+ else if (isSecretClear(value)) patch[key] = null;
13489
+ else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
13490
+ }
13491
+ if (name !== void 0) patch[this.nameField] = name;
13492
+ await this.handle.patch(id, patch);
13493
+ await this.hooks.onChanged?.(id, "updated");
13494
+ return { ok: true };
13495
+ };
13496
+ /** The switch lives in the record body; the addon is told so it applies it (D996). */
13497
+ setInstanceEnabled = async ({ id, enabled }) => {
13498
+ if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
13499
+ await this.handle.patch(id, { enabled });
13500
+ await this.hooks.onChanged?.(id, "enabled");
13501
+ return { ok: true };
13502
+ };
13503
+ /** The row and its keychain refs go together (the records door). */
13504
+ deleteInstance = async ({ id }) => {
13505
+ await this.handle.delete(id);
13506
+ await this.hooks.onChanged?.(id, "deleted");
13507
+ return { ok: true };
13508
+ };
13509
+ testInstance = async (input) => {
13510
+ if (this.hooks.test === void 0) return {
13511
+ success: false,
13512
+ status: "unsupported",
13513
+ error: "This integration declares no connection test"
13514
+ };
13515
+ return this.hooks.test(input);
13516
+ };
13517
+ /** The flat provider object to hand to `registerProvider`. */
13518
+ toProvider() {
13519
+ return {
13520
+ describe: this.describe,
13521
+ instanceFormSchema: this.instanceFormSchema,
13522
+ listInstances: this.listInstances,
13523
+ getInstance: this.getInstance,
13524
+ createInstance: this.createInstance,
13525
+ updateInstance: this.updateInstance,
13526
+ setInstanceEnabled: this.setInstanceEnabled,
13527
+ deleteInstance: this.deleteInstance,
13528
+ testInstance: this.testInstance
13529
+ };
13530
+ }
13531
+ };
12716
13532
  var EncodeProfileSchema = object({
12717
13533
  video: object({
12718
13534
  codec: _enum([
@@ -13748,7 +14564,13 @@ var MigrationLedgerEntrySchema = object({
13748
14564
  * joined by the engine from the catalogues it knows this boot. Absent when no
13749
14565
  * catalogue lists the id (a newer database).
13750
14566
  */
13751
- meta: MigrationMetaSchema.optional()
14567
+ meta: MigrationMetaSchema.optional(),
14568
+ /**
14569
+ * Set when this is an applied row of an addon owner whose catalogue the answering
14570
+ * process has not loaded (the owner has not declared yet): the row is applied, the
14571
+ * process just cannot judge it. Never `skipped-newer` — that needs the owner loaded.
14572
+ */
14573
+ ownerNotLoaded: boolean().optional()
13752
14574
  });
13753
14575
  /** A catalogued migration that is not applied, with where it stands. */
13754
14576
  var MigrationPendingEntrySchema = object({
@@ -13782,6 +14604,149 @@ var MigrationOwnerStepSchema = object({
13782
14604
  state: union([literal("pending"), MigrationStatusSchema])
13783
14605
  });
13784
14606
  /**
14607
+ * Move an integration's legacy `integration_settings` rows into a typed record of the addon's own
14608
+ * kind (planning#416, the one store). The record is keyed by the `integrations` registry id, so
14609
+ * the integration id, the devices stamped with it and the automations that name it do not change.
14610
+ *
14611
+ * Order, so a crash or a locked keychain is safe at every point:
14612
+ *
14613
+ * 1. Phase A, read only: every row of every integration of the addon is read with its secrets
14614
+ * resolved. One that cannot be read (a locked keychain) throws, naming the integration, before
14615
+ * anything is written; `block-owner` then holds the addon.
14616
+ * 2. Phase B, per integration: the addon's `bodyFrom` builds the body; the record is put with
14617
+ * `ifRev: 0` (an existing record is never overwritten). A record this pass CREATED is read back
14618
+ * and every secret leaf must equal what the rows held, else the record is deleted and the pass
14619
+ * throws; an EXISTING record must hold every secret the rows carry, else the rows are kept and
14620
+ * a warning names the path. Only then are the rows (and their keychain values) cleared.
14621
+ *
14622
+ * Idempotent: an integration whose rows are gone and whose record exists is skipped, so a rerun is
14623
+ * a no-op. A default integration with no rows still gets its record (an empty body, D985).
14624
+ * Never logs or throws a secret value; messages name integration ids and secret PATHS only.
14625
+ */
14626
+ function secretLeavesOf(body, spec) {
14627
+ const out = /* @__PURE__ */ new Map();
14628
+ 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);
14629
+ return out;
14630
+ }
14631
+ function why(err) {
14632
+ return err instanceof Error ? err.message : String(err);
14633
+ }
14634
+ async function moveIntegrationRowsToRecords(ports, spec) {
14635
+ const integrations = await ports.listIntegrations(spec.addonId);
14636
+ if (integrations.length === 0) return {
14637
+ outcome: "already-done",
14638
+ summary: { integrations: 0 }
14639
+ };
14640
+ const rowsOf = /* @__PURE__ */ new Map();
14641
+ for (const integration of integrations) try {
14642
+ rowsOf.set(integration.id, await ports.readRows(integration.id));
14643
+ } catch (err) {
14644
+ throw new Error(`integration '${integration.id}': the legacy settings cannot be read with their secrets (${why(err)}) - nothing moved`, { cause: err });
14645
+ }
14646
+ let created = 0;
14647
+ let cleared = 0;
14648
+ let kept = 0;
14649
+ for (const integration of integrations) {
14650
+ const values = rowsOf.get(integration.id) ?? {};
14651
+ const hasRows = Object.keys(values).length > 0;
14652
+ const body = spec.bodyFrom(values, ports, integration);
14653
+ const put = await ports.putRecord(integration.id, body);
14654
+ if (put === "created") created += 1;
14655
+ if (!hasRows) continue;
14656
+ const wanted = secretLeavesOf(body, spec);
14657
+ const back = await ports.readRecord(integration.id);
14658
+ if (back === null) throw new Error(`integration '${integration.id}': the record is gone after it was put`);
14659
+ const held = secretLeavesOf(back, spec);
14660
+ if (put === "created") {
14661
+ const wrong = [...wanted].filter(([path, value]) => held.get(path) !== value).map(([p]) => p);
14662
+ if (wrong.length > 0) {
14663
+ await ports.deleteRecord(integration.id);
14664
+ 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`);
14665
+ }
14666
+ } else {
14667
+ const missing = [...wanted].filter(([path]) => !held.has(path)).map(([p]) => p);
14668
+ if (missing.length > 0) {
14669
+ ports.warn(`integration '${integration.id}': the existing record holds no ${missing.join(", ")}; the legacy settings are kept, not cleared`);
14670
+ kept += 1;
14671
+ continue;
14672
+ }
14673
+ }
14674
+ await ports.clearRows(integration.id);
14675
+ cleared += 1;
14676
+ }
14677
+ return created === 0 && cleared === 0 ? {
14678
+ outcome: "already-done",
14679
+ summary: {
14680
+ integrations: integrations.length,
14681
+ kept
14682
+ }
14683
+ } : {
14684
+ outcome: "done",
14685
+ summary: {
14686
+ integrations: integrations.length,
14687
+ created,
14688
+ cleared,
14689
+ kept
14690
+ }
14691
+ };
14692
+ }
14693
+ /**
14694
+ * The addon-side ports of `moveIntegrationRowsToRecords` (planning#416): an addon runs the move
14695
+ * from its own process, so the legacy rows are reached through the hub (`ctx.api.integrations`:
14696
+ * `list`, `getSettings` - which answers the OWNER its secrets resolved - and `clearSettings`) and
14697
+ * the new record through the addon's own records handle. The hub deletes the rows and their
14698
+ * keychain values; the addon never touches the registry.
14699
+ */
14700
+ function integrationRowsPortsOverApi(deps) {
14701
+ return {
14702
+ warn: (message) => deps.log.warn(message),
14703
+ listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
14704
+ id: i.id,
14705
+ name: i.name
14706
+ })),
14707
+ readRows: (integrationId) => deps.api.getSettings({ id: integrationId }),
14708
+ putRecord: async (id, body) => {
14709
+ if (await deps.records.get(id) !== null) return "exists";
14710
+ try {
14711
+ await deps.records.put({
14712
+ id,
14713
+ data: body
14714
+ }, { ifRev: 0 });
14715
+ } catch (err) {
14716
+ if (err instanceof RevConflictError) return "exists";
14717
+ throw err;
14718
+ }
14719
+ return "created";
14720
+ },
14721
+ readRecord: async (id) => (await deps.records.getResolved(id))?.data ?? null,
14722
+ deleteRecord: async (id) => {
14723
+ await deps.records.delete(id);
14724
+ },
14725
+ clearRows: async (integrationId) => {
14726
+ await deps.api.clearSettings({ id: integrationId });
14727
+ }
14728
+ };
14729
+ }
14730
+ function defaultIntegrationApiOver(api) {
14731
+ return {
14732
+ list: () => api.integrations.list.query(),
14733
+ getSettings: (input) => api.integrations.getSettings.query(input),
14734
+ clearSettings: (input) => api.integrations.clearSettings.mutate(input),
14735
+ listDevices: (addonId) => api.deviceManager.listAll.query({
14736
+ addonId,
14737
+ projection: "slim"
14738
+ }),
14739
+ setDeviceIntegrationId: async (deviceId, integrationId) => {
14740
+ await api.deviceManager.setIntegrationId.mutate({
14741
+ deviceId,
14742
+ integrationId
14743
+ });
14744
+ },
14745
+ readDeviceHasConfig: async (deviceId) => Object.keys((await api.deviceManager.getDevice.query({ deviceId }))?.config ?? {}).length > 0,
14746
+ readDeviceIntegrationId: async (deviceId) => (await api.deviceManager.getDevice.query({ deviceId }))?.integrationId ?? null
14747
+ };
14748
+ }
14749
+ /**
13785
14750
  * The trainer contract — what the hub hands the cloud trainer and what it
13786
14751
  * gets back (cloud training, D805+).
13787
14752
  *
@@ -18866,24 +19831,52 @@ var APPLIANCE_CAP_VOCABULARY = {
18866
19831
  args: { on: false }
18867
19832
  },
18868
19833
  {
18869
- id: "petFountain.intervalOn",
18870
- method: "setPumpInterval",
19834
+ id: "petFountain.resetDailyConsumption",
19835
+ method: "resetDailyConsumption",
19836
+ label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
19837
+ phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
19838
+ icon: "rotate-ccw"
19839
+ }
19840
+ ],
19841
+ state: [{
19842
+ kind: "boolean",
19843
+ field: "empty",
19844
+ label: t("Tank empty", "Serbatoio vuoto"),
19845
+ whenTrue: t("When the tank of {device} is empty", "Quando il serbatoio di {device} è vuoto"),
19846
+ whenFalse: t("When the tank of {device} is refilled", "Quando il serbatoio di {device} viene riempito"),
19847
+ icon: "droplet"
19848
+ }, {
19849
+ kind: "numeric",
19850
+ field: "waterLevel",
19851
+ quantity: t("the water level", "il livello dell’acqua"),
19852
+ label: t("Water level", "Livello dell’acqua"),
19853
+ unit: "%",
19854
+ icon: "droplets"
19855
+ }]
19856
+ },
19857
+ "pump-cycle": {
19858
+ scope: "device",
19859
+ noun: t("Pump cycle", "Ciclo della pompa"),
19860
+ actions: [
19861
+ {
19862
+ id: "pumpCycle.on",
19863
+ method: "setEnabled",
18871
19864
  label: t("Pump cycle on", "Ciclo pompa attivo"),
18872
19865
  phrase: t("Run the pump of {device} on its on/off cycle", "Fai lavorare la pompa di {device} a ciclo acceso/spento"),
18873
19866
  icon: "timer",
18874
19867
  args: { on: true }
18875
19868
  },
18876
19869
  {
18877
- id: "petFountain.intervalOff",
18878
- method: "setPumpInterval",
19870
+ id: "pumpCycle.off",
19871
+ method: "setEnabled",
18879
19872
  label: t("Pump cycle off", "Ciclo pompa spento"),
18880
19873
  phrase: t("Run the pump of {device} continuously", "Fai lavorare la pompa di {device} in continuo"),
18881
19874
  icon: "timer-off",
18882
19875
  args: { on: false }
18883
19876
  },
18884
19877
  {
18885
- id: "petFountain.pumpOnMinutes",
18886
- method: "setPumpOnMinutes",
19878
+ id: "pumpCycle.onMinutes",
19879
+ method: "setOnMinutes",
18887
19880
  label: t("Set pump run time", "Imposta il tempo di lavoro della pompa"),
18888
19881
  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
19882
  icon: "timer",
@@ -18899,8 +19892,8 @@ var APPLIANCE_CAP_VOCABULARY = {
18899
19892
  }]
18900
19893
  },
18901
19894
  {
18902
- id: "petFountain.pumpOffMinutes",
18903
- method: "setPumpOffMinutes",
19895
+ id: "pumpCycle.offMinutes",
19896
+ method: "setOffMinutes",
18904
19897
  label: t("Set pump rest time", "Imposta il tempo di riposo della pompa"),
18905
19898
  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
19899
  icon: "timer-off",
@@ -18914,35 +19907,63 @@ var APPLIANCE_CAP_VOCABULARY = {
18914
19907
  unit: "min"
18915
19908
  }
18916
19909
  }]
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
19910
  }
18925
19911
  ],
18926
19912
  state: [{
18927
19913
  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"
19914
+ field: "enabled",
19915
+ label: t("Pump cycle", "Ciclo pompa"),
19916
+ whenTrue: t("When {device} starts running its pump on a cycle", "Quando {device} inizia a far lavorare la pompa a ciclo"),
19917
+ whenFalse: t("When {device} runs its pump continuously", "Quando {device} fa lavorare la pompa in continuo"),
19918
+ icon: "timer"
18940
19919
  }]
18941
19920
  },
18942
19921
  "media-player": {
18943
19922
  scope: "device",
18944
19923
  noun: t("Media player", "Lettore multimediale"),
18945
19924
  actions: [
19925
+ {
19926
+ id: "media.turnOn",
19927
+ method: "turnOn",
19928
+ label: t("Turn on", "Accendi"),
19929
+ phrase: t("Turn on {device}", "Accendi {device}"),
19930
+ icon: "power"
19931
+ },
19932
+ {
19933
+ id: "media.turnOff",
19934
+ method: "turnOff",
19935
+ label: t("Turn off", "Spegni"),
19936
+ phrase: t("Turn off {device}", "Spegni {device}"),
19937
+ icon: "power"
19938
+ },
19939
+ {
19940
+ id: "media.volumeUp",
19941
+ method: "volumeUp",
19942
+ label: t("Volume up", "Alza il volume"),
19943
+ phrase: t("Raise the volume of {device}", "Alza il volume di {device}"),
19944
+ icon: "volume-2"
19945
+ },
19946
+ {
19947
+ id: "media.volumeDown",
19948
+ method: "volumeDown",
19949
+ label: t("Volume down", "Abbassa il volume"),
19950
+ phrase: t("Lower the volume of {device}", "Abbassa il volume di {device}"),
19951
+ icon: "volume-2"
19952
+ },
19953
+ {
19954
+ id: "media.channelUp",
19955
+ method: "channelUp",
19956
+ label: t("Channel up", "Canale successivo"),
19957
+ phrase: t("Go to the next channel on {device}", "Passa al canale successivo su {device}"),
19958
+ icon: "skip-forward"
19959
+ },
19960
+ {
19961
+ id: "media.channelDown",
19962
+ method: "channelDown",
19963
+ label: t("Channel down", "Canale precedente"),
19964
+ phrase: t("Go to the previous channel on {device}", "Torna al canale precedente su {device}"),
19965
+ icon: "skip-back"
19966
+ },
18946
19967
  {
18947
19968
  id: "media.play",
18948
19969
  method: "play",
@@ -20829,6 +21850,7 @@ var SYSTEM_CAP_VOCABULARY = {
20829
21850
  "audio-analyzer": system(PIPELINE),
20830
21851
  "audio-codec": system(INTERNAL),
20831
21852
  "auth-provider": system(IDENTITY),
21853
+ "board-key-source": system(INTERNAL),
20832
21854
  backup: system("system backups — run and restored from the Backups page"),
20833
21855
  broker: system("message-broker connections — configured, not actuated"),
20834
21856
  "calendar-source": system(INTERNAL),
@@ -45817,6 +46839,49 @@ var binaryCapability = {
45817
46839
  volatileStateFields: ["lastChangedAt"]
45818
46840
  };
45819
46841
  /**
46842
+ * Why a board key could not be read. Typed so a caller reports the cause and
46843
+ * never treats "could not read" as "has no key" (D49).
46844
+ */
46845
+ var BoardKeyFailureReasonSchema = _enum([
46846
+ "unknown-source",
46847
+ "not-admin",
46848
+ "no-builder",
46849
+ "no-ingress-url",
46850
+ "unreachable",
46851
+ "unknown-board",
46852
+ "no-encryption-key",
46853
+ "unreadable-config"
46854
+ ]);
46855
+ var BoardKeySourceSchema = object({
46856
+ sourceId: string(),
46857
+ name: string()
46858
+ });
46859
+ var BoardKeyBoardSchema = object({
46860
+ /** The builder's file name, e.g. `kitchen.yaml`: the handle `getBoardKey` takes. */
46861
+ configuration: string(),
46862
+ /** The node name the builder gives the board. */
46863
+ name: string(),
46864
+ /** The address the builder knows the board by, when it has one. */
46865
+ address: string().nullable()
46866
+ });
46867
+ var BoardKeyFailureSchema = object({
46868
+ ok: literal(false),
46869
+ reason: BoardKeyFailureReasonSchema,
46870
+ detail: string().optional()
46871
+ });
46872
+ var ListBoardsResultSchema = discriminatedUnion("ok", [object({
46873
+ ok: literal(true),
46874
+ boards: array(BoardKeyBoardSchema).readonly()
46875
+ }), BoardKeyFailureSchema]);
46876
+ var GetBoardKeyResultSchema = discriminatedUnion("ok", [object({
46877
+ ok: literal(true),
46878
+ key: string()
46879
+ }), BoardKeyFailureSchema]);
46880
+ method(_void(), array(BoardKeySourceSchema).readonly(), { auth: "admin" }), method(object({ sourceId: string().min(1) }), ListBoardsResultSchema, { auth: "admin" }), method(object({
46881
+ sourceId: string().min(1),
46882
+ configuration: string().min(1)
46883
+ }), GetBoardKeyResultSchema, { auth: "admin" });
46884
+ /**
45820
46885
  * Dimmable-light brightness control. Co-exists with `switch` on the
45821
46886
  * same device — the switch toggles on/off, this cap sets the level
45822
46887
  * applied when the light is on. Drivers map their per-vendor dim
@@ -48506,6 +49571,244 @@ var controlCapability = {
48506
49571
  */
48507
49572
  history: "none"
48508
49573
  };
49574
+ /**
49575
+ * Media-player cap. Models HA `media_player.*` (Sonos, Chromecast,
49576
+ * Apple TV, Spotify, Roku, generic OTT receivers, …) on
49577
+ * `DeviceType.MediaPlayer`. Disjoint from the camera streaming
49578
+ * surface — those use `DeviceType.Camera` + the broker pipeline.
49579
+ *
49580
+ * The cap declares a wide method surface; not every backend supports
49581
+ * every method. Drivers signal sub-capability via the
49582
+ * `DeviceFeature.MediaPlayerXxx` flags (paired one-to-one with the
49583
+ * corresponding method) so the UI gates buttons without a slice
49584
+ * fetch — same pattern as `PanTiltZoom` for cameras.
49585
+ */
49586
+ var MediaPlayerStateSchema = _enum([
49587
+ "off",
49588
+ "on",
49589
+ "idle",
49590
+ "playing",
49591
+ "paused",
49592
+ "buffering",
49593
+ "standby"
49594
+ ]);
49595
+ var MediaPlayerRepeatSchema = _enum([
49596
+ "off",
49597
+ "all",
49598
+ "one"
49599
+ ]);
49600
+ var MediaInfoSchema = object({
49601
+ /** Free-form media kind (`music`, `tvshow`, `movie`, `app`, `channel`,
49602
+ * `podcast`, …). */
49603
+ type: string(),
49604
+ /** Human-readable title. */
49605
+ title: string(),
49606
+ /** Optional artist / channel / station label. */
49607
+ artist: string().optional(),
49608
+ /** Optional album / season / show name. */
49609
+ album: string().optional(),
49610
+ /** Optional cover-art / thumbnail URL. */
49611
+ imageUrl: string().optional()
49612
+ });
49613
+ /**
49614
+ * Where `state`, `volumeLevel`, `isMuted` and `source` come from. `reported`:
49615
+ * the device said so. `assumed`: the driver has no feedback (infrared) and
49616
+ * tracks what it last SENT; it moves only after a send was accepted, and a
49617
+ * human at the real remote makes it wrong. A UI shows an assumed value as a
49618
+ * guess, never as a reading.
49619
+ */
49620
+ var MediaPlayerStateSourceSchema = _enum(["reported", "assumed"]);
49621
+ /** The fields of a media-player status a driver can only guess. */
49622
+ var MediaPlayerAssumedFieldSchema = _enum([
49623
+ "state",
49624
+ "volumeLevel",
49625
+ "isMuted",
49626
+ "source"
49627
+ ]);
49628
+ var MediaPlayerStatusSchema = object({
49629
+ /** Playback lifecycle state. */
49630
+ state: MediaPlayerStateSchema,
49631
+ /**
49632
+ * Whether the state fields are readings or the driver's own bookkeeping.
49633
+ * A slice written before this field existed parses as `reported`.
49634
+ */
49635
+ stateSource: MediaPlayerStateSourceSchema.default("reported"),
49636
+ /**
49637
+ * Which fields are the driver's own guess. `stateSource` is `assumed` when
49638
+ * this is not empty; a field not listed here is a reading even then (power
49639
+ * from a running-state source, mute guessed from the last send).
49640
+ */
49641
+ assumedFields: array(MediaPlayerAssumedFieldSchema).default([]),
49642
+ /** Volume as 0..100 inclusive. Null when the device has no volume
49643
+ * surface. Pair with `DeviceFeature.MediaPlayerVolume`. */
49644
+ volumeLevel: number().min(0).max(100).nullable().meta(readingMeta("percentage")),
49645
+ /** Mute toggle distinct from volume=0. Null when no mute surface.
49646
+ * Pair with `DeviceFeature.MediaPlayerMute`. */
49647
+ isMuted: boolean().nullable(),
49648
+ /** Active source / input. Empty when no source surface. */
49649
+ source: string(),
49650
+ /** Selectable sources. Empty when no source surface.
49651
+ * Pair with `DeviceFeature.MediaPlayerSelectSource`. */
49652
+ availableSources: array(string()),
49653
+ /** Currently-playing media info. Null when nothing is playing. */
49654
+ currentMedia: MediaInfoSchema.nullable(),
49655
+ /** Current playback position in ms. Null when not seekable or
49656
+ * nothing is playing. Pair with `DeviceFeature.MediaPlayerSeek`. */
49657
+ position: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
49658
+ /** Total duration of the current media in ms. Null when unknown
49659
+ * (live stream) or nothing is playing. */
49660
+ duration: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
49661
+ /** Shuffle toggle. Null when no shuffle surface.
49662
+ * Pair with `DeviceFeature.MediaPlayerShuffle`. */
49663
+ shuffle: boolean().nullable(),
49664
+ /** Repeat mode. Null when no repeat surface.
49665
+ * Pair with `DeviceFeature.MediaPlayerRepeat`. */
49666
+ repeat: MediaPlayerRepeatSchema.nullable(),
49667
+ /** Ms epoch when the slice was last updated. */
49668
+ lastChangedAt: number()
49669
+ });
49670
+ var stepInput = object({
49671
+ deviceId: number().int().nonnegative(),
49672
+ /** How many presses: the caller's count (Alexa `volumeSteps`, `channelCount`). */
49673
+ steps: number().int().min(1).max(50).default(1)
49674
+ });
49675
+ var deviceOnly = object({ deviceId: number().int().nonnegative() });
49676
+ var mediaPlayerCapability = {
49677
+ name: "media-player",
49678
+ scope: "device",
49679
+ deviceNative: true,
49680
+ mode: "singleton",
49681
+ deviceTypes: [DeviceType.MediaPlayer],
49682
+ methods: {
49683
+ turnOn: method(deviceOnly, _void(), {
49684
+ kind: "mutation",
49685
+ auth: "protected"
49686
+ }),
49687
+ turnOff: method(deviceOnly, _void(), {
49688
+ kind: "mutation",
49689
+ auth: "protected"
49690
+ }),
49691
+ volumeUp: method(stepInput, _void(), {
49692
+ kind: "mutation",
49693
+ auth: "protected"
49694
+ }),
49695
+ volumeDown: method(stepInput, _void(), {
49696
+ kind: "mutation",
49697
+ auth: "protected"
49698
+ }),
49699
+ channelUp: method(stepInput, _void(), {
49700
+ kind: "mutation",
49701
+ auth: "protected"
49702
+ }),
49703
+ channelDown: method(stepInput, _void(), {
49704
+ kind: "mutation",
49705
+ auth: "protected"
49706
+ }),
49707
+ play: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49708
+ kind: "mutation",
49709
+ auth: "protected"
49710
+ }),
49711
+ pause: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49712
+ kind: "mutation",
49713
+ auth: "protected"
49714
+ }),
49715
+ stop: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49716
+ kind: "mutation",
49717
+ auth: "protected"
49718
+ }),
49719
+ next: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49720
+ kind: "mutation",
49721
+ auth: "protected"
49722
+ }),
49723
+ previous: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49724
+ kind: "mutation",
49725
+ auth: "protected"
49726
+ }),
49727
+ seek: method(object({
49728
+ deviceId: number().int().nonnegative(),
49729
+ position: number().int().nonnegative()
49730
+ }), _void(), {
49731
+ kind: "mutation",
49732
+ auth: "protected"
49733
+ }),
49734
+ setVolume: method(object({
49735
+ deviceId: number().int().nonnegative(),
49736
+ volumeLevel: number().min(0).max(100)
49737
+ }), _void(), {
49738
+ kind: "mutation",
49739
+ auth: "protected"
49740
+ }),
49741
+ setMute: method(object({
49742
+ deviceId: number().int().nonnegative(),
49743
+ muted: boolean()
49744
+ }), _void(), {
49745
+ kind: "mutation",
49746
+ auth: "protected"
49747
+ }),
49748
+ setShuffle: method(object({
49749
+ deviceId: number().int().nonnegative(),
49750
+ shuffle: boolean()
49751
+ }), _void(), {
49752
+ kind: "mutation",
49753
+ auth: "protected"
49754
+ }),
49755
+ setRepeat: method(object({
49756
+ deviceId: number().int().nonnegative(),
49757
+ repeat: MediaPlayerRepeatSchema
49758
+ }), _void(), {
49759
+ kind: "mutation",
49760
+ auth: "protected"
49761
+ }),
49762
+ selectSource: method(object({
49763
+ deviceId: number().int().nonnegative(),
49764
+ source: string().min(1)
49765
+ }), _void(), {
49766
+ kind: "mutation",
49767
+ auth: "protected"
49768
+ }),
49769
+ playMedia: method(object({
49770
+ deviceId: number().int().nonnegative(),
49771
+ /** Media identifier / URL. */
49772
+ mediaId: string().min(1),
49773
+ /** Media kind (`music`, `tvshow`, `movie`, `app`, …) — provider
49774
+ * passes it through to the upstream service. */
49775
+ mediaType: string().min(1)
49776
+ }), _void(), {
49777
+ kind: "mutation",
49778
+ auth: "protected"
49779
+ })
49780
+ },
49781
+ status: {
49782
+ schema: MediaPlayerStatusSchema,
49783
+ kind: "push"
49784
+ },
49785
+ /**
49786
+ * Runtime-state slice — mirrored by the kernel. UI players read the
49787
+ * full slice for live now-playing, volume, and progress updates
49788
+ * without polling.
49789
+ */
49790
+ runtimeState: MediaPlayerStatusSchema,
49791
+ /**
49792
+ * Runtime-state durability: **session** — a restored transport position describes a playback that stopped when the hub did.
49793
+ *
49794
+ * See `RuntimeStateDurability`. Enforced by
49795
+ * `scripts/check-runtime-state-durability.ts`.
49796
+ */
49797
+ durability: "session",
49798
+ /**
49799
+ * History (D850): volume (a level an operator or an automation sets; the
49800
+ * default 10 s floor folds a slider drag into its end value) and mute.
49801
+ * `position` is not recorded: it moves continuously while playing.
49802
+ */
49803
+ history: { fields: {
49804
+ volumeLevel: {
49805
+ kind: "gauge",
49806
+ unit: "%",
49807
+ deadband: 1
49808
+ },
49809
+ isMuted: { kind: "boolean" }
49810
+ } }
49811
+ };
48509
49812
  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
49813
  var NUMBER = {
48511
49814
  kind: "fixed",
@@ -48953,117 +50256,6 @@ function actuator(input) {
48953
50256
  };
48954
50257
  }
48955
50258
  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
50259
  DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
49068
50260
  DeviceType.Camera;
49069
50261
  `${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
@@ -49091,6 +50283,165 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
49091
50283
  }).optional()
49092
50284
  })) });
49093
50285
  /**
50286
+ * A saved Customize assignment (D936). The schema is the type: callers use
50287
+ * `z.infer`, they do not restate the shape.
50288
+ */
50289
+ var OverrideSourceSchema = object({
50290
+ addonId: string().min(1),
50291
+ stableId: string().min(1),
50292
+ cap: string().min(1),
50293
+ fieldPath: string().min(1)
50294
+ });
50295
+ var IdentityTransformDraftSchema = object({ kind: literal("identity") });
50296
+ var InvertTransformDraftSchema = object({ kind: literal("invert") });
50297
+ var ThresholdTransformDraftSchema = object({
50298
+ kind: literal("threshold"),
50299
+ comparison: _enum(["gte", "lte"]),
50300
+ threshold: number(),
50301
+ startDwellMs: number().nonnegative(),
50302
+ stopDwellMs: number().nonnegative()
50303
+ });
50304
+ var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
50305
+ IdentityTransformDraftSchema,
50306
+ InvertTransformDraftSchema,
50307
+ ThresholdTransformDraftSchema,
50308
+ object({
50309
+ kind: literal("linear"),
50310
+ scale: number(),
50311
+ offset: number(),
50312
+ clampMin: number().optional(),
50313
+ clampMax: number().optional()
50314
+ }),
50315
+ object({
50316
+ kind: literal("enum-map"),
50317
+ mapping: record(string(), string().nullable())
50318
+ }),
50319
+ object({ kind: literal("number") })
50320
+ ]);
50321
+ var ScalarOverrideDraftSchema = object({
50322
+ kind: literal("scalar"),
50323
+ cap: string().min(1),
50324
+ targetId: string().min(1),
50325
+ source: OverrideSourceSchema,
50326
+ transform: CustomizeTransformDraftSchema
50327
+ });
50328
+ var KeyedArrayOverrideDraftSchema = object({
50329
+ kind: literal("keyedArray"),
50330
+ cap: string().min(1),
50331
+ targetId: string().min(1),
50332
+ key: string().min(1),
50333
+ label: string().min(1),
50334
+ fieldPath: string().min(1),
50335
+ source: OverrideSourceSchema,
50336
+ transform: CustomizeTransformDraftSchema
50337
+ });
50338
+ var PulseOverrideDraftSchema = object({
50339
+ kind: literal("pulse"),
50340
+ cap: string().min(1),
50341
+ targetId: string().min(1),
50342
+ enabled: boolean(),
50343
+ debounceMs: number().nonnegative(),
50344
+ edges: array(_enum([
50345
+ "rising",
50346
+ "button",
50347
+ "native-event"
50348
+ ])).min(1).optional(),
50349
+ sources: array(OverrideSourceSchema).min(1)
50350
+ });
50351
+ var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: _enum([
50352
+ "in-addition",
50353
+ "confirm",
50354
+ "replace"
50355
+ ]).optional() });
50356
+ discriminatedUnion("kind", [
50357
+ ScalarOverrideDraftSchema,
50358
+ KeyedArrayOverrideDraftSchema,
50359
+ PulseOverrideDraftSchema,
50360
+ object({
50361
+ kind: literal("span"),
50362
+ cap: string().min(1),
50363
+ targetId: string().min(1),
50364
+ timeoutMs: number().nonnegative(),
50365
+ cooldownMs: number().nonnegative().optional(),
50366
+ sources: array(SpanSourceDraftSchema)
50367
+ })
50368
+ ]);
50369
+ object({
50370
+ targetId: string().min(1),
50371
+ configured: boolean(),
50372
+ source: _enum(["native", "assigned"]),
50373
+ state: _enum([
50374
+ "active",
50375
+ "stale",
50376
+ "released",
50377
+ "unavailable"
50378
+ ]),
50379
+ reason: string().nullable()
50380
+ });
50381
+ /**
50382
+ * What a running-threshold proposal says (planning#405). The schema is the
50383
+ * type: the algorithm, the capability method and the UI all read `z.infer`.
50384
+ *
50385
+ * A proposal is read-only advice: it carries the numbers it was derived from
50386
+ * (`evidence`) so the operator can judge it, and an `insufficient` answer names
50387
+ * WHY with a typed reason and the catalog defaults, never an invented number.
50388
+ */
50389
+ var RunningProposalTierSchema = _enum(["raw", "5m"]);
50390
+ var RunningProposalConfidenceSchema = _enum([
50391
+ "high",
50392
+ "medium",
50393
+ "low"
50394
+ ]);
50395
+ var RunningProposalInsufficientReasonSchema = _enum([
50396
+ "no-history",
50397
+ "span-too-short",
50398
+ "truncated",
50399
+ "no-idle-floor",
50400
+ "no-runs",
50401
+ "no-separation"
50402
+ ]);
50403
+ var RunningProposalReplaySchema = object({
50404
+ /** Intervals the real dwell expression held true over the window. */
50405
+ intervals: number().int().nonnegative(),
50406
+ /** Intervals outside every run, or a second interval inside one. */
50407
+ extra: number().int().nonnegative(),
50408
+ /** Runs without an interval of their own (none, or merged into a neighbour). */
50409
+ missed: number().int().nonnegative()
50410
+ });
50411
+ var RunningProposalEvidenceSchema = object({
50412
+ tier: RunningProposalTierSchema,
50413
+ spanMs: number().nonnegative(),
50414
+ from: number(),
50415
+ to: number(),
50416
+ points: number().int().nonnegative(),
50417
+ runsFound: number().int().nonnegative(),
50418
+ pausesFound: number().int().nonnegative(),
50419
+ longestPauseMs: number().nonnegative(),
50420
+ idleFloorW: number(),
50421
+ noiseCeilingW: number(),
50422
+ plateauW: number(),
50423
+ replay: RunningProposalReplaySchema
50424
+ });
50425
+ var RunningProposalInsufficientEvidenceSchema = object({
50426
+ spanMs: number().nonnegative(),
50427
+ points: number().int().nonnegative(),
50428
+ runsFound: number().int().nonnegative()
50429
+ });
50430
+ var RunningThresholdProposalSchema = discriminatedUnion("state", [object({
50431
+ state: literal("proposal"),
50432
+ transform: ThresholdTransformDraftSchema,
50433
+ evidence: RunningProposalEvidenceSchema,
50434
+ confidence: RunningProposalConfidenceSchema,
50435
+ /** Why the confidence is not higher; empty when nothing held it back. */
50436
+ notes: array(string())
50437
+ }), object({
50438
+ state: literal("insufficient"),
50439
+ reason: RunningProposalInsufficientReasonSchema,
50440
+ evidence: RunningProposalInsufficientEvidenceSchema,
50441
+ /** The catalog defaults, offered as what stands when nothing better is known. */
50442
+ fallback: ThresholdTransformDraftSchema
50443
+ })]);
50444
+ /**
49094
50445
  * The report of a one-shot "move this owner's plaintext secrets into the
49095
50446
  * keychain" run (D878). COUNTS only - never a value, never a ref.
49096
50447
  *
@@ -49380,6 +50731,14 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
49380
50731
  kind: "mutation",
49381
50732
  auth: "admin",
49382
50733
  access: "view"
50734
+ }), method(object({
50735
+ deviceId: number().int(),
50736
+ cap: string().min(1),
50737
+ fieldPath: string().min(1),
50738
+ deviceType: _enum(DeviceType).optional()
50739
+ }), RunningThresholdProposalSchema, {
50740
+ auth: "admin",
50741
+ access: "view"
49383
50742
  }), method(object({
49384
50743
  blockId: string().min(1),
49385
50744
  trace: AutomationRunTraceSchema.optional(),
@@ -50356,7 +51715,27 @@ method(object({
50356
51715
  * exposes only the COMMON surface: link state, supported device
50357
51716
  * kinds (so the UI can filter the device picker), and per-device
50358
51717
  * expose/unexpose.
50359
- */
51718
+ *
51719
+ * INSTANCES. One export addon can serve several independent targets (a
51720
+ * HomeKit bridge, a Home Assistant broker). `listInstances` names them.
51721
+ * `instanceId` on a READ is optional: absent = the whole addon (linked if any
51722
+ * enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
51723
+ * default instance's); present = that instance; an id the provider does not
51724
+ * serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
51725
+ * never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
51726
+ * change always names the target it changes. A single-instance provider
51727
+ * accepts an absent id on a read or its own id, and refuses any other.
51728
+ */
51729
+ /** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
51730
+ var InstanceIdSchema$1 = string().min(1);
51731
+ var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
51732
+ /** One independent export target of an addon. */
51733
+ var ExportInstanceSchema = object({
51734
+ instanceId: InstanceIdSchema$1,
51735
+ name: string(),
51736
+ enabled: boolean(),
51737
+ kind: string().optional()
51738
+ });
50360
51739
  var LinkStateSchema = _enum([
50361
51740
  "unlinked",
50362
51741
  "linked",
@@ -50407,10 +51786,14 @@ var ExposedDeviceSchema = object({
50407
51786
  capabilities: array(string()).optional()
50408
51787
  });
50409
51788
  var ExposeInputSchema = object({
51789
+ instanceId: InstanceIdSchema$1,
50410
51790
  deviceId: string(),
50411
51791
  capabilities: array(string()).optional()
50412
51792
  });
50413
- var UnexposeInputSchema = object({ deviceId: string() });
51793
+ var UnexposeInputSchema = object({
51794
+ instanceId: InstanceIdSchema$1,
51795
+ deviceId: string()
51796
+ });
50414
51797
  /**
50415
51798
  * What an exporter may expose besides devices (D968). An action and a
50416
51799
  * notification target are LIST ENTRIES, never devices (D954): they enter an
@@ -50439,15 +51822,21 @@ var ExposedEntitySchema = object({
50439
51822
  entity: ExportEntityRefSchema,
50440
51823
  exposedAs: string().optional()
50441
51824
  });
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(), {
51825
+ var ExposeEntityInputSchema = object({
51826
+ instanceId: InstanceIdSchema$1,
51827
+ entity: ExportEntityRefSchema
51828
+ });
51829
+ var UnexposeEntityInputSchema = object({
51830
+ instanceId: InstanceIdSchema$1,
51831
+ entity: ExportEntityRefSchema
51832
+ });
51833
+ method(InstancePinSchema, DeviceExportStatusSchema), method(_void(), array(ExportInstanceSchema)), method(InstancePinSchema, array(DeviceKindSchema)), method(InstancePinSchema, array(ExposedDeviceSchema)), method(ExposeInputSchema, _void(), {
50445
51834
  kind: "mutation",
50446
51835
  auth: "admin"
50447
51836
  }), method(UnexposeInputSchema, _void(), {
50448
51837
  kind: "mutation",
50449
51838
  auth: "admin"
50450
- }), optionalMethod(_void(), array(ExportEntityKindSchema)), optionalMethod(_void(), array(ExposedEntitySchema)), optionalMethod(ExposeEntityInputSchema, _void(), {
51839
+ }), optionalMethod(_void(), array(ExportEntityKindSchema)), optionalMethod(InstancePinSchema, array(ExposedEntitySchema)), optionalMethod(ExposeEntityInputSchema, _void(), {
50451
51840
  kind: "mutation",
50452
51841
  auth: "admin"
50453
51842
  }), optionalMethod(UnexposeEntityInputSchema, _void(), {
@@ -52449,7 +53838,7 @@ var DishwasherStatusSchema = object({
52449
53838
  /** Ms epoch of the last value received from the appliance; 0 = never. */
52450
53839
  lastFetchedAt: number()
52451
53840
  });
52452
- var DeviceIdSchema$1 = number().int().nonnegative();
53841
+ var DeviceIdSchema$2 = number().int().nonnegative();
52453
53842
  /** A value a program option or setting can take. */
52454
53843
  var DishwasherValueSchema = union([
52455
53844
  boolean(),
@@ -52524,77 +53913,77 @@ var dishwasherCapability = {
52524
53913
  * option feature keys; each is checked against the program's constraints.
52525
53914
  */
52526
53915
  start: method(object({
52527
- deviceId: DeviceIdSchema$1,
53916
+ deviceId: DeviceIdSchema$2,
52528
53917
  program: string().min(1).optional(),
52529
53918
  options: record(string(), DishwasherValueSchema).optional()
52530
53919
  }), _void(), {
52531
53920
  kind: "mutation",
52532
53921
  auth: "protected"
52533
53922
  }),
52534
- pause: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
53923
+ pause: method(object({ deviceId: DeviceIdSchema$2 }), _void(), {
52535
53924
  kind: "mutation",
52536
53925
  auth: "protected"
52537
53926
  }),
52538
- resume: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
53927
+ resume: method(object({ deviceId: DeviceIdSchema$2 }), _void(), {
52539
53928
  kind: "mutation",
52540
53929
  auth: "protected"
52541
53930
  }),
52542
- stop: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
53931
+ stop: method(object({ deviceId: DeviceIdSchema$2 }), _void(), {
52543
53932
  kind: "mutation",
52544
53933
  auth: "protected"
52545
53934
  }),
52546
53935
  /** Select (not start) a program; refused when the appliance does not offer it. */
52547
53936
  setProgram: method(object({
52548
- deviceId: DeviceIdSchema$1,
53937
+ deviceId: DeviceIdSchema$2,
52549
53938
  program: string().min(1)
52550
53939
  }), _void(), {
52551
53940
  kind: "mutation",
52552
53941
  auth: "protected"
52553
53942
  }),
52554
53943
  setPower: method(object({
52555
- deviceId: DeviceIdSchema$1,
53944
+ deviceId: DeviceIdSchema$2,
52556
53945
  on: boolean()
52557
53946
  }), _void(), {
52558
53947
  kind: "mutation",
52559
53948
  auth: "protected"
52560
53949
  }),
52561
53950
  setHalfLoad: method(object({
52562
- deviceId: DeviceIdSchema$1,
53951
+ deviceId: DeviceIdSchema$2,
52563
53952
  on: boolean()
52564
53953
  }), _void(), {
52565
53954
  kind: "mutation",
52566
53955
  auth: "protected"
52567
53956
  }),
52568
53957
  setHygienePlus: method(object({
52569
- deviceId: DeviceIdSchema$1,
53958
+ deviceId: DeviceIdSchema$2,
52570
53959
  on: boolean()
52571
53960
  }), _void(), {
52572
53961
  kind: "mutation",
52573
53962
  auth: "protected"
52574
53963
  }),
52575
53964
  setExtraDry: method(object({
52576
- deviceId: DeviceIdSchema$1,
53965
+ deviceId: DeviceIdSchema$2,
52577
53966
  on: boolean()
52578
53967
  }), _void(), {
52579
53968
  kind: "mutation",
52580
53969
  auth: "protected"
52581
53970
  }),
52582
53971
  setIntensiveZone: method(object({
52583
- deviceId: DeviceIdSchema$1,
53972
+ deviceId: DeviceIdSchema$2,
52584
53973
  on: boolean()
52585
53974
  }), _void(), {
52586
53975
  kind: "mutation",
52587
53976
  auth: "protected"
52588
53977
  }),
52589
53978
  setVarioSpeedPlus: method(object({
52590
- deviceId: DeviceIdSchema$1,
53979
+ deviceId: DeviceIdSchema$2,
52591
53980
  on: boolean()
52592
53981
  }), _void(), {
52593
53982
  kind: "mutation",
52594
53983
  auth: "protected"
52595
53984
  }),
52596
53985
  setChildLock: method(object({
52597
- deviceId: DeviceIdSchema$1,
53986
+ deviceId: DeviceIdSchema$2,
52598
53987
  on: boolean()
52599
53988
  }), _void(), {
52600
53989
  kind: "mutation",
@@ -52606,7 +53995,7 @@ var dishwasherCapability = {
52606
53995
  * its declared range / members.
52607
53996
  */
52608
53997
  setOption: method(object({
52609
- deviceId: DeviceIdSchema$1,
53998
+ deviceId: DeviceIdSchema$2,
52610
53999
  key: string().min(1),
52611
54000
  value: DishwasherValueSchema
52612
54001
  }), _void(), {
@@ -52614,7 +54003,7 @@ var dishwasherCapability = {
52614
54003
  auth: "protected"
52615
54004
  }),
52616
54005
  /** 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" })
54006
+ getOptions: method(object({ deviceId: DeviceIdSchema$2 }), DishwasherOptionsSchema, { auth: "protected" })
52618
54007
  },
52619
54008
  status: {
52620
54009
  schema: DishwasherStatusSchema,
@@ -54038,15 +55427,15 @@ var FanPresetCaptureResultSchema = object({
54038
55427
  items: array(FanCaptureItemSchema),
54039
55428
  omitted: array(FanCaptureOmissionSchema)
54040
55429
  });
54041
- var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
55430
+ var deviceInput$2 = object({ deviceId: number().int().nonnegative() });
54042
55431
  DeviceType.Fan;
54043
- method(deviceInput$1, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$1.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
55432
+ method(deviceInput$2, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$2.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
54044
55433
  kind: "mutation",
54045
55434
  auth: "admin"
54046
- }), method(deviceInput$1.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
55435
+ }), method(deviceInput$2.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
54047
55436
  kind: "mutation",
54048
55437
  auth: "protected"
54049
- }), method(deviceInput$1.extend({
55438
+ }), method(deviceInput$2.extend({
54050
55439
  fields: array(FanCaptureFieldSchema).optional(),
54051
55440
  steps: array(ActionStepSchema).max(20).default([])
54052
55441
  }), FanPresetCaptureResultSchema, { auth: "protected" });
@@ -54929,6 +56318,12 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
54929
56318
  }), object({ success: boolean() }), {
54930
56319
  kind: "mutation",
54931
56320
  auth: "admin"
56321
+ }), method(object({ id: string() }), object({
56322
+ rows: number().int().nonnegative(),
56323
+ secrets: number().int().nonnegative()
56324
+ }), {
56325
+ kind: "mutation",
56326
+ auth: "admin"
54932
56327
  }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
54933
56328
  addonId: string(),
54934
56329
  settings: record(string(), unknown())
@@ -54957,13 +56352,65 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
54957
56352
  */
54958
56353
  var ConfigSchemaPassthrough$3 = custom();
54959
56354
  var IntegrationInstanceIdSchema = string().min(1);
56355
+ var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
56356
+ /**
56357
+ * One kind of instance a provider can create (an adapter, an account type). The sign-in and
56358
+ * connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
56359
+ * hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
56360
+ * interactive account link (popup) and may carry `{{brokerId}}`, which the UI replaces with the
56361
+ * instance id.
56362
+ */
56363
+ var IntegrationInstanceKindSchema = object({
56364
+ /** Stable id of the kind, sent back as `createInstance.kind`. */
56365
+ id: string().min(1),
56366
+ label: string().min(1),
56367
+ /** The kind signs in through a server-held interactive session. */
56368
+ signIn: object({
56369
+ basePath: string().min(1),
56370
+ methods: array(_enum(["device-code", "proxy"])).optional()
56371
+ }).optional(),
56372
+ /** Relative hub path to start an interactive account link of an instance of this kind. */
56373
+ connectPath: string().min(1).optional(),
56374
+ /** Relative hub path to disconnect that account. */
56375
+ disconnectPath: string().min(1).optional()
56376
+ });
54960
56377
  var IntegrationInstanceDescriptionSchema = object({
56378
+ /** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
56379
+ role: _enum([
56380
+ "devices",
56381
+ "services",
56382
+ "both"
56383
+ ]),
56384
+ /** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
56385
+ discovery: object({
56386
+ mode: _enum([
56387
+ "none",
56388
+ "lan",
56389
+ "account"
56390
+ ]),
56391
+ scopedToInstance: boolean()
56392
+ }).optional(),
54961
56393
  /** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
54962
- instanceMode: _enum(["single", "multiple"]),
56394
+ instanceMode: IntegrationInstanceModeSchema,
54963
56395
  /** What the instance is, for the UI (`destination`, `relay`, `account`). */
54964
56396
  kind: string(),
54965
56397
  /** True when `testInstance` really probes the remote. */
54966
- canTest: boolean()
56398
+ canTest: boolean(),
56399
+ /**
56400
+ * The kinds an instance can be of. Absent or one entry: nothing to choose; more than one: the
56401
+ * Add flow asks which first and sends it as `createInstance.kind`.
56402
+ */
56403
+ kinds: array(IntegrationInstanceKindSchema).optional(),
56404
+ /**
56405
+ * The provider accepts `createInstance.id` for an id that once existed (an adopted id, because
56406
+ * devices carry it). The UI then offers "restore under its old id" on Add. Absent means no.
56407
+ */
56408
+ allowRestoreId: boolean().optional(),
56409
+ /**
56410
+ * `createInstance` without an `id` works: the provider mints it. Absent means the caller must
56411
+ * send an id (the UI then mints an opaque one).
56412
+ */
56413
+ mintsId: boolean().optional()
54967
56414
  });
54968
56415
  var IntegrationInstanceStatusSchema = object({
54969
56416
  state: _enum([
@@ -54972,16 +56419,28 @@ var IntegrationInstanceStatusSchema = object({
54972
56419
  "error",
54973
56420
  "unknown"
54974
56421
  ]),
54975
- detail: string().optional()
56422
+ detail: string().optional(),
56423
+ /** A short human word for the state ("Signed in", "Token expired"); shown instead of `state`. */
56424
+ label: string().optional()
54976
56425
  });
54977
56426
  var IntegrationInstanceSchema = object({
54978
56427
  id: IntegrationInstanceIdSchema,
54979
56428
  name: string(),
54980
56429
  /** The addon's own rule (an URL is present, a client id is present...). */
54981
56430
  configured: boolean(),
56431
+ /**
56432
+ * The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
56433
+ * so a row written before the field existed is on). Absent when the `integrations` registry
56434
+ * owns the switch (`describe().role` is `devices`): read it from the registry row.
56435
+ */
56436
+ enabled: boolean().optional(),
56437
+ /** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
56438
+ kind: string().optional(),
54982
56439
  /** Values for the instance form; a secret is a `SecretFieldView`, never text. */
54983
56440
  formValues: record(string(), unknown()),
54984
- status: IntegrationInstanceStatusSchema.optional()
56441
+ status: IntegrationInstanceStatusSchema.optional(),
56442
+ /** Epoch ms of the last probe of the remote that produced `status`; absent when never checked. */
56443
+ lastCheckedAt: number().optional()
54985
56444
  });
54986
56445
  var IntegrationInstancePatchSchema = object({
54987
56446
  id: IntegrationInstanceIdSchema,
@@ -54989,25 +56448,57 @@ var IntegrationInstancePatchSchema = object({
54989
56448
  /** Omitted / '' / redaction token keeps a secret; `{ $secretClear: true }` clears it. */
54990
56449
  values: record(string(), unknown())
54991
56450
  });
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
- });
56451
+ var integrationInstancesCapability = {
56452
+ name: "integration-instances",
56453
+ scope: "system",
56454
+ mode: "collection",
56455
+ methods: {
56456
+ describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
56457
+ /** The form; `id: null` is the create form. */
56458
+ instanceFormSchema: method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3, { auth: "admin" }),
56459
+ listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
56460
+ getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
56461
+ /**
56462
+ * Insert the typed record. With `id` it is stored under that id (a duplicate id is refused);
56463
+ * without one the PROVIDER mints it and answers it. `kind` picks one of `describe().kinds`.
56464
+ */
56465
+ createInstance: method(object({
56466
+ id: IntegrationInstanceIdSchema.optional(),
56467
+ name: string().min(1),
56468
+ kind: string().min(1).optional()
56469
+ }), object({ id: string() }), {
56470
+ kind: "mutation",
56471
+ auth: "admin"
56472
+ }),
56473
+ updateInstance: method(IntegrationInstancePatchSchema, object({ ok: literal(true) }), {
56474
+ kind: "mutation",
56475
+ auth: "admin"
56476
+ }),
56477
+ /**
56478
+ * Switch ONE instance on or off. A row control, not a form field: `updateInstance.values` is the
56479
+ * form patch (D62, D996). An off instance keeps its record and secrets and does no work.
56480
+ */
56481
+ setInstanceEnabled: method(object({
56482
+ id: IntegrationInstanceIdSchema,
56483
+ enabled: boolean()
56484
+ }), object({ ok: literal(true) }), {
56485
+ kind: "mutation",
56486
+ auth: "admin"
56487
+ }),
56488
+ /** Delete the record and its keychain refs together. */
56489
+ deleteInstance: method(object({ id: IntegrationInstanceIdSchema }), object({ ok: literal(true) }), {
56490
+ kind: "mutation",
56491
+ auth: "admin"
56492
+ }),
56493
+ testInstance: optionalMethod(object({
56494
+ id: IntegrationInstanceIdSchema.nullable(),
56495
+ values: record(string(), unknown())
56496
+ }), TestConnectionResultSchema$1, {
56497
+ kind: "mutation",
56498
+ auth: "admin"
56499
+ })
56500
+ }
56501
+ };
55011
56502
  /**
55012
56503
  * Two-way audio / talk-back cap. Clients open a WebRTC audio-only
55013
56504
  * session (server-initiated offer pattern, identical to the main
@@ -57025,6 +58516,11 @@ var LogEntrySchema = object({
57025
58516
  * flight, and not asking for the next slice ends the scan.
57026
58517
  */
57027
58518
  var LogReadQuerySchema = object({
58519
+ /**
58520
+ * Which destination INSTANCE answers (a destination addon may hold several records). Absent ⇒
58521
+ * the provider's first readable one, so a caller written before instances existed is unchanged.
58522
+ */
58523
+ instanceId: string().min(1).max(200).optional(),
57028
58524
  /** Correlates `cancelRead`. Caller-chosen, unique per in-flight read. */
57029
58525
  requestId: string().min(1).max(64).optional(),
57030
58526
  /** The device the line is about (`tags.deviceId`, numeric). */
@@ -57087,6 +58583,8 @@ var LogReadResultSchema = object({
57087
58583
  /** True when `cancelRead` ended this slice early. */
57088
58584
  cancelled: boolean().optional()
57089
58585
  });
58586
+ /** Names one destination instance; absent ⇒ the provider's first readable one. */
58587
+ var LogInstanceSelectorSchema = object({ instanceId: string().min(1).max(200).optional() });
57090
58588
  var LogReadCapabilitiesSchema = object({
57091
58589
  /** False ⇒ this destination only ships lines (console, forwarder, an unconfigured Loki). */
57092
58590
  readable: boolean(),
@@ -57105,7 +58603,7 @@ var LogReadCapabilitiesSchema = object({
57105
58603
  /** How far back the store reaches, when the provider knows (days). */
57106
58604
  retentionDays: number().nullable()
57107
58605
  });
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() }), {
58606
+ 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
58607
  kind: "mutation",
57110
58608
  auth: "admin"
57111
58609
  });
@@ -57209,214 +58707,6 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
57209
58707
  ]);
57210
58708
  method(_void(), array(LoginMethodContributionSchema).readonly());
57211
58709
  /**
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
58710
  * mesh-network — collection cap for mesh-VPN providers.
57421
58711
  *
57422
58712
  * Different shape from `network-access` (public tunnels):
@@ -66175,6 +67465,21 @@ var NcTemplateVarKindSchema = _enum([
66175
67465
  "sound",
66176
67466
  "system"
66177
67467
  ]);
67468
+ /**
67469
+ * The default title/body a rule of one SITUATION is delivered with when the
67470
+ * operator wrote no template — served so an editor can pre-fill it (and the
67471
+ * operator can rebuild it from placeholders) instead of starting from a blank
67472
+ * box that, once saved, silently replaces it. `id` names the situation inside
67473
+ * a rule `kind`: `appliance-cycle` is a `sensor` rule whose device is an
67474
+ * appliance finishing a cycle. Texts are raw templates (`{{var}}` intact), in
67475
+ * the hub's current language and with its overrides applied.
67476
+ */
67477
+ var NcTemplateDefaultSchema = object({
67478
+ id: _enum(["appliance-cycle"]),
67479
+ kind: NcRuleKindSchema,
67480
+ title: string(),
67481
+ body: string()
67482
+ });
66178
67483
  /** Which producer renders a template: an ordinary rule, a timelapse, a digest. */
66179
67484
  var NcTemplateFamilySchema = _enum([
66180
67485
  "rule",
@@ -67030,7 +68335,11 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
67030
68335
  }), method(object({}), object({
67031
68336
  catalog: array(NcConditionDescriptorSchema),
67032
68337
  taxonomy: NcTaxonomySchema.optional()
67033
- })), method(object({}), object({ vars: array(NcTemplateVarDescriptorSchema) })), method(NcTemplatePreviewInputSchema, NcTemplatePreviewSchema, {
68338
+ })), method(object({}), object({
68339
+ vars: array(NcTemplateVarDescriptorSchema),
68340
+ /** Per-situation default texts; absent on a hub that predates them. */
68341
+ defaults: array(NcTemplateDefaultSchema)
68342
+ })), method(NcTemplatePreviewInputSchema, NcTemplatePreviewSchema, {
67034
68343
  kind: "mutation",
67035
68344
  access: "view"
67036
68345
  }), 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 +69235,7 @@ var petFeederCapability = {
67926
69235
  /**
67927
69236
  * Pet water-fountain cap. Models the telemetry and the control surface of a
67928
69237
  * 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.
69238
+ * pet drank, whether the pump runs.
67930
69239
  *
67931
69240
  * It has no native vendor provider of its own: a fountain reaches CamStack as
67932
69241
  * a container of loose entities (a pump switch, two number boxes, a "filter
@@ -67942,8 +69251,10 @@ var petFeederCapability = {
67942
69251
  * never here. Every reading may be `null`: a source that is offline or does
67943
69252
  * not report is unknown, never zero.
67944
69253
  *
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.
69254
+ * The pump's on/off duty cycle is model-specific and lives in the optional
69255
+ * `pump-cycle` cap. The filter, the cleaning and the water change are not
69256
+ * fields of this cap: they are items of the `consumables` cap on the same
69257
+ * device (kind `wear`), reset by the same forward mechanism.
67947
69258
  */
67948
69259
  var PetFountainStatusSchema = object({
67949
69260
  /** Water in the tank, 0..100 (%). Null while the source has not reported. */
@@ -67954,27 +69265,20 @@ var PetFountainStatusSchema = object({
67954
69265
  empty: boolean().nullable(),
67955
69266
  /** True while the pump is running. Null while unknown. */
67956
69267
  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
69268
  /** Water drunk in the last drink, in litres. */
67964
69269
  lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
67965
69270
  /** Water drunk in the current hour, in litres. */
67966
69271
  currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
67967
69272
  /** Water drunk over the last 24 hours (rolling), in litres. */
67968
69273
  last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
67969
- /** Water drunk since local midnight, in litres. */
69274
+ /** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
67970
69275
  todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
67971
69276
  /** Decoded fault message. Null means healthy; a non-null string is an active fault. */
67972
69277
  error: string().nullable(),
67973
69278
  /** Ms epoch when the slice was last refreshed. */
67974
69279
  lastFetchedAt: number()
67975
69280
  });
67976
- var DeviceIdSchema = number().int().nonnegative();
67977
- var MinutesSchema = number().int().min(0);
69281
+ var DeviceIdSchema$1 = number().int().nonnegative();
67978
69282
  var petFountainCapability = {
67979
69283
  name: "pet-fountain",
67980
69284
  scope: "device",
@@ -67984,38 +69288,14 @@ var petFountainCapability = {
67984
69288
  methods: {
67985
69289
  /** Start or stop the pump. */
67986
69290
  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,
69291
+ deviceId: DeviceIdSchema$1,
67996
69292
  on: boolean()
67997
69293
  }), _void(), {
67998
69294
  kind: "mutation",
67999
69295
  auth: "protected"
68000
69296
  }),
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
69297
  /** Clear the rolling daily consumption counters on the device. */
68018
- resetDailyConsumption: method(object({ deviceId: DeviceIdSchema }), _void(), {
69298
+ resetDailyConsumption: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
68019
69299
  kind: "mutation",
68020
69300
  auth: "protected"
68021
69301
  })
@@ -69650,6 +70930,14 @@ var powerMeterCapability = {
69650
70930
  deviceNative: true,
69651
70931
  mode: "singleton",
69652
70932
  deviceTypes: POWER_METER_DEVICE_TYPES,
70933
+ deviceConfig: { ui: {
70934
+ kind: "widget",
70935
+ widgetId: "host/power-meter-line",
70936
+ tab: "power",
70937
+ placement: "hero",
70938
+ label: "Power",
70939
+ order: 4
70940
+ } },
69653
70941
  methods: {},
69654
70942
  status: {
69655
70943
  schema: PowerMeterStatusSchema,
@@ -69709,6 +70997,117 @@ var powerMeterCapability = {
69709
70997
  volatileStateFields: ["lastFetchedAt"],
69710
70998
  customize: powerMeterCustomize
69711
70999
  };
71000
+ var PowerSourceRefusalReasonSchema = _enum([
71001
+ "no-power-source",
71002
+ "switch-missing",
71003
+ "switch-offline",
71004
+ "switch-unknown",
71005
+ "restart-in-progress",
71006
+ "switch-call-failed"
71007
+ ]);
71008
+ var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
71009
+ accepted: literal(false),
71010
+ reason: PowerSourceRefusalReasonSchema,
71011
+ /** One line for the operator, naming the switch. */
71012
+ message: string()
71013
+ })]);
71014
+ var PowerSourceInfoSchema = object({
71015
+ /** False when the device has no power source linked; the rest is then empty. */
71016
+ linked: boolean(),
71017
+ switchDeviceId: number().nullable(),
71018
+ switchName: string().nullable(),
71019
+ /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
71020
+ switchOn: boolean().nullable(),
71021
+ switchOnline: boolean().nullable(),
71022
+ restartInProgress: boolean(),
71023
+ offSeconds: number().int()
71024
+ });
71025
+ /** The composed slice: the switch state the link mirrors, plus the stored off time. */
71026
+ var PowerSourceStateSchema = object({
71027
+ /** Null while the switch has not reported: unknown is never `false` (D393). */
71028
+ switchOn: boolean().nullable(),
71029
+ offSeconds: number().int(),
71030
+ lastFetchedAt: number()
71031
+ });
71032
+ var POWER_SOURCE_DEVICE_TYPES = [
71033
+ DeviceType.Gateway,
71034
+ DeviceType.Hub,
71035
+ DeviceType.Camera,
71036
+ DeviceType.Sensor,
71037
+ DeviceType.MediaPlayer,
71038
+ DeviceType.Vacuum,
71039
+ DeviceType.Generic,
71040
+ DeviceType.Washer,
71041
+ DeviceType.Dryer,
71042
+ DeviceType.Dishwasher,
71043
+ DeviceType.PetFountain,
71044
+ DeviceType.Fan,
71045
+ DeviceType.Humidifier,
71046
+ DeviceType.Climate,
71047
+ DeviceType.WaterHeater
71048
+ ];
71049
+ var powerSourceCustomize = {
71050
+ version: 1,
71051
+ targets: [{
71052
+ id: "switch",
71053
+ cardinality: "scalar",
71054
+ vocabulary: {
71055
+ cap: "power-source",
71056
+ stateField: "switchOn"
71057
+ },
71058
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
71059
+ apply: "add",
71060
+ path: "switchOn",
71061
+ sources: [{
71062
+ kind: "switch",
71063
+ transforms: [{ kind: "identity" }]
71064
+ }],
71065
+ companions: [{
71066
+ kind: "constant",
71067
+ path: "offSeconds",
71068
+ value: 10,
71069
+ when: "add"
71070
+ }, {
71071
+ kind: "clock",
71072
+ path: "lastFetchedAt",
71073
+ when: "always"
71074
+ }],
71075
+ sourceReport: { status: "assignment-status" }
71076
+ }]
71077
+ };
71078
+ var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
71079
+ var powerSourceCapability = {
71080
+ name: "power-source",
71081
+ scope: "device",
71082
+ mode: "singleton",
71083
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
71084
+ methods: {
71085
+ getStatus: systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "admin" }),
71086
+ powerOn: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
71087
+ kind: "mutation",
71088
+ auth: "admin"
71089
+ }),
71090
+ powerOff: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
71091
+ kind: "mutation",
71092
+ auth: "admin"
71093
+ }),
71094
+ forceRestart: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
71095
+ kind: "mutation",
71096
+ auth: "admin"
71097
+ })
71098
+ },
71099
+ runtimeState: PowerSourceStateSchema,
71100
+ customize: powerSourceCustomize,
71101
+ /**
71102
+ * Runtime-state durability: **session** — mirrored from the linked switch on
71103
+ * its next report; a restored value would outlive the reading it names.
71104
+ *
71105
+ * See `RuntimeStateDurability`. Enforced by
71106
+ * `scripts/check-runtime-state-durability.ts`.
71107
+ */
71108
+ durability: "session",
71109
+ history: "none"
71110
+ };
69712
71111
  /**
69713
71112
  * Presence cap. Models HA `person.*` and `device_tracker.*` entities
69714
71113
  * on `DeviceType.Presence`. Read-only — no setters: presence is
@@ -70348,6 +71747,79 @@ var ptzAutotrackCapability = {
70348
71747
  */
70349
71748
  history: "none"
70350
71749
  };
71750
+ /**
71751
+ * The on/off duty cycle of a pet fountain's pump. Some models run the pump
71752
+ * continuously and have nothing to configure; others can alternate a run time
71753
+ * and a rest time. That is model-specific, so it is its own optional cap on the
71754
+ * fountain device: a fountain without cycle entities simply never composes it
71755
+ * (planning#366), and the `pet-fountain` cap stays the model-independent core.
71756
+ *
71757
+ * Like `pet-fountain` it has no native vendor provider: an operator BUILDS the
71758
+ * cycle from loose entities (a cycle switch and two number boxes) and every
71759
+ * method is a forward to one source entity (D659, D967). Durations are stored
71760
+ * in SECONDS (D944); a number box that cannot be read back leaves them `null`
71761
+ * — unknown, never zero (D393).
71762
+ */
71763
+ var PumpCycleStatusSchema = object({
71764
+ /** True when the pump works on the on/off cycle, false when it runs continuously. Null while unknown. */
71765
+ enabled: boolean().nullable(),
71766
+ /** How long the pump runs per cycle, in seconds. Null while unknown. */
71767
+ onTime: number().min(0).nullable().meta(readingMeta("duration")),
71768
+ /** How long the pump rests per cycle, in seconds. Null while unknown. */
71769
+ offTime: number().min(0).nullable().meta(readingMeta("duration")),
71770
+ /** Ms epoch when the slice was last refreshed. */
71771
+ lastFetchedAt: number()
71772
+ });
71773
+ var DeviceIdSchema = number().int().nonnegative();
71774
+ var MinutesSchema = number().int().min(0);
71775
+ var pumpCycleCapability = {
71776
+ name: "pump-cycle",
71777
+ scope: "device",
71778
+ deviceNative: true,
71779
+ mode: "singleton",
71780
+ deviceTypes: [DeviceType.PetFountain],
71781
+ methods: {
71782
+ /** Switch the on/off duty cycle on or off (off = the pump runs continuously). */
71783
+ setEnabled: method(object({
71784
+ deviceId: DeviceIdSchema,
71785
+ on: boolean()
71786
+ }), _void(), {
71787
+ kind: "mutation",
71788
+ auth: "protected"
71789
+ }),
71790
+ /** Set how many minutes the pump runs per cycle. */
71791
+ setOnMinutes: method(object({
71792
+ deviceId: DeviceIdSchema,
71793
+ minutes: MinutesSchema
71794
+ }), _void(), {
71795
+ kind: "mutation",
71796
+ auth: "protected"
71797
+ }),
71798
+ /** Set how many minutes the pump rests per cycle. */
71799
+ setOffMinutes: method(object({
71800
+ deviceId: DeviceIdSchema,
71801
+ minutes: MinutesSchema
71802
+ }), _void(), {
71803
+ kind: "mutation",
71804
+ auth: "protected"
71805
+ })
71806
+ },
71807
+ status: {
71808
+ schema: PumpCycleStatusSchema,
71809
+ kind: "push"
71810
+ },
71811
+ /** Runtime-state slice — mirrored by the kernel; the hero card reads it whole. */
71812
+ runtimeState: PumpCycleStatusSchema,
71813
+ /**
71814
+ * Runtime-state durability: **session** — live appliance state re-published on connect.
71815
+ *
71816
+ * See `RuntimeStateDurability`. Enforced by
71817
+ * `scripts/check-runtime-state-durability.ts`.
71818
+ */
71819
+ durability: "session",
71820
+ /** History (D850): a duty-cycle setting is not a series worth recording. */
71821
+ history: "none"
71822
+ };
70351
71823
  DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, method(object({ deviceId: number().int().nonnegative() }), object({ success: literal(true) }), {
70352
71824
  kind: "mutation",
70353
71825
  auth: "admin"
@@ -73138,7 +74610,13 @@ var RemoteMediaCommandSchema = _enum([
73138
74610
  "next",
73139
74611
  "previous",
73140
74612
  "setMute",
73141
- "selectSource"
74613
+ "selectSource",
74614
+ "turnOn",
74615
+ "turnOff",
74616
+ "volumeUp",
74617
+ "volumeDown",
74618
+ "channelUp",
74619
+ "channelDown"
73142
74620
  ]);
73143
74621
  /** A send result, or `not-routed`: the role is not bound, so the native cap answers. */
73144
74622
  var RemoteMediaCommandResultSchema = discriminatedUnion("status", [...RemoteSendResultSchema.options, object({ status: literal("not-routed") })]);
@@ -73159,7 +74637,7 @@ method(deviceInput, RemoteConfigSchema, { auth: "admin" }), method(deviceInput.e
73159
74637
  }), RemoteSendResultSchema, {
73160
74638
  kind: "mutation",
73161
74639
  auth: "protected"
73162
- }), method(deviceInput.extend({
74640
+ }), method(deviceInput, MediaPlayerStatusSchema.nullable(), { auth: "protected" }), method(deviceInput.extend({
73163
74641
  command: RemoteMediaCommandSchema,
73164
74642
  muted: boolean().optional(),
73165
74643
  source: string().optional(),
@@ -75405,7 +76883,11 @@ listSignals: method(_void(), array(StreamSignalSchema).readonly()) }
75405
76883
  * `getSettingsUISchema()` surface.
75406
76884
  */
75407
76885
  var SwitchStatusSchema = object({
75408
- on: boolean().meta({ label: "On" }),
76886
+ /**
76887
+ * `null` = the device has never reported its state (a measurement that
76888
+ * has not happened is unknown, never `false`).
76889
+ */
76890
+ on: boolean().nullable().meta({ label: "On" }),
75409
76891
  /** Ms epoch of the last state change. Useful for UI "X minutes ago". */
75410
76892
  lastChangedAt: number()
75411
76893
  });
@@ -75430,7 +76912,7 @@ var switchCapability = {
75430
76912
  }) },
75431
76913
  events: { onStateChanged: { data: object({
75432
76914
  deviceId: number(),
75433
- on: boolean(),
76915
+ on: boolean().nullable(),
75434
76916
  lastChangedAt: number()
75435
76917
  }) } },
75436
76918
  status: {
@@ -79079,6 +80561,26 @@ function buildDescriptor(capName, kind) {
79079
80561
  * contributes one entry per bound cap present in this map.
79080
80562
  */
79081
80563
  var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
80564
+ /**
80565
+ * What a remote key is CALLED and what it LOOKS like, for every role (D963),
80566
+ * shared by the admin UI and the viewer. A role is data on the wire; each
80567
+ * client resolves its name from `label` (English and Italian side by side) and
80568
+ * its glyph from `icon`, a lucide id from the shared icon catalogue — the
80569
+ * server sends an id, a client maps it to its own icon set.
80570
+ *
80571
+ * `legend` is text printed on the key INSTEAD of a glyph (a digit has no
80572
+ * pictogram): a client that can draw text shows it, one that cannot falls back
80573
+ * to `icon`.
80574
+ */
80575
+ function digit(n) {
80576
+ return {
80577
+ label: t(n, n),
80578
+ icon: "hash",
80579
+ legend: n
80580
+ };
80581
+ }
80582
+ digit("0"), digit("1"), digit("2"), digit("3"), digit("4"), digit("5"), digit("6"), digit("7"), digit("8"), digit("9");
80583
+ DeviceFeature.MediaPlayerPower, DeviceFeature.MediaPlayerVolumeStep, DeviceFeature.MediaPlayerChannelStep, DeviceFeature.MediaPlayerMute, DeviceFeature.MediaPlayerStop, DeviceFeature.MediaPlayerNext, DeviceFeature.MediaPlayerPrevious;
79082
80584
  var btn = (idSuffix, row, col, init) => ({
79083
80585
  idSuffix,
79084
80586
  row,
@@ -79205,6 +80707,34 @@ discriminatedUnion("kind", [object({
79205
80707
  kind: literal("pronto"),
79206
80708
  code: string()
79207
80709
  })]);
80710
+ /**
80711
+ * Propose a running threshold from a device's own power history (planning#405).
80712
+ *
80713
+ * Pure and deterministic: the same series gives the same answer. The series is
80714
+ * a HELD-VALUE step series — a point's value stands until the next point — which
80715
+ * is how device-history stores a gauge, so "time at a level" is exact, not a
80716
+ * count of samples.
80717
+ *
80718
+ * 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
80719
+ * near F. A device that is not near one level most of the time has no floor.
80720
+ * 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
80721
+ * 3. gaps between episodes split in two by the largest log-scale jump (>= 3x):
80722
+ * the short ones are pauses INSIDE a run (a soak), the long ones separate runs.
80723
+ * 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
80724
+ * grid a person would type; stop dwell covers the longest pause; start dwell
80725
+ * covers the longest standby blip above T.
80726
+ * 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
80727
+ * run must hold exactly one true interval and nothing may flap outside.
80728
+ */
80729
+ var SECOND_MS = 1e3;
80730
+ var MINUTE_MS$1 = 60 * SECOND_MS;
80731
+ 24 * (60 * MINUTE_MS$1);
80732
+ 10 * MINUTE_MS$1;
80733
+ 30 * SECOND_MS;
80734
+ 60 * SECOND_MS;
80735
+ 20 * MINUTE_MS$1;
80736
+ 10 * SECOND_MS;
80737
+ 10 * SECOND_MS;
79208
80738
  DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverStoppable, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
79209
80739
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
79210
80740
  String.raw`rose\(active(\d+), changed(\d+), (\d+(?:\.\d+)?)\)`;
@@ -79565,6 +81095,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
79565
81095
  pressureSensor: pressureSensorCapability,
79566
81096
  privacyMask: privacyMaskCapability,
79567
81097
  ptzAutotrack: ptzAutotrackCapability,
81098
+ pumpCycle: pumpCycleCapability,
79568
81099
  recordingOnboard: recordingOnboardCapability,
79569
81100
  recordingSignal: recordingSignalCapability,
79570
81101
  runningState: runningStateCapability,
@@ -81749,6 +83280,27 @@ Object.freeze({
81749
83280
  access: "view",
81750
83281
  role: "viewer"
81751
83282
  },
83283
+ "boardKeySource.getBoardKey": {
83284
+ capName: "board-key-source",
83285
+ capScope: "system",
83286
+ addonId: null,
83287
+ access: "view",
83288
+ role: "admin"
83289
+ },
83290
+ "boardKeySource.listBoards": {
83291
+ capName: "board-key-source",
83292
+ capScope: "system",
83293
+ addonId: null,
83294
+ access: "view",
83295
+ role: "admin"
83296
+ },
83297
+ "boardKeySource.listSources": {
83298
+ capName: "board-key-source",
83299
+ capScope: "system",
83300
+ addonId: null,
83301
+ access: "view",
83302
+ role: "admin"
83303
+ },
81752
83304
  "brightness.getStatus": {
81753
83305
  capName: "brightness",
81754
83306
  capScope: "device",
@@ -82288,6 +83840,13 @@ Object.freeze({
82288
83840
  access: "create",
82289
83841
  role: "admin"
82290
83842
  },
83843
+ "coreBlocks.proposeRunningThreshold": {
83844
+ capName: "core-blocks",
83845
+ capScope: "system",
83846
+ addonId: null,
83847
+ access: "view",
83848
+ role: "admin"
83849
+ },
82291
83850
  "coreBlocks.reportAutomationRun": {
82292
83851
  capName: "core-blocks",
82293
83852
  capScope: "system",
@@ -82799,6 +84358,13 @@ Object.freeze({
82799
84358
  access: "view",
82800
84359
  role: "admin"
82801
84360
  },
84361
+ "deviceExport.listInstances": {
84362
+ capName: "device-export",
84363
+ capScope: "system",
84364
+ addonId: null,
84365
+ access: "view",
84366
+ role: "admin"
84367
+ },
82802
84368
  "deviceExport.listSupportedDeviceKinds": {
82803
84369
  capName: "device-export",
82804
84370
  capScope: "system",
@@ -84430,6 +85996,13 @@ Object.freeze({
84430
85996
  access: "view",
84431
85997
  role: "admin"
84432
85998
  },
85999
+ "integrationInstances.setInstanceEnabled": {
86000
+ capName: "integration-instances",
86001
+ capScope: "system",
86002
+ addonId: null,
86003
+ access: "create",
86004
+ role: "admin"
86005
+ },
84433
86006
  "integrationInstances.testInstance": {
84434
86007
  capName: "integration-instances",
84435
86008
  capScope: "system",
@@ -84444,6 +86017,13 @@ Object.freeze({
84444
86017
  access: "create",
84445
86018
  role: "admin"
84446
86019
  },
86020
+ "integrations.clearSettings": {
86021
+ capName: "integrations",
86022
+ capScope: "system",
86023
+ addonId: null,
86024
+ access: "delete",
86025
+ role: "admin"
86026
+ },
84447
86027
  "integrations.create": {
84448
86028
  capName: "integrations",
84449
86029
  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",
@@ -86565,27 +88187,6 @@ Object.freeze({
86565
88187
  access: "create",
86566
88188
  role: "viewer"
86567
88189
  },
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
88190
  "pipelineAnalytics.addRetrainFrameFromRecording": {
86590
88191
  capName: "pipeline-analytics",
86591
88192
  capScope: "device",
@@ -88364,6 +89965,34 @@ Object.freeze({
88364
89965
  access: "create",
88365
89966
  role: "admin"
88366
89967
  },
89968
+ "pumpCycle.getStatus": {
89969
+ capName: "pump-cycle",
89970
+ capScope: "device",
89971
+ addonId: null,
89972
+ access: "view",
89973
+ role: "viewer"
89974
+ },
89975
+ "pumpCycle.setEnabled": {
89976
+ capName: "pump-cycle",
89977
+ capScope: "device",
89978
+ addonId: null,
89979
+ access: "create",
89980
+ role: "viewer"
89981
+ },
89982
+ "pumpCycle.setOffMinutes": {
89983
+ capName: "pump-cycle",
89984
+ capScope: "device",
89985
+ addonId: null,
89986
+ access: "create",
89987
+ role: "viewer"
89988
+ },
89989
+ "pumpCycle.setOnMinutes": {
89990
+ capName: "pump-cycle",
89991
+ capScope: "device",
89992
+ addonId: null,
89993
+ access: "create",
89994
+ role: "viewer"
89995
+ },
88367
89996
  "reboot.reboot": {
88368
89997
  capName: "reboot",
88369
89998
  capScope: "device",
@@ -88868,6 +90497,13 @@ Object.freeze({
88868
90497
  access: "create",
88869
90498
  role: "admin"
88870
90499
  },
90500
+ "remote.getAssumedStatus": {
90501
+ capName: "remote",
90502
+ capScope: "system",
90503
+ addonId: null,
90504
+ access: "view",
90505
+ role: "admin"
90506
+ },
88871
90507
  "remote.getConfig": {
88872
90508
  capName: "remote",
88873
90509
  capScope: "system",
@@ -91683,6 +93319,11 @@ Object.freeze({
91683
93319
  form: "single",
91684
93320
  optional: false
91685
93321
  }],
93322
+ "coreBlocks.proposeRunningThreshold": [{
93323
+ name: "deviceId",
93324
+ form: "single",
93325
+ optional: false
93326
+ }],
91686
93327
  "cover.close": [{
91687
93328
  name: "deviceId",
91688
93329
  form: "single",
@@ -92534,6 +94175,16 @@ Object.freeze({
92534
94175
  form: "single",
92535
94176
  optional: true
92536
94177
  }],
94178
+ "mediaPlayer.channelDown": [{
94179
+ name: "deviceId",
94180
+ form: "single",
94181
+ optional: false
94182
+ }],
94183
+ "mediaPlayer.channelUp": [{
94184
+ name: "deviceId",
94185
+ form: "single",
94186
+ optional: false
94187
+ }],
92537
94188
  "mediaPlayer.getStatus": [{
92538
94189
  name: "deviceId",
92539
94190
  form: "single",
@@ -92599,6 +94250,26 @@ Object.freeze({
92599
94250
  form: "single",
92600
94251
  optional: false
92601
94252
  }],
94253
+ "mediaPlayer.turnOff": [{
94254
+ name: "deviceId",
94255
+ form: "single",
94256
+ optional: false
94257
+ }],
94258
+ "mediaPlayer.turnOn": [{
94259
+ name: "deviceId",
94260
+ form: "single",
94261
+ optional: false
94262
+ }],
94263
+ "mediaPlayer.volumeDown": [{
94264
+ name: "deviceId",
94265
+ form: "single",
94266
+ optional: false
94267
+ }],
94268
+ "mediaPlayer.volumeUp": [{
94269
+ name: "deviceId",
94270
+ form: "single",
94271
+ optional: false
94272
+ }],
92602
94273
  "meter.getStatus": [{
92603
94274
  name: "deviceId",
92604
94275
  form: "single",
@@ -92908,21 +94579,6 @@ Object.freeze({
92908
94579
  form: "single",
92909
94580
  optional: false
92910
94581
  }],
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
94582
  "pipelineAnalytics.addRetrainFrameFromRecording": [{
92927
94583
  name: "deviceId",
92928
94584
  form: "single",
@@ -93558,6 +95214,26 @@ Object.freeze({
93558
95214
  form: "single",
93559
95215
  optional: false
93560
95216
  }],
95217
+ "pumpCycle.getStatus": [{
95218
+ name: "deviceId",
95219
+ form: "single",
95220
+ optional: false
95221
+ }],
95222
+ "pumpCycle.setEnabled": [{
95223
+ name: "deviceId",
95224
+ form: "single",
95225
+ optional: false
95226
+ }],
95227
+ "pumpCycle.setOffMinutes": [{
95228
+ name: "deviceId",
95229
+ form: "single",
95230
+ optional: false
95231
+ }],
95232
+ "pumpCycle.setOnMinutes": [{
95233
+ name: "deviceId",
95234
+ form: "single",
95235
+ optional: false
95236
+ }],
93561
95237
  "reboot.reboot": [{
93562
95238
  name: "deviceId",
93563
95239
  form: "single",
@@ -93759,6 +95435,11 @@ Object.freeze({
93759
95435
  form: "single",
93760
95436
  optional: true
93761
95437
  }],
95438
+ "remote.getAssumedStatus": [{
95439
+ name: "deviceId",
95440
+ form: "single",
95441
+ optional: false
95442
+ }],
93762
95443
  "remote.getConfig": [{
93763
95444
  name: "deviceId",
93764
95445
  form: "single",
@@ -94306,99 +95987,6 @@ Object.freeze({
94306
95987
  "network-access": "ingress",
94307
95988
  "smtp-provider": "email"
94308
95989
  });
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
95990
  var G711_SCALE_CORRECTION_DB = {
94403
95991
  PCMU: 20 * Math.log10(4),
94404
95992
  PCMA: 20 * Math.log10(8)
@@ -95014,6 +96602,7 @@ var STATE_SUMMARY_VARS = [
95014
96602
  [...RULE_TEXT],
95015
96603
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
95016
96604
  ([...RULE_TEXT], [...COMBINED_ALARM]),
96605
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
95017
96606
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
95018
96607
  ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
95019
96608
  ([...RULE_TEXT], [...CONSUMABLE]),
@@ -119910,6 +121499,83 @@ function buildCcuOverviewHandlers(deps) {
119910
121499
  };
119911
121500
  }
119912
121501
  //#endregion
121502
+ //#region src/custom-actions.ts
121503
+ /**
121504
+ * Custom actions of the Homematic addon: the LAN scan behind the integration
121505
+ * form's CCU picker, and the CCU management page (`provider-homematic` admin
121506
+ * page). Reads are `query`; every CCU write is a `mutation` whose input carries
121507
+ * the operator's `confirmed` flag.
121508
+ */
121509
+ var homematicActions = defineCustomActions({
121510
+ discoverCcu: customAction(object({}), object({
121511
+ hosts: array(object({
121512
+ host: string(),
121513
+ name: string(),
121514
+ id: string()
121515
+ })),
121516
+ summary: string()
121517
+ }), {
121518
+ kind: "mutation",
121519
+ auth: "admin"
121520
+ }),
121521
+ listCcus: customAction(object({}), array(CcuListItemSchema), {
121522
+ kind: "query",
121523
+ auth: "admin"
121524
+ }),
121525
+ ccuOverview: customAction(IntegrationRefSchema, CcuOverviewSchema, {
121526
+ kind: "query",
121527
+ auth: "admin"
121528
+ }),
121529
+ listServiceMessages: customAction(IntegrationRefSchema, ServiceMessagesResultSchema, {
121530
+ kind: "query",
121531
+ auth: "admin"
121532
+ }),
121533
+ listCcuDevices: customAction(IntegrationRefSchema, CcuDevicesResultSchema, {
121534
+ kind: "query",
121535
+ auth: "admin"
121536
+ }),
121537
+ listHeatingGroups: customAction(IntegrationRefSchema, HeatingOverviewSchema, {
121538
+ kind: "query",
121539
+ auth: "admin"
121540
+ }),
121541
+ createHeatingGroup: customAction(CreateGroupInputSchema, HeatingGroupSchema, {
121542
+ kind: "mutation",
121543
+ auth: "admin"
121544
+ }),
121545
+ updateHeatingGroup: customAction(UpdateGroupInputSchema, HeatingGroupSchema, {
121546
+ kind: "mutation",
121547
+ auth: "admin"
121548
+ }),
121549
+ deleteHeatingGroup: customAction(DeleteGroupInputSchema, OkResultSchema, {
121550
+ kind: "mutation",
121551
+ auth: "admin"
121552
+ }),
121553
+ ccuPairingStatus: customAction(IntegrationRefSchema, PairingStatusSchema, {
121554
+ kind: "query",
121555
+ auth: "admin"
121556
+ }),
121557
+ setCcuInstallMode: customAction(SetInstallModeInputSchema, OkResultSchema, {
121558
+ kind: "mutation",
121559
+ auth: "admin"
121560
+ }),
121561
+ deleteCcuDevice: customAction(DeleteCcuDeviceInputSchema, OkResultSchema, {
121562
+ kind: "mutation",
121563
+ auth: "admin"
121564
+ }),
121565
+ getCcuDeviceConfig: customAction(DeviceRefSchema, DeviceConfigSchema, {
121566
+ kind: "query",
121567
+ auth: "admin"
121568
+ }),
121569
+ setCcuChannelConfig: customAction(SetChannelConfigInputSchema, OkResultSchema, {
121570
+ kind: "mutation",
121571
+ auth: "admin"
121572
+ }),
121573
+ acknowledgeServiceMessage: customAction(AcknowledgeInputSchema, OkResultSchema, {
121574
+ kind: "mutation",
121575
+ auth: "admin"
121576
+ })
121577
+ });
121578
+ //#endregion
119913
121579
  //#region src/callback-host.ts
119914
121580
  /**
119915
121581
  * Pick the hub LAN IPv4 a CCU at `ccuHost` can call back to. Prefers an
@@ -120176,83 +121842,170 @@ function buildConnectionFormSchema() {
120176
121842
  }
120177
121843
  ] };
120178
121844
  }
121845
+ var homematicConnectionsEntryKind = defineEntryKind("connections", {
121846
+ title: "Homematic CCUs",
121847
+ schema: entryBody({
121848
+ host: string().nullish(),
121849
+ enableHmipRf: boolean().nullish(),
121850
+ enableBidcosRf: boolean().nullish(),
121851
+ enableGroups: boolean().nullish(),
121852
+ enableBidcosWired: boolean().nullish(),
121853
+ username: string().nullish(),
121854
+ password: string().optional().meta({ secret: true }),
121855
+ callbackHost: string().nullish(),
121856
+ callbackPort: number().int().min(1).max(65535).nullish(),
121857
+ tls: boolean().nullish()
121858
+ }),
121859
+ writeTrigger: "an operator adds, edits or removes a Homematic CCU"
121860
+ });
121861
+ /** Every kind this addon declares, keyed by its name. */
121862
+ var homematicRecordKinds = { connections: homematicConnectionsEntryKind };
121863
+ /** The record body as the flat settings the connection schema parses: no name, no unset keys. */
121864
+ function connectionSettingsOf(body) {
121865
+ const out = {};
121866
+ for (const [key, value] of Object.entries(body)) {
121867
+ if (key === "name" || value === null || value === void 0) continue;
121868
+ out[key] = value;
121869
+ }
121870
+ return out;
121871
+ }
121872
+ function settingsReadOf(resolved) {
121873
+ return resolved === null ? {
121874
+ values: {},
121875
+ secretsLocked: false
121876
+ } : {
121877
+ values: connectionSettingsOf(resolved.body),
121878
+ secretsLocked: resolved.secrets === "unavailable"
121879
+ };
121880
+ }
121881
+ function buildHomematicInstances(records, deps) {
121882
+ return new RecordIntegrationInstances(records, homematicConnectionsEntryKind, {
121883
+ description: {
121884
+ role: "devices",
121885
+ discovery: {
121886
+ mode: "lan",
121887
+ scopedToInstance: false
121888
+ },
121889
+ instanceMode: "multiple",
121890
+ kind: "connection",
121891
+ canTest: false
121892
+ },
121893
+ formSchema: () => buildConnectionFormSchema(),
121894
+ initialBody: (name) => ({ name }),
121895
+ configured: (body) => (body.host ?? "").trim().length > 0,
121896
+ onChanged: () => deps.onChanged()
121897
+ });
121898
+ }
121899
+ /** The ONE reader of a CCU's connection: the integration's record, never the legacy rows. */
121900
+ async function readCcuConnection(instances, integrationId) {
121901
+ const read = settingsReadOf(await instances.readResolved(integrationId));
121902
+ return {
121903
+ connection: connectionFromSettings(read.values),
121904
+ secretsLocked: read.secretsLocked
121905
+ };
121906
+ }
121907
+ /** The hosts of the CCUs already set up, for discovery to leave out; an unreadable one is skipped. */
121908
+ async function knownCcuHostsOf(deps) {
121909
+ const hosts = [];
121910
+ for (const id of deps.integrationIds) try {
121911
+ const { connection } = await readCcuConnection(deps.instances, id);
121912
+ if (connection !== null) hosts.push(connection.host);
121913
+ } catch (err) {
121914
+ deps.onUnreadable(id, err);
121915
+ }
121916
+ return hosts;
121917
+ }
120179
121918
  //#endregion
120180
- //#region src/custom-actions.ts
121919
+ //#region src/migrations/integration-rows-to-record.ts
120181
121920
  /**
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.
121921
+ * Every Homematic integration moves from legacy `integration_settings` rows into its own
121922
+ * `connections` record under the registry id (planning#416, D1007): the CCU connection the live
121923
+ * session dials, the WebUI password a keychain secret declared by the kind. Each integration's
121924
+ * record is built from ITS OWN rows, never from another's. Only the integration configuration
121925
+ * moves: adopted devices, their stable ids and their history are not touched.
121926
+ *
121927
+ * Keys nothing reads any more are named in a warning, by key, and dropped with the rows once the
121928
+ * record has been read back; a value of the wrong type is left out and named by key as well.
120186
121929
  */
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"
121930
+ var HOMEMATIC_ROWS_TO_RECORD_ID = "provider-homematic/2026-11-05-integration-rows-to-record";
121931
+ var TEXT_KEYS = [
121932
+ "host",
121933
+ "username",
121934
+ "callbackHost"
121935
+ ];
121936
+ var FLAG_KEYS = [
121937
+ "enableHmipRf",
121938
+ "enableBidcosRf",
121939
+ "enableGroups",
121940
+ "enableBidcosWired",
121941
+ "tls"
121942
+ ];
121943
+ function portOf(value) {
121944
+ const n = typeof value === "string" && value.trim() !== "" ? Number(value) : value;
121945
+ return typeof n === "number" && Number.isInteger(n) && n >= 1 && n <= 65535 ? n : null;
121946
+ }
121947
+ /** The record body of one integration, from its resolved legacy rows. Never logs a value. */
121948
+ function homematicBodyFromRows(values, log, integration) {
121949
+ const body = { name: integration.name };
121950
+ const unusable = [];
121951
+ const known = new Set([
121952
+ "password",
121953
+ "callbackPort",
121954
+ ...TEXT_KEYS,
121955
+ ...FLAG_KEYS
121956
+ ]);
121957
+ for (const key of TEXT_KEYS) {
121958
+ if (!(key in values)) continue;
121959
+ const raw = values[key];
121960
+ if (typeof raw === "string") {
121961
+ if (raw.trim() !== "") body[key] = raw.trim();
121962
+ } else unusable.push(key);
121963
+ }
121964
+ for (const key of FLAG_KEYS) {
121965
+ if (!(key in values)) continue;
121966
+ const raw = values[key];
121967
+ if (typeof raw === "boolean") body[key] = raw;
121968
+ else unusable.push(key);
121969
+ }
121970
+ if ("callbackPort" in values) {
121971
+ const raw = values["callbackPort"];
121972
+ if (raw !== "" && raw !== null) {
121973
+ const port = portOf(raw);
121974
+ if (port === null) unusable.push("callbackPort");
121975
+ else body["callbackPort"] = port;
121976
+ }
121977
+ }
121978
+ if ("password" in values) {
121979
+ const password = values["password"];
121980
+ if (typeof password === "string") {
121981
+ if (password.length > 0) body["password"] = password;
121982
+ } else unusable.push("password");
121983
+ }
121984
+ const unknown = Object.keys(values).filter((key) => !known.has(key));
121985
+ if (unknown.length > 0) log.warn(`integration '${integration.id}': legacy settings nothing reads any more are dropped: ${unknown.join(", ")}`);
121986
+ if (unusable.length > 0) log.warn(`integration '${integration.id}': legacy settings with an unusable value are left out: ${unusable.join(", ")}`);
121987
+ return homematicConnectionsEntryKind.schema.parse(body);
121988
+ }
121989
+ var HOMEMATIC_ROWS_TO_RECORD_MIGRATION = {
121990
+ meta: {
121991
+ id: HOMEMATIC_ROWS_TO_RECORD_ID,
121992
+ owner: "provider-homematic",
121993
+ level: "addon-state",
121994
+ seq: 1,
121995
+ dependsOn: [],
121996
+ store: "settings",
121997
+ scope: "cluster",
121998
+ onFailure: "block-owner",
121999
+ bodyKind: "procedure",
122000
+ 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",
122001
+ fixtureMark: "a legacy setting key the migration does not know"
122002
+ },
122003
+ procedure: (ports) => moveIntegrationRowsToRecords(ports, {
122004
+ addonId: "provider-homematic",
122005
+ secretPaths: homematicConnectionsEntryKind.declaration.secretPaths,
122006
+ bodyFrom: homematicBodyFromRows
120254
122007
  })
120255
- });
122008
+ };
120256
122009
  //#endregion
120257
122010
  //#region src/homematic-facade-resolver.ts
120258
122011
  /**
@@ -123783,11 +125536,26 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123783
125536
  /** Live per-integration CCU sessions, or null before init / after shutdown. */
123784
125537
  integrationReconciler = null;
123785
125538
  clients = null;
125539
+ instances = null;
123786
125540
  constructor() {
123787
125541
  super({});
123788
125542
  }
123789
125543
  async onInitialize() {
123790
125544
  const regs = this.providerRegistrationsFromSuper(await super.onInitialize());
125545
+ const records = this.ctx.records;
125546
+ if (records === void 0) throw new Error("provider-homematic: ctx.records is required (hub-only addon)");
125547
+ await records.declare(homematicRecordKinds);
125548
+ const instances = buildHomematicInstances(records, { onChanged: () => this.reconcileIntegrations() });
125549
+ this.instances = instances;
125550
+ await this.runMigrations(defineAddonMigrations([HOMEMATIC_ROWS_TO_RECORD_MIGRATION], integrationRowsPortsOverApi({
125551
+ api: defaultIntegrationApiOver(this.ctx.api),
125552
+ records: records.kind({
125553
+ name: homematicConnectionsEntryKind.name,
125554
+ declaration: homematicConnectionsEntryKind.declaration,
125555
+ schema: record(string(), unknown())
125556
+ }),
125557
+ log: { warn: (message) => this.ctx.logger.warn(message) }
125558
+ })));
123791
125559
  this.clients = new HmClientRegistry(this.ctx.logger);
123792
125560
  this.clients.setOnConnected((integrationId) => {
123793
125561
  this.ctx.logger.info("Homematic: CCU connected", { meta: { integrationId } });
@@ -123803,6 +125571,10 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123803
125571
  return {
123804
125572
  providers: [
123805
125573
  ...regs,
125574
+ {
125575
+ capability: integrationInstancesCapability,
125576
+ provider: instances.toProvider()
125577
+ },
123806
125578
  {
123807
125579
  capability: deviceAdoptionCapability,
123808
125580
  provider: this.buildAdoptionProvider()
@@ -123876,8 +125648,9 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123876
125648
  homematicFacades.clear();
123877
125649
  await super.onShutdown();
123878
125650
  }
123879
- globalSettingsSchema() {
123880
- return buildConnectionFormSchema();
125651
+ requireInstances() {
125652
+ if (!this.instances) throw new Error("Homematic provider not initialised");
125653
+ return this.instances;
123881
125654
  }
123882
125655
  /**
123883
125656
  * Stable id, integration-scoped so two CCUs exposing the same device address
@@ -123924,20 +125697,14 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123924
125697
  async knownCcuHosts() {
123925
125698
  try {
123926
125699
  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;
125700
+ return await knownCcuHostsOf({
125701
+ instances: this.requireInstances(),
125702
+ integrationIds: all.filter((i) => i.addonId === this.ctx.id).map((i) => i.id),
125703
+ onUnreadable: (integrationId, err) => this.ctx.logger.warn("Homematic discovery: settings read failed", {
125704
+ tags: { integrationId },
125705
+ meta: { error: errMsg(err) }
125706
+ })
125707
+ });
123941
125708
  } catch (err) {
123942
125709
  this.ctx.logger.warn("Homematic discovery: integration list failed", { meta: { error: errMsg(err) } });
123943
125710
  return [];
@@ -123992,8 +125759,8 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123992
125759
  },
123993
125760
  listIntegrations: () => this.ctx.api.integrations.list.query(),
123994
125761
  applySettings: async (integration) => {
123995
- const connection = connectionFromSettings(await this.ctx.api.integrations.getSettings.query({ id: integration.id }));
123996
- if (!connection) return false;
125762
+ const { connection, secretsLocked } = await readCcuConnection(this.requireInstances(), integration.id);
125763
+ if (secretsLocked || !connection) return false;
123997
125764
  await this.requireClients().upsert(integration.id, integration.name, connection);
123998
125765
  return true;
123999
125766
  },