@camstack/addon-provider-homematic 1.2.95 → 1.2.97

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
@@ -5354,6 +5354,86 @@ var ZodIssueCode = {
5354
5354
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5355
5355
  var ZodFirstPartyTypeKind;
5356
5356
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5357
+ //#endregion
5358
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5359
+ /**
5360
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5361
+ * window to float samples (D455).
5362
+ *
5363
+ * ## Why a format at all
5364
+ *
5365
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5366
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5367
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5368
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5369
+ * the plane carried four times the source. The plane crosses hub-main twice on
5370
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5371
+ *
5372
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5373
+ * them where it needs them. That is the same argument D450 made for the rate,
5374
+ * one step further along the same wire.
5375
+ *
5376
+ * ## Why the expansion lives here
5377
+ *
5378
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5379
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5380
+ * `AudioChunkPlane` expands per subscription) and
5381
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5382
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5383
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5384
+ * into their own dist (`self-contained` externals), so this travels with a
5385
+ * `camstack deploy` and needs no published server.
5386
+ *
5387
+ * A second μ-law table anywhere else is the defect this module exists to
5388
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5389
+ * direction for the WebRTC egress — a different transform, not a copy.)
5390
+ *
5391
+ * ## Absent means f32le
5392
+ *
5393
+ * `format` is optional on the wire and its absence means `f32le` — today's
5394
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5395
+ * has always been served, because the broker only emits a coded window to a
5396
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5397
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5398
+ * deployable one addon at a time across three nodes.
5399
+ */
5400
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5401
+ var AUDIO_CHUNK_FORMATS = [
5402
+ "f32le",
5403
+ "pcmu",
5404
+ "pcma"
5405
+ ];
5406
+ /**
5407
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5408
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5409
+ *
5410
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5411
+ * it buffers the coded bytes and the plane's consumers expand.
5412
+ */
5413
+ function buildUlawTable() {
5414
+ const table = new Float32Array(256);
5415
+ for (let i = 0; i < 256; i++) {
5416
+ const complemented = ~i & 255;
5417
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5418
+ const exponent = complemented >> 4 & 7;
5419
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5420
+ }
5421
+ return table;
5422
+ }
5423
+ /** Build the A-law decode table (ITU-T G.711). */
5424
+ function buildAlawTable() {
5425
+ const table = new Float32Array(256);
5426
+ for (let i = 0; i < 256; i++) {
5427
+ const xored = i ^ 85;
5428
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5429
+ const exponent = xored >> 4 & 7;
5430
+ const mantissa = xored & 15;
5431
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5432
+ }
5433
+ return table;
5434
+ }
5435
+ buildUlawTable();
5436
+ buildAlawTable();
5357
5437
  Object.fromEntries([
5358
5438
  {
5359
5439
  id: "overview",
@@ -6646,11 +6726,20 @@ var SubscribeFramesResultSchema = object({
6646
6726
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6647
6727
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6648
6728
  */
6729
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6649
6730
  var DecodedAudioChunkSchema = object({
6650
6731
  data: _instanceof(Uint8Array),
6651
6732
  sampleRate: number().int().positive(),
6652
6733
  channels: number().int().positive(),
6653
- timestamp: number()
6734
+ timestamp: number(),
6735
+ /**
6736
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6737
+ * byte, for any peer that never heard of this field. A coded window
6738
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6739
+ * subscription that DECLARED it accepts one, so absence can never mean
6740
+ * "coded bytes a consumer will read as floats" (D455).
6741
+ */
6742
+ format: AudioChunkFormatSchema.optional()
6654
6743
  });
6655
6744
  /**
6656
6745
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6662,7 +6751,18 @@ var DecodedAudioChunkSchema = object({
6662
6751
  var SubscribeAudioChunksInputSchema = object({
6663
6752
  brokerId: string(),
6664
6753
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6665
- tag: string().optional()
6754
+ tag: string().optional(),
6755
+ /**
6756
+ * Byte formats this subscriber can READ, best first. The broker serves the
6757
+ * chunk's own format when it is in this list and expands to `f32le`
6758
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6759
+ *
6760
+ * Absent (or without the source format) means `f32le` — the behaviour every
6761
+ * subscriber had before D455, unchanged. This is the negotiation half of
6762
+ * the source-bytes lever: it is what lets the broker and its consumers
6763
+ * deploy one at a time across three nodes.
6764
+ */
6765
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6666
6766
  });
6667
6767
  /** Result of `stream-broker.subscribeAudioChunks`. */
6668
6768
  var SubscribeAudioChunksResultSchema = object({
@@ -10650,6 +10750,51 @@ var AudioAnalysisSettingsSchema = object({
10650
10750
  minConfidence: number().min(0).max(1).default(.3),
10651
10751
  allowedClasses: array(string()).default([])
10652
10752
  });
10753
+ /**
10754
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10755
+ *
10756
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10757
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10758
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10759
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10760
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10761
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10762
+ * way to the one expansion that feeds the model.
10763
+ *
10764
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10765
+ * window, the per-device node assignment, the settings read) and therefore
10766
+ * still owns the attach/detach pair. It no longer owns the bytes.
10767
+ */
10768
+ var AudioAttachDeviceInputSchema = object({
10769
+ deviceId: number(),
10770
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10771
+ brokerId: string(),
10772
+ /**
10773
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10774
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10775
+ * the orchestrator's poller pinned them before the move.
10776
+ */
10777
+ ingestNodeId: string(),
10778
+ /**
10779
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10780
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10781
+ * window: a settings change re-attaches, which is what always happened.
10782
+ */
10783
+ settings: AudioAnalysisSettingsSchema
10784
+ });
10785
+ var AudioAttachDeviceResultSchema = object({
10786
+ /** False only when the analyzer is shutting down and refused to attach. */
10787
+ attached: boolean(),
10788
+ /**
10789
+ * True when the attachment replaced a live one for the same device. An
10790
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10791
+ * double the broker's fanout and neither would know about the other.
10792
+ */
10793
+ replaced: boolean()
10794
+ });
10795
+ var AudioDetachDeviceResultSchema = object({
10796
+ /** False when no attachment existed — detach is idempotent. */
10797
+ detached: boolean() });
10653
10798
  var AudioClassificationResultSchema = object({
10654
10799
  labels: array(AudioClassificationLabelSchema).readonly(),
10655
10800
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10658,7 +10803,7 @@ var AudioClassificationResultSchema = object({
10658
10803
  method(object({
10659
10804
  chunk: AudioChunkInputSchema,
10660
10805
  settings: AudioAnalysisSettingsSchema
10661
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10806
+ }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(AudioAttachDeviceInputSchema, AudioAttachDeviceResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), AudioDetachDeviceResultSchema, { kind: "mutation" }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10662
10807
  kind: "mutation",
10663
10808
  auth: "admin"
10664
10809
  });
@@ -25948,8 +26093,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
25948
26093
  *
25949
26094
  * An **empty array reads NOTHING** — `[]` is an empty page, never
25950
26095
  * "every camera". A request for no devices is a request, not an
25951
- * omission; same contract as `deviceManager.listFleet` and
25952
- * `pipelineAnalytics.listRecentTracks`.
26096
+ * omission; same contract as `deviceManager.listAll`'s `deviceIds`
26097
+ * and `pipelineAnalytics.listRecentTracks`.
25953
26098
  *
25954
26099
  * Absent (`undefined`) is the omission, and keeps the cluster-wide view.
25955
26100
  */
@@ -34983,12 +35128,24 @@ Object.freeze({
34983
35128
  addonId: null,
34984
35129
  access: "create"
34985
35130
  },
35131
+ "audioAnalyzer.attachDevice": {
35132
+ capName: "audio-analyzer",
35133
+ capScope: "system",
35134
+ addonId: null,
35135
+ access: "create"
35136
+ },
34986
35137
  "audioAnalyzer.classify": {
34987
35138
  capName: "audio-analyzer",
34988
35139
  capScope: "system",
34989
35140
  addonId: null,
34990
35141
  access: "view"
34991
35142
  },
35143
+ "audioAnalyzer.detachDevice": {
35144
+ capName: "audio-analyzer",
35145
+ capScope: "system",
35146
+ addonId: null,
35147
+ access: "create"
35148
+ },
34992
35149
  "audioAnalyzer.dispose": {
34993
35150
  capName: "audio-analyzer",
34994
35151
  capScope: "system",
@@ -40832,11 +40989,21 @@ Object.freeze({
40832
40989
  form: "single",
40833
40990
  optional: false
40834
40991
  }],
40992
+ "audioAnalyzer.attachDevice": [{
40993
+ name: "deviceId",
40994
+ form: "single",
40995
+ optional: false
40996
+ }],
40835
40997
  "audioAnalyzer.classify": [{
40836
40998
  name: "deviceId",
40837
40999
  form: "single",
40838
41000
  optional: true
40839
41001
  }],
41002
+ "audioAnalyzer.detachDevice": [{
41003
+ name: "deviceId",
41004
+ form: "single",
41005
+ optional: false
41006
+ }],
40840
41007
  "audioMetrics.getCurrentSnapshot": [{
40841
41008
  name: "deviceId",
40842
41009
  form: "single",
@@ -42688,6 +42855,52 @@ Object.freeze({
42688
42855
  "network-access": "ingress",
42689
42856
  "smtp-provider": "email"
42690
42857
  });
42858
+ var G711_SCALE_CORRECTION_DB = {
42859
+ PCMU: 20 * Math.log10(4),
42860
+ PCMA: 20 * Math.log10(8)
42861
+ };
42862
+ /**
42863
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42864
+ * same intent on the ITU-T scale (D460).
42865
+ *
42866
+ * ## When this applies, and when it is the wrong thing to reach for
42867
+ *
42868
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42869
+ * them converts:
42870
+ *
42871
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42872
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42873
+ * after. The defect was never in the number; it was that 19 of this hub's
42874
+ * 25 cameras did not obey it. Converting such a number takes something
42875
+ * correct and makes it wrong, in order to preserve a bug.
42876
+ * - **A measurement taken through the old decoder** — a value someone read
42877
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42878
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42879
+ * louder. That is what this function is for.
42880
+ *
42881
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42882
+ * and it cannot be answered from the number. It is answered by the comment the
42883
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42884
+ * mandatory.
42885
+ *
42886
+ * ## Why a function and not a typed-in number
42887
+ *
42888
+ * `-55 + 12.04` written into a source file is, six months later, completely
42889
+ * indistinguishable from a threshold somebody simply preferred. Calling this
42890
+ * keeps the derivation, the law, and the original measurement all visible at
42891
+ * the call site, so a future reader can disagree with the *premise* instead of
42892
+ * having to reverse-engineer the sum.
42893
+ *
42894
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
42895
+ * it is declared. It must never be applied to a live sample or a stored
42896
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
42897
+ * adjusting numbers the decoder already got right is the original defect with
42898
+ * an extra place to argue with (D459).
42899
+ */
42900
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
42901
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
42902
+ }
42903
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42691
42904
  /** Schema defaults — an untouched sub-field must author exactly these. */
42692
42905
  var NC_AUDIO_DEFAULTS = {
42693
42906
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -5355,6 +5355,86 @@ var ZodIssueCode = {
5355
5355
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5356
5356
  var ZodFirstPartyTypeKind;
5357
5357
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5358
+ //#endregion
5359
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5360
+ /**
5361
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5362
+ * window to float samples (D455).
5363
+ *
5364
+ * ## Why a format at all
5365
+ *
5366
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5367
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5368
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5369
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5370
+ * the plane carried four times the source. The plane crosses hub-main twice on
5371
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5372
+ *
5373
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5374
+ * them where it needs them. That is the same argument D450 made for the rate,
5375
+ * one step further along the same wire.
5376
+ *
5377
+ * ## Why the expansion lives here
5378
+ *
5379
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5380
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5381
+ * `AudioChunkPlane` expands per subscription) and
5382
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5383
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5384
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5385
+ * into their own dist (`self-contained` externals), so this travels with a
5386
+ * `camstack deploy` and needs no published server.
5387
+ *
5388
+ * A second μ-law table anywhere else is the defect this module exists to
5389
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5390
+ * direction for the WebRTC egress — a different transform, not a copy.)
5391
+ *
5392
+ * ## Absent means f32le
5393
+ *
5394
+ * `format` is optional on the wire and its absence means `f32le` — today's
5395
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5396
+ * has always been served, because the broker only emits a coded window to a
5397
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5398
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5399
+ * deployable one addon at a time across three nodes.
5400
+ */
5401
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5402
+ var AUDIO_CHUNK_FORMATS = [
5403
+ "f32le",
5404
+ "pcmu",
5405
+ "pcma"
5406
+ ];
5407
+ /**
5408
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5409
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5410
+ *
5411
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5412
+ * it buffers the coded bytes and the plane's consumers expand.
5413
+ */
5414
+ function buildUlawTable() {
5415
+ const table = new Float32Array(256);
5416
+ for (let i = 0; i < 256; i++) {
5417
+ const complemented = ~i & 255;
5418
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5419
+ const exponent = complemented >> 4 & 7;
5420
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5421
+ }
5422
+ return table;
5423
+ }
5424
+ /** Build the A-law decode table (ITU-T G.711). */
5425
+ function buildAlawTable() {
5426
+ const table = new Float32Array(256);
5427
+ for (let i = 0; i < 256; i++) {
5428
+ const xored = i ^ 85;
5429
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5430
+ const exponent = xored >> 4 & 7;
5431
+ const mantissa = xored & 15;
5432
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5433
+ }
5434
+ return table;
5435
+ }
5436
+ buildUlawTable();
5437
+ buildAlawTable();
5358
5438
  Object.fromEntries([
5359
5439
  {
5360
5440
  id: "overview",
@@ -6647,11 +6727,20 @@ var SubscribeFramesResultSchema = object({
6647
6727
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6648
6728
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6649
6729
  */
6730
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6650
6731
  var DecodedAudioChunkSchema = object({
6651
6732
  data: _instanceof(Uint8Array),
6652
6733
  sampleRate: number().int().positive(),
6653
6734
  channels: number().int().positive(),
6654
- timestamp: number()
6735
+ timestamp: number(),
6736
+ /**
6737
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6738
+ * byte, for any peer that never heard of this field. A coded window
6739
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6740
+ * subscription that DECLARED it accepts one, so absence can never mean
6741
+ * "coded bytes a consumer will read as floats" (D455).
6742
+ */
6743
+ format: AudioChunkFormatSchema.optional()
6655
6744
  });
6656
6745
  /**
6657
6746
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6663,7 +6752,18 @@ var DecodedAudioChunkSchema = object({
6663
6752
  var SubscribeAudioChunksInputSchema = object({
6664
6753
  brokerId: string(),
6665
6754
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6666
- tag: string().optional()
6755
+ tag: string().optional(),
6756
+ /**
6757
+ * Byte formats this subscriber can READ, best first. The broker serves the
6758
+ * chunk's own format when it is in this list and expands to `f32le`
6759
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6760
+ *
6761
+ * Absent (or without the source format) means `f32le` — the behaviour every
6762
+ * subscriber had before D455, unchanged. This is the negotiation half of
6763
+ * the source-bytes lever: it is what lets the broker and its consumers
6764
+ * deploy one at a time across three nodes.
6765
+ */
6766
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6667
6767
  });
6668
6768
  /** Result of `stream-broker.subscribeAudioChunks`. */
6669
6769
  var SubscribeAudioChunksResultSchema = object({
@@ -10651,6 +10751,51 @@ var AudioAnalysisSettingsSchema = object({
10651
10751
  minConfidence: number().min(0).max(1).default(.3),
10652
10752
  allowedClasses: array(string()).default([])
10653
10753
  });
10754
+ /**
10755
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10756
+ *
10757
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10758
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10759
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10760
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10761
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10762
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10763
+ * way to the one expansion that feeds the model.
10764
+ *
10765
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10766
+ * window, the per-device node assignment, the settings read) and therefore
10767
+ * still owns the attach/detach pair. It no longer owns the bytes.
10768
+ */
10769
+ var AudioAttachDeviceInputSchema = object({
10770
+ deviceId: number(),
10771
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10772
+ brokerId: string(),
10773
+ /**
10774
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10775
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10776
+ * the orchestrator's poller pinned them before the move.
10777
+ */
10778
+ ingestNodeId: string(),
10779
+ /**
10780
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10781
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10782
+ * window: a settings change re-attaches, which is what always happened.
10783
+ */
10784
+ settings: AudioAnalysisSettingsSchema
10785
+ });
10786
+ var AudioAttachDeviceResultSchema = object({
10787
+ /** False only when the analyzer is shutting down and refused to attach. */
10788
+ attached: boolean(),
10789
+ /**
10790
+ * True when the attachment replaced a live one for the same device. An
10791
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10792
+ * double the broker's fanout and neither would know about the other.
10793
+ */
10794
+ replaced: boolean()
10795
+ });
10796
+ var AudioDetachDeviceResultSchema = object({
10797
+ /** False when no attachment existed — detach is idempotent. */
10798
+ detached: boolean() });
10654
10799
  var AudioClassificationResultSchema = object({
10655
10800
  labels: array(AudioClassificationLabelSchema).readonly(),
10656
10801
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10659,7 +10804,7 @@ var AudioClassificationResultSchema = object({
10659
10804
  method(object({
10660
10805
  chunk: AudioChunkInputSchema,
10661
10806
  settings: AudioAnalysisSettingsSchema
10662
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10807
+ }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(AudioAttachDeviceInputSchema, AudioAttachDeviceResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), AudioDetachDeviceResultSchema, { kind: "mutation" }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10663
10808
  kind: "mutation",
10664
10809
  auth: "admin"
10665
10810
  });
@@ -25949,8 +26094,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
25949
26094
  *
25950
26095
  * An **empty array reads NOTHING** — `[]` is an empty page, never
25951
26096
  * "every camera". A request for no devices is a request, not an
25952
- * omission; same contract as `deviceManager.listFleet` and
25953
- * `pipelineAnalytics.listRecentTracks`.
26097
+ * omission; same contract as `deviceManager.listAll`'s `deviceIds`
26098
+ * and `pipelineAnalytics.listRecentTracks`.
25954
26099
  *
25955
26100
  * Absent (`undefined`) is the omission, and keeps the cluster-wide view.
25956
26101
  */
@@ -34984,12 +35129,24 @@ Object.freeze({
34984
35129
  addonId: null,
34985
35130
  access: "create"
34986
35131
  },
35132
+ "audioAnalyzer.attachDevice": {
35133
+ capName: "audio-analyzer",
35134
+ capScope: "system",
35135
+ addonId: null,
35136
+ access: "create"
35137
+ },
34987
35138
  "audioAnalyzer.classify": {
34988
35139
  capName: "audio-analyzer",
34989
35140
  capScope: "system",
34990
35141
  addonId: null,
34991
35142
  access: "view"
34992
35143
  },
35144
+ "audioAnalyzer.detachDevice": {
35145
+ capName: "audio-analyzer",
35146
+ capScope: "system",
35147
+ addonId: null,
35148
+ access: "create"
35149
+ },
34993
35150
  "audioAnalyzer.dispose": {
34994
35151
  capName: "audio-analyzer",
34995
35152
  capScope: "system",
@@ -40833,11 +40990,21 @@ Object.freeze({
40833
40990
  form: "single",
40834
40991
  optional: false
40835
40992
  }],
40993
+ "audioAnalyzer.attachDevice": [{
40994
+ name: "deviceId",
40995
+ form: "single",
40996
+ optional: false
40997
+ }],
40836
40998
  "audioAnalyzer.classify": [{
40837
40999
  name: "deviceId",
40838
41000
  form: "single",
40839
41001
  optional: true
40840
41002
  }],
41003
+ "audioAnalyzer.detachDevice": [{
41004
+ name: "deviceId",
41005
+ form: "single",
41006
+ optional: false
41007
+ }],
40841
41008
  "audioMetrics.getCurrentSnapshot": [{
40842
41009
  name: "deviceId",
40843
41010
  form: "single",
@@ -42689,6 +42856,52 @@ Object.freeze({
42689
42856
  "network-access": "ingress",
42690
42857
  "smtp-provider": "email"
42691
42858
  });
42859
+ var G711_SCALE_CORRECTION_DB = {
42860
+ PCMU: 20 * Math.log10(4),
42861
+ PCMA: 20 * Math.log10(8)
42862
+ };
42863
+ /**
42864
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42865
+ * same intent on the ITU-T scale (D460).
42866
+ *
42867
+ * ## When this applies, and when it is the wrong thing to reach for
42868
+ *
42869
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42870
+ * them converts:
42871
+ *
42872
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42873
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42874
+ * after. The defect was never in the number; it was that 19 of this hub's
42875
+ * 25 cameras did not obey it. Converting such a number takes something
42876
+ * correct and makes it wrong, in order to preserve a bug.
42877
+ * - **A measurement taken through the old decoder** — a value someone read
42878
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42879
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42880
+ * louder. That is what this function is for.
42881
+ *
42882
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42883
+ * and it cannot be answered from the number. It is answered by the comment the
42884
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42885
+ * mandatory.
42886
+ *
42887
+ * ## Why a function and not a typed-in number
42888
+ *
42889
+ * `-55 + 12.04` written into a source file is, six months later, completely
42890
+ * indistinguishable from a threshold somebody simply preferred. Calling this
42891
+ * keeps the derivation, the law, and the original measurement all visible at
42892
+ * the call site, so a future reader can disagree with the *premise* instead of
42893
+ * having to reverse-engineer the sum.
42894
+ *
42895
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
42896
+ * it is declared. It must never be applied to a live sample or a stored
42897
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
42898
+ * adjusting numbers the decoder already got right is the original defect with
42899
+ * an extra place to argue with (D459).
42900
+ */
42901
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
42902
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
42903
+ }
42904
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42692
42905
  /** Schema defaults — an untouched sub-field must author exactly these. */
42693
42906
  var NC_AUDIO_DEFAULTS = {
42694
42907
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-homematic",
3
- "version": "1.2.95",
3
+ "version": "1.2.97",
4
4
  "description": "Homematic / HomematicIP (CCU3 / RaspberryMatic) device-provider addon for CamStack — wraps the nodehomematic library",
5
5
  "keywords": [
6
6
  "camstack",