@enyo-energy/sunspec-sdk 0.0.105 → 1.0.1

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/README.md CHANGED
@@ -8,6 +8,9 @@ SunSpec Modbus client for reading data from solar inverters, batteries, meters,
8
8
  - [Battery Feature Modes](#battery-feature-modes)
9
9
  - [Battery Calibration](#battery-calibration)
10
10
  - [Storage Schedule Control](#storage-schedule-control)
11
+ - [Connection Failures and Logging](#connection-failures-and-logging)
12
+ - [Transport Options](#transport-options)
13
+ - [Appliance Metadata the Registers Don't Carry](#appliance-metadata-the-registers-dont-carry)
11
14
  - [How Addressing Works](#how-addressing-works)
12
15
  - [Bulk Register Reading](#bulk-register-reading)
13
16
  - [Data Types](#data-types)
@@ -352,6 +355,93 @@ The earlier `StartStorageGridChargeV1` / `StopStorageGridChargeV1` / `SetStorage
352
355
 
353
356
  ---
354
357
 
358
+ ## Connection Failures and Logging
359
+
360
+ ### Two kinds of failure
361
+
362
+ The client distinguishes a transaction that was **attempted and failed** from one **refused because the link is already known to be dead**. On a half-open socket (the peer stops answering while the OS still reports ESTABLISHED) the first read times out and *poisons* the unit's socket; every read that lands afterwards is refused outright, without touching the wire, until the reconnect path recycles it.
363
+
364
+ | Situation | Rejection | Log level |
365
+ | --- | --- | --- |
366
+ | Read/write attempted, timed out | `ModbusOperationTimeoutError` | one WARN on the poison transition |
367
+ | Read/write refused, unit already down | `SunspecUnavailableError` (`reason: 'socket-poisoned'`) | none — `debug` only |
368
+ | Socket recovered on reconnect | — | one INFO with `poisonedForMs` |
369
+
370
+ ```ts
371
+ import { isSunspecUnavailableError } from '@enyo-energy/sunspec-sdk';
372
+
373
+ try {
374
+ await client.readRegisterValue(unitId, 40100, 1, 'uint16');
375
+ } catch (error) {
376
+ if (isSunspecUnavailableError(error)) {
377
+ // Already reported by the SDK — `error.reason` says why, `error.sinceMs` says
378
+ // how long it has been down. Log the first one of an outage at most.
379
+ return null;
380
+ }
381
+ console.error(`read failed`, error);
382
+ }
383
+ ```
384
+
385
+ Prefer `isSunspecUnavailableError()` over `instanceof` at package boundaries, where a duplicated copy of the SDK in the module graph would break class identity.
386
+
387
+ Both error classes implement `toJSON()`, so `JSON.stringify(error)` yields a usable `{ name, message, ... }` instead of the `{}` a bare `Error` serialises to.
388
+
389
+ ### One event, one line
390
+
391
+ The SDK logs **state transitions**, not states. A unit that is unreachable for an hour produces one WARN entering the poisoned state and one INFO on recovery — not one ERROR per read per poll cycle. The same rule applies to reconnect attempts: the first failure of a run is logged at ERROR, every repeat while the peer stays down at `debug`, and a success re-arms the logging for the next outage.
392
+
393
+ ### Backoff
394
+
395
+ The tiered `ConnectionRetryManager` schedule is cleared by a **healthy read cycle**, not by a reconnect that merely reopened the socket. A peer that accepts TCP connections but never answers Modbus would otherwise restart the schedule at its shortest phase on every cycle and retry forever at poll rate. Because the schedule now survives such a cycle, the elapsed clock keeps growing and the intervals widen as configured (default: 10s → 30s → 1m → 5m → 15m, infinite retry). Tune with the `retryConfig` constructor argument on any device.
396
+
397
+ ---
398
+
399
+ ## Transport Options
400
+
401
+ Everything in `IModbusTransportConfig` is forwarded verbatim to the host's `useModbus().connect()` — the SDK owns the behaviour, this client only passes the config it was constructed with. Omitted fields stay `undefined` so the host's own defaults apply.
402
+
403
+ ```ts
404
+ const client = getOrCreateSunspecClient(energyApp, host, 502, {
405
+ noParallelRequests: true, // serialize frames (slow devices, e.g. Solax)
406
+ waitBetweenMessagesMs: 40, // spacing between frames; only with noParallelRequests
407
+ pooledConnection: true, // share one socket per device (energy-app-sdk >= 1.6.0)
408
+ });
409
+ ```
410
+
411
+ `pooledConnection` takes the socket from the host's shared pool — keyed by host, port, unit ID and transport settings — instead of opening one owned exclusively by this client, and its `disconnect()` releases the connection back to the pool rather than necessarily closing it. It exists for devices that accept only a handful of simultaneous Modbus clients.
412
+
413
+ Note this SDK **already** refcounts one client per `host:port` (`getOrCreateSunspecClient` / `releaseSunspecClient`), so several devices behind one gateway share a connection either way. Pooling only adds something when code *outside* this client talks to the same device — a native driver in the same app, say. Leave it unset otherwise.
414
+
415
+ The config is applied when the client for a `host:port` is **first created**; a later caller passing a different config gets the cached instance and its config is ignored.
416
+
417
+ ---
418
+
419
+ ## Appliance Metadata the Registers Don't Carry
420
+
421
+ Three appliance fields added in energy-app-sdk 1.6.0 have no SunSpec register behind them, so the SDK cannot derive them — it publishes what the consumer configures, and writes nothing at all when nothing is configured (spreading an explicit `undefined` would erase a value the host set through another path).
422
+
423
+ ```ts
424
+ new SunspecInverter(energyApp, name, networkDevice, client, applianceManager,
425
+ 1, 502, 40000, [], retryConfig, appliance, useTls, SunspecPvPowerSource.Auto,
426
+ { controlAllowed: true, installedPeakPowerWp: 12_400 });
427
+ ```
428
+
429
+ | Field | Meaning |
430
+ | --- | --- |
431
+ | `inverter.controlAllowed` | Whether the energy manager may steer this inverter (e.g. curtail). Unset = "not configured", which is not `false`. |
432
+ | `inverter.installedPeakPowerWp` | Module peak power from the Anlagenpass. Distinct from `maxPvProductionW`, which the SDK reads from Model 121 `WMax` (the AC side). |
433
+ | `battery.roundTripEfficiencyPercent` | Measured AC-to-AC round-trip efficiency (0–100). |
434
+
435
+ Round-trip efficiency is a *measured* figure that drifts with cell age and temperature, so a value fixed at construction goes stale. Push a recomputed one at any time:
436
+
437
+ ```ts
438
+ await battery.setRoundTripEfficiencyPercent(83.2); // publishes immediately
439
+ ```
440
+
441
+ Values outside 0–100 throw. Calling it before `connect()` is fine — the value is remembered and published with the rest of the metadata once the appliance exists. Leave it unset until enough cycles have been observed: a missing value means "not yet known", which is more useful to an optimizer than a datasheet number that overstates what the pack returns.
442
+
443
+ ---
444
+
355
445
  ## How Addressing Works
356
446
 
357
447
  ### Base Address Detection
@@ -239,7 +239,14 @@ class BaseSunspecDevice {
239
239
  `opened the socket but revalidation failed — retrying with backoff`);
240
240
  return false;
241
241
  }
242
- this.retryManager.reset();
242
+ // NOT reset() here — a reopened TCP socket is not yet a working device. On a peer
243
+ // that accepts connections but stops answering reads, resetting on the reconnect
244
+ // restarts the backoff schedule from its shortest phase on every cycle, so the
245
+ // schedule never advances past 10s no matter how long the outage runs: reconnect,
246
+ // read, time out, poison, mark offline, reconnect — indefinitely, at poll rate. The
247
+ // schedule is cleared instead by the first genuinely healthy read cycle (see
248
+ // markOfflineIfUnhealthy), which is the only evidence the link actually carries
249
+ // data. Until then `elapsed` keeps growing and the phases widen as intended.
243
250
  this.consecutiveReconnectFailures = 0;
244
251
  // Update appliance state to Connected
245
252
  if (this.applianceId) {
@@ -255,7 +262,15 @@ class BaseSunspecDevice {
255
262
  await this.onConnectionFailure(this.consecutiveReconnectFailures);
256
263
  }
257
264
  catch (error) {
258
- console.error(`${this.constructor.name} ${this.applianceId}: Reconnect attempt #${attempt} failed: ${error}`);
265
+ // Transition-only: the first throw of an outage is the news; every repeat while the
266
+ // peer stays down is the same news again, so it drops to debug.
267
+ const line = `${this.constructor.name} ${this.applianceId}: Reconnect attempt #${attempt} failed: ${error}`;
268
+ if (this.consecutiveReconnectFailures === 0) {
269
+ console.error(line);
270
+ }
271
+ else {
272
+ console.debug(line);
273
+ }
259
274
  this.consecutiveReconnectFailures += 1;
260
275
  await this.onConnectionFailure(this.consecutiveReconnectFailures);
261
276
  }
@@ -323,6 +338,12 @@ class BaseSunspecDevice {
323
338
  */
324
339
  async markOfflineIfUnhealthy() {
325
340
  if (this.sunspecClient.isHealthy(this.unitId)) {
341
+ // A completed read cycle on a healthy unit is the only proof the link carries data, so
342
+ // it — not a successful reconnect — is what clears the tiered retry schedule. See the
343
+ // note in tryReconnect(): resetting on reconnect alone pins a flapping device to the
344
+ // shortest retry phase forever.
345
+ this.retryManager.reset();
346
+ this.consecutiveReconnectFailures = 0;
326
347
  return false;
327
348
  }
328
349
  console.warn(`${this.constructor.name} ${this.applianceId}: connection unhealthy after read cycle ` +
@@ -482,6 +503,7 @@ function finiteOrUndefined(value) {
482
503
  class SunspecInverter extends BaseSunspecDevice {
483
504
  capabilities;
484
505
  pvPowerSource;
506
+ metadataConfig;
485
507
  /** Emit a connection-lost faulted status after this many consecutive failed reconnect attempts. */
486
508
  static CONNECTION_FAULT_THRESHOLD = 3;
487
509
  /**
@@ -528,10 +550,29 @@ class SunspecInverter extends BaseSunspecDevice {
528
550
  // only summed MPPT strings, or Inverter to use only the inverter total —
529
551
  // e.g. for devices whose Model 160 strings are unreliable or whose AC
530
552
  // includes non-PV sources (a hybrid's battery discharge).
531
- pvPowerSource = sunspec_interfaces_js_1.SunspecPvPowerSource.Auto) {
553
+ pvPowerSource = sunspec_interfaces_js_1.SunspecPvPowerSource.Auto,
554
+ // Facts about the installation that no register carries (control policy, module peak power).
555
+ // Forwarded onto `appliance.inverter` on connect; see SunspecInverterMetadataConfig.
556
+ metadataConfig = {}) {
532
557
  super(energyApp, name, networkDevice, sunspecClient, applianceManager, unitId, port, baseAddress, retryConfig, appliance, useTls);
533
558
  this.capabilities = capabilities;
534
559
  this.pvPowerSource = pvPowerSource;
560
+ this.metadataConfig = metadataConfig;
561
+ }
562
+ /**
563
+ * The consumer-supplied inverter facts, as a spreadable object that only contains the keys that
564
+ * were actually configured. Spreading `{ controlAllowed: undefined }` over an existing appliance
565
+ * would erase a value the host set elsewhere; omitting the key leaves it alone.
566
+ */
567
+ configuredInverterMetadata() {
568
+ const configured = {};
569
+ if (this.metadataConfig.controlAllowed !== undefined) {
570
+ configured.controlAllowed = this.metadataConfig.controlAllowed;
571
+ }
572
+ if (this.metadataConfig.installedPeakPowerWp !== undefined) {
573
+ configured.installedPeakPowerWp = this.metadataConfig.installedPeakPowerWp;
574
+ }
575
+ return configured;
535
576
  }
536
577
  async connect() {
537
578
  // Ensure Sunspec client is connected
@@ -565,7 +606,8 @@ class SunspecInverter extends BaseSunspecDevice {
565
606
  inverter: {
566
607
  dcStrings: this.mapDcStringToApplianceMetadata(this.mapMPPTToStrings(mpptDataList)),
567
608
  maxPvProductionW: inverterSettings?.WMax,
568
- activeProductionLimitationW: activeProductionLimitationW
609
+ activeProductionLimitationW: activeProductionLimitationW,
610
+ ...this.configuredInverterMetadata()
569
611
  }
570
612
  });
571
613
  console.log(`Sunspec Inverter connected: ${this.networkDevice.hostname} (${this.applianceId})`);
@@ -592,7 +634,8 @@ class SunspecInverter extends BaseSunspecDevice {
592
634
  ...existingAppliance?.inverter,
593
635
  dcStrings: this.mapDcStringToApplianceMetadata(this.mapMPPTToStrings(mpptDataList)),
594
636
  maxPvProductionW: inverterSettings?.WMax,
595
- activeProductionLimitationW: activeProductionLimitationW
637
+ activeProductionLimitationW: activeProductionLimitationW,
638
+ ...this.configuredInverterMetadata()
596
639
  }
597
640
  });
598
641
  console.log(`Sunspec Inverter connected: ${this.networkDevice.hostname} (${this.applianceId})`);
@@ -1496,10 +1539,59 @@ class SunspecBattery extends BaseSunspecDevice {
1496
1539
  enyo_battery_appliance_js_1.EnyoBatteryFeature.ChargeLimitation,
1497
1540
  enyo_battery_appliance_js_1.EnyoBatteryFeature.DischargeLimitation,
1498
1541
  ];
1499
- constructor(energyApp, name, networkDevice, sunspecClient, applianceManager, featureMode, unitId = 1, port = 502, baseAddress = 40000, capabilities = [], retryConfig, appliance, useTls) {
1542
+ constructor(energyApp, name, networkDevice, sunspecClient, applianceManager, featureMode, unitId = 1, port = 502, baseAddress = 40000, capabilities = [], retryConfig, appliance, useTls,
1543
+ // Battery facts no register carries (currently the measured round-trip efficiency).
1544
+ // Forwarded onto `appliance.battery` on connect; see SunspecBatteryMetadataConfig.
1545
+ metadataConfig = {}) {
1500
1546
  super(energyApp, name, networkDevice, sunspecClient, applianceManager, unitId, port, baseAddress, retryConfig, appliance, useTls);
1501
1547
  this.featureMode = featureMode;
1502
1548
  this.capabilities = capabilities;
1549
+ this.roundTripEfficiencyPercent = metadataConfig.roundTripEfficiencyPercent;
1550
+ }
1551
+ /**
1552
+ * Last known round-trip efficiency, seeded from the constructor config and replaceable at
1553
+ * runtime via {@link setRoundTripEfficiencyPercent}. Undefined = not yet known; the SDK then
1554
+ * writes nothing, leaving whatever the appliance store already holds.
1555
+ */
1556
+ roundTripEfficiencyPercent;
1557
+ /**
1558
+ * Update the battery's measured round-trip efficiency (percent, 0-100) and push it to the
1559
+ * appliance immediately. Meant to be called whenever the host recomputes the figure from
1560
+ * completed cycles - it drifts with cell age and temperature, so a value fixed at construction
1561
+ * goes stale. Pass `undefined` to stop asserting a value (the last published one stays in the
1562
+ * appliance store; the SDK does not erase it).
1563
+ *
1564
+ * Safe to call before {@link connect}: the value is remembered and published with the rest of
1565
+ * the metadata once the appliance exists.
1566
+ */
1567
+ async setRoundTripEfficiencyPercent(percent) {
1568
+ if (percent !== undefined && (!Number.isFinite(percent) || percent < 0 || percent > 100)) {
1569
+ throw new Error(`setRoundTripEfficiencyPercent: ${percent} is not a percentage between 0 and 100`);
1570
+ }
1571
+ this.roundTripEfficiencyPercent = percent;
1572
+ if (percent === undefined || !this.applianceId)
1573
+ return;
1574
+ try {
1575
+ const existingAppliance = await this.applianceManager.findApplianceById(this.applianceId);
1576
+ await this.applianceManager.updateAppliance(this.applianceId, {
1577
+ battery: {
1578
+ ...existingAppliance?.battery,
1579
+ roundTripEfficiencyPercent: percent
1580
+ }
1581
+ });
1582
+ }
1583
+ catch (error) {
1584
+ console.error(`Failed to publish round-trip efficiency for battery ${this.applianceId}: ${error}`);
1585
+ }
1586
+ }
1587
+ /**
1588
+ * The configured battery facts as a spreadable object holding only the keys actually known.
1589
+ * Spreading an explicit `undefined` would erase a value the host set elsewhere.
1590
+ */
1591
+ configuredBatteryMetadata() {
1592
+ return this.roundTripEfficiencyPercent === undefined
1593
+ ? {}
1594
+ : { roundTripEfficiencyPercent: this.roundTripEfficiencyPercent };
1503
1595
  }
1504
1596
  /**
1505
1597
  * Wire the battery into `@enyo-energy/appliance-calibration`'s
@@ -1625,7 +1717,8 @@ class SunspecBattery extends BaseSunspecDevice {
1625
1717
  activeChargeLimitW: activeChargeLimitW,
1626
1718
  activeDischargeLimitW: activeDischargeLimitW,
1627
1719
  features,
1628
- gridChargingEnabled: batteryData?.chaGriSet === 1
1720
+ gridChargingEnabled: batteryData?.chaGriSet === 1,
1721
+ ...this.configuredBatteryMetadata()
1629
1722
  }
1630
1723
  });
1631
1724
  console.log(`Sunspec Battery connected: ${this.networkDevice.hostname} (${this.applianceId})`);
@@ -1653,7 +1746,8 @@ class SunspecBattery extends BaseSunspecDevice {
1653
1746
  activeChargeLimitW: activeChargeLimitW,
1654
1747
  activeDischargeLimitW: activeDischargeLimitW,
1655
1748
  features,
1656
- gridChargingEnabled: batteryData?.chaGriSet === 1
1749
+ gridChargingEnabled: batteryData?.chaGriSet === 1,
1750
+ ...this.configuredBatteryMetadata()
1657
1751
  }
1658
1752
  });
1659
1753
  console.log(`Sunspec Battery connected: ${this.networkDevice.hostname} (${this.applianceId})`);
@@ -1812,7 +1906,8 @@ class SunspecBattery extends BaseSunspecDevice {
1812
1906
  activeChargeLimitW: this.computeActiveChargeLimitW(batteryData),
1813
1907
  activeDischargeLimitW: this.computeActiveDischargeLimitW(batteryData),
1814
1908
  features,
1815
- gridChargingEnabled: batteryData?.chaGriSet === 1
1909
+ gridChargingEnabled: batteryData?.chaGriSet === 1,
1910
+ ...this.configuredBatteryMetadata()
1816
1911
  }
1817
1912
  });
1818
1913
  }
@@ -1,4 +1,4 @@
1
- import { type IRetryConfig, type SunspecBatteryBaseData, SunspecBatteryCapability, type SunspecBatteryControls, type SunspecBatteryData, type SunspecBatteryFeatureMode, type SunspecInverterData, SunspecInverterCapability, SunspecPvPowerSource, SunspecPvPowerOrigin, type SunspecInverterReading, type SunspecBatteryReading, SunspecMeterCapability, type SunspecMPPTData, SunspecStorageMode, type SunspecCustomDeviceConfig } from "./sunspec-interfaces.cjs";
1
+ import { type IRetryConfig, type SunspecBatteryBaseData, SunspecBatteryCapability, type SunspecBatteryControls, type SunspecBatteryData, type SunspecBatteryFeatureMode, type SunspecInverterData, SunspecInverterCapability, SunspecPvPowerSource, type SunspecInverterMetadataConfig, type SunspecBatteryMetadataConfig, SunspecPvPowerOrigin, type SunspecInverterReading, type SunspecBatteryReading, SunspecMeterCapability, type SunspecMPPTData, SunspecStorageMode, type SunspecCustomDeviceConfig } from "./sunspec-interfaces.cjs";
2
2
  import { ApplianceManager, EnergyApp } from "@enyo-energy/energy-app-sdk";
3
3
  import { type EnyoAppliance, type EnyoApplianceErrorCode, EnyoApplianceName } from "@enyo-energy/energy-app-sdk/dist/types/enyo-appliance.js";
4
4
  import { EnyoNetworkDevice } from "@enyo-energy/energy-app-sdk/dist/types/enyo-network-device.js";
@@ -208,6 +208,7 @@ type SunspecPvPower = {
208
208
  export declare class SunspecInverter extends BaseSunspecDevice {
209
209
  private readonly capabilities;
210
210
  private readonly pvPowerSource;
211
+ private readonly metadataConfig;
211
212
  /** Emit a connection-lost faulted status after this many consecutive failed reconnect attempts. */
212
213
  private static readonly CONNECTION_FAULT_THRESHOLD;
213
214
  /**
@@ -233,7 +234,13 @@ export declare class SunspecInverter extends BaseSunspecDevice {
233
234
  private acEnergyDropStreak;
234
235
  /** Consecutive corrupt reads that confirm a genuine reset/resync (vs a transient glitch). */
235
236
  private static readonly AC_ENERGY_RESET_CONFIRM;
236
- constructor(energyApp: EnergyApp, name: EnyoApplianceName[], networkDevice: EnyoNetworkDevice, sunspecClient: SunspecModbusClient, applianceManager: ApplianceManager, unitId?: number, port?: number, baseAddress?: number, capabilities?: SunspecInverterCapability[], retryConfig?: IRetryConfig, appliance?: EnyoAppliance, useTls?: boolean, pvPowerSource?: SunspecPvPowerSource);
237
+ constructor(energyApp: EnergyApp, name: EnyoApplianceName[], networkDevice: EnyoNetworkDevice, sunspecClient: SunspecModbusClient, applianceManager: ApplianceManager, unitId?: number, port?: number, baseAddress?: number, capabilities?: SunspecInverterCapability[], retryConfig?: IRetryConfig, appliance?: EnyoAppliance, useTls?: boolean, pvPowerSource?: SunspecPvPowerSource, metadataConfig?: SunspecInverterMetadataConfig);
238
+ /**
239
+ * The consumer-supplied inverter facts, as a spreadable object that only contains the keys that
240
+ * were actually configured. Spreading `{ controlAllowed: undefined }` over an existing appliance
241
+ * would erase a value the host set elsewhere; omitting the key leaves it alone.
242
+ */
243
+ private configuredInverterMetadata;
237
244
  connect(): Promise<void>;
238
245
  disconnect(): Promise<void>;
239
246
  readData(clockId: string, resolution: EnyoDataBusMessageResolution): Promise<EnyoDataBusMessage[]>;
@@ -547,7 +554,29 @@ export declare class SunspecBattery extends BaseSunspecDevice {
547
554
  * {@link computeAdvertisedFeatures}.
548
555
  */
549
556
  private static readonly CONTROLLABLE_FEATURES;
550
- constructor(energyApp: EnergyApp, name: EnyoApplianceName[], networkDevice: EnyoNetworkDevice, sunspecClient: SunspecModbusClient, applianceManager: ApplianceManager, featureMode: SunspecBatteryFeatureMode, unitId?: number, port?: number, baseAddress?: number, capabilities?: SunspecBatteryCapability[], retryConfig?: IRetryConfig, appliance?: EnyoAppliance, useTls?: boolean);
557
+ constructor(energyApp: EnergyApp, name: EnyoApplianceName[], networkDevice: EnyoNetworkDevice, sunspecClient: SunspecModbusClient, applianceManager: ApplianceManager, featureMode: SunspecBatteryFeatureMode, unitId?: number, port?: number, baseAddress?: number, capabilities?: SunspecBatteryCapability[], retryConfig?: IRetryConfig, appliance?: EnyoAppliance, useTls?: boolean, metadataConfig?: SunspecBatteryMetadataConfig);
558
+ /**
559
+ * Last known round-trip efficiency, seeded from the constructor config and replaceable at
560
+ * runtime via {@link setRoundTripEfficiencyPercent}. Undefined = not yet known; the SDK then
561
+ * writes nothing, leaving whatever the appliance store already holds.
562
+ */
563
+ private roundTripEfficiencyPercent?;
564
+ /**
565
+ * Update the battery's measured round-trip efficiency (percent, 0-100) and push it to the
566
+ * appliance immediately. Meant to be called whenever the host recomputes the figure from
567
+ * completed cycles - it drifts with cell age and temperature, so a value fixed at construction
568
+ * goes stale. Pass `undefined` to stop asserting a value (the last published one stays in the
569
+ * appliance store; the SDK does not erase it).
570
+ *
571
+ * Safe to call before {@link connect}: the value is remembered and published with the rest of
572
+ * the metadata once the appliance exists.
573
+ */
574
+ setRoundTripEfficiencyPercent(percent: number | undefined): Promise<void>;
575
+ /**
576
+ * The configured battery facts as a spreadable object holding only the keys actually known.
577
+ * Spreading an explicit `undefined` would erase a value the host set elsewhere.
578
+ */
579
+ private configuredBatteryMetadata;
551
580
  /**
552
581
  * Wire the battery into `@enyo-energy/appliance-calibration`'s
553
582
  * `BatteryCalibrator` test-charge flow. Call once after {@link connect}.
@@ -46,6 +46,26 @@ export interface IModbusPacingConfig {
46
46
  */
47
47
  waitBetweenMessagesMs?: number;
48
48
  }
49
+ /**
50
+ * Everything the client forwards verbatim to `useModbus().connect()`: the pacing options above plus
51
+ * the transport options added in energy-app-sdk 1.6.0. Kept as a superset of
52
+ * {@link IModbusPacingConfig} so callers that already pass a pacing object keep working unchanged.
53
+ */
54
+ export interface IModbusTransportConfig extends IModbusPacingConfig {
55
+ /**
56
+ * Take the connection from the host's shared pool of sockets — keyed by host, port, unit ID and
57
+ * transport settings — instead of opening one that belongs exclusively to this client (SDK
58
+ * `ModbusOptions.pooledConnection`, available from energy-app-sdk 1.6.0). Pooling lets several
59
+ * consumers of the same physical device share one TCP connection, which matters for devices that
60
+ * accept only a handful of simultaneous Modbus clients. A pooled `disconnect()` releases the
61
+ * connection back to the pool rather than necessarily closing the socket.
62
+ *
63
+ * Note that this SDK already refcounts one client per `host:port`
64
+ * ({@link getOrCreateSunspecClient}), so pooling only adds anything when something *outside* this
65
+ * client also talks to the same device. Leave it unset to keep the SDK's own default.
66
+ */
67
+ pooledConnection?: boolean;
68
+ }
49
69
  /**
50
70
  * Resilience configuration for the Modbus client: per-operation timeouts and half-open socket
51
71
  * detection. All fields are optional and default to sensible values, so existing consumers are
@@ -802,6 +822,29 @@ export declare enum SunspecStorageMode {
802
822
  export declare enum SunspecInverterCapability {
803
823
  FeedInLimit = "feed-in-limit"
804
824
  }
825
+ /**
826
+ * Nameplate/policy facts about an inverter that live outside the SunSpec register map, published
827
+ * onto `appliance.inverter` when the device connects. Nothing here is readable from Modbus — the
828
+ * installation record (Anlagenpass) or the host's own configuration is the source of truth — so the
829
+ * SDK only forwards what the consumer supplies. Fields left `undefined` are not written, so an
830
+ * existing value in the appliance store survives a reconnect.
831
+ *
832
+ * Both fields were added to the appliance model in energy-app-sdk 1.6.0.
833
+ */
834
+ export interface SunspecInverterMetadataConfig {
835
+ /**
836
+ * Whether the energy manager may actively steer this inverter (e.g. curtail production). Omit
837
+ * to leave the decision to the consumer's configured default — `undefined` is "not configured",
838
+ * which is not the same as `false`.
839
+ */
840
+ controlAllowed?: boolean;
841
+ /**
842
+ * Peak power of the PV modules attached to this inverter, in Watt-peak. Distinct from
843
+ * `maxPvProductionW`, which the SDK reads from the inverter's own AC nameplate (Model 121
844
+ * `WMax`): the module side of the installation is not in any register.
845
+ */
846
+ installedPeakPowerWp?: number;
847
+ }
805
848
  /**
806
849
  * Where an inverter's reported PV production (pvPowerW) is sourced from.
807
850
  * - Auto: summed MPPT DC strings (Model 160) when present, else the inverter's
@@ -912,6 +955,25 @@ export declare enum SunspecBatteryCapability {
912
955
  DischargeLimit = "discharge-limit",
913
956
  ChargeLimit = "charge-limit"
914
957
  }
958
+ /**
959
+ * Battery facts that live outside the SunSpec register map, published onto `appliance.battery` when
960
+ * the device connects. Fields left `undefined` are not written, so an existing value in the
961
+ * appliance store survives a reconnect.
962
+ */
963
+ export interface SunspecBatteryMetadataConfig {
964
+ /**
965
+ * Observed AC-to-AC round-trip efficiency in percent (0–100): of the energy put into the
966
+ * battery, how much comes back out. Added to the appliance model in energy-app-sdk 1.6.0.
967
+ *
968
+ * A *measured* figure, not a datasheet one — it drifts with cell age, temperature and depth of
969
+ * discharge, and no SunSpec model reports it, so the SDK cannot derive it. Supply it from
970
+ * whatever the host computes over completed cycles, either here at construction or later via
971
+ * {@link SunspecBattery.setRoundTripEfficiencyPercent}. Leave it unset until enough cycles have
972
+ * been observed: a missing value means "not yet known", and is more useful to an optimizer than
973
+ * a nameplate number that overstates what the pack returns.
974
+ */
975
+ roundTripEfficiencyPercent?: number;
976
+ }
915
977
  /**
916
978
  * Selects how `SunspecBattery` populates `appliance.battery.features`.
917
979
  *