@camstack/addon-provider-homematic 1.2.117 → 1.2.118

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.
Files changed (3) hide show
  1. package/dist/addon.js +1839 -1044
  2. package/dist/addon.mjs +1839 -1044
  3. package/package.json +2 -2
package/dist/addon.mjs CHANGED
@@ -5370,7 +5370,7 @@ var ZodIssueCode = {
5370
5370
  var ZodFirstPartyTypeKind;
5371
5371
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5372
5372
  //#endregion
5373
- //#region ../types/dist/sleep-i3eUVc-d.mjs
5373
+ //#region ../types/dist/sleep-pM_J7YnY.mjs
5374
5374
  /**
5375
5375
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5376
5376
  * window to float samples (D455).
@@ -6506,6 +6506,24 @@ function normalizeAddonInitResult(result) {
6506
6506
  if (Array.isArray(result)) return { providers: result };
6507
6507
  return result;
6508
6508
  }
6509
+ /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
6510
+ var PeerBytesTicketSchema = object({
6511
+ /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
6512
+ url: string().min(1),
6513
+ /**
6514
+ * The HOST node this URL means something on — the hub or a named agent,
6515
+ * never a runner. {@link AddonPeerBytes.open} compares it to its own and
6516
+ * refuses `cross-node` by name when they differ, without dialling.
6517
+ */
6518
+ hostNodeId: string().min(1),
6519
+ expiresAtMs: number().int().nonnegative(),
6520
+ /**
6521
+ * What the producer DECLARED the body to be, when it knows — `null` when it
6522
+ * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
6523
+ * must be able to tell "the producer did not say" from "the body is empty".
6524
+ */
6525
+ declaredBytes: number().int().nonnegative().nullable()
6526
+ });
6509
6527
  /** Shared Zod schemas used across streaming capabilities. */
6510
6528
  var CamProfileSchema = _enum([
6511
6529
  "high",
@@ -7651,7 +7669,7 @@ var AdoptionJobSchema = object({
7651
7669
  * component's original options — detection to the detection-pipeline wrapper
7652
7670
  * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7653
7671
  * (which was always first-class; the switch was a veneer over
7654
- * `recording.setDeviceConfig`), notifications to a notification-center
7672
+ * `recordingArchive.setDeviceConfig`), notifications to a notification-center
7655
7673
  * per-device setting, the two camera planes to their own components.
7656
7674
  *
7657
7675
  * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
@@ -7677,7 +7695,7 @@ var AdoptionJobSchema = object({
7677
7695
  * | `stream-broker` | `deviceManager.setDisabled` | `StreamBrokerManager.reconcileAllCatalogs` releases the brokers; `ensureBroker` refuses re-creation |
7678
7696
  * | `object-detection` | `deviceManager.setWrapperActive('detection-pipeline')` | `PipelineSettingsStore.resolvePipelineForDevice` returns `{ steps: [], audio: null }` |
7679
7697
  * | `audio-analysis` | `deviceManager.setWrapperActive('audio-analysis')` | `AudioSubscriptionController.subscribeAudioStream` returns `null` before opening the stream |
7680
- * | `recording` | `recording.setDeviceConfig` → `RecordingConfig.enabled` | `band-decision.shouldRecord` returns false; the controller detaches the device |
7698
+ * | `recording` | `recordingArchive.setDeviceConfig` → `RecordingConfig.enabled` | `band-decision.shouldRecord` returns false; the controller detaches the device |
7681
7699
  * | `notifications` | `notificationRules.setDeviceMuted` | `NotificationCenter.evaluateAndEnqueue` returns before any rule is evaluated |
7682
7700
  * | `privacy-mask` | `privacyMask.setMask({ enabled })` → the CAMERA | the camera blanks the masked regions itself; every stream and recording carries the black boxes |
7683
7701
  * | `device-audio` | `privacyMask.setAudioEnabled` → the CAMERA | the camera stops encoding an audio track at all; every consumer sees silent video |
@@ -11624,87 +11642,6 @@ var brokerCapability = {
11624
11642
  }
11625
11643
  };
11626
11644
  DeviceType.Camera;
11627
- /**
11628
- * The signals a device can emit to WAKE its own stream.
11629
- *
11630
- * A camera whose stream is built on demand sleeps until something asks for it,
11631
- * and "something" cannot be a consumer that is merely attached — a Frigate-style
11632
- * puller holds a session open for ever, and treating that as demand would keep
11633
- * a battery camera awake for ever, which is the whole thing the battery is for
11634
- * (D173). So the wake has to come from the CAMERA: an event it noticed by
11635
- * itself, with no stream running.
11636
- *
11637
- * ## The vocabulary is the PROVIDER'S, not ours
11638
- *
11639
- * Like `consumables`, this cap declares no vocabulary of its own. A provider
11640
- * names each signal with a `code` it chooses and a `label` an operator reads.
11641
- * Reolink offers motion and camera-native detection; another provider may offer
11642
- * a tamper, a doorbell press, a PIR, or something no camera in this fleet has
11643
- * yet. A fixed enum here would mean every new signal is a framework release.
11644
- *
11645
- * It is deliberately NOT derived from the caps a device already binds. Whether
11646
- * a camera CAN push firmware motion is expressed by `motionSources` containing
11647
- * `'onboard'`, and whether it does AI on-camera by the `native-object-detection`
11648
- * binding — but both answer "what drives the detection pipeline", which is a
11649
- * different question from "what may wake a sleeping stream". A camera can do
11650
- * the first and not be trusted with the second, and the operator picks per
11651
- * camera. Two questions, two authorities.
11652
- *
11653
- * ## Availability is not permission
11654
- *
11655
- * `listSignals` says what the device CAN emit. Whether a given signal actually
11656
- * wakes the stream is the operator's per-camera choice, held by the broker
11657
- * alongside the cooldown — see the stream-broker cap's wake settings. A
11658
- * provider declaring a signal is not a provider enabling it.
11659
- */
11660
- /** One signal a device can emit. */
11661
- var StreamSignalSchema = object({
11662
- /** Stable id chosen by the provider, e.g. `'motion'`, `'person'`, `'tamper'`. */
11663
- code: string().min(1),
11664
- /** What an operator reads in the picker. The provider's own wording. */
11665
- label: string().min(1),
11666
- /**
11667
- * Whether the provider recommends this signal ON when a camera is first set
11668
- * up. A provider knows which of its signals are cheap and reliable; an
11669
- * operator should not have to discover that by trial. Reolink recommends
11670
- * both of its own.
11671
- */
11672
- recommended: boolean()
11673
- });
11674
- var StreamSignalsStatusSchema = object({
11675
- signals: array(StreamSignalSchema),
11676
- lastFetchedAt: number()
11677
- });
11678
- var streamSignalsCapability = {
11679
- name: "stream-signals",
11680
- scope: "device",
11681
- deviceNative: true,
11682
- mode: "singleton",
11683
- deviceTypes: Object.values(DeviceType),
11684
- runtimeState: StreamSignalsStatusSchema,
11685
- /**
11686
- * Runtime-state durability: **session** — mirrored in RAM, never written.
11687
- *
11688
- * The slice holds what the DEVICE says it can emit. That is a probed fact,
11689
- * not an operator choice: the provider re-declares it on every registration,
11690
- * so losing it loses nothing and persisting it would freeze an answer the
11691
- * camera is entitled to change. Measured the same day on the sibling case —
11692
- * `native-object-detection.supportedClasses` was persisted, and a firmware
11693
- * class the camera really detected stayed missing for the life of the row
11694
- * because the fix could not reach it.
11695
- *
11696
- * See `RuntimeStateDurability`. Enforced by
11697
- * `scripts/check-runtime-state-durability.ts`.
11698
- */
11699
- durability: "session",
11700
- methods: {
11701
- /**
11702
- * What this device can emit. Empty is a valid and common answer — most
11703
- * cameras have nothing to offer here, and an empty list is what makes the
11704
- * broker's picker show nothing rather than a false choice.
11705
- */
11706
- listSignals: method(_void(), array(StreamSignalSchema).readonly()) }
11707
- };
11708
11645
  /** Stream delivery format. (Relocated from the retired `streaming-engine` cap.) */
11709
11646
  var StreamFormatSchema = _enum([
11710
11647
  "webrtc",
@@ -13170,6 +13107,210 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
13170
13107
  });
13171
13108
  DeviceType.Camera;
13172
13109
  /**
13110
+ * device-admin-link — "this device has a management page of its own, and here
13111
+ * is its address".
13112
+ *
13113
+ * ## Why this is not a `deviceConfig` cap
13114
+ *
13115
+ * There is nothing to edit. A `deviceConfig` cap (D14) exists so the framework
13116
+ * can DERIVE a settings form from `getOptions` + `getStatus` and route a flat
13117
+ * patch back through a setter; it costs a `builderId` reducer in
13118
+ * `device-config-contribution.ts` and a `*-config-schema.ts` beside it, and it
13119
+ * renders a form section. This cap answers ONE question with ONE read and
13120
+ * renders a button. Nothing about it is a form, so it carries no `deviceConfig`
13121
+ * block, no `settings`, no `runtimeState` and no reducer — exactly like
13122
+ * `reboot`, the other pure-RPC device-native cap.
13123
+ *
13124
+ * ## Absent, and the difference between "no page" and "we cannot say"
13125
+ *
13126
+ * The two are answered at DIFFERENT layers, on purpose:
13127
+ *
13128
+ * - **"We cannot say"** → the provider never registers the cap for that
13129
+ * device. A VeSync humidifier, a Petkit feeder, a Dreame vacuum and a Dreo
13130
+ * fan are reached only through a vendor cloud; there is no address to hand
13131
+ * out and no page to open. A Tuya plug, a Wyze camera and a Gree air
13132
+ * conditioner DO have a LAN IP, and still have no HTTP management page
13133
+ * behind it. None of them register, so `deviceManager.getBindings` never
13134
+ * lists the cap and no surface asks.
13135
+ * - **"This device has no page, and I know that"** → the provider registers
13136
+ * and `getAdminLink` returns `null`. This is the answer for a device whose
13137
+ * sibling DOES have a page: a Reolink battery camera reached over UDP by
13138
+ * `uid` with a blank `host`, an Ecowitt gateway configured in `listener`
13139
+ * transport, a Home Assistant broker authenticated by supervisor token
13140
+ * (which carries no `baseUrl` at all).
13141
+ *
13142
+ * Both draw NOTHING. A button that opens a browser error is worse than no
13143
+ * button, and D62 is the same rule from the other side: an off switch is
13144
+ * reported off, never made to look broken. There is no third state where the
13145
+ * UI renders a disabled button "because the device might have a page".
13146
+ *
13147
+ * ## The URL never carries credentials
13148
+ *
13149
+ * Not in userinfo, not in a query string. Every provider builds through
13150
+ * `buildDeviceAdminUrl` (`device-admin-link-url.ts`), which takes host, port,
13151
+ * scheme and path as separate arguments — there is no parameter a secret could
13152
+ * arrive in — and re-checks its own output for the `scheme://user:pass@` shape
13153
+ * that `scripts/check-no-credential-urls-in-fixtures.ts` bans from recorded
13154
+ * output. `scripts/check-admin-link-builder-is-the-only-url-source.ts` is what
13155
+ * keeps providers from hand-rolling one anyway.
13156
+ *
13157
+ * This matters here more than anywhere else in the repo, because every provider
13158
+ * that knows a device's host knows its PASSWORD too: `{ host, port, username,
13159
+ * password }` sit in one object on Hikvision, Amcrest, Reolink and ONVIF alike,
13160
+ * and `http://admin:hunter2@192.168.50.139/` is a URL a browser accepts. The
13161
+ * camera's own page will ask for its own login. That is correct, and pre-
13162
+ * filling it is the operator's business, not ours.
13163
+ *
13164
+ * ## It is a LAN fact
13165
+ *
13166
+ * The URL addresses the device where the NODE can see it. It is not proxied,
13167
+ * not made reachable from outside, and not sent anywhere. A surface renders it
13168
+ * as a link the operator's own browser follows, on the operator's own network,
13169
+ * or renders nothing.
13170
+ */
13171
+ /**
13172
+ * Whose page is it. The distinction is for the OPERATOR, who needs to know
13173
+ * before clicking whether he is about to land on a camera's own web server or
13174
+ * inside Home Assistant.
13175
+ */
13176
+ var AdminLinkTargetEnum = _enum(["device", "integration"]);
13177
+ var DeviceAdminLinkSchema = object({
13178
+ /**
13179
+ * Absolute `http(s)://` URL. Built by `buildDeviceAdminUrl` and therefore
13180
+ * free of userinfo and of any credential-shaped query key.
13181
+ */
13182
+ url: string(),
13183
+ /**
13184
+ * What the surface calls it — "Web UI", "Home Assistant", "UniFi controller".
13185
+ * The PROVIDER names it, because only the provider knows what the page is;
13186
+ * a UI that invented the label from the addon id would call the Home
13187
+ * Assistant device page "Provider Homeassistant".
13188
+ */
13189
+ label: string(),
13190
+ target: AdminLinkTargetEnum,
13191
+ /**
13192
+ * Host the URL points at, without scheme, port or path — for the tooltip, so
13193
+ * an operator can see WHERE the button goes before he follows it. Redundant
13194
+ * with `url` by construction; carried separately so no surface has to parse
13195
+ * a URL to show it.
13196
+ */
13197
+ host: string()
13198
+ });
13199
+ var deviceAdminLinkCapability = {
13200
+ name: "device-admin-link",
13201
+ scope: "device",
13202
+ deviceNative: true,
13203
+ mode: "singleton",
13204
+ methods: {
13205
+ /**
13206
+ * The device's management page, or `null` when this device has none.
13207
+ *
13208
+ * `auth: 'admin'` deliberately. This is administration, not actuation —
13209
+ * the same bucket as `reboot` and `camera-credentials`, and explicitly NOT
13210
+ * the actuation set `scripts/check-actuation-not-admin.ts` protects (D403).
13211
+ * The URL is also a statement about the LAN, which a household member with
13212
+ * a `view` grant on a light has no reason to be handed.
13213
+ *
13214
+ * The surfaces gate on the QUERY, never on a role they guessed: a caller
13215
+ * without the right loses the query and draws nothing, which is the same
13216
+ * thing a device with no page draws. There is no path on which a button
13217
+ * appears and then fails — the D403 failure mode, from the other end.
13218
+ */
13219
+ getAdminLink: method(object({ deviceId: number().int().nonnegative() }), DeviceAdminLinkSchema.nullable(), { auth: "admin" }) }
13220
+ };
13221
+ /**
13222
+ * Query keys that may never appear on an admin link. A credential smuggled as
13223
+ * `?password=` is the same leak as userinfo, in a form the userinfo check
13224
+ * cannot see: it survives copy-paste, referrer headers and proxy logs
13225
+ * identically.
13226
+ */
13227
+ var CREDENTIAL_QUERY_KEYS = [
13228
+ "password",
13229
+ "passwd",
13230
+ "pwd",
13231
+ "pass",
13232
+ "user",
13233
+ "username",
13234
+ "usr",
13235
+ "login",
13236
+ "token",
13237
+ "access_token",
13238
+ "auth",
13239
+ "authorization",
13240
+ "apikey",
13241
+ "api_key",
13242
+ "secret",
13243
+ "credential",
13244
+ "credentials",
13245
+ "session",
13246
+ "sessionid",
13247
+ "key"
13248
+ ];
13249
+ /**
13250
+ * The same userinfo shape `scripts/check-no-credential-urls-in-fixtures.ts`
13251
+ * scans recorded fixtures for, applied to what we are about to EMIT. Kept
13252
+ * structurally identical on purpose: a URL this function returns is a URL that
13253
+ * guard would pass.
13254
+ */
13255
+ var CREDENTIAL_URL = /[a-z][a-z0-9+.-]*:\/\/[^/\s:@'"]+:[^/\s:@'"]+@/i;
13256
+ /** A host that is safe to place in an authority component verbatim. */
13257
+ var PLAIN_HOST = /^[a-zA-Z0-9._-]+$/;
13258
+ /** A bracketed IPv6 literal, the only other authority form we emit. */
13259
+ var IPV6_HOST = /^\[[0-9a-fA-F:.]+\]$/;
13260
+ function defaultPortFor(scheme) {
13261
+ return scheme === "https" ? 443 : 80;
13262
+ }
13263
+ /**
13264
+ * Build the admin-page URL, or refuse by name.
13265
+ *
13266
+ * The refusal is never thrown: a provider answering "no page for this device"
13267
+ * is an ordinary answer (`getAdminLink` → `null`), and a throw here would turn
13268
+ * a missing host on one device into a failed query for the whole surface.
13269
+ */
13270
+ function buildDeviceAdminUrl(parts) {
13271
+ const host = parts.host.trim();
13272
+ if (host.length === 0) return {
13273
+ ok: false,
13274
+ reason: "empty-host"
13275
+ };
13276
+ if (host.includes("@")) return {
13277
+ ok: false,
13278
+ reason: "host-carries-userinfo"
13279
+ };
13280
+ if (!PLAIN_HOST.test(host) && !IPV6_HOST.test(host)) return {
13281
+ ok: false,
13282
+ reason: "host-not-plain"
13283
+ };
13284
+ if (parts.port !== null) {
13285
+ if (!Number.isInteger(parts.port) || parts.port < 1 || parts.port > 65535) return {
13286
+ ok: false,
13287
+ reason: "port-out-of-range"
13288
+ };
13289
+ }
13290
+ if (!parts.path.startsWith("/")) return {
13291
+ ok: false,
13292
+ reason: "path-not-absolute"
13293
+ };
13294
+ const query = parts.query ?? {};
13295
+ for (const key of Object.keys(query)) if (CREDENTIAL_QUERY_KEYS.includes(key.toLowerCase())) return {
13296
+ ok: false,
13297
+ reason: "credential-query-key"
13298
+ };
13299
+ const authority = parts.port === null || parts.port === defaultPortFor(parts.scheme) ? host : `${host}:${String(parts.port)}`;
13300
+ const search = new URLSearchParams();
13301
+ for (const [key, value] of Object.entries(query)) search.append(key, value);
13302
+ const suffix = search.size > 0 ? `?${search.toString()}` : "";
13303
+ const url = `${parts.scheme}://${authority}${parts.path}${suffix}`;
13304
+ if (CREDENTIAL_URL.test(url)) return {
13305
+ ok: false,
13306
+ reason: "userinfo-in-result"
13307
+ };
13308
+ return {
13309
+ ok: true,
13310
+ url
13311
+ };
13312
+ }
13313
+ /**
13173
13314
  * Identity envelope for a device's upstream-system metadata.
13174
13315
  *
13175
13316
  * Two jobs:
@@ -13621,210 +13762,6 @@ var deviceAdoptionCapability = {
13621
13762
  }
13622
13763
  };
13623
13764
  /**
13624
- * device-admin-link — "this device has a management page of its own, and here
13625
- * is its address".
13626
- *
13627
- * ## Why this is not a `deviceConfig` cap
13628
- *
13629
- * There is nothing to edit. A `deviceConfig` cap (D14) exists so the framework
13630
- * can DERIVE a settings form from `getOptions` + `getStatus` and route a flat
13631
- * patch back through a setter; it costs a `builderId` reducer in
13632
- * `device-config-contribution.ts` and a `*-config-schema.ts` beside it, and it
13633
- * renders a form section. This cap answers ONE question with ONE read and
13634
- * renders a button. Nothing about it is a form, so it carries no `deviceConfig`
13635
- * block, no `settings`, no `runtimeState` and no reducer — exactly like
13636
- * `reboot`, the other pure-RPC device-native cap.
13637
- *
13638
- * ## Absent, and the difference between "no page" and "we cannot say"
13639
- *
13640
- * The two are answered at DIFFERENT layers, on purpose:
13641
- *
13642
- * - **"We cannot say"** → the provider never registers the cap for that
13643
- * device. A VeSync humidifier, a Petkit feeder, a Dreame vacuum and a Dreo
13644
- * fan are reached only through a vendor cloud; there is no address to hand
13645
- * out and no page to open. A Tuya plug, a Wyze camera and a Gree air
13646
- * conditioner DO have a LAN IP, and still have no HTTP management page
13647
- * behind it. None of them register, so `deviceManager.getBindings` never
13648
- * lists the cap and no surface asks.
13649
- * - **"This device has no page, and I know that"** → the provider registers
13650
- * and `getAdminLink` returns `null`. This is the answer for a device whose
13651
- * sibling DOES have a page: a Reolink battery camera reached over UDP by
13652
- * `uid` with a blank `host`, an Ecowitt gateway configured in `listener`
13653
- * transport, a Home Assistant broker authenticated by supervisor token
13654
- * (which carries no `baseUrl` at all).
13655
- *
13656
- * Both draw NOTHING. A button that opens a browser error is worse than no
13657
- * button, and D62 is the same rule from the other side: an off switch is
13658
- * reported off, never made to look broken. There is no third state where the
13659
- * UI renders a disabled button "because the device might have a page".
13660
- *
13661
- * ## The URL never carries credentials
13662
- *
13663
- * Not in userinfo, not in a query string. Every provider builds through
13664
- * `buildDeviceAdminUrl` (`device-admin-link-url.ts`), which takes host, port,
13665
- * scheme and path as separate arguments — there is no parameter a secret could
13666
- * arrive in — and re-checks its own output for the `scheme://user:pass@` shape
13667
- * that `scripts/check-no-credential-urls-in-fixtures.ts` bans from recorded
13668
- * output. `scripts/check-admin-link-builder-is-the-only-url-source.ts` is what
13669
- * keeps providers from hand-rolling one anyway.
13670
- *
13671
- * This matters here more than anywhere else in the repo, because every provider
13672
- * that knows a device's host knows its PASSWORD too: `{ host, port, username,
13673
- * password }` sit in one object on Hikvision, Amcrest, Reolink and ONVIF alike,
13674
- * and `http://admin:hunter2@192.168.50.139/` is a URL a browser accepts. The
13675
- * camera's own page will ask for its own login. That is correct, and pre-
13676
- * filling it is the operator's business, not ours.
13677
- *
13678
- * ## It is a LAN fact
13679
- *
13680
- * The URL addresses the device where the NODE can see it. It is not proxied,
13681
- * not made reachable from outside, and not sent anywhere. A surface renders it
13682
- * as a link the operator's own browser follows, on the operator's own network,
13683
- * or renders nothing.
13684
- */
13685
- /**
13686
- * Whose page is it. The distinction is for the OPERATOR, who needs to know
13687
- * before clicking whether he is about to land on a camera's own web server or
13688
- * inside Home Assistant.
13689
- */
13690
- var AdminLinkTargetEnum = _enum(["device", "integration"]);
13691
- var DeviceAdminLinkSchema = object({
13692
- /**
13693
- * Absolute `http(s)://` URL. Built by `buildDeviceAdminUrl` and therefore
13694
- * free of userinfo and of any credential-shaped query key.
13695
- */
13696
- url: string(),
13697
- /**
13698
- * What the surface calls it — "Web UI", "Home Assistant", "UniFi controller".
13699
- * The PROVIDER names it, because only the provider knows what the page is;
13700
- * a UI that invented the label from the addon id would call the Home
13701
- * Assistant device page "Provider Homeassistant".
13702
- */
13703
- label: string(),
13704
- target: AdminLinkTargetEnum,
13705
- /**
13706
- * Host the URL points at, without scheme, port or path — for the tooltip, so
13707
- * an operator can see WHERE the button goes before he follows it. Redundant
13708
- * with `url` by construction; carried separately so no surface has to parse
13709
- * a URL to show it.
13710
- */
13711
- host: string()
13712
- });
13713
- var deviceAdminLinkCapability = {
13714
- name: "device-admin-link",
13715
- scope: "device",
13716
- deviceNative: true,
13717
- mode: "singleton",
13718
- methods: {
13719
- /**
13720
- * The device's management page, or `null` when this device has none.
13721
- *
13722
- * `auth: 'admin'` deliberately. This is administration, not actuation —
13723
- * the same bucket as `reboot` and `camera-credentials`, and explicitly NOT
13724
- * the actuation set `scripts/check-actuation-not-admin.ts` protects (D403).
13725
- * The URL is also a statement about the LAN, which a household member with
13726
- * a `view` grant on a light has no reason to be handed.
13727
- *
13728
- * The surfaces gate on the QUERY, never on a role they guessed: a caller
13729
- * without the right loses the query and draws nothing, which is the same
13730
- * thing a device with no page draws. There is no path on which a button
13731
- * appears and then fails — the D403 failure mode, from the other end.
13732
- */
13733
- getAdminLink: method(object({ deviceId: number().int().nonnegative() }), DeviceAdminLinkSchema.nullable(), { auth: "admin" }) }
13734
- };
13735
- /**
13736
- * Query keys that may never appear on an admin link. A credential smuggled as
13737
- * `?password=` is the same leak as userinfo, in a form the userinfo check
13738
- * cannot see: it survives copy-paste, referrer headers and proxy logs
13739
- * identically.
13740
- */
13741
- var CREDENTIAL_QUERY_KEYS = [
13742
- "password",
13743
- "passwd",
13744
- "pwd",
13745
- "pass",
13746
- "user",
13747
- "username",
13748
- "usr",
13749
- "login",
13750
- "token",
13751
- "access_token",
13752
- "auth",
13753
- "authorization",
13754
- "apikey",
13755
- "api_key",
13756
- "secret",
13757
- "credential",
13758
- "credentials",
13759
- "session",
13760
- "sessionid",
13761
- "key"
13762
- ];
13763
- /**
13764
- * The same userinfo shape `scripts/check-no-credential-urls-in-fixtures.ts`
13765
- * scans recorded fixtures for, applied to what we are about to EMIT. Kept
13766
- * structurally identical on purpose: a URL this function returns is a URL that
13767
- * guard would pass.
13768
- */
13769
- var CREDENTIAL_URL = /[a-z][a-z0-9+.-]*:\/\/[^/\s:@'"]+:[^/\s:@'"]+@/i;
13770
- /** A host that is safe to place in an authority component verbatim. */
13771
- var PLAIN_HOST = /^[a-zA-Z0-9._-]+$/;
13772
- /** A bracketed IPv6 literal, the only other authority form we emit. */
13773
- var IPV6_HOST = /^\[[0-9a-fA-F:.]+\]$/;
13774
- function defaultPortFor(scheme) {
13775
- return scheme === "https" ? 443 : 80;
13776
- }
13777
- /**
13778
- * Build the admin-page URL, or refuse by name.
13779
- *
13780
- * The refusal is never thrown: a provider answering "no page for this device"
13781
- * is an ordinary answer (`getAdminLink` → `null`), and a throw here would turn
13782
- * a missing host on one device into a failed query for the whole surface.
13783
- */
13784
- function buildDeviceAdminUrl(parts) {
13785
- const host = parts.host.trim();
13786
- if (host.length === 0) return {
13787
- ok: false,
13788
- reason: "empty-host"
13789
- };
13790
- if (host.includes("@")) return {
13791
- ok: false,
13792
- reason: "host-carries-userinfo"
13793
- };
13794
- if (!PLAIN_HOST.test(host) && !IPV6_HOST.test(host)) return {
13795
- ok: false,
13796
- reason: "host-not-plain"
13797
- };
13798
- if (parts.port !== null) {
13799
- if (!Number.isInteger(parts.port) || parts.port < 1 || parts.port > 65535) return {
13800
- ok: false,
13801
- reason: "port-out-of-range"
13802
- };
13803
- }
13804
- if (!parts.path.startsWith("/")) return {
13805
- ok: false,
13806
- reason: "path-not-absolute"
13807
- };
13808
- const query = parts.query ?? {};
13809
- for (const key of Object.keys(query)) if (CREDENTIAL_QUERY_KEYS.includes(key.toLowerCase())) return {
13810
- ok: false,
13811
- reason: "credential-query-key"
13812
- };
13813
- const authority = parts.port === null || parts.port === defaultPortFor(parts.scheme) ? host : `${host}:${String(parts.port)}`;
13814
- const search = new URLSearchParams();
13815
- for (const [key, value] of Object.entries(query)) search.append(key, value);
13816
- const suffix = search.size > 0 ? `?${search.toString()}` : "";
13817
- const url = `${parts.scheme}://${authority}${parts.path}${suffix}`;
13818
- if (CREDENTIAL_URL.test(url)) return {
13819
- ok: false,
13820
- reason: "userinfo-in-result"
13821
- };
13822
- return {
13823
- ok: true,
13824
- url
13825
- };
13826
- }
13827
- /**
13828
13765
  * `device-export` — collection cap for addons that export camstack
13829
13766
  * devices to external ecosystems (HomeAssistant via MQTT discovery,
13830
13767
  * HomeKit/HAP, Alexa Smart Home, …).
@@ -17092,6 +17029,7 @@ sub("presence", "sensor", "sensor", "#22c55e", "presence", "Presence");
17092
17029
  sub("enum-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "generic", "Sensor state");
17093
17030
  sub("device-event", "sensor", "sensor", "#10b981", "button", "Device event");
17094
17031
  sub("lock", "control", "control", "#0ea5e9", "lock", "Lock");
17032
+ sub("cover", "control", "control", "#0ea5e9", "door", "Cover");
17095
17033
  sub("switch", "control", "control", TAXONOMY_COLORS.control, "switch", "Switch");
17096
17034
  sub("siren", "control", "control", "#dc2626", "siren", "Siren");
17097
17035
  sub("button", "control", "control", "#10b981", "button", "Button");
@@ -17410,6 +17348,10 @@ var NcSystemEventKindSchema = _enum([
17410
17348
  "alarm-disarmed",
17411
17349
  "alarm-arming",
17412
17350
  "alarm-arm-refused",
17351
+ "alarm-pending",
17352
+ "alarm-rearmed",
17353
+ "alarm-sensor-bypass",
17354
+ "alarm-check-failed",
17413
17355
  "addon-updated",
17414
17356
  "server-updated",
17415
17357
  "export-completed",
@@ -18005,6 +17947,19 @@ var NcMediaFrameSchema = _enum([
18005
17947
  "full",
18006
17948
  "boxed"
18007
17949
  ]);
17950
+ /**
17951
+ * How a SENSOR notification shows the cameras that link the sensor.
17952
+ *
17953
+ * `mosaic` — one image composed of every linked camera's photograph, taken at
17954
+ * the trigger. `each` — one image per camera where the target takes several
17955
+ * attachments; a target that takes one keeps the first camera's (the degrade
17956
+ * engine drops the rest by order). Either way ONE notification per event.
17957
+ * Absent = `mosaic`, applied by the Notification Center and deliberately NOT
17958
+ * a Zod default (see NcRulePatchSchema: a default materialises on every
17959
+ * partial patch). Meaningless for a rule whose subject is not a sensor, and a
17960
+ * sensor linked to one camera ships that camera's plain snapshot either way.
17961
+ */
17962
+ var NcLinkedCameraModeSchema = _enum(["mosaic", "each"]);
18008
17963
  var NcMediaPolicySchema = object({
18009
17964
  attach: _enum([
18010
17965
  "best",
@@ -18050,7 +18005,9 @@ var NcMediaPolicySchema = object({
18050
18005
  * A profile that is not assigned falls back to the cheapest, and the render
18051
18006
  * reports which one actually ran.
18052
18007
  */
18053
- profile: CamProfileSchema.optional()
18008
+ profile: CamProfileSchema.optional(),
18009
+ /** See {@link NcLinkedCameraModeSchema}. */
18010
+ linkedCameras: NcLinkedCameraModeSchema.optional()
18054
18011
  });
18055
18012
  /**
18056
18013
  * Cooldown GRANULARITY over the subject's class — how much a fired
@@ -18170,7 +18127,7 @@ var NcRuleInputSchema = object({
18170
18127
  cooldownSec: 60,
18171
18128
  scope: "rule-device"
18172
18129
  }),
18173
- /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
18130
+ /** `{{var}}` title/body. The variables are declared in `NC_TEMPLATE_VARS` (@camstack/types) and depend on the rule kind — see `templateVarsFor`. */
18174
18131
  template: object({
18175
18132
  title: string().max(500).optional(),
18176
18133
  body: string().max(2e3).optional()
@@ -18350,6 +18307,22 @@ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
18350
18307
  throttle: NcThrottleSchema.optional(),
18351
18308
  priority: number().int().min(1).max(5).optional()
18352
18309
  });
18310
+ var NcRuleClearableKeySchema = _enum([
18311
+ "template",
18312
+ "schedule",
18313
+ "targetUsers",
18314
+ "snoozeOptions",
18315
+ "snoozeAllowGlobal",
18316
+ "waitForEnhancement",
18317
+ "actions",
18318
+ "confirm",
18319
+ "groupIdleSec"
18320
+ ]);
18321
+ var NcRuleUpdateInputSchema = object({
18322
+ ruleId: string(),
18323
+ patch: NcRulePatchSchema,
18324
+ clear: array(NcRuleClearableKeySchema).optional()
18325
+ });
18353
18326
  /** A persisted rule. */
18354
18327
  var NcRuleSchema = NcRuleInputSchema.extend({
18355
18328
  id: string(),
@@ -18381,6 +18354,85 @@ var NcTestResultSchema = object({
18381
18354
  className: string().optional(),
18382
18355
  label: string().optional()
18383
18356
  });
18357
+ /** The five rule kinds, as data. `NcRuleKind` in `notification/rule-kinds.ts`
18358
+ * is the same union; the template-vars spec pins the two together. */
18359
+ var NcRuleKindSchema = _enum([
18360
+ "detection",
18361
+ "sensor",
18362
+ "occupancy",
18363
+ "sound",
18364
+ "system"
18365
+ ]);
18366
+ /** Which producer renders a template: an ordinary rule, a timelapse, a digest. */
18367
+ var NcTemplateFamilySchema = _enum([
18368
+ "rule",
18369
+ "timelapse",
18370
+ "summary"
18371
+ ]);
18372
+ /** Which text field of that producer. `previewText` is the timelapse frame
18373
+ * caption, `captionText` the digest mosaic caption — both see fewer vars. */
18374
+ var NcTemplateFieldSchema = _enum([
18375
+ "title",
18376
+ "body",
18377
+ "previewText",
18378
+ "captionText"
18379
+ ]);
18380
+ var NcTemplateVarGroupSchema = _enum([
18381
+ "subject",
18382
+ "place",
18383
+ "time",
18384
+ "rule",
18385
+ "occupancy",
18386
+ "sound",
18387
+ "sensor",
18388
+ "system",
18389
+ "digest",
18390
+ "ai"
18391
+ ]);
18392
+ /**
18393
+ * ONE `{{var}}` a notification template may name.
18394
+ *
18395
+ * `families` / `fields` / `kinds` / `deliveries` / `systemEventKinds` say WHERE
18396
+ * it has a value; absent = no restriction on that axis. `systemEventKinds` is
18397
+ * read only for a `system` rule. `dynamic` declares a FAMILY of names
18398
+ * (`count_<class>`): the descriptor's `name` is the example member.
18399
+ */
18400
+ var NcTemplateVarDescriptorSchema = object({
18401
+ name: string().regex(/^\w+$/),
18402
+ label: string(),
18403
+ description: string().optional(),
18404
+ example: string(),
18405
+ group: NcTemplateVarGroupSchema,
18406
+ families: array(NcTemplateFamilySchema).min(1),
18407
+ fields: array(NcTemplateFieldSchema).optional(),
18408
+ kinds: array(NcRuleKindSchema).optional(),
18409
+ deliveries: array(NcDeliverySchema).optional(),
18410
+ systemEventKinds: array(NcSystemEventKindSchema).optional(),
18411
+ dynamic: object({
18412
+ prefix: literal("count_"),
18413
+ from: literal("classes")
18414
+ }).optional()
18415
+ });
18416
+ /** Input to `previewTemplate` — the editor's own context, plus the draft text. */
18417
+ var NcTemplatePreviewInputSchema = object({
18418
+ context: object({
18419
+ family: NcTemplateFamilySchema,
18420
+ field: NcTemplateFieldSchema,
18421
+ kind: NcRuleKindSchema.optional(),
18422
+ delivery: NcDeliverySchema.optional(),
18423
+ systemEventKinds: array(NcSystemEventKindSchema).optional()
18424
+ }),
18425
+ template: object({
18426
+ title: string().max(500).optional(),
18427
+ body: string().max(2e3).optional()
18428
+ })
18429
+ });
18430
+ var NcTemplatePreviewSchema = object({
18431
+ title: string().nullable(),
18432
+ body: string().nullable(),
18433
+ /** Names the template uses that this context never fills — they render empty. */
18434
+ unknown: array(string())
18435
+ });
18384
18436
  var NcConditionDescriptorSchema = object({
18385
18437
  /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
18386
18438
  id: string(),
@@ -18646,8 +18698,17 @@ object({
18646
18698
  lastAt: number()
18647
18699
  });
18648
18700
  /**
18649
- * The three durations the panel's state machine runs on, plus who hears about
18650
- * an arm.
18701
+ * The per-mode lists, at most one per mode. Two lists for one mode have no
18702
+ * meaning a reader could agree on (union? the last one?), so they are refused
18703
+ * at the boundary rather than interpreted.
18704
+ */
18705
+ var NcAlarmNonBlockingListSchema = array(object({
18706
+ mode: AlarmArmModeSchema,
18707
+ deviceIds: array(number().int()).max(200)
18708
+ })).max(8).refine((lists) => new Set(lists.map((l) => l.mode)).size === lists.length, { message: "nonBlocking: at most one list per arm mode" });
18709
+ /**
18710
+ * The three durations the panel's state machine runs on, who hears about its
18711
+ * transitions, and which openings each mode tolerates.
18651
18712
  *
18652
18713
  * They live on the NOTIFICATION-RULES cap, not on `alarm-panel`, on purpose:
18653
18714
  * `alarm-panel` is `deviceNative` and its other provider mirrors somebody
@@ -18666,21 +18727,39 @@ var NcAlarmSettingsSchema = object({
18666
18727
  * existed, and therefore what an untouched install keeps doing.
18667
18728
  */
18668
18729
  triggeredDurationSec: number().int().min(0).max(3600),
18669
- /** Send a notification when a mode takes effect. */
18670
- announceArm: boolean(),
18671
18730
  /**
18672
- * Where that notification goes. Target ids from `notification-output`.
18731
+ * Deprecated by D630 — every transition is announced. Parsed, never read;
18732
+ * remove after one release. Optional so an older admin's patch (which still
18733
+ * sends it) parses rather than failing the whole save.
18734
+ */
18735
+ announceArm: boolean().optional(),
18736
+ /**
18737
+ * Target ids from `notification-output`: every alarm transition goes here.
18673
18738
  *
18674
- * Explicit rather than "everyone": an arm announcement is a household
18739
+ * Explicit rather than "everyone": an alarm announcement is a household
18675
18740
  * message, and broadcasting it to every configured endpoint (including a
18676
18741
  * webhook wired to something else) is not a default anybody would choose.
18677
- * Empty with `announceArm: true` sends nothing, and the server logs that —
18678
- * silence must be attributable.
18742
+ * Empty sends nothing, and the server logs that — silence must be
18743
+ * attributable.
18744
+ */
18745
+ announceTargets: array(string().min(1)).max(16),
18746
+ /**
18747
+ * Per arm mode, the covered devices whose being OPEN does not refuse the
18748
+ * arm (a window left ajar for the cat under `home`, say). At most one entry
18749
+ * per mode is meaningful. Defaulted to `[]` so a blob stored before D630
18750
+ * parses as "every opening blocks" — the behaviour it was written under.
18679
18751
  */
18680
- announceTargets: array(string().min(1)).max(16)
18752
+ nonBlocking: NcAlarmNonBlockingListSchema.default([])
18681
18753
  });
18682
- /** Every field optional — a tab edits one control at a time. */
18683
- var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
18754
+ /**
18755
+ * Every field optional — a tab edits one control at a time.
18756
+ *
18757
+ * `nonBlocking` is re-declared WITHOUT its default: `.partial()` does not
18758
+ * remove an inner `.default()`, so a patch that never named the field would
18759
+ * parse to `nonBlocking: []` and wipe every mode's list on an unrelated edit
18760
+ * (the same trap {@link NcRulePatchSchema} documents).
18761
+ */
18762
+ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.extend({ nonBlocking: NcAlarmNonBlockingListSchema }).partial();
18684
18763
  /**
18685
18764
  * What one arm mode actually arms, DERIVED from the enabled rules gated on it.
18686
18765
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
@@ -18725,6 +18804,36 @@ var NcAlarmModeCoverageSchema = object({
18725
18804
  */
18726
18805
  skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
18727
18806
  });
18807
+ /** One covered device that reads open, and whether that refuses the arm. */
18808
+ var NcAlarmOpeningSchema = object({
18809
+ deviceId: number().int(),
18810
+ name: string(),
18811
+ /** The device's state word as read (`open`, `unlocked`, …). */
18812
+ state: string(),
18813
+ /** False when the mode's non-blocking list names this device. */
18814
+ blocking: boolean()
18815
+ });
18816
+ /** A device the panel is currently ignoring, and which side of it it is on. */
18817
+ var NcAlarmExclusionViewSchema = object({
18818
+ deviceId: number().int(),
18819
+ name: string(),
18820
+ phase: _enum(["open", "closed"])
18821
+ });
18822
+ /** One mode's openings: devices read open, plus those whose state is unknown. */
18823
+ var NcAlarmModeOpeningsSchema = object({
18824
+ mode: AlarmArmModeSchema,
18825
+ devices: array(NcAlarmOpeningSchema),
18826
+ /** Covered devices whose state could not be read (D49): neither open nor closed. */
18827
+ unknown: array(number().int())
18828
+ });
18829
+ var NcAlarmLiveSchema = object({
18830
+ state: AlarmStateSchema,
18831
+ /** The mode being armed into (exit delay) or held; null when disarmed. */
18832
+ targetMode: AlarmArmModeSchema.nullable(),
18833
+ availableModes: array(AlarmArmModeSchema),
18834
+ openings: array(NcAlarmModeOpeningsSchema),
18835
+ exclusions: array(NcAlarmExclusionViewSchema)
18836
+ });
18728
18837
  var NcAlarmConfigSchema = object({
18729
18838
  /**
18730
18839
  * The panel's device id, or null when this install has no panel (the ensure
@@ -18734,7 +18843,13 @@ var NcAlarmConfigSchema = object({
18734
18843
  */
18735
18844
  deviceId: number().int().nullable(),
18736
18845
  settings: NcAlarmSettingsSchema,
18737
- coverage: array(NcAlarmModeCoverageSchema)
18846
+ coverage: array(NcAlarmModeCoverageSchema),
18847
+ /**
18848
+ * The panel as it is NOW — state, what each mode would find open, what is
18849
+ * excluded. Optional: a panel-less hub answers without it, and a client
18850
+ * must not read its absence as "nothing is open".
18851
+ */
18852
+ live: NcAlarmLiveSchema.optional()
18738
18853
  });
18739
18854
  /**
18740
18855
  * ONE rule's demand on ONE camera's clip ring.
@@ -18782,10 +18897,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
18782
18897
  kind: "mutation",
18783
18898
  auth: "admin",
18784
18899
  caller: "required"
18785
- }), method(object({
18786
- ruleId: string(),
18787
- patch: NcRulePatchSchema
18788
- }), object({ rule: NcRuleSchema }), {
18900
+ }), method(NcRuleUpdateInputSchema, object({ rule: NcRuleSchema }), {
18789
18901
  kind: "mutation",
18790
18902
  auth: "admin",
18791
18903
  caller: "required"
@@ -18813,7 +18925,10 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
18813
18925
  }), method(object({}), object({
18814
18926
  catalog: array(NcConditionDescriptorSchema),
18815
18927
  taxonomy: NcTaxonomySchema.optional()
18816
- })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { 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 }), {
18928
+ })), method(object({}), object({ vars: array(NcTemplateVarDescriptorSchema) })), method(NcTemplatePreviewInputSchema, NcTemplatePreviewSchema, {
18929
+ kind: "mutation",
18930
+ access: "view"
18931
+ }), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { 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 }), {
18817
18932
  kind: "mutation",
18818
18933
  caller: "required"
18819
18934
  }), method(object({ snoozeId: string() }), object({ success: literal(true) }), {
@@ -23286,6 +23401,7 @@ var CAP_TO_KIND = {
23286
23401
  "enum-sensor": "enum-sensor",
23287
23402
  "event-emitter": "device-event",
23288
23403
  "lock-control": "lock",
23404
+ cover: "cover",
23289
23405
  switch: "switch",
23290
23406
  button: "button",
23291
23407
  doorbell: "doorbell"
@@ -24103,6 +24219,87 @@ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config:
24103
24219
  kind: "mutation",
24104
24220
  auth: "admin"
24105
24221
  });
24222
+ /**
24223
+ * The signals a device can emit to WAKE its own stream.
24224
+ *
24225
+ * A camera whose stream is built on demand sleeps until something asks for it,
24226
+ * and "something" cannot be a consumer that is merely attached — a Frigate-style
24227
+ * puller holds a session open for ever, and treating that as demand would keep
24228
+ * a battery camera awake for ever, which is the whole thing the battery is for
24229
+ * (D173). So the wake has to come from the CAMERA: an event it noticed by
24230
+ * itself, with no stream running.
24231
+ *
24232
+ * ## The vocabulary is the PROVIDER'S, not ours
24233
+ *
24234
+ * Like `consumables`, this cap declares no vocabulary of its own. A provider
24235
+ * names each signal with a `code` it chooses and a `label` an operator reads.
24236
+ * Reolink offers motion and camera-native detection; another provider may offer
24237
+ * a tamper, a doorbell press, a PIR, or something no camera in this fleet has
24238
+ * yet. A fixed enum here would mean every new signal is a framework release.
24239
+ *
24240
+ * It is deliberately NOT derived from the caps a device already binds. Whether
24241
+ * a camera CAN push firmware motion is expressed by `motionSources` containing
24242
+ * `'onboard'`, and whether it does AI on-camera by the `native-object-detection`
24243
+ * binding — but both answer "what drives the detection pipeline", which is a
24244
+ * different question from "what may wake a sleeping stream". A camera can do
24245
+ * the first and not be trusted with the second, and the operator picks per
24246
+ * camera. Two questions, two authorities.
24247
+ *
24248
+ * ## Availability is not permission
24249
+ *
24250
+ * `listSignals` says what the device CAN emit. Whether a given signal actually
24251
+ * wakes the stream is the operator's per-camera choice, held by the broker
24252
+ * alongside the cooldown — see the stream-broker cap's wake settings. A
24253
+ * provider declaring a signal is not a provider enabling it.
24254
+ */
24255
+ /** One signal a device can emit. */
24256
+ var StreamSignalSchema = object({
24257
+ /** Stable id chosen by the provider, e.g. `'motion'`, `'person'`, `'tamper'`. */
24258
+ code: string().min(1),
24259
+ /** What an operator reads in the picker. The provider's own wording. */
24260
+ label: string().min(1),
24261
+ /**
24262
+ * Whether the provider recommends this signal ON when a camera is first set
24263
+ * up. A provider knows which of its signals are cheap and reliable; an
24264
+ * operator should not have to discover that by trial. Reolink recommends
24265
+ * both of its own.
24266
+ */
24267
+ recommended: boolean()
24268
+ });
24269
+ var StreamSignalsStatusSchema = object({
24270
+ signals: array(StreamSignalSchema),
24271
+ lastFetchedAt: number()
24272
+ });
24273
+ var streamSignalsCapability = {
24274
+ name: "stream-signals",
24275
+ scope: "device",
24276
+ deviceNative: true,
24277
+ mode: "singleton",
24278
+ deviceTypes: Object.values(DeviceType),
24279
+ runtimeState: StreamSignalsStatusSchema,
24280
+ /**
24281
+ * Runtime-state durability: **session** — mirrored in RAM, never written.
24282
+ *
24283
+ * The slice holds what the DEVICE says it can emit. That is a probed fact,
24284
+ * not an operator choice: the provider re-declares it on every registration,
24285
+ * so losing it loses nothing and persisting it would freeze an answer the
24286
+ * camera is entitled to change. Measured the same day on the sibling case —
24287
+ * `native-object-detection.supportedClasses` was persisted, and a firmware
24288
+ * class the camera really detected stayed missing for the life of the row
24289
+ * because the fix could not reach it.
24290
+ *
24291
+ * See `RuntimeStateDurability`. Enforced by
24292
+ * `scripts/check-runtime-state-durability.ts`.
24293
+ */
24294
+ durability: "session",
24295
+ methods: {
24296
+ /**
24297
+ * What this device can emit. Empty is a valid and common answer — most
24298
+ * cameras have nothing to offer here, and an empty list is what makes the
24299
+ * broker's picker show nothing rather than a false choice.
24300
+ */
24301
+ listSignals: method(_void(), array(StreamSignalSchema).readonly()) }
24302
+ };
24106
24303
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
24107
24304
  var ProfileSettingsSchemaBridge = unknown().nullable();
24108
24305
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -24675,6 +24872,7 @@ _enum([
24675
24872
  "sleeping",
24676
24873
  "camera-refused",
24677
24874
  "no-keyframe",
24875
+ "decode-failed",
24678
24876
  "no-catalog-row",
24679
24877
  "unsupported",
24680
24878
  "unknown-device",
@@ -24949,6 +25147,32 @@ var ClipBytesSchema = object({
24949
25147
  durationMs: number().positive().optional()
24950
25148
  });
24951
25149
  /**
25150
+ * Where a clip's finished bytes can be TAKEN (D613) — the answer to
25151
+ * {@link videoclipsCapability.methods.offerClipBytes}.
25152
+ *
25153
+ * Everything {@link ClipBytesSchema} carries except the bytes themselves, plus
25154
+ * the one-shot ticket that leads to them. The metadata is answered BEFORE the
25155
+ * transfer on purpose: a consumer learns which twin it got, what to call the
25156
+ * file and how long the clip runs without having to read a byte, so a decision
25157
+ * it would make on that metadata (a wrong twin, an implausible duration) costs
25158
+ * no transfer at all.
25159
+ */
25160
+ var ClipBytesOfferSchema = object({
25161
+ /**
25162
+ * One shot, seconds-long, loopback, on the PROVIDER's own host. Open it with
25163
+ * `ctx.peerBytes.open(...)`, which refuses a ticket from another node by
25164
+ * name rather than dialling a port that means something else here.
25165
+ */
25166
+ ticket: PeerBytesTicketSchema,
25167
+ contentType: string(),
25168
+ /** Suggested filename, extension included. */
25169
+ name: string(),
25170
+ /** Which twin was actually served — see {@link ClipBytesSchema.served}. */
25171
+ served: CamProfileSchema,
25172
+ /** See {@link ClipBytesSchema.durationMs}. Absent when nothing measured it. */
25173
+ durationMs: number().positive().optional()
25174
+ });
25175
+ /**
24952
25176
  * Where a clip's STREAM can be dialled (D597) — the answer to
24953
25177
  * {@link videoclipsCapability.methods.dialClipStream}.
24954
25178
  *
@@ -25024,6 +25248,44 @@ var ClipStreamDialSchema = object({
25024
25248
  /** Why `servedAudio` is `none` although sound was asked for. */
25025
25249
  audioReason: ClipStreamAudioReasonSchema.optional()
25026
25250
  });
25251
+ /**
25252
+ * What a surface may DRAW for this provider's clips — the answer to
25253
+ * {@link videoclipsCapability.methods.getPlaybackOptions} (D612).
25254
+ *
25255
+ * The envelope is a PROVIDER fact, not a clip fact, and that is measured, not
25256
+ * assumed: the broker's `chooseClipPath` reads exactly two inputs — whether
25257
+ * `dialClipStream` and `readClipBytes` are wired — and both are constants of
25258
+ * the broker's own closure over the provider's methods. The `profile` it is
25259
+ * handed is explicitly not read. So every clip of a provider is served the
25260
+ * same way, and a per-clip channel carried a value that could not vary. The
25261
+ * per-clip `clipTransport` server message was removed for exactly that reason.
25262
+ *
25263
+ * Queried per camera, before a clip is picked, so a control is rendered or
25264
+ * DISABLED rather than offered and refused at play time (D62: a disabled
25265
+ * control reads as unavailable, one that undoes the gesture reads as broken).
25266
+ */
25267
+ var ClipPlaybackOptionsSchema = object({
25268
+ /**
25269
+ * How this provider's clips reach the player. `stream` is the provider's
25270
+ * forward-only fMP4 (D597); `file` is one bounded by-handle fetch of the
25271
+ * whole clip, `stbl` indexed (D575).
25272
+ */
25273
+ transport: _enum(["stream", "file"]),
25274
+ /** `forward` = only ahead of the playhead. `free` = anywhere. */
25275
+ seek: _enum(["forward", "free"]),
25276
+ /** Frame-step BACKWARD is meaningful. Forward always is. */
25277
+ stepBack: boolean(),
25278
+ /** Whether the scrub gesture is served, as opposed to refused by name. */
25279
+ scrub: boolean(),
25280
+ /**
25281
+ * The rates that can be delivered, ascending, always containing `1`. The
25282
+ * viewer draws its picker from this and from nothing else — a constant it
25283
+ * keeps instead is the second authority that produced the defect: `8` and
25284
+ * `16` were offered, the broker clamped them to `4`, and no line anywhere
25285
+ * said so. `0` is not a member: pause is the absence of a rate.
25286
+ */
25287
+ rates: array(number().positive()).min(1).readonly()
25288
+ });
25027
25289
  var ClipSourceAvailabilitySchema = object({
25028
25290
  state: _enum([
25029
25291
  "ok",
@@ -25183,6 +25445,29 @@ DeviceType.Camera, method(object({
25183
25445
  }), ClipBytesSchema, {
25184
25446
  kind: "query",
25185
25447
  auth: "protected"
25448
+ }), optionalMethod(object({
25449
+ deviceId: number(),
25450
+ clipId: string().min(1),
25451
+ /** WHICH provider holds the bytes — see `readClipBytes.provider`. */
25452
+ provider: string().min(1),
25453
+ /** Which twin — `low | mid` → the sub file, `high` → the main twin. */
25454
+ profile: CamProfileSchema.optional(),
25455
+ /**
25456
+ * The CALLER's byte bound, so an over-size clip is refused before the
25457
+ * camera is touched rather than after. Capped by
25458
+ * {@link VIDEOCLIPS_MAX_OFFER_BYTES} whatever is passed; absent means
25459
+ * that ceiling.
25460
+ */
25461
+ maxBytes: number().int().positive().optional(),
25462
+ /**
25463
+ * The operator's authorisation to wake a sleeping camera for this
25464
+ * read. Absent — the default — means a sleeping standalone battery
25465
+ * camera is REFUSED by name, before any session is opened.
25466
+ */
25467
+ wake: ClipWakeSchema.optional()
25468
+ }), ClipBytesOfferSchema, {
25469
+ kind: "query",
25470
+ auth: "protected"
25186
25471
  }), optionalMethod(object({
25187
25472
  deviceId: number(),
25188
25473
  clipId: string().min(1),
@@ -25204,6 +25489,15 @@ DeviceType.Camera, method(object({
25204
25489
  }), ClipStreamDialSchema, {
25205
25490
  kind: "query",
25206
25491
  auth: "protected"
25492
+ }), optionalMethod(object({
25493
+ deviceId: number(),
25494
+ /** WHICH provider to ask — the `addonId` a {@link ClipSourceSchema}
25495
+ * row carries. Required for the same reason `listClips` requires it:
25496
+ * a collection cap has no "the bound one" to resolve to (D554). */
25497
+ provider: string().min(1)
25498
+ }), ClipPlaybackOptionsSchema, {
25499
+ kind: "query",
25500
+ auth: "protected"
25207
25501
  });
25208
25502
  /**
25209
25503
  * Optional client-side hints sent at session creation to help the provider
@@ -26564,6 +26858,143 @@ DeviceType.Camera, method(object({ deviceId: number() }), CameraCredentialsSchem
26564
26858
  auth: "admin"
26565
26859
  });
26566
26860
  /**
26861
+ * camera-grid-layout — the geometry of a COMPOSITE camera, on the camera's own
26862
+ * page.
26863
+ *
26864
+ * ## Why this is a capability and not an addon settings schema
26865
+ *
26866
+ * It was one, and it did not render. The addon declared the editor as a
26867
+ * `type: 'widget'` field inside its own `deviceSettingsSchema()`; the hub
26868
+ * returned that section correctly and `ConfigFormField` renders `type:'widget'`
26869
+ * perfectly well — and nothing ever asked camera-grid for it. The Cluster →
26870
+ * Pipeline → Device Overrides page interrogates a HAND-WRITTEN list of four
26871
+ * addons (`PIPELINE_CLUSTER_DEVICE_ADDONS`), whose own comment says an addon
26872
+ * not on it "falls off silently".
26873
+ *
26874
+ * Adding a fifth name to that list would have been the wrong fix twice over:
26875
+ * that page is per-camera DETECTION tuning, and a grid's geometry belongs
26876
+ * beside PTZ and motion zones on the camera itself. The device page is
26877
+ * BINDING-driven (D12), so the way in is a capability bound to the device —
26878
+ * and this cap carries its section the way `recording` does, by RETURNING it
26879
+ * from `getDeviceSettingsContribution`.
26880
+ *
26881
+ * Seven other widgets are still declared the other way, through a
26882
+ * `deviceConfig.ui` block the framework derives a section from. That route
26883
+ * gives the addon no say in where its own panel lands and no way to decline
26884
+ * for a device the panel does not suit, which is why this one does not use it.
26885
+ *
26886
+ * ## Why one addon may implement it
26887
+ *
26888
+ * It is a device-scoped NATIVE cap, registered by the grid camera device
26889
+ * itself. Nothing else declares a composite camera, so nothing else has a
26890
+ * layout — and the device-scoped route means the widget asks THE camera, not
26891
+ * "the camera-grid addon", which is what let the old custom-action pair be
26892
+ * reached only by a caller that already knew the addon id.
26893
+ *
26894
+ * ## The tab
26895
+ *
26896
+ * `streaming`, not a top-tab of its own. A grid's geometry IS what its stream
26897
+ * is, so the Streaming tab is where it belongs; a `grid` top-tab would need an
26898
+ * entry in `WELL_KNOWN_TAB_MAP` or the device page renders the raw id as the
26899
+ * label (measured on the robot camera, 2026-09-06 — a tab called "navigation"
26900
+ * next to "PTZ").
26901
+ */
26902
+ /** A rectangle in normalized [0,1] coordinates of whatever contains it. */
26903
+ var GridNormalizedRectSchema = object({
26904
+ x: number().min(0).max(1),
26905
+ y: number().min(0).max(1),
26906
+ width: number().gt(0).max(1),
26907
+ height: number().gt(0).max(1)
26908
+ });
26909
+ /**
26910
+ * One source camera, the part of its picture taken, and where that part lands.
26911
+ *
26912
+ * Both rectangles are NORMALIZED (D519): a source camera can change resolution
26913
+ * — a profile switch, a firmware update, a substream that comes back different
26914
+ * — and a stored PIXEL rectangle would quietly start cutting the wrong region,
26915
+ * which is the class of bug nobody files.
26916
+ */
26917
+ var GridLayoutCellSchema = object({
26918
+ deviceId: number().int().positive(),
26919
+ /** The part of the SOURCE taken, normalized against the source. */
26920
+ source: GridNormalizedRectSchema,
26921
+ /** Where it lands, normalized against the CANVAS. */
26922
+ cell: GridNormalizedRectSchema
26923
+ });
26924
+ /**
26925
+ * Which profiles this grid can actually compose, and why not.
26926
+ *
26927
+ * A grid's `high` composes its sources' `high` and its `low` their `low`, so a
26928
+ * profile is on offer only when EVERY source can serve it. The refusal NAMES
26929
+ * the sources, because "this grid has no low" is not a finding — "615 has no
26930
+ * low" is, and it is the one an operator can act on.
26931
+ */
26932
+ var GridProfileOfferSchema = object({
26933
+ profile: _enum([
26934
+ "high",
26935
+ "mid",
26936
+ "low"
26937
+ ]),
26938
+ offered: boolean(),
26939
+ /** Sources that cannot serve it. Empty when it is offered, or when there are no cells. */
26940
+ missingSources: array(number().int().positive()),
26941
+ /**
26942
+ * The canvas this profile composes onto, `WxH`, or empty when it is not
26943
+ * offered. DERIVED from the cells and the sources' own size at this profile —
26944
+ * it is reported because nothing else in the system would ever say what the
26945
+ * grid came out as, and because it is the number an operator would otherwise
26946
+ * expect to type.
26947
+ */
26948
+ canvas: string(),
26949
+ /**
26950
+ * Whether this profile is PUBLISHED, of the ones the grid could serve.
26951
+ *
26952
+ * A grid's `high` is composed of its sources' `high`, so on a 4K fleet it is
26953
+ * a 4K canvas built from 4K decodes — something to opt into, not something a
26954
+ * viewer's adaptive should be handed by climbing to the top rung it can see.
26955
+ * Default is `mid` + `low`.
26956
+ */
26957
+ published: boolean()
26958
+ });
26959
+ var GridLayoutViewSchema = object({
26960
+ /** The persisted grid row this camera was declared from. */
26961
+ instanceId: string(),
26962
+ deviceId: number().int().nonnegative(),
26963
+ name: string(),
26964
+ /**
26965
+ * NO canvas size. A grid's resolution is not authored: each profile derives
26966
+ * its own from the cells and its sources' dimensions. The two numbers that
26967
+ * used to be here were a text field that silently decided both how much the
26968
+ * composite cost and how sharp it was — see `profiles[].canvas` for what it
26969
+ * came out as.
26970
+ */
26971
+ fps: number().int(),
26972
+ cells: array(GridLayoutCellSchema),
26973
+ /** What the catalog will publish, and what it refuses to. Read-only. */
26974
+ profiles: array(GridProfileOfferSchema)
26975
+ });
26976
+ var GridLayoutPatchSchema = object({
26977
+ deviceId: number().int().nonnegative(),
26978
+ name: string().min(1).max(160).optional(),
26979
+ fps: number().int().min(1).max(60).optional(),
26980
+ /** Which profiles to publish. See `GridProfileOffer.published`. */
26981
+ publishedProfiles: array(_enum([
26982
+ "high",
26983
+ "mid",
26984
+ "low"
26985
+ ])).max(3).optional(),
26986
+ /**
26987
+ * The whole cell list at once. A per-cell patch would need an ordering the
26988
+ * editor does not have, and a half-applied layout is a picture nobody asked
26989
+ * for.
26990
+ */
26991
+ cells: array(GridLayoutCellSchema).max(16)
26992
+ });
26993
+ DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), GridLayoutViewSchema.nullable(), { auth: "admin" }), method(GridLayoutPatchSchema, GridLayoutViewSchema, {
26994
+ kind: "mutation",
26995
+ auth: "admin"
26996
+ });
26997
+ /**
26567
26998
  * Carbon-monoxide alarm sensor. Drives Home Assistant `binary_sensor`
26568
26999
  * entries with `device_class: carbon_monoxide`. Push-driven.
26569
27000
  */
@@ -27366,346 +27797,6 @@ var dayNightCapability = {
27366
27797
  volatileStateFields: ["lastFetchedAt"]
27367
27798
  };
27368
27799
  /**
27369
- * Vendor-neutral **onboard** recording + storage cap — what the CAMERA
27370
- * writes to the CAMERA's own card, on the camera's own schedule.
27371
- *
27372
- * This is NOT `recording.cap.ts`. That one is CamStack's recorder: our
27373
- * footage ledger, our storage locations, our retention. This one has a
27374
- * different authority — the camera's firmware — and per D62 it stores
27375
- * nothing of its own. Every value here is read from the camera and every
27376
- * write goes back to the camera; there is no CamStack-side mirror that
27377
- * could disagree with the device.
27378
- *
27379
- * ## One shape, two firmwares
27380
- *
27381
- * Measured 2026-09-22 against the live fleet:
27382
- *
27383
- * | fact | Hikvision (ISAPI) | Reolink (Baichuan) |
27384
- * | --- | --- | --- |
27385
- * | storage | `ContentMgmt/Storage` `<hdd>` rows: status, capacity, freeSpace (MB) | `getHddInfoList` (cmd 102): `mount`, `format`, `capacity` GB + `capacityM` MB remainder |
27386
- * | tracks | several (101 **and** 103 on both 1436 and 3833), each with its own schedule | one per channel |
27387
- * | schedule | per track, 7 `ScheduleAction` blocks: DayOfWeek + TimeOfDay range + ONE `ActionRecordingMode` | per trigger type, a 168-char weekly HOUR mask |
27388
- * | triggers | `CMR`, `MOTION` | `Normal`, `MD`, `people`, `vehicle`, `dog_cat`, `crossline`, `intrude`, `loitering` |
27389
- * | pre-record | `PreRecordTimeSeconds` | `preRecordTime` |
27390
- * | post-record | `PostRecordTimeSeconds` | `recordDelayTime` |
27391
- * | overwrite | per track `LoopEnable` | `cycle`, with `cycleList` enumerating the accepted values |
27392
- * | segment length | not exposed on V5.7.1 | `packageTime` (minutes) |
27393
- *
27394
- * The two schedule models look different and are the same thing in
27395
- * different coordinates: both answer "for this trigger, during which
27396
- * weekly windows does the camera record". {@link RecordWindow} is that
27397
- * question in one shape — Hikvision's ranges map straight onto it,
27398
- * Reolink's mask expands into hour-aligned windows.
27399
- *
27400
- * ## Union, not intersection
27401
- *
27402
- * **The same fields exist on every camera.** What differs per device is
27403
- * which VALUES that device accepts, and that is what {@link
27404
- * RecordingOnboardOptions} reports — a `{ readable, writable, reason }`
27405
- * per field plus the schedule's own limits. A control a camera cannot
27406
- * honour is rendered DISABLED WITH ITS REASON, never missing and never
27407
- * dead: disabled must not look like broken.
27408
- *
27409
- * ## Refusal by name
27410
- *
27411
- * A write a camera cannot honour is refused with a sentence the operator
27412
- * can read — never accepted and dropped. Both providers refuse through
27413
- * {@link describeOnboardRefusal}, so the vocabulary is one function and
27414
- * one test, not two hand-written vendor opinions.
27415
- *
27416
- * Follows the D14 `deviceConfig` archetype (see `stream-params.cap.ts`):
27417
- * `getOptions` advertises per-camera availability, `getStatus` (auto-
27418
- * injected from `status`) reports the live values, and a single
27419
- * `setSettings` mutation applies a partial change. No hand-written
27420
- * settings-contribution methods.
27421
- */
27422
- /**
27423
- * What makes the camera start recording during a window.
27424
- *
27425
- * The union of both vendors' vocabularies. `continuous` is Hikvision's
27426
- * `CMR` and Reolink's `Normal`; `motion` is `MOTION` / `MD`. The
27427
- * object-class triggers are Reolink-only today and the smart-event ones
27428
- * (`lineCrossing`, `intrusion`, `loitering`) are Reolink-only on the
27429
- * firmwares measured — a camera that cannot record on a trigger simply
27430
- * does not list it in `options.schedule.triggers`, and a window naming
27431
- * it is REFUSED, not dropped.
27432
- */
27433
- var RecordTriggerSchema = _enum([
27434
- "continuous",
27435
- "motion",
27436
- "person",
27437
- "vehicle",
27438
- "animal",
27439
- "lineCrossing",
27440
- "intrusion",
27441
- "loitering",
27442
- "alarmInput"
27443
- ]);
27444
- /**
27445
- * One weekly recording window: "on `day`, from `startMinute` to
27446
- * `endMinute`, record on `trigger`".
27447
- *
27448
- * `day` is 0 = Monday … 6 = Sunday (ISO order, which is also the order
27449
- * both firmwares enumerate). Minutes are local camera time since
27450
- * midnight; `endMinute` may be 1440, meaning end of day — that is
27451
- * Hikvision's literal `24:00` and Reolink's 24th mask slot, and
27452
- * collapsing it to 0 would turn a whole-day window into an empty one.
27453
- */
27454
- var RecordWindowSchema = object({
27455
- trigger: RecordTriggerSchema,
27456
- day: number().int().min(0).max(6),
27457
- startMinute: number().int().min(0).max(1439),
27458
- endMinute: number().int().min(1).max(1440)
27459
- });
27460
- /** Status of one physical volume, as the camera itself describes it. */
27461
- var OnboardStorageVolumeSchema = object({
27462
- /** The camera's own id for the volume (`hdd/id`, Reolink `HddInfo/number`). */
27463
- id: string(),
27464
- /** The camera's own name for it, when it gives one (`hddName`). */
27465
- label: string().optional(),
27466
- status: _enum([
27467
- "ok",
27468
- "unformatted",
27469
- "error",
27470
- "offline",
27471
- "unknown"
27472
- ]),
27473
- /**
27474
- * Total size in MB, or **null when the camera did not say**.
27475
- *
27476
- * Never 0 for an unreadable value: a measurement that failed is not a
27477
- * measurement (D393), and a card whose size is unknown must not be
27478
- * rendered as a card of size zero.
27479
- */
27480
- capacityMb: number().nullable(),
27481
- /**
27482
- * Free space in MB, or null when unknown.
27483
- *
27484
- * **Not a proxy for "has footage".** Measured 2026-09-22: 1436 and
27485
- * 1439 both report exactly 11776 MB free — the fixed reserve a looping
27486
- * card converges on once it has wrapped. At loop steady state the
27487
- * number is identical whether the camera recorded yesterday or stopped
27488
- * a month ago.
27489
- */
27490
- freeMb: number().nullable(),
27491
- /** True when the camera reports the volume writable (`property` RW). */
27492
- writable: boolean().optional()
27493
- });
27494
- /**
27495
- * What the camera is doing with its own storage, right now.
27496
- *
27497
- * Every scalar is nullable and **null means the camera did not answer**,
27498
- * never a default. A form that seeds `0` from an unanswered read invites
27499
- * the operator to save that 0 back onto the camera.
27500
- */
27501
- var RecordingOnboardStatusSchema = object({
27502
- storage: discriminatedUnion("kind", [
27503
- object({
27504
- kind: literal("present"),
27505
- volumes: array(OnboardStorageVolumeSchema)
27506
- }),
27507
- object({
27508
- kind: literal("absent"),
27509
- reason: string()
27510
- }),
27511
- object({
27512
- kind: literal("unknown"),
27513
- reason: string()
27514
- })
27515
- ]),
27516
- tracks: array(object({
27517
- id: string(),
27518
- enabled: boolean(),
27519
- isVideo: boolean(),
27520
- /** From the camera's own track description. Null when it does not say. */
27521
- codec: string().nullable(),
27522
- resolution: string().nullable(),
27523
- /** Per-track overwrite flag, where the firmware keeps it per track. */
27524
- overwriteWhenFull: boolean().nullable()
27525
- })),
27526
- /**
27527
- * The track the write path targets — the enabled VIDEO one. Null when
27528
- * no track could be identified, which is itself a refusal reason.
27529
- */
27530
- primaryTrackId: string().nullable(),
27531
- /** Master "record to the card at all" switch. */
27532
- enabled: boolean().nullable(),
27533
- overwriteWhenFull: boolean().nullable(),
27534
- preRecordSec: number().nullable(),
27535
- postRecordSec: number().nullable(),
27536
- /** Length of one recorded file, in minutes. */
27537
- segmentMinutes: number().nullable(),
27538
- /** The primary track's weekly windows, flattened. */
27539
- windows: array(RecordWindowSchema),
27540
- /**
27541
- * How many windows the camera described that CamStack could NOT read —
27542
- * an unrecognised trigger, an unparseable clock, a weekday it does not
27543
- * name.
27544
- *
27545
- * A dropped window is work the reader threw away, and a schedule that
27546
- * silently shows fewer rows than the camera holds is how an operator
27547
- * saves back a schedule shorter than the one they were looking at
27548
- * (D391). Non-zero means the window list is INCOMPLETE and a write
27549
- * that replaces it would delete what was not shown — which is why a
27550
- * provider reporting a non-zero count also reports the schedule as not
27551
- * writable.
27552
- */
27553
- unreadableWindows: number(),
27554
- /**
27555
- * The camera is scheduled to record and has NO usable storage.
27556
- *
27557
- * A first-class fact because it is the fleet's most common silent
27558
- * defect: measured 2026-09-22, 1441 and 3831 are both motion-recording
27559
- * to a card that is not there. Neither the schedule nor the storage
27560
- * read says anything wrong on its own; only the pair does.
27561
- */
27562
- recordingToNowhere: boolean(),
27563
- lastFetchedAt: number()
27564
- });
27565
- /** Numeric range descriptor — `{ min, max, step }` per the getOptions convention. */
27566
- var RangeSchema = object({
27567
- min: number(),
27568
- max: number(),
27569
- step: number()
27570
- });
27571
- /**
27572
- * The values a camera actually takes for a numeric field, when they are a SET
27573
- * rather than a range.
27574
- *
27575
- * `{min,max,step}` cannot say what these two firmwares do. Measured on 1436
27576
- * (I91DN) on 2026-09-22 by writing each value and reading it back:
27577
- *
27578
- * - pre-record: `0, 5, 10, 15, 20, 25, 30` and `2147483647` (INT32_MAX, the
27579
- * camera's "no limit" — `-1` and `4294967295` both land on it);
27580
- * - post-record: `5, 10, 30, 60, 120, 300, 600`.
27581
- *
27582
- * Neither is expressible as a step: the first has a sentinel two billion away
27583
- * from its neighbours, the second doubles and then jumps. A range that tried
27584
- * would forbid values the camera takes AND permit values it silently replaces
27585
- * with 5 — wrong in both directions at once.
27586
- *
27587
- * `sentinel` names the member that is not a duration, so a surface can render
27588
- * "no limit" instead of `2147483647` seconds.
27589
- */
27590
- var AllowedValuesSchema = object({
27591
- values: array(number()).min(1),
27592
- sentinel: object({
27593
- value: number(),
27594
- meaning: _enum(["no-limit", "disabled"])
27595
- }).optional()
27596
- });
27597
- /**
27598
- * Per-field availability on ONE camera.
27599
- *
27600
- * The field exists on every camera — this says whether this one can be
27601
- * read and whether it can be written, and `reason` says why not when
27602
- * either is false. The UI renders the control DISABLED with the reason
27603
- * rather than hiding it, so a limitation is legible instead of looking
27604
- * like a missing feature.
27605
- */
27606
- var OnboardFieldSupportSchema = object({
27607
- readable: boolean(),
27608
- writable: boolean(),
27609
- /** Required whenever `readable` or `writable` is false. */
27610
- reason: string().optional()
27611
- });
27612
- /** What this camera's schedule model can express. */
27613
- var OnboardScheduleSupportSchema = object({
27614
- support: OnboardFieldSupportSchema,
27615
- /**
27616
- * The smallest time step the camera can express, in minutes.
27617
- *
27618
- * Hikvision takes arbitrary minutes (`00:05:00`–`23:57:00` observed on
27619
- * 1436's track 103). Reolink's schedule is a 7×24 HOUR mask, so 60. A
27620
- * window whose edges are not a multiple of this is REFUSED rather than
27621
- * quietly rounded — rounding is how an operator's 06:30 becomes 06:00
27622
- * and nothing says so.
27623
- */
27624
- granularityMinutes: number(),
27625
- /** Triggers this camera can record on. A window naming another is refused. */
27626
- triggers: array(RecordTriggerSchema),
27627
- /**
27628
- * False when the camera stores ONE trigger per time range, so two
27629
- * windows overlapping on the same day cannot carry different triggers.
27630
- * True on Reolink, whose mask is per-trigger and independent.
27631
- */
27632
- supportsOverlappingTriggers: boolean()
27633
- });
27634
- var RecordingOnboardOptionsSchema = object({
27635
- enabled: OnboardFieldSupportSchema,
27636
- overwriteWhenFull: OnboardFieldSupportSchema,
27637
- preRecordSec: OnboardFieldSupportSchema,
27638
- preRecordSecRange: RangeSchema.optional(),
27639
- /** Preferred over the range when the camera takes a SET, not a span. */
27640
- preRecordSecAllowed: AllowedValuesSchema.optional(),
27641
- postRecordSec: OnboardFieldSupportSchema,
27642
- postRecordSecRange: RangeSchema.optional(),
27643
- /** Preferred over the range when the camera takes a SET, not a span. */
27644
- postRecordSecAllowed: AllowedValuesSchema.optional(),
27645
- segmentMinutes: OnboardFieldSupportSchema,
27646
- segmentMinutesRange: RangeSchema.optional(),
27647
- /** Preferred over the range when the camera takes a SET, not a span. */
27648
- segmentMinutesAllowed: AllowedValuesSchema.optional(),
27649
- schedule: OnboardScheduleSupportSchema
27650
- });
27651
- /**
27652
- * A partial change. Every field optional.
27653
- *
27654
- * Unlike the other `deviceConfig` caps, a provider here does **NOT**
27655
- * silently ignore a field it cannot support — it refuses, by name,
27656
- * through {@link describeOnboardRefusal}. Silence on a recording setting
27657
- * is the failure D62 exists to prevent: the operator believes the camera
27658
- * is recording the way the form says, and it is not.
27659
- */
27660
- var RecordingOnboardPatchSchema = object({
27661
- enabled: boolean().optional(),
27662
- overwriteWhenFull: boolean().optional(),
27663
- preRecordSec: number().optional(),
27664
- postRecordSec: number().optional(),
27665
- segmentMinutes: number().optional(),
27666
- /** The complete new window set for the primary track — not a delta. */
27667
- windows: array(RecordWindowSchema).optional()
27668
- });
27669
- var recordingOnboardCapability = {
27670
- name: "recording-onboard",
27671
- scope: "device",
27672
- deviceNative: true,
27673
- mode: "singleton",
27674
- deviceTypes: [DeviceType.Camera],
27675
- deviceConfig: { ui: {
27676
- kind: "derived-form",
27677
- builderId: "recording-onboard",
27678
- tab: "recording"
27679
- } },
27680
- methods: {
27681
- getOptions: method(object({ deviceId: number() }), RecordingOnboardOptionsSchema),
27682
- setSettings: method(object({
27683
- deviceId: number(),
27684
- settings: RecordingOnboardPatchSchema
27685
- }), _void(), {
27686
- kind: "mutation",
27687
- auth: "admin"
27688
- })
27689
- },
27690
- status: {
27691
- schema: RecordingOnboardStatusSchema,
27692
- kind: "poll"
27693
- },
27694
- runtimeState: RecordingOnboardStatusSchema,
27695
- /**
27696
- * Runtime-state durability: **restored** — operator-set camera-side
27697
- * recording config; mutation-driven, and the storage half is the last
27698
- * thing the camera said about its own card.
27699
- *
27700
- * See `RuntimeStateDurability`. Enforced by
27701
- * `scripts/check-runtime-state-durability.ts`.
27702
- */
27703
- durability: "restored",
27704
- /** Clock fields: written, but excluded from the compare that decides
27705
- * whether persisting is worth a SQLite commit. */
27706
- volatileStateFields: ["lastFetchedAt"]
27707
- };
27708
- /**
27709
27800
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
27710
27801
  * for every device, regardless of provider — the kernel needs a uniform
27711
27802
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -27924,30 +28015,6 @@ var eventEmitterCapability = {
27924
28015
  */
27925
28016
  durability: "session"
27926
28017
  };
27927
- var EventItemSchema = object({
27928
- id: string(),
27929
- type: string(),
27930
- timestamp: number(),
27931
- label: string().optional(),
27932
- thumbnailUrl: string().optional(),
27933
- clipUrl: string().optional(),
27934
- metadata: record(string(), unknown()).optional()
27935
- });
27936
- DeviceType.Camera, method(object({
27937
- deviceId: number(),
27938
- from: number().optional(),
27939
- to: number().optional(),
27940
- limit: number().optional()
27941
- }), array(EventItemSchema)), method(object({
27942
- deviceId: number(),
27943
- eventId: string()
27944
- }), object({
27945
- base64: string(),
27946
- contentType: string()
27947
- }).nullable()), method(object({
27948
- deviceId: number(),
27949
- eventId: string()
27950
- }), string().nullable());
27951
28018
  var IdentitySchema = object({
27952
28019
  id: string(),
27953
28020
  name: string(),
@@ -30200,143 +30267,6 @@ var motionTriggerCapability = {
30200
30267
  durability: "session"
30201
30268
  };
30202
30269
  /**
30203
- * camera-grid-layout — the geometry of a COMPOSITE camera, on the camera's own
30204
- * page.
30205
- *
30206
- * ## Why this is a capability and not an addon settings schema
30207
- *
30208
- * It was one, and it did not render. The addon declared the editor as a
30209
- * `type: 'widget'` field inside its own `deviceSettingsSchema()`; the hub
30210
- * returned that section correctly and `ConfigFormField` renders `type:'widget'`
30211
- * perfectly well — and nothing ever asked camera-grid for it. The Cluster →
30212
- * Pipeline → Device Overrides page interrogates a HAND-WRITTEN list of four
30213
- * addons (`PIPELINE_CLUSTER_DEVICE_ADDONS`), whose own comment says an addon
30214
- * not on it "falls off silently".
30215
- *
30216
- * Adding a fifth name to that list would have been the wrong fix twice over:
30217
- * that page is per-camera DETECTION tuning, and a grid's geometry belongs
30218
- * beside PTZ and motion zones on the camera itself. The device page is
30219
- * BINDING-driven (D12), so the way in is a capability bound to the device —
30220
- * and this cap carries its section the way `recording` does, by RETURNING it
30221
- * from `getDeviceSettingsContribution`.
30222
- *
30223
- * Seven other widgets are still declared the other way, through a
30224
- * `deviceConfig.ui` block the framework derives a section from. That route
30225
- * gives the addon no say in where its own panel lands and no way to decline
30226
- * for a device the panel does not suit, which is why this one does not use it.
30227
- *
30228
- * ## Why one addon may implement it
30229
- *
30230
- * It is a device-scoped NATIVE cap, registered by the grid camera device
30231
- * itself. Nothing else declares a composite camera, so nothing else has a
30232
- * layout — and the device-scoped route means the widget asks THE camera, not
30233
- * "the camera-grid addon", which is what let the old custom-action pair be
30234
- * reached only by a caller that already knew the addon id.
30235
- *
30236
- * ## The tab
30237
- *
30238
- * `streaming`, not a top-tab of its own. A grid's geometry IS what its stream
30239
- * is, so the Streaming tab is where it belongs; a `grid` top-tab would need an
30240
- * entry in `WELL_KNOWN_TAB_MAP` or the device page renders the raw id as the
30241
- * label (measured on the robot camera, 2026-09-06 — a tab called "navigation"
30242
- * next to "PTZ").
30243
- */
30244
- /** A rectangle in normalized [0,1] coordinates of whatever contains it. */
30245
- var GridNormalizedRectSchema = object({
30246
- x: number().min(0).max(1),
30247
- y: number().min(0).max(1),
30248
- width: number().gt(0).max(1),
30249
- height: number().gt(0).max(1)
30250
- });
30251
- /**
30252
- * One source camera, the part of its picture taken, and where that part lands.
30253
- *
30254
- * Both rectangles are NORMALIZED (D519): a source camera can change resolution
30255
- * — a profile switch, a firmware update, a substream that comes back different
30256
- * — and a stored PIXEL rectangle would quietly start cutting the wrong region,
30257
- * which is the class of bug nobody files.
30258
- */
30259
- var GridLayoutCellSchema = object({
30260
- deviceId: number().int().positive(),
30261
- /** The part of the SOURCE taken, normalized against the source. */
30262
- source: GridNormalizedRectSchema,
30263
- /** Where it lands, normalized against the CANVAS. */
30264
- cell: GridNormalizedRectSchema
30265
- });
30266
- /**
30267
- * Which profiles this grid can actually compose, and why not.
30268
- *
30269
- * A grid's `high` composes its sources' `high` and its `low` their `low`, so a
30270
- * profile is on offer only when EVERY source can serve it. The refusal NAMES
30271
- * the sources, because "this grid has no low" is not a finding — "615 has no
30272
- * low" is, and it is the one an operator can act on.
30273
- */
30274
- var GridProfileOfferSchema = object({
30275
- profile: _enum([
30276
- "high",
30277
- "mid",
30278
- "low"
30279
- ]),
30280
- offered: boolean(),
30281
- /** Sources that cannot serve it. Empty when it is offered, or when there are no cells. */
30282
- missingSources: array(number().int().positive()),
30283
- /**
30284
- * The canvas this profile composes onto, `WxH`, or empty when it is not
30285
- * offered. DERIVED from the cells and the sources' own size at this profile —
30286
- * it is reported because nothing else in the system would ever say what the
30287
- * grid came out as, and because it is the number an operator would otherwise
30288
- * expect to type.
30289
- */
30290
- canvas: string(),
30291
- /**
30292
- * Whether this profile is PUBLISHED, of the ones the grid could serve.
30293
- *
30294
- * A grid's `high` is composed of its sources' `high`, so on a 4K fleet it is
30295
- * a 4K canvas built from 4K decodes — something to opt into, not something a
30296
- * viewer's adaptive should be handed by climbing to the top rung it can see.
30297
- * Default is `mid` + `low`.
30298
- */
30299
- published: boolean()
30300
- });
30301
- var GridLayoutViewSchema = object({
30302
- /** The persisted grid row this camera was declared from. */
30303
- instanceId: string(),
30304
- deviceId: number().int().nonnegative(),
30305
- name: string(),
30306
- /**
30307
- * NO canvas size. A grid's resolution is not authored: each profile derives
30308
- * its own from the cells and its sources' dimensions. The two numbers that
30309
- * used to be here were a text field that silently decided both how much the
30310
- * composite cost and how sharp it was — see `profiles[].canvas` for what it
30311
- * came out as.
30312
- */
30313
- fps: number().int(),
30314
- cells: array(GridLayoutCellSchema),
30315
- /** What the catalog will publish, and what it refuses to. Read-only. */
30316
- profiles: array(GridProfileOfferSchema)
30317
- });
30318
- var GridLayoutPatchSchema = object({
30319
- deviceId: number().int().nonnegative(),
30320
- name: string().min(1).max(160).optional(),
30321
- fps: number().int().min(1).max(60).optional(),
30322
- /** Which profiles to publish. See `GridProfileOffer.published`. */
30323
- publishedProfiles: array(_enum([
30324
- "high",
30325
- "mid",
30326
- "low"
30327
- ])).max(3).optional(),
30328
- /**
30329
- * The whole cell list at once. A per-cell patch would need an ordering the
30330
- * editor does not have, and a half-applied layout is a picture nobody asked
30331
- * for.
30332
- */
30333
- cells: array(GridLayoutCellSchema).max(16)
30334
- });
30335
- DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), GridLayoutViewSchema.nullable(), { auth: "admin" }), method(GridLayoutPatchSchema, GridLayoutViewSchema, {
30336
- kind: "mutation",
30337
- auth: "admin"
30338
- });
30339
- /**
30340
30270
  * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
30341
30271
  * on-camera motion-detection mask is a single `grid` region (a row-major
30342
30272
  * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
@@ -32699,37 +32629,37 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
32699
32629
  kind: "mutation",
32700
32630
  auth: "admin"
32701
32631
  });
32702
- /**
32703
- * `recording` cap — footage availability + HLS playback manifests + per-device
32704
- * recording config. NOTE on events (source of truth, R5/C3): this cap carries
32705
- * NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
32706
- * events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
32707
- * rows) and are the ONLY event surface — the recorder has none. The in-RAM
32708
- * playback markers it used to build were deleted on 2026-08-29 because nothing
32709
- * ever read them. Event<->footage joins are by time, padded with the shared
32710
- * `EVENT_PAD_MS` (`interfaces/recording-config.ts`).
32711
- */
32712
- var RecordingStatusSchema = object({
32713
- deviceId: number(),
32714
- enabled: boolean(),
32715
- /** THE derived storage mode, from the one definition
32716
- * (`deriveRecordingMode`) — never a second enum. A duplicated list is how
32717
- * `on-device-decision` could have reached the recorder and not the status. */
32718
- activeMode: RecordingStorageModeSchema,
32719
- nodeId: string(),
32720
- storageBytes: number()
32721
- });
32722
32632
  var RecordingRangeSchema = object({
32723
32633
  profile: string(),
32724
32634
  startMs: number(),
32725
32635
  endMs: number()
32726
32636
  });
32637
+ /**
32638
+ * How a source ANSWERED, on every singular read of this cap.
32639
+ *
32640
+ * `'read'` — it looked. `ranges: []` / `days: []` is then a real claim: this
32641
+ * source has no coverage in the window. `'unreadable'` — nobody could look
32642
+ * (the camera was unreachable, the calendar rung threw, the location is
32643
+ * unmounted, the node is still on the old build), and the emptiness beside it
32644
+ * means NOTHING.
32645
+ *
32646
+ * The batch rows have carried this since the grid existed; the SINGULAR
32647
+ * answers gained it with the collection (D625 §10.4), because they are the
32648
+ * ones the single-camera picker uses and because a half-converted fleet makes
32649
+ * "nobody looked" common for the length of a deploy. Without it the timeline
32650
+ * has no vocabulary for it, and `(data ?? [])` in a viewer turns a rollout into
32651
+ * a fleet of cameras that appear to have lost their recordings (D315, D393).
32652
+ */
32653
+ var RecordingReadSchema = _enum(["read", "unreadable"]);
32727
32654
  var RecordingAvailabilitySchema = object({
32728
32655
  deviceId: number(),
32656
+ /** See {@link RecordingReadSchema}. An `'unreadable'` answer carries an empty
32657
+ * `ranges` that means nothing — never draw it as "no footage". */
32658
+ read: RecordingReadSchema,
32729
32659
  ranges: array(RecordingRangeSchema),
32730
32660
  /**
32731
- * Every profile this camera has footage in — not only the one `ranges`
32732
- * describes (D433).
32661
+ * Every profile this camera has footage in AT THIS SOURCE — not only the one
32662
+ * `ranges` describes (D433).
32733
32663
  *
32734
32664
  * `ranges` answers for ONE profile by design: the timeline is a single bar,
32735
32665
  * and enumerating all of them triples the directory reads for a bar that
@@ -32746,15 +32676,285 @@ var RecordingAvailabilitySchema = object({
32746
32676
  });
32747
32677
  var RecordingDaysSchema = object({
32748
32678
  deviceId: number(),
32679
+ /** See {@link RecordingReadSchema}. `days: []` on an `'unreadable'` answer is
32680
+ * "nobody could look", and the date-picker must not spell it the same as
32681
+ * "no footage this month". */
32682
+ read: RecordingReadSchema,
32749
32683
  /** Local-midnight epochs (UTC ms) of days that have ≥1 recorded segment. */
32750
32684
  days: array(number())
32751
32685
  });
32686
+ var RecordingManifestSchema = object({
32687
+ deviceId: number(),
32688
+ /** Local filesystem path to the master playlist; null when no recording exists for the requested range. */
32689
+ localMasterPath: string().nullable(),
32690
+ /** HTTP(S) URL to the master playlist on the recording node's playback server
32691
+ * (the PRIMARY candidate); null when no recording / server. Carries the
32692
+ * scoped playback token in its path. */
32693
+ playbackUrl: string().nullable(),
32694
+ /**
32695
+ * Candidate master-playlist URLs the client tries in order (LAN first, then
32696
+ * remote — Tailscale/Cloudflare if the operator configured extra hosts), each
32697
+ * carrying the same scoped token. `playbackUrl` is the first entry. Empty when
32698
+ * there is no recording / server.
32699
+ */
32700
+ playbackEndpoints: array(string())
32701
+ });
32702
+ var RecordingSourceAvailabilitySchema = object({
32703
+ state: _enum([
32704
+ "ok",
32705
+ "sleeping",
32706
+ "unreachable",
32707
+ "no-storage",
32708
+ "index-empty"
32709
+ ]),
32710
+ /** Free text, shown verbatim. Names the camera's own refusal when there is one. */
32711
+ reason: string().optional(),
32712
+ /** When this source's coverage was last CONFIRMED. A cached answer is never
32713
+ * drawn as current: the surface shows the age whenever it is older than the
32714
+ * refresh interval. The clip catalog's `catalogAsOf`, under the name the
32715
+ * timeline uses for it. */
32716
+ coverageAsOf: number().optional()
32717
+ });
32718
+ /**
32719
+ * One SOURCE of recorded coverage for a camera — a row of the picker.
32720
+ *
32721
+ * A provider lists the sources IT serves for that device, and answers for each
32722
+ * of them whether it can answer at all. A provider with nothing to offer on a
32723
+ * camera returns `[]` — it is not that camera's business. The five availability
32724
+ * states are `ClipSourceAvailability`'s verbatim: they mean exactly the same
32725
+ * things about a coverage index as about a clip catalog, and `sleeping` in
32726
+ * particular is what stops a battery camera being woken to paint a bar.
32727
+ */
32728
+ var RecordingSourceSchema = object({
32729
+ /** The source id. {@link RECORDING_SOURCE_CAMSTACK} for ours (RESERVED), a
32730
+ * vendor namespace (`native:reolink:onboard`, …) for a camera's own store. */
32731
+ source: string(),
32732
+ /** Operator-facing name of the source ("CamStack recordings", "SD card"). */
32733
+ label: string(),
32734
+ /**
32735
+ * The addon that SERVES this row, and the value a later call passes as
32736
+ * `provider`.
32737
+ *
32738
+ * Optional for version skew only. The collection dispatcher stamps it from
32739
+ * the registry, so a row that travelled through the fan-out carries the
32740
+ * authoritative id whatever the provider filled in (D557 §4).
32741
+ */
32742
+ addonId: string().optional(),
32743
+ availability: RecordingSourceAvailabilitySchema
32744
+ });
32745
+ /**
32746
+ * What a surface may DRAW for this (camera, source) — D612's rule applied to a
32747
+ * timeline: **the source declares what it can do, and the surface draws what
32748
+ * was declared. It never assumes, and never offers a gesture it will then
32749
+ * refuse.** D612 exists because `8` and `16` were offered as clip rates, the
32750
+ * broker clamped them to `4`, and no line anywhere said so.
32751
+ *
32752
+ * Asked once per (camera, source) before anything is drawn — never replaced by
32753
+ * a constant the surface keeps, which is the second authority D612 ends.
32754
+ */
32755
+ var RecordingSourceOptionsSchema = object({
32756
+ /** How this source's media reaches the player.
32757
+ * `archive` = our own indexed segment tree; `stream` = the provider's
32758
+ * forward-only fMP4 (D597); `realtime` = a replay bound to wall clock. */
32759
+ transport: _enum([
32760
+ "archive",
32761
+ "stream",
32762
+ "realtime"
32763
+ ]),
32764
+ /** What the BAR means. `continuous` = gaps are holes in a recording;
32765
+ * `sparse` = gaps are the absence of one, and must be drawn as such.
32766
+ *
32767
+ * Not an onboard-only concession: measured 2026-09-24, OUR bar covers 98.8 %
32768
+ * of 592's day and 1.2 % of 1436's. It is a fact about a (source, camera)
32769
+ * pair, and ours answers it per camera from `deriveRecordingMode`. */
32770
+ coverage: _enum(["continuous", "sparse"]),
32771
+ /** Where the playhead may be put.
32772
+ * `free` — anywhere, to the frame.
32773
+ * `forward` — only ahead of the current position.
32774
+ * `segment` — a position SNAPS to the head of the covering segment; a finer
32775
+ * ask is accepted by the camera and SILENTLY IGNORED. Measured
32776
+ * on 1436 (Hikvision V5.7.1, 2026-09-23): a window-narrowed
32777
+ * `ContentMgmt/search` returns a row and a `playbackURI`, the
32778
+ * replay opens 200 and delivers media — and the burned-in OSD of
32779
+ * the first frame reads the SEGMENT HEAD every time. Calling
32780
+ * that `forward` would tell the surface it may move the playhead
32781
+ * ahead within a loaded segment, which it may not. */
32782
+ seek: _enum([
32783
+ "free",
32784
+ "forward",
32785
+ "segment"
32786
+ ]),
32787
+ /** Frame-step BACKWARD is meaningful. */
32788
+ stepBack: boolean(),
32789
+ /** Whether the drag-scrub gesture is served, as opposed to refused by name. */
32790
+ scrub: boolean(),
32791
+ /** Deliverable rates, ascending, always containing `1`. The surface draws its
32792
+ * picker from this and from NOTHING else (D612, D620, D621). `0` is not a
32793
+ * member: pause is the absence of a rate. */
32794
+ rates: array(number().positive()).min(1).readonly(),
32795
+ /** TRUE when a read of this source HOLDS the camera's only playback session.
32796
+ * A surface with this set makes at most ONE read at a time and draws no
32797
+ * scrub-thumbnail strip, no hover preview, no prefetch and no background
32798
+ * refresh. The precedent is exact and expensive: filling one screen of
32799
+ * Hikvision thumbnails at 1.01× realtime consumed fifteen minutes of that
32800
+ * camera's only playback session (1.2.126, reported within minutes), and a
32801
+ * timeline is a screenful of reads by construction. */
32802
+ exclusive: boolean()
32803
+ });
32804
+ /**
32805
+ * How to PLAY the instant that was asked for, from the chosen source.
32806
+ *
32807
+ * No new media transport is built for onboard sources: the `clip` arm is a
32808
+ * DELEGATION to the `videoclips` transport that vendor already has (D597 /
32809
+ * D616 / D617). The onboard half of this collection is a PROJECTION of
32810
+ * `videoclips` for coverage and a delegation to it for bytes.
32811
+ */
32812
+ var RecordingPlaybackSchema = discriminatedUnion("kind", [
32813
+ object({
32814
+ kind: literal("hls"),
32815
+ manifest: RecordingManifestSchema
32816
+ }),
32817
+ object({
32818
+ kind: literal("clip"),
32819
+ /** The `videoclips` source namespace this clip id belongs to. */
32820
+ source: string(),
32821
+ clipId: string(),
32822
+ /** Where this clip actually STARTS. On a `seek: 'segment'` source the
32823
+ * playhead lands here, not at the requested instant — the surface must be
32824
+ * TOLD, not left to discover it from a burned-in OSD. */
32825
+ startsAtMs: number()
32826
+ }),
32827
+ object({
32828
+ kind: literal("none"),
32829
+ reason: string()
32830
+ })
32831
+ ]);
32832
+ DeviceType.Camera, method(object({ deviceId: number() }), array(RecordingSourceSchema).readonly(), {
32833
+ kind: "query",
32834
+ auth: "protected"
32835
+ }), method(object({
32836
+ deviceId: number(),
32837
+ /**
32838
+ * WHICH provider to ask — the `addonId` a {@link RecordingSourceSchema}
32839
+ * row carries, never a source id and never a list. **REQUIRED**, in the
32840
+ * schema, where the generated types make it unomittable rather than
32841
+ * merely discouraged (D554 amended).
32842
+ *
32843
+ * It was learned the expensive way on `videoclips.listClips`: measured
32844
+ * on the live hub 2026-09-20, device 592 bound to `recorder` AND
32845
+ * `provider-reolink`, a bare call with `limit: 3` answered SIX rows,
32846
+ * three from each source, merged — `device-collection-dispatch.ts`
32847
+ * leaves an unpinned fan-out un-narrowed, so absence buys the union the
32848
+ * method exists not to be. An un-narrowed `getAvailability` would do
32849
+ * that to a TIMELINE: our ranges and the card's clips unioned into one
32850
+ * bar, which is "two sources are never drawn together" broken in the
32851
+ * one place it matters most.
32852
+ *
32853
+ * A provider the device is not bound to is refused BY NAME (D552's
32854
+ * `rejectUnresolvedAddonPin`), never answered by another one.
32855
+ */
32856
+ provider: string().min(1),
32857
+ fromMs: number(),
32858
+ toMs: number(),
32859
+ /**
32860
+ * Answer for THIS profile instead of the source's preferred one (D433).
32861
+ * Absent keeps the timeline's behaviour — one bar, one profile, one set
32862
+ * of reads. `profilesWithFootage` on the answer says what may be asked
32863
+ * for.
32864
+ */
32865
+ profile: string().optional()
32866
+ }), RecordingAvailabilitySchema, {
32867
+ kind: "query",
32868
+ auth: "protected"
32869
+ }), method(object({
32870
+ deviceId: number(),
32871
+ provider: string().min(1),
32872
+ fromMs: number(),
32873
+ toMs: number(),
32874
+ tzOffsetMinutes: number()
32875
+ }), RecordingDaysSchema, {
32876
+ kind: "query",
32877
+ auth: "protected"
32878
+ }), method(object({
32879
+ deviceId: number(),
32880
+ provider: string().min(1),
32881
+ fromMs: number(),
32882
+ toMs: number(),
32883
+ profile: CamProfileSchema.optional()
32884
+ }), RecordingPlaybackSchema, {
32885
+ kind: "query",
32886
+ auth: "protected"
32887
+ }), method(object({
32888
+ deviceId: number(),
32889
+ provider: string().min(1)
32890
+ }), RecordingSourceOptionsSchema, {
32891
+ kind: "query",
32892
+ auth: "protected"
32893
+ });
32894
+ /**
32895
+ * `recording-archive` — OUR archive, and the intent that fills it.
32896
+ *
32897
+ * The system-singleton half of the 2026-09-24 cut (D625). `recording` used to
32898
+ * be one 33-method system singleton holding two unrelated subjects: three
32899
+ * per-camera READS about coverage and playback, and everything else — storage
32900
+ * locations, retention, relocation, rebalance, the ops log, the placement
32901
+ * table and the byte-plane primitives our scrub and export are built on.
32902
+ *
32903
+ * The reads became a device-scoped COLLECTION, so a camera's own card can be a
32904
+ * source beside ours (`recording.cap.ts`). Everything that is about OUR store,
32905
+ * or unimplementable by a camera, stayed here.
32906
+ *
32907
+ * ## On the name
32908
+ *
32909
+ * `recording-storage` was the obvious choice and is wrong: this cap also holds
32910
+ * `getDeviceConfig`/`setDeviceConfig`, which are recording INTENT — bands,
32911
+ * retention, the D62 switch authority — and a name that says "storage" invites
32912
+ * the next reader to move them out again. An archive is a thing we keep, and
32913
+ * what we keep it under is a policy; the name covers both halves honestly and
32914
+ * sits in the existing family (`recording-onboard`, `recording-export`,
32915
+ * `recording-signal`).
32916
+ *
32917
+ * ## What must NOT happen to it
32918
+ *
32919
+ * It stays a SINGLETON. It is registered by `recorder`, which is
32920
+ * `placement: 'any-node'` and runs on every recording node; the hub dispatches
32921
+ * to one of them. Putting the ledger, the placement table or the relocation
32922
+ * jobs behind a fan-out is the one genuinely dangerous move in this cut.
32923
+ *
32924
+ * `getDeviceConfig` / `setDeviceConfig` in particular are the D62 recording
32925
+ * authority (`CameraSwitch.authority`). If a write reached a different provider
32926
+ * than the read — which a collection fan-out permits — two authorities would
32927
+ * decide when one camera records, and the symptom (recording silently off, or
32928
+ * a `bands` array clobbered by a partial write) is durable and silent. Keeping
32929
+ * them here means the worst case during a rollout is a 412: the switch refuses
32930
+ * to flip and SAYS so. **Do not move them into the collection, at any point,
32931
+ * for any reason.**
32932
+ *
32933
+ * ## The two batch reads
32934
+ *
32935
+ * `getAvailabilityBatch` / `getDaysWithRecordingsBatch` take `deviceIds:
32936
+ * number[]` with no single `deviceId`, and a device-scoped mount routes
32937
+ * through `getProviderForDevice(deviceId)` — there is nothing for it to route
32938
+ * on. They stay here, and on this cap the batch is explicitly OURS: a grid has
32939
+ * no per-camera picker, and a caller that wants another source's coverage asks
32940
+ * `recording.getAvailability` per device with that source's `provider`.
32941
+ */
32942
+ var RecordingStatusSchema = object({
32943
+ deviceId: number(),
32944
+ enabled: boolean(),
32945
+ /** THE derived storage mode, from the one definition
32946
+ * (`deriveRecordingMode`) — never a second enum. A duplicated list is how
32947
+ * `on-device-decision` could have reached the recorder and not the status. */
32948
+ activeMode: RecordingStorageModeSchema,
32949
+ nodeId: string(),
32950
+ storageBytes: number()
32951
+ });
32752
32952
  /**
32753
32953
  * One camera's row in a `getAvailabilityBatch` answer.
32754
32954
  *
32755
- * `ranges` is EXACTLY what `getAvailability` returns for that camera — the
32756
- * batch collapses the transport, not the work — plus the one thing the singular
32757
- * method never had to say:
32955
+ * `ranges` is EXACTLY what `recording.getAvailability` returns for that camera
32956
+ * at OUR source — the batch collapses the transport, not the work — plus the
32957
+ * `read` mark the singular answer now carries too (D625):
32758
32958
  *
32759
32959
  * - `read: 'read'` — answered. `ranges: []` means "read, and this camera has
32760
32960
  * no footage in the window", which is a real claim.
@@ -32786,22 +32986,6 @@ var RecordingDaysForDeviceSchema = object({
32786
32986
  /** Local-midnight epochs (UTC ms) of days that have ≥1 recorded segment. */
32787
32987
  days: array(number()).readonly()
32788
32988
  });
32789
- var RecordingManifestSchema = object({
32790
- deviceId: number(),
32791
- /** Local filesystem path to the master playlist; null when no recording exists for the requested range. */
32792
- localMasterPath: string().nullable(),
32793
- /** HTTP(S) URL to the master playlist on the recording node's playback server
32794
- * (the PRIMARY candidate); null when no recording / server. Carries the
32795
- * scoped playback token in its path. */
32796
- playbackUrl: string().nullable(),
32797
- /**
32798
- * Candidate master-playlist URLs the client tries in order (LAN first, then
32799
- * remote — Tailscale/Cloudflare if the operator configured extra hosts), each
32800
- * carrying the same scoped token. `playbackUrl` is the first entry. Empty when
32801
- * there is no recording / server.
32802
- */
32803
- playbackEndpoints: array(string())
32804
- });
32805
32989
  /**
32806
32990
  * Recording storage usage for one camera — what the ARCHIVE holds for it,
32807
32991
  * across every profile and every resolvable location on this node.
@@ -33060,34 +33244,12 @@ var ReadWindowBytesResultSchema = discriminatedUnion("kind", [object({
33060
33244
  segmentEndMs: number()
33061
33245
  })]);
33062
33246
  method(object({
33063
- deviceId: number(),
33064
- fromMs: number(),
33065
- toMs: number(),
33066
- /**
33067
- * Answer for THIS profile instead of the preferred one (D433). Absent
33068
- * keeps the timeline's behaviour — one bar, one profile, one set of
33069
- * reads. `profilesWithFootage` on the answer says what may be asked
33070
- * for.
33071
- */
33072
- profile: string().optional()
33073
- }), RecordingAvailabilitySchema, {
33074
- kind: "query",
33075
- auth: "protected"
33076
- }), method(object({
33077
33247
  deviceIds: array(number()).min(1).max(200),
33078
33248
  fromMs: number(),
33079
33249
  toMs: number()
33080
33250
  }), array(RecordingAvailabilityForDeviceSchema).readonly(), {
33081
33251
  kind: "query",
33082
33252
  auth: "protected"
33083
- }), method(object({
33084
- deviceId: number(),
33085
- fromMs: number(),
33086
- toMs: number(),
33087
- tzOffsetMinutes: number()
33088
- }), RecordingDaysSchema, {
33089
- kind: "query",
33090
- auth: "protected"
33091
33253
  }), method(object({
33092
33254
  deviceIds: array(number()).min(1).max(200),
33093
33255
  fromMs: number(),
@@ -33096,13 +33258,6 @@ method(object({
33096
33258
  }), array(RecordingDaysForDeviceSchema).readonly(), {
33097
33259
  kind: "query",
33098
33260
  auth: "protected"
33099
- }), method(object({
33100
- deviceId: number(),
33101
- fromMs: number(),
33102
- toMs: number()
33103
- }), RecordingManifestSchema, {
33104
- kind: "query",
33105
- auth: "protected"
33106
33261
  }), method(object({}), RecordingStorageUsageSchema, {
33107
33262
  kind: "query",
33108
33263
  auth: "admin"
@@ -33550,6 +33705,346 @@ method(object({
33550
33705
  auth: "protected"
33551
33706
  });
33552
33707
  /**
33708
+ * Vendor-neutral **onboard** recording + storage cap — what the CAMERA
33709
+ * writes to the CAMERA's own card, on the camera's own schedule.
33710
+ *
33711
+ * This is NOT `recording.cap.ts`. That one is CamStack's recorder: our
33712
+ * footage ledger, our storage locations, our retention. This one has a
33713
+ * different authority — the camera's firmware — and per D62 it stores
33714
+ * nothing of its own. Every value here is read from the camera and every
33715
+ * write goes back to the camera; there is no CamStack-side mirror that
33716
+ * could disagree with the device.
33717
+ *
33718
+ * ## One shape, two firmwares
33719
+ *
33720
+ * Measured 2026-09-22 against the live fleet:
33721
+ *
33722
+ * | fact | Hikvision (ISAPI) | Reolink (Baichuan) |
33723
+ * | --- | --- | --- |
33724
+ * | storage | `ContentMgmt/Storage` `<hdd>` rows: status, capacity, freeSpace (MB) | `getHddInfoList` (cmd 102): `mount`, `format`, `capacity` GB + `capacityM` MB remainder |
33725
+ * | tracks | several (101 **and** 103 on both 1436 and 3833), each with its own schedule | one per channel |
33726
+ * | schedule | per track, 7 `ScheduleAction` blocks: DayOfWeek + TimeOfDay range + ONE `ActionRecordingMode` | per trigger type, a 168-char weekly HOUR mask |
33727
+ * | triggers | `CMR`, `MOTION` | `Normal`, `MD`, `people`, `vehicle`, `dog_cat`, `crossline`, `intrude`, `loitering` |
33728
+ * | pre-record | `PreRecordTimeSeconds` | `preRecordTime` |
33729
+ * | post-record | `PostRecordTimeSeconds` | `recordDelayTime` |
33730
+ * | overwrite | per track `LoopEnable` | `cycle`, with `cycleList` enumerating the accepted values |
33731
+ * | segment length | not exposed on V5.7.1 | `packageTime` (minutes) |
33732
+ *
33733
+ * The two schedule models look different and are the same thing in
33734
+ * different coordinates: both answer "for this trigger, during which
33735
+ * weekly windows does the camera record". {@link RecordWindow} is that
33736
+ * question in one shape — Hikvision's ranges map straight onto it,
33737
+ * Reolink's mask expands into hour-aligned windows.
33738
+ *
33739
+ * ## Union, not intersection
33740
+ *
33741
+ * **The same fields exist on every camera.** What differs per device is
33742
+ * which VALUES that device accepts, and that is what {@link
33743
+ * RecordingOnboardOptions} reports — a `{ readable, writable, reason }`
33744
+ * per field plus the schedule's own limits. A control a camera cannot
33745
+ * honour is rendered DISABLED WITH ITS REASON, never missing and never
33746
+ * dead: disabled must not look like broken.
33747
+ *
33748
+ * ## Refusal by name
33749
+ *
33750
+ * A write a camera cannot honour is refused with a sentence the operator
33751
+ * can read — never accepted and dropped. Both providers refuse through
33752
+ * {@link describeOnboardRefusal}, so the vocabulary is one function and
33753
+ * one test, not two hand-written vendor opinions.
33754
+ *
33755
+ * Follows the D14 `deviceConfig` archetype (see `stream-params.cap.ts`):
33756
+ * `getOptions` advertises per-camera availability, `getStatus` (auto-
33757
+ * injected from `status`) reports the live values, and a single
33758
+ * `setSettings` mutation applies a partial change. No hand-written
33759
+ * settings-contribution methods.
33760
+ */
33761
+ /**
33762
+ * What makes the camera start recording during a window.
33763
+ *
33764
+ * The union of both vendors' vocabularies. `continuous` is Hikvision's
33765
+ * `CMR` and Reolink's `Normal`; `motion` is `MOTION` / `MD`. The
33766
+ * object-class triggers are Reolink-only today and the smart-event ones
33767
+ * (`lineCrossing`, `intrusion`, `loitering`) are Reolink-only on the
33768
+ * firmwares measured — a camera that cannot record on a trigger simply
33769
+ * does not list it in `options.schedule.triggers`, and a window naming
33770
+ * it is REFUSED, not dropped.
33771
+ */
33772
+ var RecordTriggerSchema = _enum([
33773
+ "continuous",
33774
+ "motion",
33775
+ "person",
33776
+ "vehicle",
33777
+ "animal",
33778
+ "lineCrossing",
33779
+ "intrusion",
33780
+ "loitering",
33781
+ "alarmInput"
33782
+ ]);
33783
+ /**
33784
+ * One weekly recording window: "on `day`, from `startMinute` to
33785
+ * `endMinute`, record on `trigger`".
33786
+ *
33787
+ * `day` is 0 = Monday … 6 = Sunday (ISO order, which is also the order
33788
+ * both firmwares enumerate). Minutes are local camera time since
33789
+ * midnight; `endMinute` may be 1440, meaning end of day — that is
33790
+ * Hikvision's literal `24:00` and Reolink's 24th mask slot, and
33791
+ * collapsing it to 0 would turn a whole-day window into an empty one.
33792
+ */
33793
+ var RecordWindowSchema = object({
33794
+ trigger: RecordTriggerSchema,
33795
+ day: number().int().min(0).max(6),
33796
+ startMinute: number().int().min(0).max(1439),
33797
+ endMinute: number().int().min(1).max(1440)
33798
+ });
33799
+ /** Status of one physical volume, as the camera itself describes it. */
33800
+ var OnboardStorageVolumeSchema = object({
33801
+ /** The camera's own id for the volume (`hdd/id`, Reolink `HddInfo/number`). */
33802
+ id: string(),
33803
+ /** The camera's own name for it, when it gives one (`hddName`). */
33804
+ label: string().optional(),
33805
+ status: _enum([
33806
+ "ok",
33807
+ "unformatted",
33808
+ "error",
33809
+ "offline",
33810
+ "unknown"
33811
+ ]),
33812
+ /**
33813
+ * Total size in MB, or **null when the camera did not say**.
33814
+ *
33815
+ * Never 0 for an unreadable value: a measurement that failed is not a
33816
+ * measurement (D393), and a card whose size is unknown must not be
33817
+ * rendered as a card of size zero.
33818
+ */
33819
+ capacityMb: number().nullable(),
33820
+ /**
33821
+ * Free space in MB, or null when unknown.
33822
+ *
33823
+ * **Not a proxy for "has footage".** Measured 2026-09-22: 1436 and
33824
+ * 1439 both report exactly 11776 MB free — the fixed reserve a looping
33825
+ * card converges on once it has wrapped. At loop steady state the
33826
+ * number is identical whether the camera recorded yesterday or stopped
33827
+ * a month ago.
33828
+ */
33829
+ freeMb: number().nullable(),
33830
+ /** True when the camera reports the volume writable (`property` RW). */
33831
+ writable: boolean().optional()
33832
+ });
33833
+ /**
33834
+ * What the camera is doing with its own storage, right now.
33835
+ *
33836
+ * Every scalar is nullable and **null means the camera did not answer**,
33837
+ * never a default. A form that seeds `0` from an unanswered read invites
33838
+ * the operator to save that 0 back onto the camera.
33839
+ */
33840
+ var RecordingOnboardStatusSchema = object({
33841
+ storage: discriminatedUnion("kind", [
33842
+ object({
33843
+ kind: literal("present"),
33844
+ volumes: array(OnboardStorageVolumeSchema)
33845
+ }),
33846
+ object({
33847
+ kind: literal("absent"),
33848
+ reason: string()
33849
+ }),
33850
+ object({
33851
+ kind: literal("unknown"),
33852
+ reason: string()
33853
+ })
33854
+ ]),
33855
+ tracks: array(object({
33856
+ id: string(),
33857
+ enabled: boolean(),
33858
+ isVideo: boolean(),
33859
+ /** From the camera's own track description. Null when it does not say. */
33860
+ codec: string().nullable(),
33861
+ resolution: string().nullable(),
33862
+ /** Per-track overwrite flag, where the firmware keeps it per track. */
33863
+ overwriteWhenFull: boolean().nullable()
33864
+ })),
33865
+ /**
33866
+ * The track the write path targets — the enabled VIDEO one. Null when
33867
+ * no track could be identified, which is itself a refusal reason.
33868
+ */
33869
+ primaryTrackId: string().nullable(),
33870
+ /** Master "record to the card at all" switch. */
33871
+ enabled: boolean().nullable(),
33872
+ overwriteWhenFull: boolean().nullable(),
33873
+ preRecordSec: number().nullable(),
33874
+ postRecordSec: number().nullable(),
33875
+ /** Length of one recorded file, in minutes. */
33876
+ segmentMinutes: number().nullable(),
33877
+ /** The primary track's weekly windows, flattened. */
33878
+ windows: array(RecordWindowSchema),
33879
+ /**
33880
+ * How many windows the camera described that CamStack could NOT read —
33881
+ * an unrecognised trigger, an unparseable clock, a weekday it does not
33882
+ * name.
33883
+ *
33884
+ * A dropped window is work the reader threw away, and a schedule that
33885
+ * silently shows fewer rows than the camera holds is how an operator
33886
+ * saves back a schedule shorter than the one they were looking at
33887
+ * (D391). Non-zero means the window list is INCOMPLETE and a write
33888
+ * that replaces it would delete what was not shown — which is why a
33889
+ * provider reporting a non-zero count also reports the schedule as not
33890
+ * writable.
33891
+ */
33892
+ unreadableWindows: number(),
33893
+ /**
33894
+ * The camera is scheduled to record and has NO usable storage.
33895
+ *
33896
+ * A first-class fact because it is the fleet's most common silent
33897
+ * defect: measured 2026-09-22, 1441 and 3831 are both motion-recording
33898
+ * to a card that is not there. Neither the schedule nor the storage
33899
+ * read says anything wrong on its own; only the pair does.
33900
+ */
33901
+ recordingToNowhere: boolean(),
33902
+ lastFetchedAt: number()
33903
+ });
33904
+ /** Numeric range descriptor — `{ min, max, step }` per the getOptions convention. */
33905
+ var RangeSchema = object({
33906
+ min: number(),
33907
+ max: number(),
33908
+ step: number()
33909
+ });
33910
+ /**
33911
+ * The values a camera actually takes for a numeric field, when they are a SET
33912
+ * rather than a range.
33913
+ *
33914
+ * `{min,max,step}` cannot say what these two firmwares do. Measured on 1436
33915
+ * (I91DN) on 2026-09-22 by writing each value and reading it back:
33916
+ *
33917
+ * - pre-record: `0, 5, 10, 15, 20, 25, 30` and `2147483647` (INT32_MAX, the
33918
+ * camera's "no limit" — `-1` and `4294967295` both land on it);
33919
+ * - post-record: `5, 10, 30, 60, 120, 300, 600`.
33920
+ *
33921
+ * Neither is expressible as a step: the first has a sentinel two billion away
33922
+ * from its neighbours, the second doubles and then jumps. A range that tried
33923
+ * would forbid values the camera takes AND permit values it silently replaces
33924
+ * with 5 — wrong in both directions at once.
33925
+ *
33926
+ * `sentinel` names the member that is not a duration, so a surface can render
33927
+ * "no limit" instead of `2147483647` seconds.
33928
+ */
33929
+ var AllowedValuesSchema = object({
33930
+ values: array(number()).min(1),
33931
+ sentinel: object({
33932
+ value: number(),
33933
+ meaning: _enum(["no-limit", "disabled"])
33934
+ }).optional()
33935
+ });
33936
+ /**
33937
+ * Per-field availability on ONE camera.
33938
+ *
33939
+ * The field exists on every camera — this says whether this one can be
33940
+ * read and whether it can be written, and `reason` says why not when
33941
+ * either is false. The UI renders the control DISABLED with the reason
33942
+ * rather than hiding it, so a limitation is legible instead of looking
33943
+ * like a missing feature.
33944
+ */
33945
+ var OnboardFieldSupportSchema = object({
33946
+ readable: boolean(),
33947
+ writable: boolean(),
33948
+ /** Required whenever `readable` or `writable` is false. */
33949
+ reason: string().optional()
33950
+ });
33951
+ /** What this camera's schedule model can express. */
33952
+ var OnboardScheduleSupportSchema = object({
33953
+ support: OnboardFieldSupportSchema,
33954
+ /**
33955
+ * The smallest time step the camera can express, in minutes.
33956
+ *
33957
+ * Hikvision takes arbitrary minutes (`00:05:00`–`23:57:00` observed on
33958
+ * 1436's track 103). Reolink's schedule is a 7×24 HOUR mask, so 60. A
33959
+ * window whose edges are not a multiple of this is REFUSED rather than
33960
+ * quietly rounded — rounding is how an operator's 06:30 becomes 06:00
33961
+ * and nothing says so.
33962
+ */
33963
+ granularityMinutes: number(),
33964
+ /** Triggers this camera can record on. A window naming another is refused. */
33965
+ triggers: array(RecordTriggerSchema),
33966
+ /**
33967
+ * False when the camera stores ONE trigger per time range, so two
33968
+ * windows overlapping on the same day cannot carry different triggers.
33969
+ * True on Reolink, whose mask is per-trigger and independent.
33970
+ */
33971
+ supportsOverlappingTriggers: boolean()
33972
+ });
33973
+ var RecordingOnboardOptionsSchema = object({
33974
+ enabled: OnboardFieldSupportSchema,
33975
+ overwriteWhenFull: OnboardFieldSupportSchema,
33976
+ preRecordSec: OnboardFieldSupportSchema,
33977
+ preRecordSecRange: RangeSchema.optional(),
33978
+ /** Preferred over the range when the camera takes a SET, not a span. */
33979
+ preRecordSecAllowed: AllowedValuesSchema.optional(),
33980
+ postRecordSec: OnboardFieldSupportSchema,
33981
+ postRecordSecRange: RangeSchema.optional(),
33982
+ /** Preferred over the range when the camera takes a SET, not a span. */
33983
+ postRecordSecAllowed: AllowedValuesSchema.optional(),
33984
+ segmentMinutes: OnboardFieldSupportSchema,
33985
+ segmentMinutesRange: RangeSchema.optional(),
33986
+ /** Preferred over the range when the camera takes a SET, not a span. */
33987
+ segmentMinutesAllowed: AllowedValuesSchema.optional(),
33988
+ schedule: OnboardScheduleSupportSchema
33989
+ });
33990
+ /**
33991
+ * A partial change. Every field optional.
33992
+ *
33993
+ * Unlike the other `deviceConfig` caps, a provider here does **NOT**
33994
+ * silently ignore a field it cannot support — it refuses, by name,
33995
+ * through {@link describeOnboardRefusal}. Silence on a recording setting
33996
+ * is the failure D62 exists to prevent: the operator believes the camera
33997
+ * is recording the way the form says, and it is not.
33998
+ */
33999
+ var RecordingOnboardPatchSchema = object({
34000
+ enabled: boolean().optional(),
34001
+ overwriteWhenFull: boolean().optional(),
34002
+ preRecordSec: number().optional(),
34003
+ postRecordSec: number().optional(),
34004
+ segmentMinutes: number().optional(),
34005
+ /** The complete new window set for the primary track — not a delta. */
34006
+ windows: array(RecordWindowSchema).optional()
34007
+ });
34008
+ var recordingOnboardCapability = {
34009
+ name: "recording-onboard",
34010
+ scope: "device",
34011
+ deviceNative: true,
34012
+ mode: "singleton",
34013
+ deviceTypes: [DeviceType.Camera],
34014
+ deviceConfig: { ui: {
34015
+ kind: "derived-form",
34016
+ builderId: "recording-onboard",
34017
+ tab: "recording"
34018
+ } },
34019
+ methods: {
34020
+ getOptions: method(object({ deviceId: number() }), RecordingOnboardOptionsSchema),
34021
+ setSettings: method(object({
34022
+ deviceId: number(),
34023
+ settings: RecordingOnboardPatchSchema
34024
+ }), _void(), {
34025
+ kind: "mutation",
34026
+ auth: "admin"
34027
+ })
34028
+ },
34029
+ status: {
34030
+ schema: RecordingOnboardStatusSchema,
34031
+ kind: "poll"
34032
+ },
34033
+ runtimeState: RecordingOnboardStatusSchema,
34034
+ /**
34035
+ * Runtime-state durability: **restored** — operator-set camera-side
34036
+ * recording config; mutation-driven, and the storage half is the last
34037
+ * thing the camera said about its own card.
34038
+ *
34039
+ * See `RuntimeStateDurability`. Enforced by
34040
+ * `scripts/check-runtime-state-durability.ts`.
34041
+ */
34042
+ durability: "restored",
34043
+ /** Clock fields: written, but excluded from the compare that decides
34044
+ * whether persisting is worth a SQLite commit. */
34045
+ volatileStateFields: ["lastFetchedAt"]
34046
+ };
34047
+ /**
33553
34048
  * A camera's own "record me NOW" LEVEL — a signal the device raises while
33554
34049
  * something it knows about is happening (a robot vacuum cleaning, a machine
33555
34050
  * running, a gate open) and lowers when it stops.
@@ -41010,24 +41505,6 @@ Object.freeze({
41010
41505
  addonId: null,
41011
41506
  access: "view"
41012
41507
  },
41013
- "events.getEventClipUrl": {
41014
- capName: "events",
41015
- capScope: "device",
41016
- addonId: null,
41017
- access: "view"
41018
- },
41019
- "events.getEvents": {
41020
- capName: "events",
41021
- capScope: "device",
41022
- addonId: null,
41023
- access: "view"
41024
- },
41025
- "events.getEventThumbnail": {
41026
- capName: "events",
41027
- capScope: "device",
41028
- addonId: null,
41029
- access: "view"
41030
- },
41031
41508
  "faceGallery.assignFace": {
41032
41509
  capName: "face-gallery",
41033
41510
  capScope: "system",
@@ -42348,6 +42825,12 @@ Object.freeze({
42348
42825
  addonId: null,
42349
42826
  access: "view"
42350
42827
  },
42828
+ "notificationRules.getTemplateCatalog": {
42829
+ capName: "notification-rules",
42830
+ capScope: "system",
42831
+ addonId: null,
42832
+ access: "view"
42833
+ },
42351
42834
  "notificationRules.listDeviceMutes": {
42352
42835
  capName: "notification-rules",
42353
42836
  capScope: "system",
@@ -42366,6 +42849,12 @@ Object.freeze({
42366
42849
  addonId: null,
42367
42850
  access: "view"
42368
42851
  },
42852
+ "notificationRules.previewTemplate": {
42853
+ capName: "notification-rules",
42854
+ capScope: "system",
42855
+ addonId: null,
42856
+ access: "view"
42857
+ },
42369
42858
  "notificationRules.resolveArtifactUrl": {
42370
42859
  capName: "notification-rules",
42371
42860
  capScope: "system",
@@ -43902,224 +44391,236 @@ Object.freeze({
43902
44391
  addonId: null,
43903
44392
  access: "create"
43904
44393
  },
43905
- "recording.applyDeviceSettingsPatch": {
44394
+ "recording.getAvailability": {
43906
44395
  capName: "recording",
43907
- capScope: "system",
44396
+ capScope: "device",
43908
44397
  addonId: null,
43909
- access: "create"
44398
+ access: "view"
43910
44399
  },
43911
- "recording.cancelRelocateJob": {
44400
+ "recording.getDaysWithRecordings": {
43912
44401
  capName: "recording",
43913
- capScope: "system",
44402
+ capScope: "device",
43914
44403
  addonId: null,
43915
- access: "create"
44404
+ access: "view"
43916
44405
  },
43917
- "recording.cancelStorageMigrationMove": {
44406
+ "recording.getPlayback": {
43918
44407
  capName: "recording",
43919
- capScope: "system",
44408
+ capScope: "device",
43920
44409
  addonId: null,
43921
- access: "create"
44410
+ access: "view"
43922
44411
  },
43923
- "recording.deleteFootprint": {
44412
+ "recording.getPlaybackOptions": {
43924
44413
  capName: "recording",
43925
- capScope: "system",
44414
+ capScope: "device",
43926
44415
  addonId: null,
43927
- access: "delete"
44416
+ access: "view"
43928
44417
  },
43929
- "recording.getAvailability": {
44418
+ "recording.listSources": {
43930
44419
  capName: "recording",
43931
- capScope: "system",
44420
+ capScope: "device",
43932
44421
  addonId: null,
43933
44422
  access: "view"
43934
44423
  },
43935
- "recording.getAvailabilityBatch": {
43936
- capName: "recording",
44424
+ "recordingArchive.applyDeviceSettingsPatch": {
44425
+ capName: "recording-archive",
43937
44426
  capScope: "system",
43938
44427
  addonId: null,
43939
- access: "view"
44428
+ access: "create"
43940
44429
  },
43941
- "recording.getDaysWithRecordings": {
43942
- capName: "recording",
44430
+ "recordingArchive.cancelRelocateJob": {
44431
+ capName: "recording-archive",
43943
44432
  capScope: "system",
43944
44433
  addonId: null,
43945
- access: "view"
44434
+ access: "create"
43946
44435
  },
43947
- "recording.getDaysWithRecordingsBatch": {
43948
- capName: "recording",
44436
+ "recordingArchive.cancelStorageMigrationMove": {
44437
+ capName: "recording-archive",
44438
+ capScope: "system",
44439
+ addonId: null,
44440
+ access: "create"
44441
+ },
44442
+ "recordingArchive.deleteFootprint": {
44443
+ capName: "recording-archive",
44444
+ capScope: "system",
44445
+ addonId: null,
44446
+ access: "delete"
44447
+ },
44448
+ "recordingArchive.getAvailabilityBatch": {
44449
+ capName: "recording-archive",
43949
44450
  capScope: "system",
43950
44451
  addonId: null,
43951
44452
  access: "view"
43952
44453
  },
43953
- "recording.getDeviceConfig": {
43954
- capName: "recording",
44454
+ "recordingArchive.getDaysWithRecordingsBatch": {
44455
+ capName: "recording-archive",
43955
44456
  capScope: "system",
43956
44457
  addonId: null,
43957
44458
  access: "view"
43958
44459
  },
43959
- "recording.getDeviceLiveContribution": {
43960
- capName: "recording",
44460
+ "recordingArchive.getDeviceConfig": {
44461
+ capName: "recording-archive",
43961
44462
  capScope: "system",
43962
44463
  addonId: null,
43963
44464
  access: "view"
43964
44465
  },
43965
- "recording.getDeviceSettingsContribution": {
43966
- capName: "recording",
44466
+ "recordingArchive.getDeviceLiveContribution": {
44467
+ capName: "recording-archive",
43967
44468
  capScope: "system",
43968
44469
  addonId: null,
43969
44470
  access: "view"
43970
44471
  },
43971
- "recording.getPlacement": {
43972
- capName: "recording",
44472
+ "recordingArchive.getDeviceSettingsContribution": {
44473
+ capName: "recording-archive",
43973
44474
  capScope: "system",
43974
44475
  addonId: null,
43975
44476
  access: "view"
43976
44477
  },
43977
- "recording.getPlaybackManifest": {
43978
- capName: "recording",
44478
+ "recordingArchive.getPlacement": {
44479
+ capName: "recording-archive",
43979
44480
  capScope: "system",
43980
44481
  addonId: null,
43981
44482
  access: "view"
43982
44483
  },
43983
- "recording.getRelocateResidue": {
43984
- capName: "recording",
44484
+ "recordingArchive.getRelocateResidue": {
44485
+ capName: "recording-archive",
43985
44486
  capScope: "system",
43986
44487
  addonId: null,
43987
44488
  access: "view"
43988
44489
  },
43989
- "recording.getStatus": {
43990
- capName: "recording",
44490
+ "recordingArchive.getStatus": {
44491
+ capName: "recording-archive",
43991
44492
  capScope: "system",
43992
44493
  addonId: null,
43993
44494
  access: "view"
43994
44495
  },
43995
- "recording.getStorageMigrationMoveStatus": {
43996
- capName: "recording",
44496
+ "recordingArchive.getStorageMigrationMoveStatus": {
44497
+ capName: "recording-archive",
43997
44498
  capScope: "system",
43998
44499
  addonId: null,
43999
44500
  access: "view"
44000
44501
  },
44001
- "recording.getStorageUsage": {
44002
- capName: "recording",
44502
+ "recordingArchive.getStorageUsage": {
44503
+ capName: "recording-archive",
44003
44504
  capScope: "system",
44004
44505
  addonId: null,
44005
44506
  access: "view"
44006
44507
  },
44007
- "recording.listOpsLog": {
44008
- capName: "recording",
44508
+ "recordingArchive.listOpsLog": {
44509
+ capName: "recording-archive",
44009
44510
  capScope: "system",
44010
44511
  addonId: null,
44011
44512
  access: "view"
44012
44513
  },
44013
- "recording.listRelocateJobs": {
44014
- capName: "recording",
44514
+ "recordingArchive.listRelocateJobs": {
44515
+ capName: "recording-archive",
44015
44516
  capScope: "system",
44016
44517
  addonId: null,
44017
44518
  access: "view"
44018
44519
  },
44019
- "recording.locateSegment": {
44020
- capName: "recording",
44520
+ "recordingArchive.locateSegment": {
44521
+ capName: "recording-archive",
44021
44522
  capScope: "system",
44022
44523
  addonId: null,
44023
44524
  access: "view"
44024
44525
  },
44025
- "recording.pauseForStorageMigration": {
44026
- capName: "recording",
44526
+ "recordingArchive.pauseForStorageMigration": {
44527
+ capName: "recording-archive",
44027
44528
  capScope: "system",
44028
44529
  addonId: null,
44029
44530
  access: "create"
44030
44531
  },
44031
- "recording.planStorageRebalance": {
44032
- capName: "recording",
44532
+ "recordingArchive.planStorageRebalance": {
44533
+ capName: "recording-archive",
44033
44534
  capScope: "system",
44034
44535
  addonId: null,
44035
44536
  access: "view"
44036
44537
  },
44037
- "recording.pruneFootage": {
44038
- capName: "recording",
44538
+ "recordingArchive.pruneFootage": {
44539
+ capName: "recording-archive",
44039
44540
  capScope: "system",
44040
44541
  addonId: null,
44041
44542
  access: "create"
44042
44543
  },
44043
- "recording.readGopBytes": {
44044
- capName: "recording",
44544
+ "recordingArchive.readGopBytes": {
44545
+ capName: "recording-archive",
44045
44546
  capScope: "system",
44046
44547
  addonId: null,
44047
44548
  access: "view"
44048
44549
  },
44049
- "recording.readSegmentBytes": {
44050
- capName: "recording",
44550
+ "recordingArchive.readSegmentBytes": {
44551
+ capName: "recording-archive",
44051
44552
  capScope: "system",
44052
44553
  addonId: null,
44053
44554
  access: "view"
44054
44555
  },
44055
- "recording.readWindowBytes": {
44056
- capName: "recording",
44556
+ "recordingArchive.readWindowBytes": {
44557
+ capName: "recording-archive",
44057
44558
  capScope: "system",
44058
44559
  addonId: null,
44059
44560
  access: "view"
44060
44561
  },
44061
- "recording.reconcileLedgerAgainstDisk": {
44062
- capName: "recording",
44562
+ "recordingArchive.reconcileLedgerAgainstDisk": {
44563
+ capName: "recording-archive",
44063
44564
  capScope: "system",
44064
44565
  addonId: null,
44065
44566
  access: "create"
44066
44567
  },
44067
- "recording.refreshStorageLocationsForMigration": {
44068
- capName: "recording",
44568
+ "recordingArchive.refreshStorageLocationsForMigration": {
44569
+ capName: "recording-archive",
44069
44570
  capScope: "system",
44070
44571
  addonId: null,
44071
44572
  access: "create"
44072
44573
  },
44073
- "recording.relocateFootage": {
44074
- capName: "recording",
44574
+ "recordingArchive.relocateFootage": {
44575
+ capName: "recording-archive",
44075
44576
  capScope: "system",
44076
44577
  addonId: null,
44077
44578
  access: "create"
44078
44579
  },
44079
- "recording.renderClip": {
44080
- capName: "recording",
44580
+ "recordingArchive.renderClip": {
44581
+ capName: "recording-archive",
44081
44582
  capScope: "system",
44082
44583
  addonId: null,
44083
44584
  access: "create"
44084
44585
  },
44085
- "recording.renderGif": {
44086
- capName: "recording",
44586
+ "recordingArchive.renderGif": {
44587
+ capName: "recording-archive",
44087
44588
  capScope: "system",
44088
44589
  addonId: null,
44089
44590
  access: "create"
44090
44591
  },
44091
- "recording.rescanStorage": {
44092
- capName: "recording",
44592
+ "recordingArchive.rescanStorage": {
44593
+ capName: "recording-archive",
44093
44594
  capScope: "system",
44094
44595
  addonId: null,
44095
44596
  access: "create"
44096
44597
  },
44097
- "recording.resumeForStorageMigration": {
44098
- capName: "recording",
44598
+ "recordingArchive.resumeForStorageMigration": {
44599
+ capName: "recording-archive",
44099
44600
  capScope: "system",
44100
44601
  addonId: null,
44101
44602
  access: "create"
44102
44603
  },
44103
- "recording.setDeviceConfig": {
44104
- capName: "recording",
44604
+ "recordingArchive.setDeviceConfig": {
44605
+ capName: "recording-archive",
44105
44606
  capScope: "system",
44106
44607
  addonId: null,
44107
44608
  access: "create"
44108
44609
  },
44109
- "recording.setDevicePlacement": {
44110
- capName: "recording",
44610
+ "recordingArchive.setDevicePlacement": {
44611
+ capName: "recording-archive",
44111
44612
  capScope: "system",
44112
44613
  addonId: null,
44113
44614
  access: "create"
44114
44615
  },
44115
- "recording.startStorageMigrationMove": {
44116
- capName: "recording",
44616
+ "recordingArchive.startStorageMigrationMove": {
44617
+ capName: "recording-archive",
44117
44618
  capScope: "system",
44118
44619
  addonId: null,
44119
44620
  access: "create"
44120
44621
  },
44121
- "recording.startStorageRebalance": {
44122
- capName: "recording",
44622
+ "recordingArchive.startStorageRebalance": {
44623
+ capName: "recording-archive",
44123
44624
  capScope: "system",
44124
44625
  addonId: null,
44125
44626
  access: "create"
@@ -45648,6 +46149,12 @@ Object.freeze({
45648
46149
  addonId: null,
45649
46150
  access: "view"
45650
46151
  },
46152
+ "videoclips.getPlaybackOptions": {
46153
+ capName: "videoclips",
46154
+ capScope: "device",
46155
+ addonId: null,
46156
+ access: "view"
46157
+ },
45651
46158
  "videoclips.listClips": {
45652
46159
  capName: "videoclips",
45653
46160
  capScope: "device",
@@ -45660,6 +46167,12 @@ Object.freeze({
45660
46167
  addonId: null,
45661
46168
  access: "view"
45662
46169
  },
46170
+ "videoclips.offerClipBytes": {
46171
+ capName: "videoclips",
46172
+ capScope: "device",
46173
+ addonId: null,
46174
+ access: "view"
46175
+ },
45663
46176
  "videoclips.readClipBytes": {
45664
46177
  capName: "videoclips",
45665
46178
  capScope: "device",
@@ -46412,21 +46925,6 @@ Object.freeze({
46412
46925
  form: "single",
46413
46926
  optional: false
46414
46927
  }],
46415
- "events.getEventClipUrl": [{
46416
- name: "deviceId",
46417
- form: "single",
46418
- optional: false
46419
- }],
46420
- "events.getEvents": [{
46421
- name: "deviceId",
46422
- form: "single",
46423
- optional: false
46424
- }],
46425
- "events.getEventThumbnail": [{
46426
- name: "deviceId",
46427
- form: "single",
46428
- optional: false
46429
- }],
46430
46928
  "faceGallery.getFaceByTrack": [{
46431
46929
  name: "deviceId",
46432
46930
  form: "single",
@@ -47345,107 +47843,117 @@ Object.freeze({
47345
47843
  form: "single",
47346
47844
  optional: false
47347
47845
  }],
47348
- "recording.deleteFootprint": [{
47846
+ "recording.getAvailability": [{
47349
47847
  name: "deviceId",
47350
47848
  form: "single",
47351
47849
  optional: false
47352
47850
  }],
47353
- "recording.getAvailability": [{
47851
+ "recording.getDaysWithRecordings": [{
47354
47852
  name: "deviceId",
47355
47853
  form: "single",
47356
47854
  optional: false
47357
47855
  }],
47358
- "recording.getAvailabilityBatch": [{
47359
- name: "deviceIds",
47360
- form: "array",
47856
+ "recording.getPlayback": [{
47857
+ name: "deviceId",
47858
+ form: "single",
47361
47859
  optional: false
47362
47860
  }],
47363
- "recording.getDaysWithRecordings": [{
47861
+ "recording.getPlaybackOptions": [{
47364
47862
  name: "deviceId",
47365
47863
  form: "single",
47366
47864
  optional: false
47367
47865
  }],
47368
- "recording.getDaysWithRecordingsBatch": [{
47369
- name: "deviceIds",
47370
- form: "array",
47866
+ "recording.listSources": [{
47867
+ name: "deviceId",
47868
+ form: "single",
47371
47869
  optional: false
47372
47870
  }],
47373
- "recording.getDeviceConfig": [{
47871
+ "recordingArchive.deleteFootprint": [{
47374
47872
  name: "deviceId",
47375
47873
  form: "single",
47376
47874
  optional: false
47377
47875
  }],
47378
- "recording.getPlaybackManifest": [{
47876
+ "recordingArchive.getAvailabilityBatch": [{
47877
+ name: "deviceIds",
47878
+ form: "array",
47879
+ optional: false
47880
+ }],
47881
+ "recordingArchive.getDaysWithRecordingsBatch": [{
47882
+ name: "deviceIds",
47883
+ form: "array",
47884
+ optional: false
47885
+ }],
47886
+ "recordingArchive.getDeviceConfig": [{
47379
47887
  name: "deviceId",
47380
47888
  form: "single",
47381
47889
  optional: false
47382
47890
  }],
47383
- "recording.listOpsLog": [{
47891
+ "recordingArchive.listOpsLog": [{
47384
47892
  name: "deviceId",
47385
47893
  form: "single",
47386
47894
  optional: true
47387
47895
  }],
47388
- "recording.locateSegment": [{
47896
+ "recordingArchive.locateSegment": [{
47389
47897
  name: "deviceId",
47390
47898
  form: "single",
47391
47899
  optional: false
47392
47900
  }],
47393
- "recording.pruneFootage": [{
47901
+ "recordingArchive.pruneFootage": [{
47394
47902
  name: "deviceId",
47395
47903
  form: "single",
47396
47904
  optional: false
47397
47905
  }],
47398
- "recording.readGopBytes": [{
47906
+ "recordingArchive.readGopBytes": [{
47399
47907
  name: "deviceId",
47400
47908
  form: "single",
47401
47909
  optional: false
47402
47910
  }],
47403
- "recording.readSegmentBytes": [{
47911
+ "recordingArchive.readSegmentBytes": [{
47404
47912
  name: "deviceId",
47405
47913
  form: "single",
47406
47914
  optional: false
47407
47915
  }],
47408
- "recording.readWindowBytes": [{
47916
+ "recordingArchive.readWindowBytes": [{
47409
47917
  name: "deviceId",
47410
47918
  form: "single",
47411
47919
  optional: false
47412
47920
  }],
47413
- "recording.reconcileLedgerAgainstDisk": [{
47921
+ "recordingArchive.reconcileLedgerAgainstDisk": [{
47414
47922
  name: "deviceId",
47415
47923
  form: "single",
47416
47924
  optional: true
47417
47925
  }],
47418
- "recording.relocateFootage": [{
47926
+ "recordingArchive.relocateFootage": [{
47419
47927
  name: "deviceId",
47420
47928
  form: "single",
47421
47929
  optional: true
47422
47930
  }],
47423
- "recording.renderClip": [{
47931
+ "recordingArchive.renderClip": [{
47424
47932
  name: "deviceId",
47425
47933
  form: "single",
47426
47934
  optional: false
47427
47935
  }],
47428
- "recording.renderGif": [{
47936
+ "recordingArchive.renderGif": [{
47429
47937
  name: "deviceId",
47430
47938
  form: "single",
47431
47939
  optional: false
47432
47940
  }],
47433
- "recording.rescanStorage": [{
47941
+ "recordingArchive.rescanStorage": [{
47434
47942
  name: "deviceId",
47435
47943
  form: "single",
47436
47944
  optional: false
47437
47945
  }],
47438
- "recording.setDeviceConfig": [{
47946
+ "recordingArchive.setDeviceConfig": [{
47439
47947
  name: "deviceId",
47440
47948
  form: "single",
47441
47949
  optional: false
47442
47950
  }],
47443
- "recording.setDevicePlacement": [{
47951
+ "recordingArchive.setDevicePlacement": [{
47444
47952
  name: "deviceId",
47445
47953
  form: "single",
47446
47954
  optional: false
47447
47955
  }],
47448
- "recording.startStorageMigrationMove": [{
47956
+ "recordingArchive.startStorageMigrationMove": [{
47449
47957
  name: "deviceId",
47450
47958
  form: "single",
47451
47959
  optional: true
@@ -47706,6 +48214,11 @@ Object.freeze({
47706
48214
  form: "single",
47707
48215
  optional: false
47708
48216
  }],
48217
+ "videoclips.getPlaybackOptions": [{
48218
+ name: "deviceId",
48219
+ form: "single",
48220
+ optional: false
48221
+ }],
47709
48222
  "videoclips.listClips": [{
47710
48223
  name: "deviceId",
47711
48224
  form: "single",
@@ -47716,6 +48229,11 @@ Object.freeze({
47716
48229
  form: "single",
47717
48230
  optional: false
47718
48231
  }],
48232
+ "videoclips.offerClipBytes": [{
48233
+ name: "deviceId",
48234
+ form: "single",
48235
+ optional: false
48236
+ }],
47719
48237
  "videoclips.readClipBytes": [{
47720
48238
  name: "deviceId",
47721
48239
  form: "single",
@@ -47904,6 +48422,37 @@ var NC_AUDIO_DEFAULTS = {
47904
48422
  };
47905
48423
  new Set(["devices", "classes"]);
47906
48424
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
48425
+ var RULE_BODY_ONLY = ["body"];
48426
+ var RULE_TEXT = ["title", "body"];
48427
+ var BATTERY = ["device-battery-low", "device-battery-normal"];
48428
+ var CONSUMABLE = ["device-consumable-low", "device-consumable-normal"];
48429
+ var UPDATES = [
48430
+ "addon-update-available",
48431
+ "server-update-available",
48432
+ "wrapper-update-available"
48433
+ ];
48434
+ var PACKAGE_UPDATES = ["addon-update-available", "server-update-available"];
48435
+ var ALARM = [
48436
+ "alarm-triggered",
48437
+ "alarm-armed",
48438
+ "alarm-disarmed",
48439
+ "alarm-arming",
48440
+ "alarm-arm-refused"
48441
+ ];
48442
+ var COMBINED_ALARM = ["alarm-triggered"];
48443
+ var DEVICE_EVENTS = [
48444
+ "device-online",
48445
+ "device-offline",
48446
+ "device-disabled",
48447
+ "device-enabled",
48448
+ ...BATTERY,
48449
+ ...CONSUMABLE,
48450
+ "stream-online",
48451
+ "stream-offline",
48452
+ "detection-blind",
48453
+ ...ALARM
48454
+ ];
48455
+ [...DEVICE_EVENTS], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_BODY_ONLY], [...RULE_TEXT], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...BATTERY, ...CONSUMABLE], [...RULE_TEXT], [...CONSUMABLE], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT];
47907
48456
  /**
47908
48457
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
47909
48458
  *
@@ -69714,7 +70263,8 @@ var PROFILE_CONFIGS = {
69714
70263
  {
69715
70264
  field: "LEVEL",
69716
70265
  parameter: "LEVEL",
69717
- visible: true
70266
+ visible: true,
70267
+ readChannelOffset: -1
69718
70268
  },
69719
70269
  {
69720
70270
  field: "STOP",
@@ -69723,7 +70273,8 @@ var PROFILE_CONFIGS = {
69723
70273
  {
69724
70274
  field: "DIRECTION",
69725
70275
  parameter: "ACTIVITY_STATE",
69726
- visible: true
70276
+ visible: true,
70277
+ readChannelOffset: -1
69727
70278
  }
69728
70279
  ]
69729
70280
  },
@@ -69752,12 +70303,14 @@ var PROFILE_CONFIGS = {
69752
70303
  {
69753
70304
  field: "LEVEL",
69754
70305
  parameter: "LEVEL",
69755
- visible: true
70306
+ visible: true,
70307
+ readChannelOffset: -1
69756
70308
  },
69757
70309
  {
69758
70310
  field: "LEVEL_2",
69759
70311
  parameter: "LEVEL_2",
69760
- visible: true
70312
+ visible: true,
70313
+ readChannelOffset: -1
69761
70314
  },
69762
70315
  {
69763
70316
  field: "STOP",
@@ -69766,7 +70319,8 @@ var PROFILE_CONFIGS = {
69766
70319
  {
69767
70320
  field: "DIRECTION",
69768
70321
  parameter: "ACTIVITY_STATE",
69769
- visible: true
70322
+ visible: true,
70323
+ readChannelOffset: -1
69770
70324
  }
69771
70325
  ]
69772
70326
  },
@@ -69803,29 +70357,75 @@ var CustomEntity = class {
69803
70357
  primaryChannelAddress;
69804
70358
  type;
69805
70359
  #dataPoints;
70360
+ #readDataPoints;
69806
70361
  #writer;
69807
70362
  constructor(init) {
69808
70363
  this.deviceAddress = init.deviceAddress;
69809
70364
  this.primaryChannelAddress = init.primaryChannelAddress;
69810
70365
  this.type = init.type;
69811
70366
  this.#dataPoints = new Map(init.dataPoints);
70367
+ this.#readDataPoints = new Map(init.readDataPoints ?? []);
69812
70368
  this.#writer = init.writer;
69813
70369
  }
69814
- /** The resolved data point for a field, or `undefined` if absent. */
70370
+ /**
70371
+ * The data point a field is READ from — its read binding when it has one,
70372
+ * the command binding otherwise.
70373
+ *
70374
+ * Every getter goes through here; {@link write} deliberately does not, so a
70375
+ * field whose status lives on another channel is still commanded where the
70376
+ * CCU accepts writes.
70377
+ */
69815
70378
  dp(field) {
70379
+ return this.#readDataPoints.get(field) ?? this.#dataPoints.get(field);
70380
+ }
70381
+ /** The data point a field is WRITTEN to. Never the read binding. */
70382
+ writeDp(field) {
69816
70383
  return this.#dataPoints.get(field);
69817
70384
  }
69818
70385
  /** The resolved data point for a field; throws if it was not resolved. */
69819
70386
  requireDp(field) {
69820
- const dp = this.#dataPoints.get(field);
70387
+ const dp = this.dp(field);
69821
70388
  if (dp === void 0) throw new DescriptionNotFoundError(`Field ${field} is not available on ${this.kind} entity ${this.primaryChannelAddress}`);
69822
70389
  return dp;
69823
70390
  }
69824
70391
  /** Resolve the data point for a field and route a converted write to it. */
69825
70392
  async write(field, value) {
69826
- const dp = this.requireDp(field);
70393
+ const dp = this.writeDp(field);
70394
+ if (dp === void 0) throw new DescriptionNotFoundError(`Field ${field} is not writable on ${this.kind} entity ${this.primaryChannelAddress}`);
69827
70395
  await this.#writer(dp.dpk.channelAddress, dp.parameter, value);
69828
70396
  }
70397
+ /**
70398
+ * Every channel this entity touches — command bindings and read bindings —
70399
+ * de-duplicated, in a stable order.
70400
+ *
70401
+ * A consumer that watches events per channel needs this: an HmIP cover reads
70402
+ * its position on the transmitter and is commanded on the virtual receiver,
70403
+ * so filtering events by {@link primaryChannelAddress} alone drops exactly
70404
+ * the reports the entity exists to expose. That happened downstream and cost
70405
+ * an evening — the library resolved the right channel and the consumer threw
70406
+ * its events away.
70407
+ */
70408
+ get channelAddresses() {
70409
+ const seen = /* @__PURE__ */ new Set();
70410
+ for (const dp of [...this.#dataPoints.values(), ...this.#readDataPoints.values()]) seen.add(dp.dpk.channelAddress);
70411
+ return [...seen];
70412
+ }
70413
+ /**
70414
+ * The channels this entity READS from, when those differ from where it is
70415
+ * commanded. Empty when every field is read where it is written.
70416
+ *
70417
+ * Separate from {@link channelAddresses} because knowing the union is not
70418
+ * enough for a consumer that watches raw parameter events: an HmIP cover
70419
+ * carries `LEVEL` on BOTH the transmitter and the virtual receiver, so
70420
+ * accepting both and taking the last arrival is a coin toss that the
70421
+ * receiver wins — 100 % against a slat at 47.5 %. A parameter available on a
70422
+ * status channel must be taken from THERE and nowhere else.
70423
+ */
70424
+ get statusChannelAddresses() {
70425
+ const seen = /* @__PURE__ */ new Set();
70426
+ for (const dp of this.#readDataPoints.values()) seen.add(dp.dpk.channelAddress);
70427
+ return [...seen];
70428
+ }
69829
70429
  /** True when at least one underlying data point was resolved. */
69830
70430
  get available() {
69831
70431
  return this.#dataPoints.size > 0;
@@ -69836,7 +70436,12 @@ var CustomEntity = class {
69836
70436
  */
69837
70437
  subscribe(cb) {
69838
70438
  const unsubscribers = [];
69839
- for (const dp of this.#dataPoints.values()) unsubscribers.push(dp.subscribe(() => cb()));
70439
+ const seen = /* @__PURE__ */ new Set();
70440
+ for (const dp of [...this.#dataPoints.values(), ...this.#readDataPoints.values()]) {
70441
+ if (seen.has(dp)) continue;
70442
+ seen.add(dp);
70443
+ unsubscribers.push(dp.subscribe(() => cb()));
70444
+ }
69840
70445
  return () => {
69841
70446
  for (const unsubscribe of unsubscribers) unsubscribe();
69842
70447
  };
@@ -70011,8 +70616,14 @@ var DimmerEntity = class extends CustomEntity {
70011
70616
  return typeof value === "number" ? value : null;
70012
70617
  }
70013
70618
  };
70014
- var DIRECTION_UP = "UP";
70015
- var DIRECTION_DOWN = "DOWN";
70619
+ var TRAVEL_BY_NAME = {
70620
+ UP: "opening",
70621
+ DOWN: "closing",
70622
+ STABLE: "stable",
70623
+ NONE: "stable",
70624
+ UNKNOWN: "unknown",
70625
+ UNDEFINED: "unknown"
70626
+ };
70016
70627
  var CoverEntity = class extends CustomEntity {
70017
70628
  kind = "cover";
70018
70629
  /** Current position 0..100 from LEVEL, or `null` when unavailable. */
@@ -70020,17 +70631,45 @@ var CoverEntity = class extends CustomEntity {
70020
70631
  const level = this.level;
70021
70632
  return level === null ? null : levelToPosition(level);
70022
70633
  }
70023
- /** True when the cover is fully closed (LEVEL 0). */
70634
+ /**
70635
+ * True when the cover is fully closed (LEVEL 0).
70636
+ *
70637
+ * `false` here covers BOTH "open" and "LEVEL has not been read yet" — check
70638
+ * {@link currentPosition} for `null` to tell them apart. Kept as a plain
70639
+ * boolean because narrowing it would change every caller's type.
70640
+ */
70024
70641
  get isClosed() {
70025
70642
  return this.level === 0;
70026
70643
  }
70027
- /** True while the cover is travelling open (DIRECTION 'UP'). */
70644
+ /**
70645
+ * What the cover is doing, from its travel data point.
70646
+ *
70647
+ * The data point is `ACTIVITY_STATE` on HmIP and `DIRECTION` on RF; the
70648
+ * profile maps whichever one the device has onto {@link Field.DIRECTION}, so
70649
+ * this getter never needs to know which family it is looking at.
70650
+ *
70651
+ * The ENUM arrives already converted to its value-list member (the inbound
70652
+ * converter resolves the CCU's index), so this reads names. A numeric value
70653
+ * means the list could not be resolved: index 0 is the non-travelling member
70654
+ * in both families, 1 is up and 2 is down.
70655
+ */
70656
+ get travel() {
70657
+ const value = this.dp("DIRECTION")?.value;
70658
+ if (typeof value === "string") return TRAVEL_BY_NAME[value.toUpperCase()] ?? "unknown";
70659
+ if (typeof value === "number") {
70660
+ if (value === 0) return "stable";
70661
+ if (value === 1) return "opening";
70662
+ if (value === 2) return "closing";
70663
+ }
70664
+ return "unknown";
70665
+ }
70666
+ /** True while the cover is travelling open. */
70028
70667
  get isOpening() {
70029
- return this.dp("DIRECTION")?.value === DIRECTION_UP;
70668
+ return this.travel === "opening";
70030
70669
  }
70031
- /** True while the cover is travelling closed (DIRECTION 'DOWN'). */
70670
+ /** True while the cover is travelling closed. */
70032
70671
  get isClosing() {
70033
- return this.dp("DIRECTION")?.value === DIRECTION_DOWN;
70672
+ return this.travel === "closing";
70034
70673
  }
70035
70674
  /** Open the cover fully (LEVEL 1). */
70036
70675
  async open() {
@@ -70114,19 +70753,27 @@ var RfLockEntity = class extends CustomEntity {
70114
70753
  function channelAddress(deviceAddress, channel) {
70115
70754
  return `${deviceAddress}:${channel}`;
70116
70755
  }
70117
- function resolveFields(device, baseChannel, mappings, defaultOffset, target) {
70756
+ function resolveFields(device, baseChannel, mappings, defaultOffset, target, readTarget) {
70118
70757
  for (const mapping of mappings) {
70119
70758
  const offset = mapping.channelOffset ?? defaultOffset;
70120
70759
  const address = channelAddress(device.address, baseChannel + offset);
70121
70760
  const dp = device.dataPoint(address, mapping.parameter);
70122
70761
  if (dp !== void 0) target.set(mapping.field, dp);
70762
+ if (mapping.readChannelOffset === void 0) continue;
70763
+ const readAddress = channelAddress(device.address, baseChannel + mapping.readChannelOffset);
70764
+ const readDp = device.dataPoint(readAddress, mapping.parameter);
70765
+ if (readDp !== void 0) readTarget.set(mapping.field, readDp);
70123
70766
  }
70124
70767
  }
70125
70768
  function buildDataPoints(device, baseChannel, profileConfig) {
70126
70769
  const dataPoints = /* @__PURE__ */ new Map();
70127
- resolveFields(device, baseChannel, profileConfig.fields, 0, dataPoints);
70128
- if (profileConfig.channelFields !== void 0) for (const [offsetKey, mappings] of Object.entries(profileConfig.channelFields)) resolveFields(device, baseChannel, mappings, Number(offsetKey), dataPoints);
70129
- return dataPoints;
70770
+ const readDataPoints = /* @__PURE__ */ new Map();
70771
+ resolveFields(device, baseChannel, profileConfig.fields, 0, dataPoints, readDataPoints);
70772
+ if (profileConfig.channelFields !== void 0) for (const [offsetKey, mappings] of Object.entries(profileConfig.channelFields)) resolveFields(device, baseChannel, mappings, Number(offsetKey), dataPoints, readDataPoints);
70773
+ return {
70774
+ dataPoints,
70775
+ readDataPoints
70776
+ };
70130
70777
  }
70131
70778
  function buildCustomEntities(device, writer) {
70132
70779
  const configs = deviceProfileRegistry.getConfigs(device.type);
@@ -70135,7 +70782,7 @@ function buildCustomEntities(device, writer) {
70135
70782
  const profileConfig = getProfileConfig(config.profile);
70136
70783
  const primaryOffset = profileConfig.primaryChannel ?? 0;
70137
70784
  for (const baseChannel of config.channels) {
70138
- const dataPoints = buildDataPoints(device, baseChannel, profileConfig);
70785
+ const { dataPoints, readDataPoints } = buildDataPoints(device, baseChannel, profileConfig);
70139
70786
  if (dataPoints.size === 0) continue;
70140
70787
  const primaryChannelAddress = channelAddress(device.address, baseChannel + primaryOffset);
70141
70788
  entities.push(new config.entityClass({
@@ -70143,6 +70790,7 @@ function buildCustomEntities(device, writer) {
70143
70790
  primaryChannelAddress,
70144
70791
  type: device.type,
70145
70792
  dataPoints,
70793
+ readDataPoints,
70146
70794
  writer
70147
70795
  }));
70148
70796
  }
@@ -70924,8 +71572,11 @@ function toHmCustomEntity(entity) {
70924
71572
  kind: entity.kind === "blind" ? "blind" : "cover",
70925
71573
  device,
70926
71574
  channel,
71575
+ channels: entity.channelAddresses,
71576
+ statusChannels: entity.statusChannelAddresses,
70927
71577
  currentPosition: entity.currentPosition,
70928
71578
  isClosed: entity.isClosed,
71579
+ travel: entity.travel,
70929
71580
  ...entity instanceof BlindEntity ? { currentTiltPosition: entity.currentTiltPosition } : {}
70930
71581
  };
70931
71582
  if (entity instanceof IpLockEntity || entity instanceof RfLockEntity) return {
@@ -72887,11 +73538,70 @@ var HmChildDevice = class extends BaseDevice {
72887
73538
  * Channel-less children (event-emitter, firmware update) span the whole
72888
73539
  * device by design and accept every channel.
72889
73540
  */
73541
+ /**
73542
+ * Every channel this child may accept, ASKED OF THE LIBRARY.
73543
+ *
73544
+ * An HmIP cover reports its position on the SHUTTER_TRANSMITTER channel and
73545
+ * is commanded on a SHUTTER_VIRTUAL_RECEIVER, so the command channel alone
73546
+ * drops exactly the reports the entity exists to expose — measured: the
73547
+ * receiver held 100 % while the slat sat at 47.5 %, and the library's own fix
73548
+ * was invisible here because these events never got past the filter.
73549
+ *
73550
+ * `HmCustomEntity.channels` is the library's answer, so the `-1` offset lives
73551
+ * in ONE place (the profile) rather than being re-spelled here. Falls back to
73552
+ * the command channel alone when the entity cannot be resolved — a narrower
73553
+ * filter is the safe direction: it costs a report, where a wider one lets a
73554
+ * sibling relay write this child's slice.
73555
+ */
73556
+ ownedChannels() {
73557
+ const owned = this.channel;
73558
+ if (owned === void 0) return [];
73559
+ const declared = this.entityChannels();
73560
+ return declared.all.length > 0 ? declared.all : [owned];
73561
+ }
73562
+ /**
73563
+ * The entity's channels, split into all-of-them and the STATUS ones.
73564
+ *
73565
+ * Both are needed and they answer different questions. `all` is what may be
73566
+ * accepted at all; `status` is where a parameter must be taken FROM when it
73567
+ * exists in both places — `LEVEL` is on an HmIP cover's transmitter AND its
73568
+ * virtual receiver, so merely accepting both and letting the last arrival
73569
+ * win is a coin toss the receiver keeps winning: 100 % against a slat at
73570
+ * 47.5 %. Measured, after widening the filter and before this.
73571
+ */
73572
+ entityChannels() {
73573
+ const owned = this.channel;
73574
+ const mine = (this.facade?.customEntities() ?? []).find((e) => e.device === this.address && e.channel === owned);
73575
+ if (mine === void 0) return {
73576
+ all: [],
73577
+ status: []
73578
+ };
73579
+ return {
73580
+ all: "channels" in mine ? mine.channels : [],
73581
+ status: "statusChannels" in mine ? mine.statusChannels : []
73582
+ };
73583
+ }
73584
+ /**
73585
+ * Is this (channel, parameter) the one to believe?
73586
+ *
73587
+ * A parameter carried by a STATUS channel is taken only from there. Anything
73588
+ * else passes — a command-only datapoint (`STOP`) has no status twin, and a
73589
+ * device with no split has no status channels at all.
73590
+ */
73591
+ isPreferredSource(event) {
73592
+ const { status } = this.entityChannels();
73593
+ if (status.length === 0) return true;
73594
+ if (status.includes(event.channel)) return true;
73595
+ return this.resolveHmDevice()?.channels.some((c) => status.includes(c.address) && (c.dataPoints ?? []).some((d) => d.parameter === event.parameter)) !== true;
73596
+ }
72890
73597
  ownsEventChannel(event) {
72891
73598
  const owned = this.channel;
72892
73599
  if (owned === void 0) return true;
72893
73600
  const channel = event.channel;
72894
- if (typeof channel === "string" && channel.length > 0) return channel === owned;
73601
+ if (typeof channel === "string" && channel.length > 0) {
73602
+ if (!this.ownedChannels().includes(channel)) return false;
73603
+ return this.isPreferredSource(event);
73604
+ }
72895
73605
  this.ctx.logger.warn("Homematic value event without a channel — dropped", {
72896
73606
  tags: { deviceId: this.ctx.id },
72897
73607
  meta: {
@@ -72919,10 +73629,20 @@ var HmChildDevice = class extends BaseDevice {
72919
73629
  const device = this.resolveHmDevice();
72920
73630
  if (device === null) return;
72921
73631
  const now = Date.now();
73632
+ const accepted = this.ownedChannels();
72922
73633
  for (const channel of device.channels) {
72923
- if (channel.address !== this.channel) continue;
73634
+ if (!accepted.includes(channel.address)) continue;
72924
73635
  for (const dp of channel.dataPoints ?? []) {
72925
73636
  if (dp.value === null || dp.value === void 0) continue;
73637
+ if (!this.isPreferredSource({
73638
+ dpId: dp.id,
73639
+ device: this.address,
73640
+ channel: channel.address,
73641
+ parameter: dp.parameter,
73642
+ value: dp.value,
73643
+ prevValue: null,
73644
+ ts: now
73645
+ })) continue;
72926
73646
  handle({
72927
73647
  dpId: dp.id,
72928
73648
  device: this.address,
@@ -72982,25 +73702,91 @@ function levelToPercent(level) {
72982
73702
  * lifecycle state.
72983
73703
  */
72984
73704
  function decodeCover(previous, parameter, value, now) {
72985
- if ((parameter === "LEVEL" || parameter === "LEVEL_STATUS") && typeof value === "number") {
73705
+ if (parameter === "LEVEL" && typeof value === "number") {
72986
73706
  const position = levelToPercent(value);
72987
73707
  return {
72988
73708
  ...previous,
72989
73709
  position,
72990
- state: position <= 0 ? "closed" : "open",
73710
+ state: isMoving(previous.state) ? previous.state : restingState(position),
72991
73711
  lastChangedAt: now
72992
73712
  };
72993
73713
  }
72994
- if (parameter === "ACTIVITY_STATE" && typeof value === "number") {
72995
- const state = value === 1 ? "opening" : value === 2 ? "closing" : previous.state;
73714
+ if (parameter === "ACTIVITY_STATE" || parameter === "DIRECTION") {
73715
+ const travel = readTravel(value);
73716
+ if (travel === "unknown") return null;
73717
+ if (travel === "opening") return {
73718
+ ...previous,
73719
+ state: "opening",
73720
+ lastChangedAt: now
73721
+ };
73722
+ if (travel === "closing") return {
73723
+ ...previous,
73724
+ state: "closing",
73725
+ lastChangedAt: now
73726
+ };
72996
73727
  return {
72997
73728
  ...previous,
72998
- state,
73729
+ state: restingState(previous.position),
72999
73730
  lastChangedAt: now
73000
73731
  };
73001
73732
  }
73002
73733
  return null;
73003
73734
  }
73735
+ /** The two states a cover rests in. `null` position = no intermediate surface;
73736
+ * such a device reports its rest state through LEVEL's 0/1 ends only, so an
73737
+ * unknown position keeps whatever was last known rather than inventing one. */
73738
+ function restingState(position) {
73739
+ if (position === null) return "stopped";
73740
+ return position <= 0 ? "closed" : "open";
73741
+ }
73742
+ /** Is this a MOVE in progress? The two transient states, named once. */
73743
+ function isMoving(state) {
73744
+ return state === "opening" || state === "closing";
73745
+ }
73746
+ /**
73747
+ * Read a cover's travel datapoint, whichever of the two it is and in whichever
73748
+ * form the library hands it over.
73749
+ *
73750
+ * Two axes, and getting either wrong costs the whole transient:
73751
+ *
73752
+ * - **The PARAMETER differs by family.** HmIP reports travel on
73753
+ * `ACTIVITY_STATE`, classic RF on `DIRECTION` — `nodehomematic`'s profiles
73754
+ * map both onto its own `Field.DIRECTION`. Listening only for
73755
+ * `ACTIVITY_STATE` left every RF cover with no travel at all.
73756
+ * - **The VALUE is a converted string, not the wire index.** The library's
73757
+ * `ValueChangedEvent.value` is documented as "New converted value", and its
73758
+ * inbound ENUM converter maps the CCU's index onto the value-list member.
73759
+ * This decoder tested `typeof value === 'number'`, which a converted ENUM
73760
+ * never is — so the branch never fired and the cover never reported a move.
73761
+ * That is why the operator pressed "down" and saw nothing.
73762
+ *
73763
+ * Matched BY NAME on purpose. The two value lists differ in their members,
73764
+ * not merely their order: measured on this CCU, HmIP's `ACTIVITY_STATE` is
73765
+ * `UNKNOWN|UP|DOWN|STABLE` — its rest member is `STABLE` and it carries a
73766
+ * fourth meaning, "no opinion", that RF's `NONE|UP|DOWN|UNDEFINED` has no
73767
+ * equivalent for. An index mapping would be a guess about a list this code
73768
+ * never sees; a name mapping is not.
73769
+ *
73770
+ * The numeric arm survives only for a datapoint whose value list the library
73771
+ * could not resolve. Index 0 is the non-travelling member in BOTH families, so
73772
+ * it ends a move; 1 and 2 are up and down in both.
73773
+ */
73774
+ function readTravel(value) {
73775
+ if (typeof value === "string") {
73776
+ const v = value.toUpperCase();
73777
+ if (v === "UP" || v === "OPENING") return "opening";
73778
+ if (v === "DOWN" || v === "CLOSING") return "closing";
73779
+ if (v === "STABLE" || v === "NONE" || v === "INACTIVE" || v === "STOP" || v === "STOPPED") return "idle";
73780
+ return "unknown";
73781
+ }
73782
+ if (typeof value === "number") {
73783
+ if (value === 0) return "idle";
73784
+ if (value === 1) return "opening";
73785
+ if (value === 2) return "closing";
73786
+ return "unknown";
73787
+ }
73788
+ return "unknown";
73789
+ }
73004
73790
  /**
73005
73791
  * Decode a lock datapoint into a LockControlStatus patch. `LOCK_STATE`
73006
73792
  * is an ENUM (0 unknown, 1 locked, 2 unlocked); `ACTIVITY_STATE`
@@ -73185,6 +73971,15 @@ var HmActuatorDevice = class extends HmChildDevice {
73185
73971
  }
73186
73972
  if (cap === "cover") {
73187
73973
  const next = decodeCover(this.runtimeState.getCapState("cover") ?? COLD_COVER, parameter, value, now);
73974
+ if (next === null && (parameter === "ACTIVITY_STATE" || parameter === "DIRECTION")) this.ctx.logger.warn("Homematic cover: travel value not understood — state unchanged", {
73975
+ tags: { deviceId: this.id },
73976
+ meta: {
73977
+ deviceId: this.id,
73978
+ parameter,
73979
+ value,
73980
+ valueType: typeof value
73981
+ }
73982
+ });
73188
73983
  if (next) this.runtimeState.setCapState("cover", next);
73189
73984
  return;
73190
73985
  }