@camstack/addon-provider-homematic 1.2.38 → 1.2.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.js CHANGED
@@ -5925,6 +5925,40 @@ var BaseAddon = class {
5925
5925
  deviceSettingsSchema() {
5926
5926
  return null;
5927
5927
  }
5928
+ /**
5929
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5930
+ * ARE the configuration of its integration.
5931
+ *
5932
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5933
+ * operator should find on the addon's integration page (System →
5934
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5935
+ * addon. Empty (the default) means the addon has no integration-level
5936
+ * settings and no such surface is offered — this is opt-in, because whether
5937
+ * an addon's configuration IS its integration's configuration depends on the
5938
+ * nature of the integration.
5939
+ *
5940
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5941
+ * the ONE global schema, in the ONE addon store, written by the ONE
5942
+ * `updateGlobalSettings` path. There is deliberately no
5943
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5944
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5945
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5946
+ *
5947
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5948
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5949
+ * removed with the reason recorded at
5950
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5951
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5952
+ * marker sprinkled across sections also has to borrow a field that already
5953
+ * means something else; borrowing `section.tab` put the literal word
5954
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5955
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5956
+ * supersedes D268). One declaration, in one place, next to the schema whose
5957
+ * ids it names.
5958
+ */
5959
+ integrationSettingSections() {
5960
+ return [];
5961
+ }
5928
5962
  async getGlobalSettings(overlay, cap, nodeId) {
5929
5963
  const schema = this.globalSettingsSchema(cap);
5930
5964
  if (!schema) return { sections: [] };
@@ -5935,6 +5969,55 @@ var BaseAddon = class {
5935
5969
  } : projected);
5936
5970
  }
5937
5971
  /**
5972
+ * The integration-level view of this addon's settings: exactly the sections
5973
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5974
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5975
+ *
5976
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5977
+ * no integration settings surface at all, rather than an empty one that reads
5978
+ * as a failed load.
5979
+ *
5980
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5981
+ * and not in whichever UI happens to render this:
5982
+ *
5983
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5984
+ * shown here is the same field, with the same bare key, that the addon's
5985
+ * own page shows. There is no integration-specific writer — callers save
5986
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5987
+ * not merely discouraged.
5988
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5989
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5990
+ * such a field silently picked would be a wrong answer for the operator
5991
+ * who opened the page (D266).
5992
+ * 3. **No silent typo.** A declared id that names no section throws. The
5993
+ * alternative — skip it — turns a rename into a surface that quietly
5994
+ * empties, which looks exactly like an addon with nothing to configure.
5995
+ */
5996
+ async getIntegrationSettings(nodeId) {
5997
+ const declared = this.integrationSettingSections();
5998
+ if (declared.length === 0) return null;
5999
+ const schema = this.globalSettingsSchema();
6000
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6001
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6002
+ const sections = [];
6003
+ for (const id of declared) {
6004
+ const section = byId.get(id);
6005
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6006
+ const fields = dropPerNodeFields(section.fields);
6007
+ if (fields.length === 0) continue;
6008
+ sections.push({
6009
+ ...section,
6010
+ fields
6011
+ });
6012
+ }
6013
+ if (sections.length === 0) return null;
6014
+ const projected = await this.resolveGlobalStore(nodeId);
6015
+ return hydrateSchema({
6016
+ ...schema,
6017
+ sections
6018
+ }, projected);
6019
+ }
6020
+ /**
5938
6021
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5939
6022
  * every `perNode: true` field carries THAT node's scoped value on its bare
5940
6023
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6238,6 +6321,41 @@ var BaseAddon = class {
6238
6321
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6239
6322
  * don't declare `perNode` and are excluded by the `in` narrowing.
6240
6323
  */
6324
+ /**
6325
+ * The same fields with every `perNode: true` one removed, recursing into layout
6326
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6327
+ * with no child is dropped rather than rendered empty.
6328
+ *
6329
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6330
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6331
+ */
6332
+ function dropPerNodeFields(fields) {
6333
+ const kept = [];
6334
+ for (const field of fields) {
6335
+ if (field.type === "group") {
6336
+ const inner = dropPerNodeFields(field.fields);
6337
+ if (inner.length > 0) kept.push({
6338
+ ...field,
6339
+ fields: inner
6340
+ });
6341
+ continue;
6342
+ }
6343
+ if (field.type === "sub-tabs") {
6344
+ const tabs = field.tabs.map((tab) => ({
6345
+ ...tab,
6346
+ fields: dropPerNodeFields(tab.fields)
6347
+ })).filter((tab) => tab.fields.length > 0);
6348
+ if (tabs.length > 0) kept.push({
6349
+ ...field,
6350
+ tabs
6351
+ });
6352
+ continue;
6353
+ }
6354
+ if ("perNode" in field && field.perNode === true) continue;
6355
+ kept.push(field);
6356
+ }
6357
+ return kept;
6358
+ }
6241
6359
  function collectPerNodeFieldKeys(fields) {
6242
6360
  const collected = [];
6243
6361
  for (const field of fields) {
@@ -9407,6 +9525,9 @@ method(object({
9407
9525
  kind: "mutation",
9408
9526
  auth: "admin"
9409
9527
  }), method(object({
9528
+ addonId: string(),
9529
+ nodeId: string().optional()
9530
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9410
9531
  addonId: string(),
9411
9532
  deviceId: number(),
9412
9533
  nodeId: string().optional()
@@ -13421,6 +13542,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13421
13542
  limit: number().optional(),
13422
13543
  tags: record(string(), string()).optional()
13423
13544
  }), array(LogEntrySchema).readonly());
13545
+ /**
13546
+ * `failure-contribution` — the capability an addon reports its OWN losses
13547
+ * through, per camera, with the denominator attached. It stores nothing.
13548
+ *
13549
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13550
+ *
13551
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13552
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13553
+ * copied: the contributor reports what it already knows, hub-main adds only
13554
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13555
+ * somebody to forget to edit.
13556
+ *
13557
+ * They are not merged, because their invariants are opposites:
13558
+ *
13559
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13560
+ * claim a camera cost nothing, which is a measurement nobody made;
13561
+ * - a `failure-contribution` zero is the **most valuable value on the
13562
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13563
+ * and it is exactly what an absent entry cannot say.
13564
+ *
13565
+ * Putting a loss counter on a cost entry would also break the reconciliation
13566
+ * that gives `load-contribution` its point: contributions are subtracted from
13567
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13568
+ * has no process.
13569
+ *
13570
+ * ## Why not a log line, since the counters already exist
13571
+ *
13572
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13573
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13574
+ * ends in a log line, and a log line is the thing the operator asked to stop
13575
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13576
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13577
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13578
+ * media blackout were both diagnosed. The counters stay; this is where they can
13579
+ * be READ.
13580
+ *
13581
+ * ## The rate is served with its denominator or not at all
13582
+ *
13583
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13584
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13585
+ * than yesterday" and was **flat across twelve hours** once divided by the
13586
+ * successes on the same path. A surface that publishes only the numerator
13587
+ * reproduces that mistake on every read.
13588
+ *
13589
+ * ## Shape
13590
+ *
13591
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13592
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13593
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13594
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13595
+ * a forked runner's entries reach hub-main over transport that already exists.
13596
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13597
+ * result through `system.getFailureContributions`.
13598
+ */
13599
+ var FailureReasonCountSchema = object({
13600
+ /**
13601
+ * Why the attempt did not land, in the contributor's own vocabulary —
13602
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13603
+ * strings that already appear in this repo's logs and, where one exists, the
13604
+ * same string the per-track `previewMissReason` records (D276): a second
13605
+ * vocabulary for the same loss would make the row and the counter
13606
+ * un-joinable.
13607
+ */
13608
+ reason: string(),
13609
+ count: number().int().nonnegative()
13610
+ });
13611
+ var FailureContributionSchema = object({
13612
+ /**
13613
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13614
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13615
+ * `unit` free: the families are owned by different addons and a shared enum
13616
+ * is a central list that rots invisibly.
13617
+ */
13618
+ family: string(),
13619
+ /**
13620
+ * The NUMERIC device id — the same value every log line carries as
13621
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13622
+ * cannot name the camera must not emit the entry, because a fleet total
13623
+ * cannot answer the only question anybody asks of this surface.
13624
+ */
13625
+ deviceId: number().int().positive(),
13626
+ /**
13627
+ * A second dimension inside the family: the model / step id for an inference
13628
+ * timeout, so "which camera AND which model" is one read. Absent when the
13629
+ * family has a single variant.
13630
+ */
13631
+ variant: string().optional(),
13632
+ /**
13633
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13634
+ * differencing two reads must drop the interval when it changes, because the
13635
+ * counter restarted from zero in a respawned runner. Same discipline as
13636
+ * `LoadContribution.startedAtMs`.
13637
+ */
13638
+ sinceMs: number(),
13639
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13640
+ atMs: number(),
13641
+ /**
13642
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13643
+ * window. A failure count published without it is the mistake this schema
13644
+ * exists to make impossible.
13645
+ */
13646
+ attempts: number().int().nonnegative(),
13647
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13648
+ succeeded: number().int().nonnegative(),
13649
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13650
+ reasons: array(FailureReasonCountSchema).readonly()
13651
+ });
13652
+ method(_void(), array(FailureContributionSchema).readonly());
13424
13653
  var LoadContributionSchema = object({
13425
13654
  role: _enum([
13426
13655
  "decode",
@@ -18011,6 +18240,20 @@ var TrackSchema = object({
18011
18240
  * `=== true` and render nothing otherwise — never infer "no rider".
18012
18241
  */
18013
18242
  hasRider: boolean().optional(),
18243
+ /**
18244
+ * WHY this track ended without a NATIVE best-shot tile
18245
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18246
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18247
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18248
+ * the late-keyFrame upgrade when a native tile lands after all. The
18249
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18250
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18251
+ *
18252
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18253
+ * that predates the field, and every track whose tile landed native all
18254
+ * omit it. Render nothing when absent.
18255
+ */
18256
+ previewMissReason: string().optional(),
18014
18257
  ...TrackFlagFields,
18015
18258
  ...TrackRetrainFields
18016
18259
  });
@@ -29186,6 +29429,13 @@ var LoggingSettingsPatchSchema = object({
29186
29429
  * anyone but its owner.
29187
29430
  */
29188
29431
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29432
+ /**
29433
+ * One per-camera failure counter, plus WHO reported it.
29434
+ *
29435
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29436
+ * the hub as it enumerates providers, never by the contributor.
29437
+ */
29438
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29189
29439
  var GetLoggingSettingsInputSchema = object({
29190
29440
  scopeNodeId: string().optional(),
29191
29441
  /**
@@ -29244,7 +29494,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29244
29494
  }), method(_void(), SiteLocationStatusSchema, {
29245
29495
  kind: "mutation",
29246
29496
  auth: "admin"
29247
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29497
+ }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(_void(), array(ReportedFailureContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29248
29498
  kind: "mutation",
29249
29499
  auth: "admin"
29250
29500
  });
@@ -31566,6 +31816,12 @@ Object.freeze({
31566
31816
  addonId: null,
31567
31817
  access: "view"
31568
31818
  },
31819
+ "addonSettings.getIntegrationSettings": {
31820
+ capName: "addon-settings",
31821
+ capScope: "system",
31822
+ addonId: null,
31823
+ access: "view"
31824
+ },
31569
31825
  "addonSettings.updateDeviceSettings": {
31570
31826
  capName: "addon-settings",
31571
31827
  capScope: "system",
@@ -33228,6 +33484,12 @@ Object.freeze({
33228
33484
  addonId: null,
33229
33485
  access: "create"
33230
33486
  },
33487
+ "failureContribution.list": {
33488
+ capName: "failure-contribution",
33489
+ capScope: "system",
33490
+ addonId: null,
33491
+ access: "view"
33492
+ },
33231
33493
  "fanControl.setDirection": {
33232
33494
  capName: "fan-control",
33233
33495
  capScope: "device",
@@ -36534,6 +36796,12 @@ Object.freeze({
36534
36796
  addonId: null,
36535
36797
  access: "create"
36536
36798
  },
36799
+ "system.getFailureContributions": {
36800
+ capName: "system",
36801
+ capScope: "system",
36802
+ addonId: null,
36803
+ access: "view"
36804
+ },
36537
36805
  "system.getLoadContributions": {
36538
36806
  capName: "system",
36539
36807
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -5926,6 +5926,40 @@ var BaseAddon = class {
5926
5926
  deviceSettingsSchema() {
5927
5927
  return null;
5928
5928
  }
5929
+ /**
5930
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5931
+ * ARE the configuration of its integration.
5932
+ *
5933
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5934
+ * operator should find on the addon's integration page (System →
5935
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5936
+ * addon. Empty (the default) means the addon has no integration-level
5937
+ * settings and no such surface is offered — this is opt-in, because whether
5938
+ * an addon's configuration IS its integration's configuration depends on the
5939
+ * nature of the integration.
5940
+ *
5941
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5942
+ * the ONE global schema, in the ONE addon store, written by the ONE
5943
+ * `updateGlobalSettings` path. There is deliberately no
5944
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5945
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5946
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5947
+ *
5948
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5949
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5950
+ * removed with the reason recorded at
5951
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5952
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5953
+ * marker sprinkled across sections also has to borrow a field that already
5954
+ * means something else; borrowing `section.tab` put the literal word
5955
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5956
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5957
+ * supersedes D268). One declaration, in one place, next to the schema whose
5958
+ * ids it names.
5959
+ */
5960
+ integrationSettingSections() {
5961
+ return [];
5962
+ }
5929
5963
  async getGlobalSettings(overlay, cap, nodeId) {
5930
5964
  const schema = this.globalSettingsSchema(cap);
5931
5965
  if (!schema) return { sections: [] };
@@ -5936,6 +5970,55 @@ var BaseAddon = class {
5936
5970
  } : projected);
5937
5971
  }
5938
5972
  /**
5973
+ * The integration-level view of this addon's settings: exactly the sections
5974
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5975
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5976
+ *
5977
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5978
+ * no integration settings surface at all, rather than an empty one that reads
5979
+ * as a failed load.
5980
+ *
5981
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5982
+ * and not in whichever UI happens to render this:
5983
+ *
5984
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5985
+ * shown here is the same field, with the same bare key, that the addon's
5986
+ * own page shows. There is no integration-specific writer — callers save
5987
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5988
+ * not merely discouraged.
5989
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5990
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5991
+ * such a field silently picked would be a wrong answer for the operator
5992
+ * who opened the page (D266).
5993
+ * 3. **No silent typo.** A declared id that names no section throws. The
5994
+ * alternative — skip it — turns a rename into a surface that quietly
5995
+ * empties, which looks exactly like an addon with nothing to configure.
5996
+ */
5997
+ async getIntegrationSettings(nodeId) {
5998
+ const declared = this.integrationSettingSections();
5999
+ if (declared.length === 0) return null;
6000
+ const schema = this.globalSettingsSchema();
6001
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6002
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6003
+ const sections = [];
6004
+ for (const id of declared) {
6005
+ const section = byId.get(id);
6006
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6007
+ const fields = dropPerNodeFields(section.fields);
6008
+ if (fields.length === 0) continue;
6009
+ sections.push({
6010
+ ...section,
6011
+ fields
6012
+ });
6013
+ }
6014
+ if (sections.length === 0) return null;
6015
+ const projected = await this.resolveGlobalStore(nodeId);
6016
+ return hydrateSchema({
6017
+ ...schema,
6018
+ sections
6019
+ }, projected);
6020
+ }
6021
+ /**
5939
6022
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5940
6023
  * every `perNode: true` field carries THAT node's scoped value on its bare
5941
6024
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6239,6 +6322,41 @@ var BaseAddon = class {
6239
6322
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6240
6323
  * don't declare `perNode` and are excluded by the `in` narrowing.
6241
6324
  */
6325
+ /**
6326
+ * The same fields with every `perNode: true` one removed, recursing into layout
6327
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6328
+ * with no child is dropped rather than rendered empty.
6329
+ *
6330
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6331
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6332
+ */
6333
+ function dropPerNodeFields(fields) {
6334
+ const kept = [];
6335
+ for (const field of fields) {
6336
+ if (field.type === "group") {
6337
+ const inner = dropPerNodeFields(field.fields);
6338
+ if (inner.length > 0) kept.push({
6339
+ ...field,
6340
+ fields: inner
6341
+ });
6342
+ continue;
6343
+ }
6344
+ if (field.type === "sub-tabs") {
6345
+ const tabs = field.tabs.map((tab) => ({
6346
+ ...tab,
6347
+ fields: dropPerNodeFields(tab.fields)
6348
+ })).filter((tab) => tab.fields.length > 0);
6349
+ if (tabs.length > 0) kept.push({
6350
+ ...field,
6351
+ tabs
6352
+ });
6353
+ continue;
6354
+ }
6355
+ if ("perNode" in field && field.perNode === true) continue;
6356
+ kept.push(field);
6357
+ }
6358
+ return kept;
6359
+ }
6242
6360
  function collectPerNodeFieldKeys(fields) {
6243
6361
  const collected = [];
6244
6362
  for (const field of fields) {
@@ -9408,6 +9526,9 @@ method(object({
9408
9526
  kind: "mutation",
9409
9527
  auth: "admin"
9410
9528
  }), method(object({
9529
+ addonId: string(),
9530
+ nodeId: string().optional()
9531
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9411
9532
  addonId: string(),
9412
9533
  deviceId: number(),
9413
9534
  nodeId: string().optional()
@@ -13422,6 +13543,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13422
13543
  limit: number().optional(),
13423
13544
  tags: record(string(), string()).optional()
13424
13545
  }), array(LogEntrySchema).readonly());
13546
+ /**
13547
+ * `failure-contribution` — the capability an addon reports its OWN losses
13548
+ * through, per camera, with the denominator attached. It stores nothing.
13549
+ *
13550
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13551
+ *
13552
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13553
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13554
+ * copied: the contributor reports what it already knows, hub-main adds only
13555
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13556
+ * somebody to forget to edit.
13557
+ *
13558
+ * They are not merged, because their invariants are opposites:
13559
+ *
13560
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13561
+ * claim a camera cost nothing, which is a measurement nobody made;
13562
+ * - a `failure-contribution` zero is the **most valuable value on the
13563
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13564
+ * and it is exactly what an absent entry cannot say.
13565
+ *
13566
+ * Putting a loss counter on a cost entry would also break the reconciliation
13567
+ * that gives `load-contribution` its point: contributions are subtracted from
13568
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13569
+ * has no process.
13570
+ *
13571
+ * ## Why not a log line, since the counters already exist
13572
+ *
13573
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13574
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13575
+ * ends in a log line, and a log line is the thing the operator asked to stop
13576
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13577
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13578
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13579
+ * media blackout were both diagnosed. The counters stay; this is where they can
13580
+ * be READ.
13581
+ *
13582
+ * ## The rate is served with its denominator or not at all
13583
+ *
13584
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13585
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13586
+ * than yesterday" and was **flat across twelve hours** once divided by the
13587
+ * successes on the same path. A surface that publishes only the numerator
13588
+ * reproduces that mistake on every read.
13589
+ *
13590
+ * ## Shape
13591
+ *
13592
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13593
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13594
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13595
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13596
+ * a forked runner's entries reach hub-main over transport that already exists.
13597
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13598
+ * result through `system.getFailureContributions`.
13599
+ */
13600
+ var FailureReasonCountSchema = object({
13601
+ /**
13602
+ * Why the attempt did not land, in the contributor's own vocabulary —
13603
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13604
+ * strings that already appear in this repo's logs and, where one exists, the
13605
+ * same string the per-track `previewMissReason` records (D276): a second
13606
+ * vocabulary for the same loss would make the row and the counter
13607
+ * un-joinable.
13608
+ */
13609
+ reason: string(),
13610
+ count: number().int().nonnegative()
13611
+ });
13612
+ var FailureContributionSchema = object({
13613
+ /**
13614
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13615
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13616
+ * `unit` free: the families are owned by different addons and a shared enum
13617
+ * is a central list that rots invisibly.
13618
+ */
13619
+ family: string(),
13620
+ /**
13621
+ * The NUMERIC device id — the same value every log line carries as
13622
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13623
+ * cannot name the camera must not emit the entry, because a fleet total
13624
+ * cannot answer the only question anybody asks of this surface.
13625
+ */
13626
+ deviceId: number().int().positive(),
13627
+ /**
13628
+ * A second dimension inside the family: the model / step id for an inference
13629
+ * timeout, so "which camera AND which model" is one read. Absent when the
13630
+ * family has a single variant.
13631
+ */
13632
+ variant: string().optional(),
13633
+ /**
13634
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13635
+ * differencing two reads must drop the interval when it changes, because the
13636
+ * counter restarted from zero in a respawned runner. Same discipline as
13637
+ * `LoadContribution.startedAtMs`.
13638
+ */
13639
+ sinceMs: number(),
13640
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13641
+ atMs: number(),
13642
+ /**
13643
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13644
+ * window. A failure count published without it is the mistake this schema
13645
+ * exists to make impossible.
13646
+ */
13647
+ attempts: number().int().nonnegative(),
13648
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13649
+ succeeded: number().int().nonnegative(),
13650
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13651
+ reasons: array(FailureReasonCountSchema).readonly()
13652
+ });
13653
+ method(_void(), array(FailureContributionSchema).readonly());
13425
13654
  var LoadContributionSchema = object({
13426
13655
  role: _enum([
13427
13656
  "decode",
@@ -18012,6 +18241,20 @@ var TrackSchema = object({
18012
18241
  * `=== true` and render nothing otherwise — never infer "no rider".
18013
18242
  */
18014
18243
  hasRider: boolean().optional(),
18244
+ /**
18245
+ * WHY this track ended without a NATIVE best-shot tile
18246
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18247
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18248
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18249
+ * the late-keyFrame upgrade when a native tile lands after all. The
18250
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18251
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18252
+ *
18253
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18254
+ * that predates the field, and every track whose tile landed native all
18255
+ * omit it. Render nothing when absent.
18256
+ */
18257
+ previewMissReason: string().optional(),
18015
18258
  ...TrackFlagFields,
18016
18259
  ...TrackRetrainFields
18017
18260
  });
@@ -29187,6 +29430,13 @@ var LoggingSettingsPatchSchema = object({
29187
29430
  * anyone but its owner.
29188
29431
  */
29189
29432
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29433
+ /**
29434
+ * One per-camera failure counter, plus WHO reported it.
29435
+ *
29436
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29437
+ * the hub as it enumerates providers, never by the contributor.
29438
+ */
29439
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29190
29440
  var GetLoggingSettingsInputSchema = object({
29191
29441
  scopeNodeId: string().optional(),
29192
29442
  /**
@@ -29245,7 +29495,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29245
29495
  }), method(_void(), SiteLocationStatusSchema, {
29246
29496
  kind: "mutation",
29247
29497
  auth: "admin"
29248
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29498
+ }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(_void(), array(ReportedFailureContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29249
29499
  kind: "mutation",
29250
29500
  auth: "admin"
29251
29501
  });
@@ -31567,6 +31817,12 @@ Object.freeze({
31567
31817
  addonId: null,
31568
31818
  access: "view"
31569
31819
  },
31820
+ "addonSettings.getIntegrationSettings": {
31821
+ capName: "addon-settings",
31822
+ capScope: "system",
31823
+ addonId: null,
31824
+ access: "view"
31825
+ },
31570
31826
  "addonSettings.updateDeviceSettings": {
31571
31827
  capName: "addon-settings",
31572
31828
  capScope: "system",
@@ -33229,6 +33485,12 @@ Object.freeze({
33229
33485
  addonId: null,
33230
33486
  access: "create"
33231
33487
  },
33488
+ "failureContribution.list": {
33489
+ capName: "failure-contribution",
33490
+ capScope: "system",
33491
+ addonId: null,
33492
+ access: "view"
33493
+ },
33232
33494
  "fanControl.setDirection": {
33233
33495
  capName: "fan-control",
33234
33496
  capScope: "device",
@@ -36535,6 +36797,12 @@ Object.freeze({
36535
36797
  addonId: null,
36536
36798
  access: "create"
36537
36799
  },
36800
+ "system.getFailureContributions": {
36801
+ capName: "system",
36802
+ capScope: "system",
36803
+ addonId: null,
36804
+ access: "view"
36805
+ },
36538
36806
  "system.getLoadContributions": {
36539
36807
  capName: "system",
36540
36808
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-homematic",
3
- "version": "1.2.38",
3
+ "version": "1.2.40",
4
4
  "description": "Homematic / HomematicIP (CCU3 / RaspberryMatic) device-provider addon for CamStack — wraps the nodehomematic library",
5
5
  "keywords": [
6
6
  "camstack",