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