@camstack/addon-provider-reolink 1.2.227 → 1.2.229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.229] - 2026-11-05
11
+
12
+ ### Changed
13
+
14
+ - A Reolink Home Hub / NVR integration no longer offers the manual Enter parameters add in Add device
15
+
16
+ ## [1.2.228] - 2026-11-05
17
+
18
+ ### Fixed
19
+
20
+ - A deleted camera stops its timers at once instead of polling until the worker restarts
21
+
10
22
  ## [1.2.227] - 2026-11-05
11
23
 
12
24
  ### Changed
package/dist/addon.js CHANGED
@@ -114374,12 +114374,22 @@ var RecordIntegrationInstances = class {
114374
114374
  ...this.hooks.description,
114375
114375
  mintsId: true
114376
114376
  };
114377
- instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
114377
+ /**
114378
+ * The record an id names. A caller holding the `integrations` registry id (the Integrations
114379
+ * page) reaches a kind whose body links to it through `integrationId`; an id that is itself a
114380
+ * record id answers as it is. An id that names nothing comes back unchanged.
114381
+ */
114382
+ async resolveRecordId(id) {
114383
+ if (await this.handle.get(id) !== null) return id;
114384
+ const linked = (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.find((record) => record.data["integrationId"] === id);
114385
+ return linked === void 0 ? id : linked.id;
114386
+ }
114387
+ instanceFormSchema = async ({ id }) => this.hooks.formSchema(id === null ? null : await this.resolveRecordId(id));
114378
114388
  listInstances = async () => {
114379
114389
  return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
114380
114390
  };
114381
114391
  getInstance = async ({ id }) => {
114382
- const record = await this.handle.get(id);
114392
+ const record = await this.handle.get(await this.resolveRecordId(id));
114383
114393
  return record === null ? null : this.viewOf(record);
114384
114394
  };
114385
114395
  /** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
@@ -114396,7 +114406,8 @@ var RecordIntegrationInstances = class {
114396
114406
  await this.hooks.onChanged?.(minted, "created");
114397
114407
  return { id: minted };
114398
114408
  };
114399
- updateInstance = async ({ id, name, values }) => {
114409
+ updateInstance = async ({ id: askedId, name, values }) => {
114410
+ const id = await this.resolveRecordId(askedId);
114400
114411
  const patch = {};
114401
114412
  for (const [key, value] of Object.entries(values)) {
114402
114413
  if (value === void 0) continue;
@@ -114431,7 +114442,10 @@ var RecordIntegrationInstances = class {
114431
114442
  status: "unsupported",
114432
114443
  error: "This integration declares no connection test"
114433
114444
  };
114434
- return this.hooks.test(input);
114445
+ return this.hooks.test(input.id === null ? input : {
114446
+ ...input,
114447
+ id: await this.resolveRecordId(input.id)
114448
+ });
114435
114449
  };
114436
114450
  /** The flat provider object to hand to `registerProvider`. */
114437
114451
  toProvider() {
@@ -153613,7 +153627,14 @@ var DiscoveryCandidateSchema = object({
153613
153627
  /** `stableId` of the gateway candidate this device was found BEHIND. */
153614
153628
  parentStableId: string().optional(),
153615
153629
  /** `false` = shown for context but not pickable. Default true. */
153616
- selectable: boolean().optional()
153630
+ selectable: boolean().optional(),
153631
+ /**
153632
+ * Keys of the provider's creation form (`getChildCreationSchema`) this candidate
153633
+ * cannot be adopted without — a key for an encrypted board, a pairing code. The
153634
+ * admin asks for exactly these, on the creation form prefilled with
153635
+ * `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
153636
+ */
153637
+ needsParams: array(string()).optional()
153617
153638
  });
153618
153639
  /**
153619
153640
  * Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
@@ -153740,8 +153761,14 @@ var deviceProviderCapability = {
153740
153761
  * provider does not support manual creation. Lets the Add-Device dialog
153741
153762
  * pick the right type instead of assuming Camera.
153742
153763
  */
153743
- getManualCreationType: method(object({}), object({ deviceType: _enum(DeviceType).nullable() })),
153744
- adoptDiscoveredDevice: method(object({ candidate: DiscoveryCandidateSchema }), DeviceSummarySchema, {
153764
+ getManualCreationType: method(object({
153765
+ /** The integration asked about; a provider whose integrations differ answers per one. */
153766
+ integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })),
153767
+ adoptDiscoveredDevice: method(object({
153768
+ candidate: DiscoveryCandidateSchema,
153769
+ /** The integration the operator adopts into; a provider with several instances needs it. */
153770
+ integrationId: string().optional()
153771
+ }), DeviceSummarySchema, {
153745
153772
  kind: "mutation",
153746
153773
  auth: "admin"
153747
153774
  }),
@@ -153752,10 +153779,16 @@ var deviceProviderCapability = {
153752
153779
  * devices of that type. The output is a `ConfigUISchema` — the
153753
153780
  * router type-asserts it at the boundary.
153754
153781
  */
153755
- getChildCreationSchema: method(object({ type: _enum(DeviceType) }), CreationSchemaOutputSchema),
153782
+ getChildCreationSchema: method(object({
153783
+ type: _enum(DeviceType),
153784
+ /** The integration asked about; a provider whose integrations differ answers per one. */
153785
+ integrationId: string().optional()
153786
+ }), CreationSchemaOutputSchema),
153756
153787
  createDevice: method(object({
153757
153788
  type: _enum(DeviceType),
153758
- config: record(string(), unknown())
153789
+ config: record(string(), unknown()),
153790
+ /** The integration the operator adds the device to; a provider with several instances needs it. */
153791
+ integrationId: string().optional()
153759
153792
  }), DeviceSummarySchema, {
153760
153793
  kind: "mutation",
153761
153794
  auth: "admin"
@@ -154480,7 +154513,10 @@ method(object({
154480
154513
  auth: "admin"
154481
154514
  }), method(object({
154482
154515
  addonId: string(),
154483
- type: _enum(DeviceType)
154516
+ type: _enum(DeviceType),
154517
+ /** The integration the form is for; a provider whose integrations differ (a hub
154518
+ * integration takes no manual add) answers per integration. Absent = the addon's own. */
154519
+ integrationId: string().optional()
154484
154520
  }), unknown().nullable()), method(object({
154485
154521
  addonId: string(),
154486
154522
  type: _enum(DeviceType),
@@ -154564,7 +154600,11 @@ method(object({
154564
154600
  kind: "mutation",
154565
154601
  auth: "admin",
154566
154602
  timeoutMs: 12e4
154567
- }), method(object({ addonId: string() }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
154603
+ }), method(object({
154604
+ addonId: string(),
154605
+ /** The integration the Add-Device dialog is open on; absent = the addon's own. */
154606
+ integrationId: string().optional()
154607
+ }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
154568
154608
  deviceId: number(),
154569
154609
  key: string(),
154570
154610
  value: unknown()
@@ -184768,7 +184808,7 @@ var BaseDeviceProvider = class extends BaseAddon {
184768
184808
  * `deviceClasses` map (first registered type). `null` when manual creation is
184769
184809
  * unsupported. Lets the Add-Device dialog pick the right type per provider.
184770
184810
  */
184771
- async getManualCreationType() {
184811
+ async getManualCreationType(_input) {
184772
184812
  if (!await this.supportsManualCreation()) return { deviceType: null };
184773
184813
  return { deviceType: Object.values(DeviceType).find((t) => this.deviceClasses[t] !== void 0) ?? null };
184774
184814
  }
@@ -184779,7 +184819,7 @@ var BaseDeviceProvider = class extends BaseAddon {
184779
184819
  return true;
184780
184820
  }
184781
184821
  async getChildCreationSchema(input) {
184782
- return this.onGetCreationSchema(input.type);
184822
+ return this.onGetCreationSchema(input.type, { integrationId: input.integrationId });
184783
184823
  }
184784
184824
  /**
184785
184825
  * Default kernel-orchestrated `createDevice` implementation. The
@@ -184791,7 +184831,7 @@ var BaseDeviceProvider = class extends BaseAddon {
184791
184831
  * `deviceClasses` instead.
184792
184832
  */
184793
184833
  async createDevice(input) {
184794
- const spec = await this.onCreateDevice(input.type, input.config);
184834
+ const spec = await this.onCreateDevice(input.type, input.config, { ...input.integrationId !== void 0 ? { integrationId: input.integrationId } : {} });
184795
184835
  const Class = this.deviceClasses[spec.meta.type];
184796
184836
  if (!Class) throw new Error(`${this.providerName} provider: no device class registered for type "${spec.meta.type}" — add it to the deviceClasses map`);
184797
184837
  const stableId = this.generateStableId(spec.meta.type, spec.config);
@@ -212785,6 +212825,8 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
212785
212825
  * Mirrors the reference's `batteryUpdateTimer`: fires every hour,
212786
212826
  * passively checks sleep state, and short-circuits if sleeping. */
212787
212827
  batteryUpdateTimer = null;
212828
+ /** Set by `removeDevice`: nothing may re-arm a timer on a removed camera. */
212829
+ removed = false;
212788
212830
  /** Single-flight gate so two interval fires can't overlap. */
212789
212831
  /** Aux accessory references registered by spawned children
212790
212832
  * (siren / floodlight / pir). The parent's centralised align
@@ -217584,6 +217626,11 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
217584
217626
  });
217585
217627
  }
217586
217628
  async removeDevice() {
217629
+ this.removed = true;
217630
+ this.stopSleepPoll();
217631
+ this.stopBatteryUpdatePolling();
217632
+ this.stopAlignAuxPolling();
217633
+ this.stopWatchdogs();
217587
217634
  this.detachFromHubSession();
217588
217635
  if (this.reconnectTimer) {
217589
217636
  clearTimeout(this.reconnectTimer);
@@ -217753,6 +217800,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
217753
217800
  * `sleeping`/`awake` transition (firmware quirks, NAT timeouts).
217754
217801
  */
217755
217802
  startSleepPoll() {
217803
+ if (this.removed) return;
217756
217804
  if (this.sleepPollTimer) return;
217757
217805
  if (!this.isBattery) return;
217758
217806
  if (this.isHubChild()) return;
@@ -217892,6 +217940,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
217892
217940
  /** Start periodic align for wired cams. No-op for battery cams (wake
217893
217941
  * path handles it). Idempotent. */
217894
217942
  startAlignAuxPolling() {
217943
+ if (this.removed) return;
217895
217944
  if (this.alignAuxTimer) return;
217896
217945
  if (this.isBattery) return;
217897
217946
  const POLL_MS = 1e4;
@@ -217972,6 +218021,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
217972
218021
  /** Arm the scheduled-refresh check. No-op for wired cams (their state is
217973
218022
  * kept fresh by the 10 s aux-align poll and push events). Idempotent. */
217974
218023
  startBatteryUpdatePolling() {
218024
+ if (this.removed) return;
217975
218025
  if (this.batteryUpdateTimer) return;
217976
218026
  if (!this.isBattery) return;
217977
218027
  this.batteryUpdateTimer = setInterval(() => {
@@ -218101,6 +218151,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
218101
218151
  * with parallel watchdogs after a reconnect cycle.
218102
218152
  */
218103
218153
  startWatchdogs() {
218154
+ if (this.removed) return;
218104
218155
  this.stopWatchdogs();
218105
218156
  this.watchdogStartedAt = Date.now();
218106
218157
  this.consecutivePingFailures = 0;
@@ -218365,6 +218416,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
218365
218416
  * re-subscribes the moment the socket comes back up.
218366
218417
  */
218367
218418
  startEventHealthCheck() {
218419
+ if (this.removed) return;
218368
218420
  this.stopEventHealthCheck();
218369
218421
  this.consecutiveStaleHealthChecks = 0;
218370
218422
  this.nextEventHealthCheckAt = 0;
@@ -220500,6 +220552,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
220500
220552
  }
220501
220553
  });
220502
220554
  this.api = null;
220555
+ if (this.removed) return;
220503
220556
  this.reconnectTimer = setTimeout(() => {
220504
220557
  this.reconnectTimer = null;
220505
220558
  this.ctx.logger.debug("Baichuan reconnect window elapsed — ready for next demand", { tags: { deviceId: this.id } });
@@ -221690,6 +221743,19 @@ function reolinkInstancesProvider(instances, deps) {
221690
221743
  }
221691
221744
  };
221692
221745
  }
221746
+ /**
221747
+ * Whether an integration IS one NVR / Home Hub (its devices come from the hub, so there is no
221748
+ * manual add by IP). An integration the registry cannot name is not a hub for this question.
221749
+ */
221750
+ async function integrationIsHub(instances, deps, id) {
221751
+ const [evidence, body] = await Promise.all([deps.registryEvidenceOf(id), instances.getResolved(id)]);
221752
+ if (evidence === null) return false;
221753
+ return isHubIntegration({
221754
+ originStableId: evidence.originStableId,
221755
+ info: evidence.info,
221756
+ settings: body === null ? {} : hubSettingsOf(body)
221757
+ });
221758
+ }
221693
221759
  //#endregion
221694
221760
  //#region src/migrations/integration-rows-to-record.ts
221695
221761
  /**
@@ -222468,6 +222534,7 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
222468
222534
  autodetectCache = new AutodetectCache();
222469
222535
  hubManager = null;
222470
222536
  instances = null;
222537
+ hubIntegrationProbe = null;
222471
222538
  /**
222472
222539
  * The camera mailbox bridge (`email-push-bridge.ts`, D999): battery cameras mail motion to a
222473
222540
  * mailbox of the `smtp-inbound` broker, the bridge turns each message into the camera's
@@ -222978,6 +223045,7 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
222978
223045
  registryEvidenceOf
222979
223046
  });
222980
223047
  this.instances = instances;
223048
+ this.hubIntegrationProbe = (id) => integrationIsHub(instances, { registryEvidenceOf }, id);
222981
223049
  await this.runMigrations([...defineAddonMigrations(REOLINK_MIGRATIONS, this.migrationPorts()), ...defineAddonMigrations(REOLINK_INTEGRATION_MIGRATIONS, integrationPorts)]);
222982
223050
  this.wireEmailBridge();
222983
223051
  const wireSleepPushResolvers = (event, via) => {
@@ -223311,10 +223379,22 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
223311
223379
  config: input.candidate.prefilledConfig
223312
223380
  });
223313
223381
  }
223314
- async onGetCreationSchema(type) {
223382
+ async onGetCreationSchema(type, context) {
223315
223383
  if (type !== DeviceType.Camera) return null;
223384
+ if (await this.isHubIntegrationId(context?.integrationId)) return null;
223316
223385
  return buildCreationFormSchema();
223317
223386
  }
223387
+ /** A hub integration's devices come from the hub: no manual add by IP for it. */
223388
+ async getManualCreationType(input) {
223389
+ if (await this.isHubIntegrationId(input?.integrationId)) return { deviceType: null };
223390
+ return super.getManualCreationType(input);
223391
+ }
223392
+ /** `false` for no integration, or one the registry cannot name (the addon's own default). */
223393
+ async isHubIntegrationId(id) {
223394
+ const probe = this.hubIntegrationProbe;
223395
+ if (id === void 0 || probe === null) return false;
223396
+ return probe(id);
223397
+ }
223318
223398
  async onCreateDevice(type, config) {
223319
223399
  if (type !== DeviceType.Camera) throw new Error(`Reolink provider does not support device type: ${type}`);
223320
223400
  const name = getString(config, "name").trim();
package/dist/addon.mjs CHANGED
@@ -114366,12 +114366,22 @@ var RecordIntegrationInstances = class {
114366
114366
  ...this.hooks.description,
114367
114367
  mintsId: true
114368
114368
  };
114369
- instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
114369
+ /**
114370
+ * The record an id names. A caller holding the `integrations` registry id (the Integrations
114371
+ * page) reaches a kind whose body links to it through `integrationId`; an id that is itself a
114372
+ * record id answers as it is. An id that names nothing comes back unchanged.
114373
+ */
114374
+ async resolveRecordId(id) {
114375
+ if (await this.handle.get(id) !== null) return id;
114376
+ const linked = (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.find((record) => record.data["integrationId"] === id);
114377
+ return linked === void 0 ? id : linked.id;
114378
+ }
114379
+ instanceFormSchema = async ({ id }) => this.hooks.formSchema(id === null ? null : await this.resolveRecordId(id));
114370
114380
  listInstances = async () => {
114371
114381
  return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
114372
114382
  };
114373
114383
  getInstance = async ({ id }) => {
114374
- const record = await this.handle.get(id);
114384
+ const record = await this.handle.get(await this.resolveRecordId(id));
114375
114385
  return record === null ? null : this.viewOf(record);
114376
114386
  };
114377
114387
  /** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
@@ -114388,7 +114398,8 @@ var RecordIntegrationInstances = class {
114388
114398
  await this.hooks.onChanged?.(minted, "created");
114389
114399
  return { id: minted };
114390
114400
  };
114391
- updateInstance = async ({ id, name, values }) => {
114401
+ updateInstance = async ({ id: askedId, name, values }) => {
114402
+ const id = await this.resolveRecordId(askedId);
114392
114403
  const patch = {};
114393
114404
  for (const [key, value] of Object.entries(values)) {
114394
114405
  if (value === void 0) continue;
@@ -114423,7 +114434,10 @@ var RecordIntegrationInstances = class {
114423
114434
  status: "unsupported",
114424
114435
  error: "This integration declares no connection test"
114425
114436
  };
114426
- return this.hooks.test(input);
114437
+ return this.hooks.test(input.id === null ? input : {
114438
+ ...input,
114439
+ id: await this.resolveRecordId(input.id)
114440
+ });
114427
114441
  };
114428
114442
  /** The flat provider object to hand to `registerProvider`. */
114429
114443
  toProvider() {
@@ -153605,7 +153619,14 @@ var DiscoveryCandidateSchema = object({
153605
153619
  /** `stableId` of the gateway candidate this device was found BEHIND. */
153606
153620
  parentStableId: string().optional(),
153607
153621
  /** `false` = shown for context but not pickable. Default true. */
153608
- selectable: boolean().optional()
153622
+ selectable: boolean().optional(),
153623
+ /**
153624
+ * Keys of the provider's creation form (`getChildCreationSchema`) this candidate
153625
+ * cannot be adopted without — a key for an encrypted board, a pairing code. The
153626
+ * admin asks for exactly these, on the creation form prefilled with
153627
+ * `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
153628
+ */
153629
+ needsParams: array(string()).optional()
153609
153630
  });
153610
153631
  /**
153611
153632
  * Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
@@ -153732,8 +153753,14 @@ var deviceProviderCapability = {
153732
153753
  * provider does not support manual creation. Lets the Add-Device dialog
153733
153754
  * pick the right type instead of assuming Camera.
153734
153755
  */
153735
- getManualCreationType: method(object({}), object({ deviceType: _enum(DeviceType).nullable() })),
153736
- adoptDiscoveredDevice: method(object({ candidate: DiscoveryCandidateSchema }), DeviceSummarySchema, {
153756
+ getManualCreationType: method(object({
153757
+ /** The integration asked about; a provider whose integrations differ answers per one. */
153758
+ integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })),
153759
+ adoptDiscoveredDevice: method(object({
153760
+ candidate: DiscoveryCandidateSchema,
153761
+ /** The integration the operator adopts into; a provider with several instances needs it. */
153762
+ integrationId: string().optional()
153763
+ }), DeviceSummarySchema, {
153737
153764
  kind: "mutation",
153738
153765
  auth: "admin"
153739
153766
  }),
@@ -153744,10 +153771,16 @@ var deviceProviderCapability = {
153744
153771
  * devices of that type. The output is a `ConfigUISchema` — the
153745
153772
  * router type-asserts it at the boundary.
153746
153773
  */
153747
- getChildCreationSchema: method(object({ type: _enum(DeviceType) }), CreationSchemaOutputSchema),
153774
+ getChildCreationSchema: method(object({
153775
+ type: _enum(DeviceType),
153776
+ /** The integration asked about; a provider whose integrations differ answers per one. */
153777
+ integrationId: string().optional()
153778
+ }), CreationSchemaOutputSchema),
153748
153779
  createDevice: method(object({
153749
153780
  type: _enum(DeviceType),
153750
- config: record(string(), unknown())
153781
+ config: record(string(), unknown()),
153782
+ /** The integration the operator adds the device to; a provider with several instances needs it. */
153783
+ integrationId: string().optional()
153751
153784
  }), DeviceSummarySchema, {
153752
153785
  kind: "mutation",
153753
153786
  auth: "admin"
@@ -154472,7 +154505,10 @@ method(object({
154472
154505
  auth: "admin"
154473
154506
  }), method(object({
154474
154507
  addonId: string(),
154475
- type: _enum(DeviceType)
154508
+ type: _enum(DeviceType),
154509
+ /** The integration the form is for; a provider whose integrations differ (a hub
154510
+ * integration takes no manual add) answers per integration. Absent = the addon's own. */
154511
+ integrationId: string().optional()
154476
154512
  }), unknown().nullable()), method(object({
154477
154513
  addonId: string(),
154478
154514
  type: _enum(DeviceType),
@@ -154556,7 +154592,11 @@ method(object({
154556
154592
  kind: "mutation",
154557
154593
  auth: "admin",
154558
154594
  timeoutMs: 12e4
154559
- }), method(object({ addonId: string() }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
154595
+ }), method(object({
154596
+ addonId: string(),
154597
+ /** The integration the Add-Device dialog is open on; absent = the addon's own. */
154598
+ integrationId: string().optional()
154599
+ }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
154560
154600
  deviceId: number(),
154561
154601
  key: string(),
154562
154602
  value: unknown()
@@ -184760,7 +184800,7 @@ var BaseDeviceProvider = class extends BaseAddon {
184760
184800
  * `deviceClasses` map (first registered type). `null` when manual creation is
184761
184801
  * unsupported. Lets the Add-Device dialog pick the right type per provider.
184762
184802
  */
184763
- async getManualCreationType() {
184803
+ async getManualCreationType(_input) {
184764
184804
  if (!await this.supportsManualCreation()) return { deviceType: null };
184765
184805
  return { deviceType: Object.values(DeviceType).find((t) => this.deviceClasses[t] !== void 0) ?? null };
184766
184806
  }
@@ -184771,7 +184811,7 @@ var BaseDeviceProvider = class extends BaseAddon {
184771
184811
  return true;
184772
184812
  }
184773
184813
  async getChildCreationSchema(input) {
184774
- return this.onGetCreationSchema(input.type);
184814
+ return this.onGetCreationSchema(input.type, { integrationId: input.integrationId });
184775
184815
  }
184776
184816
  /**
184777
184817
  * Default kernel-orchestrated `createDevice` implementation. The
@@ -184783,7 +184823,7 @@ var BaseDeviceProvider = class extends BaseAddon {
184783
184823
  * `deviceClasses` instead.
184784
184824
  */
184785
184825
  async createDevice(input) {
184786
- const spec = await this.onCreateDevice(input.type, input.config);
184826
+ const spec = await this.onCreateDevice(input.type, input.config, { ...input.integrationId !== void 0 ? { integrationId: input.integrationId } : {} });
184787
184827
  const Class = this.deviceClasses[spec.meta.type];
184788
184828
  if (!Class) throw new Error(`${this.providerName} provider: no device class registered for type "${spec.meta.type}" — add it to the deviceClasses map`);
184789
184829
  const stableId = this.generateStableId(spec.meta.type, spec.config);
@@ -212777,6 +212817,8 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
212777
212817
  * Mirrors the reference's `batteryUpdateTimer`: fires every hour,
212778
212818
  * passively checks sleep state, and short-circuits if sleeping. */
212779
212819
  batteryUpdateTimer = null;
212820
+ /** Set by `removeDevice`: nothing may re-arm a timer on a removed camera. */
212821
+ removed = false;
212780
212822
  /** Single-flight gate so two interval fires can't overlap. */
212781
212823
  /** Aux accessory references registered by spawned children
212782
212824
  * (siren / floodlight / pir). The parent's centralised align
@@ -217576,6 +217618,11 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
217576
217618
  });
217577
217619
  }
217578
217620
  async removeDevice() {
217621
+ this.removed = true;
217622
+ this.stopSleepPoll();
217623
+ this.stopBatteryUpdatePolling();
217624
+ this.stopAlignAuxPolling();
217625
+ this.stopWatchdogs();
217579
217626
  this.detachFromHubSession();
217580
217627
  if (this.reconnectTimer) {
217581
217628
  clearTimeout(this.reconnectTimer);
@@ -217745,6 +217792,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
217745
217792
  * `sleeping`/`awake` transition (firmware quirks, NAT timeouts).
217746
217793
  */
217747
217794
  startSleepPoll() {
217795
+ if (this.removed) return;
217748
217796
  if (this.sleepPollTimer) return;
217749
217797
  if (!this.isBattery) return;
217750
217798
  if (this.isHubChild()) return;
@@ -217884,6 +217932,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
217884
217932
  /** Start periodic align for wired cams. No-op for battery cams (wake
217885
217933
  * path handles it). Idempotent. */
217886
217934
  startAlignAuxPolling() {
217935
+ if (this.removed) return;
217887
217936
  if (this.alignAuxTimer) return;
217888
217937
  if (this.isBattery) return;
217889
217938
  const POLL_MS = 1e4;
@@ -217964,6 +218013,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
217964
218013
  /** Arm the scheduled-refresh check. No-op for wired cams (their state is
217965
218014
  * kept fresh by the 10 s aux-align poll and push events). Idempotent. */
217966
218015
  startBatteryUpdatePolling() {
218016
+ if (this.removed) return;
217967
218017
  if (this.batteryUpdateTimer) return;
217968
218018
  if (!this.isBattery) return;
217969
218019
  this.batteryUpdateTimer = setInterval(() => {
@@ -218093,6 +218143,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
218093
218143
  * with parallel watchdogs after a reconnect cycle.
218094
218144
  */
218095
218145
  startWatchdogs() {
218146
+ if (this.removed) return;
218096
218147
  this.stopWatchdogs();
218097
218148
  this.watchdogStartedAt = Date.now();
218098
218149
  this.consecutivePingFailures = 0;
@@ -218357,6 +218408,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
218357
218408
  * re-subscribes the moment the socket comes back up.
218358
218409
  */
218359
218410
  startEventHealthCheck() {
218411
+ if (this.removed) return;
218360
218412
  this.stopEventHealthCheck();
218361
218413
  this.consecutiveStaleHealthChecks = 0;
218362
218414
  this.nextEventHealthCheckAt = 0;
@@ -220492,6 +220544,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
220492
220544
  }
220493
220545
  });
220494
220546
  this.api = null;
220547
+ if (this.removed) return;
220495
220548
  this.reconnectTimer = setTimeout(() => {
220496
220549
  this.reconnectTimer = null;
220497
220550
  this.ctx.logger.debug("Baichuan reconnect window elapsed — ready for next demand", { tags: { deviceId: this.id } });
@@ -221682,6 +221735,19 @@ function reolinkInstancesProvider(instances, deps) {
221682
221735
  }
221683
221736
  };
221684
221737
  }
221738
+ /**
221739
+ * Whether an integration IS one NVR / Home Hub (its devices come from the hub, so there is no
221740
+ * manual add by IP). An integration the registry cannot name is not a hub for this question.
221741
+ */
221742
+ async function integrationIsHub(instances, deps, id) {
221743
+ const [evidence, body] = await Promise.all([deps.registryEvidenceOf(id), instances.getResolved(id)]);
221744
+ if (evidence === null) return false;
221745
+ return isHubIntegration({
221746
+ originStableId: evidence.originStableId,
221747
+ info: evidence.info,
221748
+ settings: body === null ? {} : hubSettingsOf(body)
221749
+ });
221750
+ }
221685
221751
  //#endregion
221686
221752
  //#region src/migrations/integration-rows-to-record.ts
221687
221753
  /**
@@ -222460,6 +222526,7 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
222460
222526
  autodetectCache = new AutodetectCache();
222461
222527
  hubManager = null;
222462
222528
  instances = null;
222529
+ hubIntegrationProbe = null;
222463
222530
  /**
222464
222531
  * The camera mailbox bridge (`email-push-bridge.ts`, D999): battery cameras mail motion to a
222465
222532
  * mailbox of the `smtp-inbound` broker, the bridge turns each message into the camera's
@@ -222970,6 +223037,7 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
222970
223037
  registryEvidenceOf
222971
223038
  });
222972
223039
  this.instances = instances;
223040
+ this.hubIntegrationProbe = (id) => integrationIsHub(instances, { registryEvidenceOf }, id);
222973
223041
  await this.runMigrations([...defineAddonMigrations(REOLINK_MIGRATIONS, this.migrationPorts()), ...defineAddonMigrations(REOLINK_INTEGRATION_MIGRATIONS, integrationPorts)]);
222974
223042
  this.wireEmailBridge();
222975
223043
  const wireSleepPushResolvers = (event, via) => {
@@ -223303,10 +223371,22 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
223303
223371
  config: input.candidate.prefilledConfig
223304
223372
  });
223305
223373
  }
223306
- async onGetCreationSchema(type) {
223374
+ async onGetCreationSchema(type, context) {
223307
223375
  if (type !== DeviceType.Camera) return null;
223376
+ if (await this.isHubIntegrationId(context?.integrationId)) return null;
223308
223377
  return buildCreationFormSchema();
223309
223378
  }
223379
+ /** A hub integration's devices come from the hub: no manual add by IP for it. */
223380
+ async getManualCreationType(input) {
223381
+ if (await this.isHubIntegrationId(input?.integrationId)) return { deviceType: null };
223382
+ return super.getManualCreationType(input);
223383
+ }
223384
+ /** `false` for no integration, or one the registry cannot name (the addon's own default). */
223385
+ async isHubIntegrationId(id) {
223386
+ const probe = this.hubIntegrationProbe;
223387
+ if (id === void 0 || probe === null) return false;
223388
+ return probe(id);
223389
+ }
223310
223390
  async onCreateDevice(type, config) {
223311
223391
  if (type !== DeviceType.Camera) throw new Error(`Reolink provider does not support device type: ${type}`);
223312
223392
  const name = getString(config, "name").trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-reolink",
3
- "version": "1.2.227",
3
+ "version": "1.2.229",
4
4
  "description": "Reolink camera device provider addon for CamStack — native Baichuan protocol",
5
5
  "keywords": [
6
6
  "camstack",
@@ -96,7 +96,7 @@
96
96
  "werift"
97
97
  ],
98
98
  "requires": {
99
- "server": ">=1.2.775"
99
+ "server": ">=1.2.779"
100
100
  }
101
101
  },
102
102
  "files": [