@camstack/addon-provider-reolink 1.2.259 → 1.2.260

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.mjs CHANGED
@@ -105922,9 +105922,9 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
105922
105922
  */
105923
105923
  EventCategory["DeviceStateChanged"] = "device.state-changed";
105924
105924
  /**
105925
- * A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
105926
- * transition audit (D1022): confirmed, already in place, unconfirmed or
105927
- * failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
105925
+ * A device COMMAND (a vocabulary action, D920/D983) completed, as the hub's
105926
+ * command audit saw it (D1022, D1084): the call returned (`ok`) or threw
105927
+ * (`failed`). Never a device's own change, and never proof the device obeyed. Payload: `DeviceCommandSettledEvent`
105928
105928
  * (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
105929
105929
  * the Notification Center `device-command` kind. Telemetry (D8): losing one
105930
105930
  * costs a notification, never state; the audit row is the record.
@@ -109023,6 +109023,15 @@ var BaseAddon = class {
109023
109023
  /** The instance kinds whose switch move this process already ran (or tried), by record kind name. */
109024
109024
  switchMoved = /* @__PURE__ */ new Set();
109025
109025
  lastDeclared = [];
109026
+ /**
109027
+ * Every switch migration this process added to a declaration so far, by id. The engine replaces
109028
+ * an owner's catalogue on each declare, so a later one (a late kind) carries them all: dropping
109029
+ * an earlier id would read its applied ledger row as a newer database.
109030
+ */
109031
+ switchDeclared = /* @__PURE__ */ new Map();
109032
+ /** The seq each kind's move got, fixed at its first declare so its id and seq never change. */
109033
+ switchSeqs = /* @__PURE__ */ new Map();
109034
+ moveInDeclared = false;
109026
109035
  registrySwitchBound() {
109027
109036
  const api = this.ctx.migrationApi;
109028
109037
  const spec = this.registrySwitchSpec;
@@ -109033,7 +109042,7 @@ var BaseAddon = class {
109033
109042
  return [];
109034
109043
  }
109035
109044
  const date = "2026-11-06";
109036
- const moveIn = spec === null ? [] : migrationSet([registrySwitchToBodyMigration({
109045
+ const moveIn = spec === null || this.moveInDeclared ? [] : migrationSet([registrySwitchToBodyMigration({
109037
109046
  addonId: this.ctx.id,
109038
109047
  date,
109039
109048
  seq: 1e3,
@@ -109043,12 +109052,15 @@ var BaseAddon = class {
109043
109052
  records: switchRecordsOverMigrationApi(a),
109044
109053
  kind: spec.kind
109045
109054
  })).bind(api);
109046
- const moveBack = kinds.flatMap(({ kind }, index) => {
109055
+ if (spec !== null) this.moveInDeclared = true;
109056
+ const moveBack = kinds.flatMap(({ kind }) => {
109047
109057
  this.switchMoved.add(kind.name);
109058
+ const seq = 1001 + this.switchSeqs.size;
109059
+ this.switchSeqs.set(kind.name, seq);
109048
109060
  return migrationSet([bodySwitchToRegistryMigration({
109049
109061
  addonId: this.ctx.id,
109050
109062
  date: "2026-11-19",
109051
- seq: 1001 + index,
109063
+ seq,
109052
109064
  kindName: kind.name,
109053
109065
  ...spec === null ? {} : { followsDate: date }
109054
109066
  })], (a) => bodySwitchPortsOver({
@@ -109086,7 +109098,8 @@ var BaseAddon = class {
109086
109098
  async runBound(declared, options) {
109087
109099
  this.lastDeclared = declared;
109088
109100
  const added = this.registrySwitchBound();
109089
- const migrations = [...declared, ...added];
109101
+ for (const m of added) this.switchDeclared.set(m.meta.id, m);
109102
+ const migrations = [...declared, ...[...this.switchDeclared.values()].filter((m) => !declared.some((d) => d.meta.id === m.meta.id))];
109090
109103
  const widened = options?.only === void 0 || added.length === 0 ? options : {
109091
109104
  ...options,
109092
109105
  only: [...new Set([...options.only, ...added.map((m) => m.meta.id)])]
@@ -110256,6 +110269,7 @@ function method(input, output, options) {
110256
110269
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
110257
110270
  ...options?.actions !== void 0 ? { actions: options.actions } : {},
110258
110271
  ...options?.notOperatorFacing !== void 0 ? { notOperatorFacing: options.notOperatorFacing } : {},
110272
+ ...options?.description !== void 0 ? { description: options.description } : {},
110259
110273
  timeoutMs: options?.timeoutMs
110260
110274
  };
110261
110275
  }
@@ -111871,6 +111885,11 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
111871
111885
  * water, cooling, solar), its system modes and its power. One main read-only
111872
111886
  * `heat-pump-status` cap carries all of it; `heat-pump-control` sets it (D1026). */
111873
111887
  DeviceType["HeatPump"] = "heat-pump";
111888
+ /** A road vehicle reached through its maker's connected-car account: odometer, range,
111889
+ * openings, tyre warnings and the 12 V battery in one read-only `vehicle` cap; where it
111890
+ * is in `location`; fuel, fluids and service in `consumables`. Its lock and its cabin
111891
+ * climate are accessory children (`lock-vehicle`, `climate-vehicle`). */
111892
+ DeviceType["Vehicle"] = "vehicle";
111874
111893
  /** A home energy installation (any vendor): solar, grid, house, a metered heat pump
111875
111894
  * and the storage as branches of one bus. One read-only `energy-system` cap carries
111876
111895
  * every value; the storage is a field of it, never the `battery` cap (#513, #522). */
@@ -112113,6 +112132,14 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
112113
112132
  /** One heating/cooling circuit of a heat pump: a water loop with comfort /
112114
112133
  * eco setpoints and a heat/cool mode, no room sensor. */
112115
112134
  DeviceRole["ClimateHeatPumpCircuit"] = "climate-heat-pump-circuit";
112135
+ /** A car's cabin: pre-conditioning (start / stop, target temperature) through the
112136
+ * maker's connected-car account. An accessory child of a vehicle. */
112137
+ DeviceRole["ClimateVehicle"] = "climate-vehicle";
112138
+ /** A car's central locking, an accessory child of a vehicle. Slow, cloud-held
112139
+ * commands; exports decide by `isVehicleLock`. */
112140
+ DeviceRole["LockVehicle"] = "lock-vehicle";
112141
+ /** A television: power, volume, channel, source and apps. */
112142
+ DeviceRole["MediaPlayerTv"] = "media-player-tv";
112116
112143
  /** Generic motion / occupancy / moving event source. Distinct from
112117
112144
  * the camera accessory PirSensor role: that one is a camera child;
112118
112145
  * this is a standalone HA / 3rd-party motion sensor. */
@@ -112687,7 +112714,9 @@ var brightnessCapability = {
112687
112714
  deviceNative: true,
112688
112715
  mode: "singleton",
112689
112716
  deviceTypes: [DeviceType.Light],
112690
- methods: { setBrightness: /* @__PURE__ */ method(/* @__PURE__ */ object({
112717
+ methods: {
112718
+ /** Set the light's brightness level from 0 to 100. */
112719
+ setBrightness: /* @__PURE__ */ method(/* @__PURE__ */ object({
112691
112720
  deviceId: /* @__PURE__ */ number().int().nonnegative(),
112692
112721
  level: /* @__PURE__ */ number().min(0).max(100)
112693
112722
  }), /* @__PURE__ */ _void(), {
@@ -112883,7 +112912,9 @@ var dayNightCapability = {
112883
112912
  tab: "image"
112884
112913
  } },
112885
112914
  methods: {
112915
+ /** The camera's day/night modes and current settings. */
112886
112916
  getOptions: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), DayNightOptionsSchema),
112917
+ /** Change the camera's day/night mode, sensitivity or switch delay. */
112887
112918
  setSettings: /* @__PURE__ */ method(/* @__PURE__ */ object({
112888
112919
  deviceId: /* @__PURE__ */ number(),
112889
112920
  settings: DayNightSettingsPatchSchema
@@ -113248,21 +113279,28 @@ var deviceAdoptionCapability = {
113248
113279
  kind: "poll"
113249
113280
  },
113250
113281
  methods: {
113282
+ /** The filters an integration offers to narrow its discovered candidates. */
113251
113283
  listCandidateFilters: /* @__PURE__ */ method(/* @__PURE__ */ object({ integrationId: /* @__PURE__ */ string() }), /* @__PURE__ */ object({ filters: /* @__PURE__ */ array(AdoptionFilterSchema) }), { auth: "admin" }),
113284
+ /** List the devices an integration has discovered and that can be adopted. */
113252
113285
  listCandidates: /* @__PURE__ */ method(ListCandidatesInputSchema, ListCandidatesOutputSchema, { auth: "admin" }),
113286
+ /** Fetch one discovered candidate; null when unknown. */
113253
113287
  getCandidate: /* @__PURE__ */ method(GetCandidateInputSchema, /* @__PURE__ */ DiscoveredChildDeviceSchema.nullable(), { auth: "admin" }),
113288
+ /** Rescan an integration for new candidates and report the adoption status. */
113254
113289
  refresh: /* @__PURE__ */ method(/* @__PURE__ */ object({ integrationId: /* @__PURE__ */ string() }), AdoptionStatusSchema, {
113255
113290
  kind: "mutation",
113256
113291
  auth: "admin"
113257
113292
  }),
113293
+ /** Adopt a discovered candidate as a device. */
113258
113294
  adopt: /* @__PURE__ */ method(AdoptInputSchema, AdoptResultSchema, {
113259
113295
  kind: "mutation",
113260
113296
  auth: "admin"
113261
113297
  }),
113298
+ /** Release an adopted device back to the candidate list. */
113262
113299
  release: /* @__PURE__ */ method(ReleaseInputSchema, /* @__PURE__ */ _void(), {
113263
113300
  kind: "mutation",
113264
113301
  auth: "admin"
113265
113302
  }),
113303
+ /** Re-read an adopted device from the integration and reconcile it. */
113266
113304
  resync: /* @__PURE__ */ method(ResyncInputSchema, ResyncResultSchema, {
113267
113305
  kind: "mutation",
113268
113306
  auth: "admin"
@@ -113626,9 +113664,13 @@ var deviceProviderCapability = {
113626
113664
  scope: "system",
113627
113665
  mode: "collection",
113628
113666
  methods: {
113667
+ /** Start the provider so it begins serving its devices. */
113629
113668
  start: /* @__PURE__ */ method(/* @__PURE__ */ _void(), /* @__PURE__ */ _void(), { kind: "mutation" }),
113669
+ /** Stop the provider. */
113630
113670
  stop: /* @__PURE__ */ method(/* @__PURE__ */ _void(), /* @__PURE__ */ _void(), { kind: "mutation" }),
113671
+ /** The provider's current status. */
113631
113672
  getStatus: /* @__PURE__ */ method(/* @__PURE__ */ _void(), ProviderStatusSchema),
113673
+ /** List the devices the provider serves. */
113632
113674
  getDevices: /* @__PURE__ */ method(/* @__PURE__ */ _void(), /* @__PURE__ */ array(/* @__PURE__ */ object({
113633
113675
  id: /* @__PURE__ */ string(),
113634
113676
  name: /* @__PURE__ */ string(),
@@ -113663,6 +113705,7 @@ var deviceProviderCapability = {
113663
113705
  kind: "mutation",
113664
113706
  timeoutMs: 3 * 6e4
113665
113707
  }),
113708
+ /** Whether the provider can discover devices on the network. */
113666
113709
  supportsDiscovery: /* @__PURE__ */ method(/* @__PURE__ */ object({}), /* @__PURE__ */ boolean()),
113667
113710
  /**
113668
113711
  * Run a network scan. `params` carries optional provider-specific scan
@@ -113708,6 +113751,7 @@ var deviceProviderCapability = {
113708
113751
  getManualCreationType: /* @__PURE__ */ method(/* @__PURE__ */ object({
113709
113752
  /** The integration asked about; a provider whose integrations differ answers per one. */
113710
113753
  integrationId: /* @__PURE__ */ string().optional() }), /* @__PURE__ */ object({ deviceType: /* @__PURE__ */ _enum(DeviceType).nullable() })),
113754
+ /** Adopt a discovered candidate as a device, optionally into an integration instance. */
113711
113755
  adoptDiscoveredDevice: /* @__PURE__ */ method(/* @__PURE__ */ object({
113712
113756
  candidate: DiscoveryCandidateSchema,
113713
113757
  /** The integration the operator adopts into; a provider with several instances needs it. */
@@ -113716,6 +113760,7 @@ integrationId: /* @__PURE__ */ string().optional() }), /* @__PURE__ */ object({
113716
113760
  kind: "mutation",
113717
113761
  auth: "admin"
113718
113762
  }),
113763
+ /** Whether devices can be created by hand through this provider. */
113719
113764
  supportsManualCreation: /* @__PURE__ */ method(/* @__PURE__ */ object({}), /* @__PURE__ */ boolean()),
113720
113765
  /**
113721
113766
  * Fetch the creation form schema for a given DeviceType. Returns
@@ -113728,6 +113773,7 @@ integrationId: /* @__PURE__ */ string().optional() }), /* @__PURE__ */ object({
113728
113773
  /** The integration asked about; a provider whose integrations differ answers per one. */
113729
113774
  integrationId: /* @__PURE__ */ string().optional()
113730
113775
  }), CreationSchemaOutputSchema),
113776
+ /** Create a device of a given type with the given config. */
113731
113777
  createDevice: /* @__PURE__ */ method(/* @__PURE__ */ object({
113732
113778
  type: /* @__PURE__ */ _enum(DeviceType),
113733
113779
  config: /* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ unknown()),
@@ -113837,11 +113883,13 @@ var deviceStateRefreshCapability = {
113837
113883
  deviceNative: true,
113838
113884
  mode: "singleton",
113839
113885
  methods: {
113886
+ /** Re-read a device's state from the source now. */
113840
113887
  refresh: /* @__PURE__ */ method(DeviceStateRefreshInputSchema, DeviceStateRefreshResultSchema, {
113841
113888
  kind: "mutation",
113842
113889
  auth: "admin",
113843
113890
  notOperatorFacing: NOT_OPERATOR_FACING
113844
113891
  }),
113892
+ /** Re-establish a device's live state subscription. */
113845
113893
  resubscribe: /* @__PURE__ */ method(DeviceStateResubscribeInputSchema, DeviceStateRefreshResultSchema, {
113846
113894
  kind: "mutation",
113847
113895
  auth: "admin",
@@ -114054,7 +114102,10 @@ onPressed: {
114054
114102
  };
114055
114103
  //#endregion
114056
114104
  //#region ../types/dist/esm/capabilities/error.cap.mjs
114057
- /** How loudly a fault wants the operator. Both tiers raise the attention event. */
114105
+ /**
114106
+ * How loudly a fault wants the operator. An `error` raises the attention event;
114107
+ * a `warning` is shown on the device and opens a warning alert, nothing more.
114108
+ */
114058
114109
  var DeviceErrorSeveritySchema = /* @__PURE__ */ _enum(["warning", "error"]);
114059
114110
  /** One fault of a device that can raise several at once. */
114060
114111
  var DeviceFaultSchema = /* @__PURE__ */ object({
@@ -114508,7 +114559,9 @@ var imageSettingsCapability = {
114508
114559
  tab: "image"
114509
114560
  } },
114510
114561
  methods: {
114562
+ /** The camera's picture-adjustment options and current values. */
114511
114563
  getOptions: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), ImageSettingsOptionsSchema),
114564
+ /** Change the camera's picture settings (brightness, contrast, orientation, exposure, ...). */
114512
114565
  setSettings: /* @__PURE__ */ method(/* @__PURE__ */ object({
114513
114566
  deviceId: /* @__PURE__ */ number(),
114514
114567
  settings: ImageSettingsPatchSchema
@@ -114798,6 +114851,7 @@ var integrationInstancesCapability = {
114798
114851
  scope: "system",
114799
114852
  mode: "collection",
114800
114853
  methods: {
114854
+ /** What kind of instances this addon's integration holds and how to configure them. */
114801
114855
  describe: /* @__PURE__ */ method(/* @__PURE__ */ _void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
114802
114856
  /** The form; `id: null` is the create form. */
114803
114857
  instanceFormSchema: /* @__PURE__ */ method(/* @__PURE__ */ object({
@@ -114813,10 +114867,12 @@ var integrationInstancesCapability = {
114813
114867
  /** The discovery candidate the wizard was seeded from (`stableId`), if any. */
114814
114868
  candidateStableId: /* @__PURE__ */ string().min(1).optional()
114815
114869
  }), ConfigSchemaPassthrough, { auth: "admin" }),
114870
+ /** List the integration's instances (accounts, relays, destinations). */
114816
114871
  listInstances: /* @__PURE__ */ method(/* @__PURE__ */ looseObject({}), /* @__PURE__ */ array(IntegrationInstanceSchema).readonly(), {
114817
114872
  auth: "protected",
114818
114873
  caller: "scoped"
114819
114874
  }),
114875
+ /** Fetch one integration instance by id; null when absent. */
114820
114876
  getInstance: /* @__PURE__ */ method(/* @__PURE__ */ object({ id: IntegrationInstanceIdSchema }), /* @__PURE__ */ IntegrationInstanceSchema.nullable(), {
114821
114877
  auth: "protected",
114822
114878
  caller: "scoped"
@@ -114856,6 +114912,7 @@ var integrationInstancesCapability = {
114856
114912
  auth: "protected",
114857
114913
  caller: "scoped"
114858
114914
  }),
114915
+ /** Create or change an integration instance. */
114859
114916
  updateInstance: /* @__PURE__ */ method(IntegrationInstancePatchSchema, /* @__PURE__ */ object({ ok: /* @__PURE__ */ literal(true) }), {
114860
114917
  kind: "mutation",
114861
114918
  auth: "protected",
@@ -114884,6 +114941,7 @@ var integrationInstancesCapability = {
114884
114941
  auth: "protected",
114885
114942
  caller: "scoped"
114886
114943
  }),
114944
+ /** Test an instance's connection with the given values before saving. */
114887
114945
  testInstance: /* @__PURE__ */ optionalMethod(/* @__PURE__ */ object({
114888
114946
  id: /* @__PURE__ */ IntegrationInstanceIdSchema.nullable(),
114889
114947
  values: /* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ unknown()),
@@ -115001,6 +115059,7 @@ var intercomCapability = {
115001
115059
  auth: "protected",
115002
115060
  notOperatorFacing: "live-stream session plumbing driven by a viewer, never a discrete step"
115003
115061
  }),
115062
+ /** Pass the viewer's SDP answer to an open two-way audio session. */
115004
115063
  handleAnswer: /* @__PURE__ */ method(/* @__PURE__ */ object({
115005
115064
  deviceId: /* @__PURE__ */ number(),
115006
115065
  sessionId: /* @__PURE__ */ string(),
@@ -115671,7 +115730,12 @@ DeviceType.Camera;
115671
115730
  * - `pipeline` — the chosen detector plus the operator's detail steps
115672
115731
  * (faces, plates, classifiers, CLIP…), on varied frames from the bench
115673
115732
  * clip: how many parallel sessions the node carries before latency, drops,
115674
- * CPU, RAM or the event loop give out.
115733
+ * CPU, RAM or the event loop give out;
115734
+ * - `decode` — the node, no accelerator of the inference plane: an encoded
115735
+ * camera-like stream (a profile: resolution, rate, codec) served on the
115736
+ * loopback and decoded by the session decode worker a camera gets, with a
115737
+ * motion pass on its frames: how many concurrent streams keep the profile
115738
+ * frame rate inside the same CPU and RAM limits (D1078).
115675
115739
  */
115676
115740
  /** Defaults and bounds, one place. */
115677
115741
  var NODE_BENCHMARK_DEFAULTS = {
@@ -115690,9 +115754,24 @@ var NODE_BENCHMARK_DEFAULTS = {
115690
115754
  /** Candidate models per device in one run. */
115691
115755
  maxModelsPerDevice: 6
115692
115756
  };
115757
+ /**
115758
+ * The camera-like streams the `decode` measurement ramps, heaviest first: a
115759
+ * 4K H.265 main stream and a 1080p H.264 one, at a camera frame rate.
115760
+ */
115761
+ var NODE_BENCH_DECODE_PROFILES = [{
115762
+ width: 3840,
115763
+ height: 2160,
115764
+ fps: 15,
115765
+ codec: "h265"
115766
+ }, {
115767
+ width: 1920,
115768
+ height: 1080,
115769
+ fps: 15,
115770
+ codec: "h264"
115771
+ }];
115693
115772
  NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice;
115694
115773
  NODE_BENCHMARK_DEFAULTS.fpsPerStream, NODE_BENCHMARK_DEFAULTS.budgetMinutes;
115695
- NODE_BENCHMARK_DEFAULTS.settleSec, NODE_BENCHMARK_DEFAULTS.measureSec;
115774
+ [...NODE_BENCH_DECODE_PROFILES], NODE_BENCHMARK_DEFAULTS.settleSec, NODE_BENCHMARK_DEFAULTS.measureSec;
115696
115775
  /**
115697
115776
  * Per-camera tunable ranges + defaults. Single source of truth used
115698
115777
  * by both the Zod data schema (validation + default fallback) and
@@ -116052,7 +116131,9 @@ var motionTriggerCapability = {
116052
116131
  DeviceType.Siren,
116053
116132
  DeviceType.Switch
116054
116133
  ],
116055
- methods: { setMotionTrigger: /* @__PURE__ */ method(/* @__PURE__ */ object({
116134
+ methods: {
116135
+ /** Turn on or off activating the accessory when the camera detects motion. */
116136
+ setMotionTrigger: /* @__PURE__ */ method(/* @__PURE__ */ object({
116056
116137
  deviceId: /* @__PURE__ */ number().int().nonnegative(),
116057
116138
  enabled: /* @__PURE__ */ boolean()
116058
116139
  }), /* @__PURE__ */ _void(), {
@@ -116171,7 +116252,9 @@ var motionZonesCapability = {
116171
116252
  label: "Motion Zones"
116172
116253
  } },
116173
116254
  methods: {
116255
+ /** The camera's onboard motion zone options and current zone. */
116174
116256
  getOptions: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), MotionZoneOptionsSchema),
116257
+ /** Change the camera's onboard motion zone. */
116175
116258
  setZone: /* @__PURE__ */ method(/* @__PURE__ */ object({
116176
116259
  deviceId: /* @__PURE__ */ number(),
116177
116260
  patch: MotionZonePatchSchema
@@ -116299,7 +116382,9 @@ var nativeObjectDetectionCapability = {
116299
116382
  mode: "singleton",
116300
116383
  deviceTypes: [DeviceType.Camera],
116301
116384
  methods: {
116385
+ /** The object classes the camera's onboard detection supports and its current settings. */
116302
116386
  getOptions: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), NativeObjectDetectionOptionsSchema),
116387
+ /** Change the camera's onboard object detection settings. */
116303
116388
  setSettings: /* @__PURE__ */ method(/* @__PURE__ */ object({
116304
116389
  deviceId: /* @__PURE__ */ number(),
116305
116390
  settings: NativeObjectDetectionSettingsPatchSchema
@@ -116307,6 +116392,7 @@ var nativeObjectDetectionCapability = {
116307
116392
  kind: "mutation",
116308
116393
  auth: "admin"
116309
116394
  }),
116395
+ /** Turn the camera's onboard object detection on or off. */
116310
116396
  setEnabled: /* @__PURE__ */ method(/* @__PURE__ */ object({
116311
116397
  deviceId: /* @__PURE__ */ number(),
116312
116398
  enabled: /* @__PURE__ */ boolean()
@@ -116742,7 +116828,9 @@ var privacyMaskCapability = {
116742
116828
  label: "Privacy Mask"
116743
116829
  } },
116744
116830
  methods: {
116831
+ /** The camera's privacy mask options and current mask. */
116745
116832
  getOptions: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), PrivacyMaskOptionsSchema),
116833
+ /** Change the camera's privacy mask. */
116746
116834
  setMask: /* @__PURE__ */ method(/* @__PURE__ */ object({
116747
116835
  deviceId: /* @__PURE__ */ number(),
116748
116836
  patch: PrivacyMaskPatchSchema
@@ -117033,10 +117121,12 @@ var ptzCapability = {
117033
117121
  order: 0
117034
117122
  } },
117035
117123
  methods: {
117124
+ /** Nudge the camera by a relative pan, tilt or zoom step. */
117036
117125
  move: /* @__PURE__ */ method(/* @__PURE__ */ PtzMoveCommandSchema.extend({ deviceId: /* @__PURE__ */ number() }), /* @__PURE__ */ _void(), {
117037
117126
  kind: "mutation",
117038
117127
  notOperatorFacing: "a relative nudge from the live-view joystick; a fixed place is a preset"
117039
117128
  }),
117129
+ /** Move the camera continuously until stopped. */
117040
117130
  continuousMove: /* @__PURE__ */ method(/* @__PURE__ */ PtzMoveCommandSchema.extend({ deviceId: /* @__PURE__ */ number() }), /* @__PURE__ */ _void(), {
117041
117131
  kind: "mutation",
117042
117132
  notOperatorFacing: "joystick motion held until released — continuous, not a discrete step"
@@ -117055,7 +117145,9 @@ var ptzCapability = {
117055
117145
  icon: "house"
117056
117146
  }]
117057
117147
  }),
117148
+ /** List the camera's PTZ presets. */
117058
117149
  getPresets: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), /* @__PURE__ */ array(PtzPresetSchema)),
117150
+ /** Move the camera to a preset. */
117059
117151
  goToPreset: /* @__PURE__ */ method(/* @__PURE__ */ object({
117060
117152
  deviceId: /* @__PURE__ */ number(),
117061
117153
  presetId: /* @__PURE__ */ string()
@@ -117079,6 +117171,7 @@ var ptzCapability = {
117079
117171
  }]
117080
117172
  }]
117081
117173
  }),
117174
+ /** Save the camera's current position as a named preset. */
117082
117175
  savePreset: /* @__PURE__ */ method(/* @__PURE__ */ object({
117083
117176
  deviceId: /* @__PURE__ */ number(),
117084
117177
  presetId: /* @__PURE__ */ string(),
@@ -117108,6 +117201,7 @@ var ptzCapability = {
117108
117201
  }]
117109
117202
  }]
117110
117203
  }),
117204
+ /** Delete a PTZ preset. */
117111
117205
  deletePreset: /* @__PURE__ */ method(/* @__PURE__ */ object({
117112
117206
  deviceId: /* @__PURE__ */ number(),
117113
117207
  presetId: /* @__PURE__ */ string()
@@ -117115,7 +117209,9 @@ var ptzCapability = {
117115
117209
  kind: "mutation",
117116
117210
  auth: "admin"
117117
117211
  }),
117212
+ /** What the camera's PTZ supports (axes, speeds, presets). */
117118
117213
  getOptions: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), PtzOptionsSchema),
117214
+ /** Stop any PTZ movement. */
117119
117215
  stop: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), /* @__PURE__ */ _void(), {
117120
117216
  kind: "mutation",
117121
117217
  actions: [{
@@ -117476,7 +117572,9 @@ var rebootCapability = {
117476
117572
  DeviceType.Switch,
117477
117573
  DeviceType.Gateway
117478
117574
  ],
117479
- methods: { reboot: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number().int().nonnegative() }), /* @__PURE__ */ object({ success: /* @__PURE__ */ literal(true) }), {
117575
+ methods: {
117576
+ /** Reboot the device. */
117577
+ reboot: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number().int().nonnegative() }), /* @__PURE__ */ object({ success: /* @__PURE__ */ literal(true) }), {
117480
117578
  kind: "mutation",
117481
117579
  auth: "admin",
117482
117580
  actions: [{
@@ -118193,6 +118291,7 @@ var videoclipsCapability = {
118193
118291
  order: 100
118194
118292
  } },
118195
118293
  methods: {
118294
+ /** List a camera's clips in a time window, from every clip source. */
118196
118295
  listClips: /* @__PURE__ */ method(/* @__PURE__ */ object({
118197
118296
  deviceId: /* @__PURE__ */ number(),
118198
118297
  since: /* @__PURE__ */ number(),
@@ -118251,6 +118350,7 @@ var videoclipsCapability = {
118251
118350
  kind: "query",
118252
118351
  auth: "protected"
118253
118352
  }),
118353
+ /** How to play one clip, at the requested quality. */
118254
118354
  getClipPlayback: /* @__PURE__ */ method(/* @__PURE__ */ object({
118255
118355
  deviceId: /* @__PURE__ */ number(),
118256
118356
  clipId: /* @__PURE__ */ string(),
@@ -118865,7 +118965,9 @@ var recordingOnboardCapability = {
118865
118965
  tab: "recording"
118866
118966
  } },
118867
118967
  methods: {
118968
+ /** The camera's onboard recording options and current settings. */
118868
118969
  getOptions: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), RecordingOnboardOptionsSchema),
118970
+ /** Change the camera's onboard recording settings. */
118869
118971
  setSettings: /* @__PURE__ */ method(/* @__PURE__ */ object({
118870
118972
  deviceId: /* @__PURE__ */ number(),
118871
118973
  settings: RecordingOnboardPatchSchema
@@ -119177,6 +119279,7 @@ var snapshotCapability = {
119177
119279
  deviceTypes: [DeviceType.Camera],
119178
119280
  exposesDeviceSettings: true,
119179
119281
  methods: {
119282
+ /** A current snapshot image of a camera, optionally bypassing the cache. */
119180
119283
  getSnapshot: /* @__PURE__ */ method(/* @__PURE__ */ object({
119181
119284
  deviceId: /* @__PURE__ */ number(),
119182
119285
  streamId: /* @__PURE__ */ string().optional(),
@@ -119198,6 +119301,7 @@ var snapshotCapability = {
119198
119301
  */
119199
119302
  force: /* @__PURE__ */ boolean().optional()
119200
119303
  }), /* @__PURE__ */ SnapshotImageSchema.nullable()),
119304
+ /** Drop a camera's cached snapshot. */
119201
119305
  invalidateCache: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), /* @__PURE__ */ _void(), {
119202
119306
  kind: "mutation",
119203
119307
  auth: "admin"
@@ -119449,7 +119553,9 @@ var streamCatalogCapability = {
119449
119553
  deviceNative: true,
119450
119554
  mode: "singleton",
119451
119555
  deviceTypes: [DeviceType.Camera],
119452
- methods: { getCatalog: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number().int().nonnegative() }), /* @__PURE__ */ array(CamStreamDescriptorSchema).readonly()) },
119556
+ methods: {
119557
+ /** List the streams a camera offers. */
119558
+ getCatalog: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number().int().nonnegative() }), /* @__PURE__ */ array(CamStreamDescriptorSchema).readonly()) },
119453
119559
  runtimeState: StreamCatalogStateSchema,
119454
119560
  /**
119455
119561
  * Runtime-state durability: **restored** — see the schema doc. A cold
@@ -119581,7 +119687,9 @@ var streamParamsCapability = {
119581
119687
  tab: "streaming"
119582
119688
  } },
119583
119689
  methods: {
119690
+ /** The camera's stream profiles and their encoding options. */
119584
119691
  getOptions: /* @__PURE__ */ method(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), StreamParamsOptionsSchema),
119692
+ /** Change the encoding settings of one stream profile. */
119585
119693
  setProfile: /* @__PURE__ */ method(/* @__PURE__ */ object({
119586
119694
  deviceId: /* @__PURE__ */ number(),
119587
119695
  profile: StreamProfileSchema,
@@ -119811,6 +119919,7 @@ var switchCapability = {
119811
119919
  DeviceType.Fan
119812
119920
  ],
119813
119921
  methods: {
119922
+ /** Turn the switch on or off. */
119814
119923
  setState: /* @__PURE__ */ method(/* @__PURE__ */ object({
119815
119924
  deviceId: /* @__PURE__ */ number(),
119816
119925
  on: /* @__PURE__ */ boolean()
@@ -119841,12 +119950,15 @@ var switchCapability = {
119841
119950
  offeredWhen: SWITCH_SETTABLE_GATE
119842
119951
  }]
119843
119952
  }),
119953
+ /** The options the switch supports. */
119844
119954
  getOptions: /* @__PURE__ */ optionalMethod(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), SwitchOptionsSchema, { auth: "protected" }),
119955
+ /** Power-cycle the device the switch powers. */
119845
119956
  powerCycle: /* @__PURE__ */ optionalMethod(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), /* @__PURE__ */ _void(), {
119846
119957
  kind: "mutation",
119847
119958
  auth: "protected",
119848
119959
  notOperatorFacing: "a power cycle is the forced restart of the device the switch powers (power-source), never a step of its own"
119849
119960
  }),
119961
+ /** Flip the switch to the opposite state. */
119850
119962
  toggle: /* @__PURE__ */ optionalMethod(/* @__PURE__ */ object({ deviceId: /* @__PURE__ */ number() }), /* @__PURE__ */ _void(), {
119851
119963
  kind: "mutation",
119852
119964
  auth: "protected",
@@ -121175,6 +121287,10 @@ async function declareDeviceIdentifiers(deps, raw, options = {}) {
121175
121287
  }
121176
121288
  }
121177
121289
  //#endregion
121290
+ //#region ../types/dist/esm/notification/alert-episode.mjs
121291
+ /** The category of the alert a device's `error` cap opens for its fault. */
121292
+ var DEVICE_ERROR_ALERT_CATEGORY = "device.error";
121293
+ //#endregion
121178
121294
  //#region ../types/dist/esm/device/device-error-episode.mjs
121179
121295
  /**
121180
121296
  * The edge between two readings, or `null` for no edge.
@@ -121190,6 +121306,75 @@ function deviceErrorEdge(previous, next) {
121190
121306
  if (next.active === false && previous?.active === true) return "resolve";
121191
121307
  return null;
121192
121308
  }
121309
+ /**
121310
+ * The alert severity of a fault tier. `error` is the cap's top tier and asks
121311
+ * for attention (`critical`); `warning` stays a warning.
121312
+ */
121313
+ function deviceErrorAlertSeverity(severity) {
121314
+ return severity === "error" ? "critical" : "warning";
121315
+ }
121316
+ var DEVICE_ERROR_ALERT_IDLE = {
121317
+ neverOpened: false,
121318
+ pending: null,
121319
+ attempts: 0
121320
+ };
121321
+ /**
121322
+ * The alert write a reading asks for.
121323
+ *
121324
+ * - a START opens; a `warning` fault that becomes an `error` opens again (same
121325
+ * alert id and episode, now critical). An error that eases to a warning
121326
+ * writes nothing: its critical alert stays until the fault resolves;
121327
+ * - a RESOLVE closes, except an alert this process knows was never accepted —
121328
+ * that one has nothing to close, and its failed open is dropped;
121329
+ * - with no edge, a failed write is tried again while the reading still asks
121330
+ * for it. An unknown reading asks for nothing (D49).
121331
+ */
121332
+ function planDeviceErrorAlert(delivery, edge, previous, next) {
121333
+ if (edge === "start") return {
121334
+ write: "open",
121335
+ delivery: {
121336
+ neverOpened: true,
121337
+ pending: "open",
121338
+ attempts: 0
121339
+ }
121340
+ };
121341
+ if (edge === "resolve") {
121342
+ if (delivery.neverOpened) return {
121343
+ write: null,
121344
+ delivery: DEVICE_ERROR_ALERT_IDLE
121345
+ };
121346
+ return {
121347
+ write: "close",
121348
+ delivery: {
121349
+ neverOpened: false,
121350
+ pending: "close",
121351
+ attempts: 0
121352
+ }
121353
+ };
121354
+ }
121355
+ if (next.active === true) {
121356
+ if (previous?.active === true && previous.severity === "warning" && next.severity === "error") return {
121357
+ write: "open",
121358
+ delivery: {
121359
+ ...delivery,
121360
+ pending: "open",
121361
+ attempts: 0
121362
+ }
121363
+ };
121364
+ if (delivery.pending === "open") return {
121365
+ write: "open",
121366
+ delivery
121367
+ };
121368
+ }
121369
+ if (next.active === false && delivery.pending === "close") return {
121370
+ write: "close",
121371
+ delivery
121372
+ };
121373
+ return {
121374
+ write: null,
121375
+ delivery
121376
+ };
121377
+ }
121193
121378
  function deviceErrorAlertId(deviceId) {
121194
121379
  return `device-error:${String(deviceId)}`;
121195
121380
  }
@@ -121214,8 +121399,8 @@ function buildDeviceErrorAlert(deviceId, deviceName, status, now) {
121214
121399
  const alertId = deviceErrorAlertId(deviceId);
121215
121400
  return {
121216
121401
  id: alertId,
121217
- category: "device.error",
121218
- severity: "critical",
121402
+ category: DEVICE_ERROR_ALERT_CATEGORY,
121403
+ severity: deviceErrorAlertSeverity(status.severity),
121219
121404
  title: `${deviceName}: ${label}`,
121220
121405
  message: `${deviceName} reports a fault: ${label}.`,
121221
121406
  action: {
@@ -121292,6 +121477,7 @@ var DEVICE_LOCAL_STATE_CAP_NAMES = {
121292
121477
  intercom: "intercom",
121293
121478
  irTransmitter: "ir-transmitter",
121294
121479
  lawnMowerControl: "lawn-mower-control",
121480
+ location: "location",
121295
121481
  lockControl: "lock-control",
121296
121482
  lowPowerSleep: "low-power-sleep",
121297
121483
  mediaPlayer: "media-player",
@@ -121330,6 +121516,7 @@ var DEVICE_LOCAL_STATE_CAP_NAMES = {
121330
121516
  update: "update",
121331
121517
  vacuumControl: "vacuum-control",
121332
121518
  valve: "valve",
121519
+ vehicle: "vehicle",
121333
121520
  vibration: "vibration",
121334
121521
  waterHeater: "water-heater",
121335
121522
  weather: "weather",
@@ -121349,6 +121536,8 @@ var BaseDevice = class {
121349
121536
  statusIsExternal;
121350
121537
  /** The fault catalog the integration declared; `[]` until it does. */
121351
121538
  faultTypes = [];
121539
+ /** What the alerts cap accepted for this device's fault, and the write still owed to it. */
121540
+ errorAlertDelivery = DEVICE_ERROR_ALERT_IDLE;
121352
121541
  name;
121353
121542
  parentDeviceId;
121354
121543
  role;
@@ -121701,51 +121890,81 @@ var BaseDevice = class {
121701
121890
  /**
121702
121891
  * Publish the device's fault. The slice is written; on an EDGE (a fault
121703
121892
  * starts, or one resolves) an attention episode opens or closes through the
121704
- * alerts cap, which the notification center announces as
121705
- * `device-attention-required` / `-resolved`. An unknown reading is never an
121706
- * edge. No rule exists by default: it notifies when the operator makes one.
121893
+ * alerts cap, at the severity of the fault's tier: an `error` fault is a
121894
+ * critical alert, which the notification center announces as
121895
+ * `device-attention-required` / `-resolved`; a `warning` fault is a warning
121896
+ * alert and announces nothing until it becomes an error. An unknown reading
121897
+ * is never an edge. No rule exists by default: it notifies when the operator
121898
+ * makes one.
121899
+ *
121900
+ * An alert write that fails is tried again on the next reading that still
121901
+ * asks for it, `DEVICE_ERROR_ALERT_MAX_ATTEMPTS` times at most.
121707
121902
  */
121708
121903
  async publishError(reading) {
121709
121904
  const previous = this.getCapSlice(errorCapability);
121710
121905
  if (reading.active === null && previous !== null && previous.active !== null) return;
121711
121906
  const now = Date.now();
121712
121907
  const edge = deviceErrorEdge(previous, reading);
121713
- const next = edge === "start" && reading.since === null ? {
121908
+ const next = this.withErrorSince(previous, reading, edge === "start", now);
121909
+ this.setCapSlice(errorCapability, next);
121910
+ const plan = planDeviceErrorAlert(this.errorAlertDelivery, edge, previous, next);
121911
+ this.errorAlertDelivery = plan.delivery;
121912
+ if (plan.write === null) return;
121913
+ await this.writeErrorAlert(plan.write, next, now);
121914
+ }
121915
+ /** A fault keeps the start it was given: stamped on the start, carried while it lasts. */
121916
+ withErrorSince(previous, reading, starts, now) {
121917
+ if (reading.active !== true || reading.since !== null) return reading;
121918
+ if (starts) return {
121714
121919
  ...reading,
121715
121920
  since: now
121716
- } : reading;
121717
- this.setCapSlice(errorCapability, next);
121718
- if (edge === null) return;
121719
- const alerts = this.ctx.api.alerts;
121720
- if (alerts === void 0) {
121721
- this.ctx.logger.warn("device error: attention event skipped — alerts capability missing", {
121722
- tags: { deviceId: this.id },
121723
- meta: { edge }
121724
- });
121725
- return;
121726
- }
121921
+ };
121922
+ return previous?.since == null ? reading : {
121923
+ ...reading,
121924
+ since: previous.since
121925
+ };
121926
+ }
121927
+ /** One attempt at the alert write the plan asked for; a failure stays owed, under the bound. */
121928
+ async writeErrorAlert(write, status, now) {
121929
+ const attempt = this.errorAlertDelivery.attempts + 1;
121727
121930
  try {
121728
- if (edge === "start") await alerts.emit.mutate(buildDeviceErrorAlert(this.id, this.name, next, now));
121729
- else await alerts.update.mutate({
121730
- alertId: deviceErrorAlertId(this.id),
121731
- patch: {
121732
- status: "completed",
121733
- read: true,
121734
- updatedAt: now
121735
- }
121736
- });
121737
- this.ctx.logger.info(`device error: ${edge === "start" ? "raised" : "resolved"}`, {
121931
+ const alerts = this.ctx.api.alerts;
121932
+ if (alerts === void 0) throw new Error("alerts capability missing");
121933
+ if (write === "open") {
121934
+ await alerts.emit.mutate(buildDeviceErrorAlert(this.id, this.name, status, now));
121935
+ this.errorAlertDelivery = DEVICE_ERROR_ALERT_IDLE;
121936
+ } else {
121937
+ await alerts.update.mutate({
121938
+ alertId: deviceErrorAlertId(this.id),
121939
+ patch: {
121940
+ status: "completed",
121941
+ read: true,
121942
+ updatedAt: now
121943
+ }
121944
+ });
121945
+ this.errorAlertDelivery = DEVICE_ERROR_ALERT_IDLE;
121946
+ }
121947
+ this.ctx.logger.info(`device error: ${write === "open" ? "raised" : "resolved"}`, {
121738
121948
  tags: { deviceId: this.id },
121739
121949
  meta: {
121740
- code: next.code,
121741
- label: next.label
121950
+ code: status.code,
121951
+ label: status.label,
121952
+ severity: status.severity,
121953
+ attempt
121742
121954
  }
121743
121955
  });
121744
121956
  } catch (err) {
121745
- this.ctx.logger.warn("device error: attention event failed", {
121957
+ const givenUp = attempt >= 5;
121958
+ this.errorAlertDelivery = {
121959
+ ...this.errorAlertDelivery,
121960
+ pending: givenUp ? null : write,
121961
+ attempts: givenUp ? 0 : attempt
121962
+ };
121963
+ this.ctx.logger.warn(givenUp ? "device error: attention event given up, the alert is not written" : "device error: attention event failed, retried on the next reading", {
121746
121964
  tags: { deviceId: this.id },
121747
121965
  meta: {
121748
- edge,
121966
+ write,
121967
+ attempt,
121749
121968
  error: errMsg$3(err)
121750
121969
  }
121751
121970
  });
@@ -129718,12 +129937,21 @@ function reportsPowerSource(info) {
129718
129937
  * sleep, or while on mains or a panel, reports `0` as a placeholder — device
129719
129938
  * 3628 sat at 100% on its adapter and raised a low-battery notification on
129720
129939
  * every hourly wake. Those zeros are UNMEASURED: the caller keeps the last real
129721
- * level. A `0` from an awake camera running on its cell alone (or of unknown
129722
- * source) is a genuine empty cell and passes, as does every non-zero level.
129940
+ * level.
129941
+ *
129942
+ * The same placeholder also arrives with NO power source to blame (device 3628,
129943
+ * its own Baichuan read): `batteryPercent: 0, chargeStatus: "none",
129944
+ * adapterStatus: "none", voltage: 0, current: 0, temperature: 0`, awake — an
129945
+ * all-zero payload that raised an empty-battery alert; the next read was 99.
129946
+ * A `0` level with a present `voltage` of 0 carries no cell measurement at all,
129947
+ * so it is UNMEASURED too. A `0` from an awake camera on its cell alone with a
129948
+ * real voltage (or a payload without the field) is a genuine empty cell and
129949
+ * passes, as does every non-zero level.
129723
129950
  */
129724
129951
  function isMeasuredCameraBatteryLevel(level, context) {
129725
129952
  if (level !== 0) return true;
129726
129953
  if (context.sleeping) return false;
129954
+ if (context.voltage === 0) return false;
129727
129955
  return context.charging !== "dc" && context.charging !== "solar";
129728
129956
  }
129729
129957
  /** What the cell is doing, from `chargeStatus`. Absent is `'unknown'`, never `'idle'` (D315). */
@@ -135989,6 +136217,13 @@ var REOLINK_AUDIO_STREAM_KEYS = [
135989
136217
  "thirdStream"
135990
136218
  ];
135991
136219
  /** Generate a short random hex token for per-stream RTSP-style credentials. */
136220
+ /**
136221
+ * The error a login dialled with replaced settings ends with. A caller still
136222
+ * awaiting it retries through `ensureApi`, which dials with the new settings.
136223
+ */
136224
+ function supersededLoginError(cause) {
136225
+ return new Error("Reolink login superseded by a connection settings change", { cause: cause ?? void 0 });
136226
+ }
135992
136227
  function randomToken(bytes) {
135993
136228
  return randomBytes(bytes).toString("hex");
135994
136229
  }
@@ -136389,6 +136624,14 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
136389
136624
  }
136390
136625
  /** Login lock — concurrent demand events must not race the login flow. */
136391
136626
  loginPromise = null;
136627
+ /**
136628
+ * Bumped by `disconnectAll`. A login started under an older generation was
136629
+ * dialled with the OLD settings (e.g. the relay before the operator picked
136630
+ * local-direct): it is closed and discarded instead of becoming `this.api`.
136631
+ */
136632
+ loginGeneration = 0;
136633
+ /** The client a login in flight is dialling, so `disconnectAll` can abort it. */
136634
+ pendingLoginApi = null;
136392
136635
  /** Wall-clock ms of the last video packet the stream server produced; 0 = none yet. */
136393
136636
  lastVideoFlowAt = 0;
136394
136637
  /** True once we've discovered (via getBatteryInfo) that this is a battery cam. */
@@ -137761,7 +138004,8 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
137761
138004
  const reported = typeof info.batteryPercent === "number" ? Math.max(0, Math.min(100, Math.round(info.batteryPercent))) : void 0;
137762
138005
  const measured = reported !== void 0 && isMeasuredCameraBatteryLevel(reported, {
137763
138006
  sleeping,
137764
- charging
138007
+ charging,
138008
+ voltage: info.voltage
137765
138009
  });
137766
138010
  if (reported === 0) this.ctx.logger.info("battery read reporting 0", {
137767
138011
  tags: { deviceId: this.id },
@@ -142265,6 +142509,13 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
142265
142509
  const entries = [...this.active.values()];
142266
142510
  this.active.clear();
142267
142511
  this.keepAwake.stop();
142512
+ this.loginGeneration += 1;
142513
+ this.loginPromise = null;
142514
+ const pending = this.pendingLoginApi;
142515
+ this.pendingLoginApi = null;
142516
+ if (pending) try {
142517
+ await pending.close({ reason: "login-superseded" });
142518
+ } catch {}
142268
142519
  for (const entry of entries) try {
142269
142520
  await entry.server.close("disconnect-all");
142270
142521
  } catch {}
@@ -143388,7 +143639,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
143388
143639
  if (Object.keys(rest).length === 0 && !hasOsdPatch) return;
143389
143640
  if (Object.keys(rest).length > 0) await this.config.setAll(rest);
143390
143641
  const typedPatch = patch;
143391
- if (typedPatch.host || typedPatch.port || typedPatch.username || typedPatch.password) {
143642
+ if (typedPatch.host || typedPatch.port || typedPatch.username || typedPatch.password || typedPatch.transport || typedPatch.uid || typedPatch.udpDiscoveryMethod) {
143392
143643
  await this.disconnectAll();
143393
143644
  return;
143394
143645
  }
@@ -143874,6 +144125,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
143874
144125
  debugOptions: debugOptions === void 0 ? null : Object.keys(debugOptions)
143875
144126
  }
143876
144127
  });
144128
+ const generation = this.loginGeneration;
143877
144129
  this.loginPromise = (async () => {
143878
144130
  const api = new ReolinkBaichuanApi({
143879
144131
  host,
@@ -143886,14 +144138,24 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
143886
144138
  ...debugOptions ? { debugOptions } : {},
143887
144139
  logger: this.libLoggerAdapter()
143888
144140
  });
144141
+ this.pendingLoginApi = api;
143889
144142
  try {
143890
144143
  await api.login();
143891
144144
  } catch (err) {
144145
+ if (generation !== this.loginGeneration) throw supersededLoginError(err);
144146
+ this.pendingLoginApi = null;
143892
144147
  this.loginPromise = null;
143893
144148
  if (isConnectivityFailure(err)) this.noteUnreachable(err instanceof Error ? err.message : String(err));
143894
144149
  else if (this.ownsReachability()) this.reachability.noteReachable();
143895
144150
  throw err;
143896
144151
  }
144152
+ if (generation !== this.loginGeneration) {
144153
+ try {
144154
+ await api.close({ reason: "login-superseded" });
144155
+ } catch {}
144156
+ throw supersededLoginError(null);
144157
+ }
144158
+ this.pendingLoginApi = null;
143897
144159
  this.api = api;
143898
144160
  this.loginPromise = null;
143899
144161
  this.reconnectAttempts = 0;
@@ -144464,7 +144726,8 @@ var AutodetectCache = class {
144464
144726
  input.username,
144465
144727
  passHash,
144466
144728
  input.uid?.trim() ?? "",
144467
- input.transport
144729
+ input.transport,
144730
+ input.udpDiscoveryMethod ?? ""
144468
144731
  ].join(":");
144469
144732
  }
144470
144733
  /**
@@ -144527,6 +144790,34 @@ var AutodetectCache = class {
144527
144790
  }
144528
144791
  };
144529
144792
  //#endregion
144793
+ //#region src/autodetect-inputs.ts
144794
+ function readString(obj, key) {
144795
+ const v = obj[key];
144796
+ return typeof v === "string" ? v : "";
144797
+ }
144798
+ function readTransportMode(obj) {
144799
+ const v = obj["transport"];
144800
+ return v === "tcp" || v === "udp" || v === "auto" ? v : "auto";
144801
+ }
144802
+ /** `auto` / unknown / absent mean "race every method"; only a real method is kept. */
144803
+ function readDiscoveryMethod(obj) {
144804
+ const parsed = ReolinkUdpDiscoveryMethodSchema.safeParse(obj["udpDiscoveryMethod"]);
144805
+ return parsed.success ? parsed.data : void 0;
144806
+ }
144807
+ function buildAutodetectInputs(form) {
144808
+ const rawUid = readString(form, "uid").trim();
144809
+ const rawPort = form["port"];
144810
+ return {
144811
+ host: readString(form, "host").trim(),
144812
+ username: (readString(form, "username") || "admin").trim(),
144813
+ password: readString(form, "password"),
144814
+ uid: rawUid.length > 0 ? rawUid : void 0,
144815
+ transport: readTransportMode(form),
144816
+ port: typeof rawPort === "number" && Number.isFinite(rawPort) ? rawPort : 9e3,
144817
+ udpDiscoveryMethod: readDiscoveryMethod(form)
144818
+ };
144819
+ }
144820
+ //#endregion
144530
144821
  //#region src/creation-schema.ts
144531
144822
  /**
144532
144823
  * Creation form for Reolink devices.
@@ -144704,6 +144995,28 @@ function buildCreationFormSchema() {
144704
144995
  field: "transport",
144705
144996
  notEquals: "tcp"
144706
144997
  }
144998
+ },
144999
+ {
145000
+ type: "select",
145001
+ key: "udpDiscoveryMethod",
145002
+ label: "UDP discovery",
145003
+ labelKey: "provider-reolink:creation.s_connection.udpDiscoveryMethod.label",
145004
+ default: "auto",
145005
+ description: "Auto races every method and may settle on the Reolink relay. \"Local only\" talks straight to the camera IP and never uses Reolink servers.",
145006
+ descriptionKey: "provider-reolink:creation.s_connection.udpDiscoveryMethod.description",
145007
+ options: [{
145008
+ value: "auto",
145009
+ label: "Auto (may use the Reolink relay)",
145010
+ labelKey: "provider-reolink:creation.s_connection.udpDiscoveryMethod.o_auto.label"
145011
+ }, {
145012
+ value: "local-direct",
145013
+ label: "Local only (direct to the camera IP)",
145014
+ labelKey: "provider-reolink:creation.s_connection.udpDiscoveryMethod.o_local.label"
145015
+ }],
145016
+ showWhen: {
145017
+ field: "transport",
145018
+ notEquals: "tcp"
145019
+ }
144707
145020
  }
144708
145021
  ]
144709
145022
  },
@@ -146435,28 +146748,6 @@ function getString(obj, key) {
146435
146748
  const v = obj[key];
146436
146749
  return typeof v === "string" ? v : "";
146437
146750
  }
146438
- function getNumber(obj, key, fallback) {
146439
- const v = obj[key];
146440
- return typeof v === "number" && Number.isFinite(v) ? v : fallback;
146441
- }
146442
- function getTransportMode(obj) {
146443
- const v = obj["transport"];
146444
- return v === "tcp" || v === "udp" || v === "auto" ? v : "auto";
146445
- }
146446
- function buildAutodetectInputs(form) {
146447
- const host = getString(form, "host").trim();
146448
- const username = (getString(form, "username") || "admin").trim();
146449
- const password = getString(form, "password");
146450
- const rawUid = getString(form, "uid").trim();
146451
- return {
146452
- host,
146453
- username,
146454
- password,
146455
- uid: rawUid.length > 0 ? rawUid : void 0,
146456
- transport: getTransportMode(form),
146457
- port: getNumber(form, "port", 9e3)
146458
- };
146459
- }
146460
146751
  function buildAutodetectLabels(result) {
146461
146752
  const labels = [];
146462
146753
  const model = result.deviceInfo?.type;
@@ -147450,6 +147741,7 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
147450
147741
  username: inputs.username,
147451
147742
  password: inputs.password,
147452
147743
  ...inputs.uid ? { uid: inputs.uid } : {},
147744
+ ...inputs.udpDiscoveryMethod ? { udpDiscoveryMethod: inputs.udpDiscoveryMethod } : {},
147453
147745
  mode: inputs.transport
147454
147746
  });
147455
147747
  } else this.ctx.logger.info("autodetect cache hit — reusing api", {
@@ -147598,6 +147890,7 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
147598
147890
  username: inputs.username,
147599
147891
  password: inputs.password,
147600
147892
  ...inputs.uid ? { uid: inputs.uid } : {},
147893
+ ...inputs.udpDiscoveryMethod ? { udpDiscoveryMethod: inputs.udpDiscoveryMethod } : {},
147601
147894
  mode: inputs.transport,
147602
147895
  logger: buildAutodetectLibLogger(probeLogger)
147603
147896
  });