@enyo-energy/sunspec-sdk 1.10.0 → 1.12.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/dist/cjs/sunspec-devices.cjs +37 -11
- package/dist/cjs/sunspec-devices.d.cts +20 -6
- package/dist/cjs/sunspec-interfaces.cjs +1 -1
- package/dist/cjs/sunspec-interfaces.d.cts +2 -2
- package/dist/cjs/sunspec-modbus-client.cjs +1 -1
- package/dist/cjs/version.cjs +1 -1
- package/dist/cjs/version.d.cts +1 -1
- package/dist/sunspec-devices.d.ts +20 -6
- package/dist/sunspec-devices.js +36 -11
- package/dist/sunspec-interfaces.d.ts +2 -2
- package/dist/sunspec-interfaces.js +1 -1
- package/dist/sunspec-modbus-client.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -5
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SunspecCustomDevice = exports.SunspecMeter = exports.SunspecBattery = exports.SunspecInverter = exports.BaseSunspecDevice = void 0;
|
|
4
4
|
exports.detectFeaturesFromRegisters = detectFeaturesFromRegisters;
|
|
5
5
|
exports.ratedDischargePowerW = ratedDischargePowerW;
|
|
6
|
+
exports.mpptStorageStringKind = mpptStorageStringKind;
|
|
6
7
|
exports.sumMpptBatteryPowerW = sumMpptBatteryPowerW;
|
|
7
8
|
exports.selectLiveBatteryPowerW = selectLiveBatteryPowerW;
|
|
8
9
|
exports.filterFeaturesByCalibrationResult = filterFeaturesByCalibrationResult;
|
|
@@ -1203,13 +1204,14 @@ class SunspecInverter extends BaseSunspecDevice {
|
|
|
1203
1204
|
}
|
|
1204
1205
|
/**
|
|
1205
1206
|
* Map MPPT data to DC string structure for data bus
|
|
1206
|
-
* Filters out battery-related strings (StCha
|
|
1207
|
+
* Filters out battery-related strings (StCha n, StDisCha n+1; see
|
|
1208
|
+
* {@link mpptStorageStringKind})
|
|
1207
1209
|
*/
|
|
1208
1210
|
mapMPPTToStrings(mpptDataList) {
|
|
1209
1211
|
const result = [];
|
|
1210
1212
|
mpptDataList.forEach((mppt, index) => {
|
|
1211
1213
|
// Skip battery-related strings - they will be handled separately
|
|
1212
|
-
if (mppt.stringId
|
|
1214
|
+
if (mpptStorageStringKind(mppt.stringId) !== undefined) {
|
|
1213
1215
|
return;
|
|
1214
1216
|
}
|
|
1215
1217
|
// Only include strings with valid data
|
|
@@ -1428,7 +1430,7 @@ function ratedDischargePowerW(batteryData) {
|
|
|
1428
1430
|
/**
|
|
1429
1431
|
* Pick the live battery power, in preference order:
|
|
1430
1432
|
*
|
|
1431
|
-
* 1. Model 160 (MPPT) `StCha
|
|
1433
|
+
* 1. Model 160 (MPPT) `StCha n` / `StDisCha n+1` — direct DC-link reading,
|
|
1432
1434
|
* passed in as the already-summed `mpptBatteryPowerW`.
|
|
1433
1435
|
* 2. Model 802 `w` (offset 47) — surfaced as `chargePower` / `dischargePower`
|
|
1434
1436
|
* by the Model 802 path of `SunspecModbusClient.readBatteryData`.
|
|
@@ -1442,11 +1444,33 @@ function ratedDischargePowerW(batteryData) {
|
|
|
1442
1444
|
* Exported as a free function so the preference logic can be unit-tested
|
|
1443
1445
|
* without the full `SunspecBattery` scaffold.
|
|
1444
1446
|
*/
|
|
1447
|
+
/**
|
|
1448
|
+
* Classify a Model 160 module by its `IDStr` as a DC-coupled battery string.
|
|
1449
|
+
*
|
|
1450
|
+
* Fronius hybrids list the battery as two extra Model 160 modules after the PV
|
|
1451
|
+
* MPPTs: `StCha <n>` (charge power) and `StDisCha <n+1>` (discharge power). The
|
|
1452
|
+
* number is the module position, so it depends on how many PV trackers the
|
|
1453
|
+
* device has: a GEN24 Plus (2 MPPTs) reports `StCha 3` / `StDisCha 4`, a
|
|
1454
|
+
* Verto (3 MPPTs) `StCha 4` / `StDisCha 5`. Match the prefix, never the full
|
|
1455
|
+
* label, or a battery module is counted as a PV string.
|
|
1456
|
+
*
|
|
1457
|
+
* Returns `undefined` for a PV string.
|
|
1458
|
+
*/
|
|
1459
|
+
function mpptStorageStringKind(stringId) {
|
|
1460
|
+
const id = stringId?.trim() ?? '';
|
|
1461
|
+
if (/^StCha\b/i.test(id)) {
|
|
1462
|
+
return 'charge';
|
|
1463
|
+
}
|
|
1464
|
+
if (/^StDisCha\b/i.test(id)) {
|
|
1465
|
+
return 'discharge';
|
|
1466
|
+
}
|
|
1467
|
+
return undefined;
|
|
1468
|
+
}
|
|
1445
1469
|
/**
|
|
1446
1470
|
* Sum battery charge/discharge power from Model 160 MPPT strings.
|
|
1447
1471
|
*
|
|
1448
|
-
* - `StCha
|
|
1449
|
-
* - `StDisCha
|
|
1472
|
+
* - `StCha n` → charging power (added, positive)
|
|
1473
|
+
* - `StDisCha n+1` → discharging power (subtracted)
|
|
1450
1474
|
*
|
|
1451
1475
|
* The result follows the battery-power sign convention used across this file:
|
|
1452
1476
|
* positive = charging, negative = discharging. Returns `undefined` when neither
|
|
@@ -1458,10 +1482,11 @@ function ratedDischargePowerW(batteryData) {
|
|
|
1458
1482
|
function sumMpptBatteryPowerW(mpptDataList) {
|
|
1459
1483
|
let batteryPowerW;
|
|
1460
1484
|
for (const mppt of mpptDataList) {
|
|
1461
|
-
|
|
1485
|
+
const kind = mpptStorageStringKind(mppt.stringId);
|
|
1486
|
+
if (kind === 'charge' && mppt.dcPower !== undefined) {
|
|
1462
1487
|
batteryPowerW = (batteryPowerW ?? 0) + mppt.dcPower;
|
|
1463
1488
|
}
|
|
1464
|
-
else if (
|
|
1489
|
+
else if (kind === 'discharge' && mppt.dcPower !== undefined) {
|
|
1465
1490
|
batteryPowerW = (batteryPowerW ?? 0) - mppt.dcPower;
|
|
1466
1491
|
}
|
|
1467
1492
|
}
|
|
@@ -1972,8 +1997,8 @@ class SunspecBattery extends BaseSunspecDevice {
|
|
|
1972
1997
|
}
|
|
1973
1998
|
/**
|
|
1974
1999
|
* Extract battery power from MPPT strings with specific IDs
|
|
1975
|
-
* StCha
|
|
1976
|
-
* StDisCha
|
|
2000
|
+
* StCha n: Battery charging power (positive)
|
|
2001
|
+
* StDisCha n+1: Battery discharging power (negative)
|
|
1977
2002
|
*/
|
|
1978
2003
|
extractBatteryPowerFromMPPT(mpptDataList) {
|
|
1979
2004
|
return sumMpptBatteryPowerW(mpptDataList);
|
|
@@ -1985,10 +2010,11 @@ class SunspecBattery extends BaseSunspecDevice {
|
|
|
1985
2010
|
let hasCharge = false;
|
|
1986
2011
|
let hasDischarge = false;
|
|
1987
2012
|
mpptDataList.forEach((mppt) => {
|
|
1988
|
-
|
|
2013
|
+
const kind = mpptStorageStringKind(mppt.stringId);
|
|
2014
|
+
if (kind === 'charge' && mppt.dcPower !== undefined && mppt.dcPower > 0) {
|
|
1989
2015
|
hasCharge = true;
|
|
1990
2016
|
}
|
|
1991
|
-
else if (
|
|
2017
|
+
else if (kind === 'discharge' && mppt.dcPower !== undefined && mppt.dcPower > 0) {
|
|
1992
2018
|
hasDischarge = true;
|
|
1993
2019
|
}
|
|
1994
2020
|
});
|
|
@@ -422,7 +422,8 @@ export declare class SunspecInverter extends BaseSunspecDevice {
|
|
|
422
422
|
private sumDcStringsW;
|
|
423
423
|
/**
|
|
424
424
|
* Map MPPT data to DC string structure for data bus
|
|
425
|
-
* Filters out battery-related strings (StCha
|
|
425
|
+
* Filters out battery-related strings (StCha n, StDisCha n+1; see
|
|
426
|
+
* {@link mpptStorageStringKind})
|
|
426
427
|
*/
|
|
427
428
|
protected mapMPPTToStrings(mpptDataList: SunspecMPPTData[]): EnyoDataBusInverterValuesV1String[];
|
|
428
429
|
private mapMPPTOperatingState;
|
|
@@ -494,7 +495,7 @@ export declare function ratedDischargePowerW(batteryData: SunspecBatteryData | n
|
|
|
494
495
|
/**
|
|
495
496
|
* Pick the live battery power, in preference order:
|
|
496
497
|
*
|
|
497
|
-
* 1. Model 160 (MPPT) `StCha
|
|
498
|
+
* 1. Model 160 (MPPT) `StCha n` / `StDisCha n+1` — direct DC-link reading,
|
|
498
499
|
* passed in as the already-summed `mpptBatteryPowerW`.
|
|
499
500
|
* 2. Model 802 `w` (offset 47) — surfaced as `chargePower` / `dischargePower`
|
|
500
501
|
* by the Model 802 path of `SunspecModbusClient.readBatteryData`.
|
|
@@ -508,11 +509,24 @@ export declare function ratedDischargePowerW(batteryData: SunspecBatteryData | n
|
|
|
508
509
|
* Exported as a free function so the preference logic can be unit-tested
|
|
509
510
|
* without the full `SunspecBattery` scaffold.
|
|
510
511
|
*/
|
|
512
|
+
/**
|
|
513
|
+
* Classify a Model 160 module by its `IDStr` as a DC-coupled battery string.
|
|
514
|
+
*
|
|
515
|
+
* Fronius hybrids list the battery as two extra Model 160 modules after the PV
|
|
516
|
+
* MPPTs: `StCha <n>` (charge power) and `StDisCha <n+1>` (discharge power). The
|
|
517
|
+
* number is the module position, so it depends on how many PV trackers the
|
|
518
|
+
* device has: a GEN24 Plus (2 MPPTs) reports `StCha 3` / `StDisCha 4`, a
|
|
519
|
+
* Verto (3 MPPTs) `StCha 4` / `StDisCha 5`. Match the prefix, never the full
|
|
520
|
+
* label, or a battery module is counted as a PV string.
|
|
521
|
+
*
|
|
522
|
+
* Returns `undefined` for a PV string.
|
|
523
|
+
*/
|
|
524
|
+
export declare function mpptStorageStringKind(stringId: string | undefined): 'charge' | 'discharge' | undefined;
|
|
511
525
|
/**
|
|
512
526
|
* Sum battery charge/discharge power from Model 160 MPPT strings.
|
|
513
527
|
*
|
|
514
|
-
* - `StCha
|
|
515
|
-
* - `StDisCha
|
|
528
|
+
* - `StCha n` → charging power (added, positive)
|
|
529
|
+
* - `StDisCha n+1` → discharging power (subtracted)
|
|
516
530
|
*
|
|
517
531
|
* The result follows the battery-power sign convention used across this file:
|
|
518
532
|
* positive = charging, negative = discharging. Returns `undefined` when neither
|
|
@@ -677,8 +691,8 @@ export declare class SunspecBattery extends BaseSunspecDevice {
|
|
|
677
691
|
readData(clockId: string, resolution: EnyoDataBusMessageResolution): Promise<EnyoDataBusMessage[]>;
|
|
678
692
|
/**
|
|
679
693
|
* Extract battery power from MPPT strings with specific IDs
|
|
680
|
-
* StCha
|
|
681
|
-
* StDisCha
|
|
694
|
+
* StCha n: Battery charging power (positive)
|
|
695
|
+
* StDisCha n+1: Battery discharging power (negative)
|
|
682
696
|
*/
|
|
683
697
|
private extractBatteryPowerFromMPPT;
|
|
684
698
|
/**
|
|
@@ -332,7 +332,7 @@ var SunspecPvPowerSource;
|
|
|
332
332
|
* consumer can see which telemetry produced the number.
|
|
333
333
|
*
|
|
334
334
|
* - `MpptStrings`: summed per-string DC power from Model 160 (battery strings
|
|
335
|
-
* `StCha
|
|
335
|
+
* `StCha n` / `StDisCha n+1` excluded). Already pure PV — never battery-adjusted.
|
|
336
336
|
* - `InverterDc`: the inverter's total DC power (Model 101 `DCW`). Pure PV — never
|
|
337
337
|
* battery-adjusted.
|
|
338
338
|
* - `InverterAc`: the inverter's total AC power (Model 101 `W`). On a hybrid this
|
|
@@ -892,7 +892,7 @@ export declare enum SunspecPvPowerSource {
|
|
|
892
892
|
* consumer can see which telemetry produced the number.
|
|
893
893
|
*
|
|
894
894
|
* - `MpptStrings`: summed per-string DC power from Model 160 (battery strings
|
|
895
|
-
* `StCha
|
|
895
|
+
* `StCha n` / `StDisCha n+1` excluded). Already pure PV — never battery-adjusted.
|
|
896
896
|
* - `InverterDc`: the inverter's total DC power (Model 101 `DCW`). Pure PV — never
|
|
897
897
|
* battery-adjusted.
|
|
898
898
|
* - `InverterAc`: the inverter's total AC power (Model 101 `W`). On a hybrid this
|
|
@@ -932,7 +932,7 @@ export interface SunspecInverterReading {
|
|
|
932
932
|
inverterPowerWRaw: number;
|
|
933
933
|
/**
|
|
934
934
|
* Summed per-string MPPT DC power (W) from Model 160 (battery strings
|
|
935
|
-
* `StCha
|
|
935
|
+
* `StCha n` / `StDisCha n+1` excluded), clamped to ≥ 0. Always computed and
|
|
936
936
|
* reported independently of `powerOrigin` — `0` when no PV strings are readable.
|
|
937
937
|
*/
|
|
938
938
|
inverterPowerWDcStrings: number;
|
|
@@ -2494,7 +2494,7 @@ class SunspecModbusClient {
|
|
|
2494
2494
|
// a live measurement — and produces e.g. 5000 W of "charging"
|
|
2495
2495
|
// for an idle battery with inWRte = 100 % and a 5 kW nameplate.
|
|
2496
2496
|
// Live battery power must come from a real source: Model 160
|
|
2497
|
-
// StCha
|
|
2497
|
+
// StCha n / StDisCha n+1 (see SunspecBattery.extractBatteryPower
|
|
2498
2498
|
// FromMPPT) or Model 802 `w` at offset 47 (the Model 802 branch
|
|
2499
2499
|
// of this method, just below). Model-124-only devices should
|
|
2500
2500
|
// publish "no signal" rather than the commanded cap.
|
package/dist/cjs/version.cjs
CHANGED
|
@@ -9,7 +9,7 @@ exports.getSdkVersion = getSdkVersion;
|
|
|
9
9
|
/**
|
|
10
10
|
* Current version of the enyo Energy App SDK.
|
|
11
11
|
*/
|
|
12
|
-
exports.SDK_VERSION = '1.
|
|
12
|
+
exports.SDK_VERSION = '1.12.1';
|
|
13
13
|
/**
|
|
14
14
|
* Gets the current SDK version.
|
|
15
15
|
* @returns The semantic version string of the SDK
|
package/dist/cjs/version.d.cts
CHANGED
|
@@ -422,7 +422,8 @@ export declare class SunspecInverter extends BaseSunspecDevice {
|
|
|
422
422
|
private sumDcStringsW;
|
|
423
423
|
/**
|
|
424
424
|
* Map MPPT data to DC string structure for data bus
|
|
425
|
-
* Filters out battery-related strings (StCha
|
|
425
|
+
* Filters out battery-related strings (StCha n, StDisCha n+1; see
|
|
426
|
+
* {@link mpptStorageStringKind})
|
|
426
427
|
*/
|
|
427
428
|
protected mapMPPTToStrings(mpptDataList: SunspecMPPTData[]): EnyoDataBusInverterValuesV1String[];
|
|
428
429
|
private mapMPPTOperatingState;
|
|
@@ -494,7 +495,7 @@ export declare function ratedDischargePowerW(batteryData: SunspecBatteryData | n
|
|
|
494
495
|
/**
|
|
495
496
|
* Pick the live battery power, in preference order:
|
|
496
497
|
*
|
|
497
|
-
* 1. Model 160 (MPPT) `StCha
|
|
498
|
+
* 1. Model 160 (MPPT) `StCha n` / `StDisCha n+1` — direct DC-link reading,
|
|
498
499
|
* passed in as the already-summed `mpptBatteryPowerW`.
|
|
499
500
|
* 2. Model 802 `w` (offset 47) — surfaced as `chargePower` / `dischargePower`
|
|
500
501
|
* by the Model 802 path of `SunspecModbusClient.readBatteryData`.
|
|
@@ -508,11 +509,24 @@ export declare function ratedDischargePowerW(batteryData: SunspecBatteryData | n
|
|
|
508
509
|
* Exported as a free function so the preference logic can be unit-tested
|
|
509
510
|
* without the full `SunspecBattery` scaffold.
|
|
510
511
|
*/
|
|
512
|
+
/**
|
|
513
|
+
* Classify a Model 160 module by its `IDStr` as a DC-coupled battery string.
|
|
514
|
+
*
|
|
515
|
+
* Fronius hybrids list the battery as two extra Model 160 modules after the PV
|
|
516
|
+
* MPPTs: `StCha <n>` (charge power) and `StDisCha <n+1>` (discharge power). The
|
|
517
|
+
* number is the module position, so it depends on how many PV trackers the
|
|
518
|
+
* device has: a GEN24 Plus (2 MPPTs) reports `StCha 3` / `StDisCha 4`, a
|
|
519
|
+
* Verto (3 MPPTs) `StCha 4` / `StDisCha 5`. Match the prefix, never the full
|
|
520
|
+
* label, or a battery module is counted as a PV string.
|
|
521
|
+
*
|
|
522
|
+
* Returns `undefined` for a PV string.
|
|
523
|
+
*/
|
|
524
|
+
export declare function mpptStorageStringKind(stringId: string | undefined): 'charge' | 'discharge' | undefined;
|
|
511
525
|
/**
|
|
512
526
|
* Sum battery charge/discharge power from Model 160 MPPT strings.
|
|
513
527
|
*
|
|
514
|
-
* - `StCha
|
|
515
|
-
* - `StDisCha
|
|
528
|
+
* - `StCha n` → charging power (added, positive)
|
|
529
|
+
* - `StDisCha n+1` → discharging power (subtracted)
|
|
516
530
|
*
|
|
517
531
|
* The result follows the battery-power sign convention used across this file:
|
|
518
532
|
* positive = charging, negative = discharging. Returns `undefined` when neither
|
|
@@ -677,8 +691,8 @@ export declare class SunspecBattery extends BaseSunspecDevice {
|
|
|
677
691
|
readData(clockId: string, resolution: EnyoDataBusMessageResolution): Promise<EnyoDataBusMessage[]>;
|
|
678
692
|
/**
|
|
679
693
|
* Extract battery power from MPPT strings with specific IDs
|
|
680
|
-
* StCha
|
|
681
|
-
* StDisCha
|
|
694
|
+
* StCha n: Battery charging power (positive)
|
|
695
|
+
* StDisCha n+1: Battery discharging power (negative)
|
|
682
696
|
*/
|
|
683
697
|
private extractBatteryPowerFromMPPT;
|
|
684
698
|
/**
|
package/dist/sunspec-devices.js
CHANGED
|
@@ -1193,13 +1193,14 @@ export class SunspecInverter extends BaseSunspecDevice {
|
|
|
1193
1193
|
}
|
|
1194
1194
|
/**
|
|
1195
1195
|
* Map MPPT data to DC string structure for data bus
|
|
1196
|
-
* Filters out battery-related strings (StCha
|
|
1196
|
+
* Filters out battery-related strings (StCha n, StDisCha n+1; see
|
|
1197
|
+
* {@link mpptStorageStringKind})
|
|
1197
1198
|
*/
|
|
1198
1199
|
mapMPPTToStrings(mpptDataList) {
|
|
1199
1200
|
const result = [];
|
|
1200
1201
|
mpptDataList.forEach((mppt, index) => {
|
|
1201
1202
|
// Skip battery-related strings - they will be handled separately
|
|
1202
|
-
if (mppt.stringId
|
|
1203
|
+
if (mpptStorageStringKind(mppt.stringId) !== undefined) {
|
|
1203
1204
|
return;
|
|
1204
1205
|
}
|
|
1205
1206
|
// Only include strings with valid data
|
|
@@ -1417,7 +1418,7 @@ export function ratedDischargePowerW(batteryData) {
|
|
|
1417
1418
|
/**
|
|
1418
1419
|
* Pick the live battery power, in preference order:
|
|
1419
1420
|
*
|
|
1420
|
-
* 1. Model 160 (MPPT) `StCha
|
|
1421
|
+
* 1. Model 160 (MPPT) `StCha n` / `StDisCha n+1` — direct DC-link reading,
|
|
1421
1422
|
* passed in as the already-summed `mpptBatteryPowerW`.
|
|
1422
1423
|
* 2. Model 802 `w` (offset 47) — surfaced as `chargePower` / `dischargePower`
|
|
1423
1424
|
* by the Model 802 path of `SunspecModbusClient.readBatteryData`.
|
|
@@ -1431,11 +1432,33 @@ export function ratedDischargePowerW(batteryData) {
|
|
|
1431
1432
|
* Exported as a free function so the preference logic can be unit-tested
|
|
1432
1433
|
* without the full `SunspecBattery` scaffold.
|
|
1433
1434
|
*/
|
|
1435
|
+
/**
|
|
1436
|
+
* Classify a Model 160 module by its `IDStr` as a DC-coupled battery string.
|
|
1437
|
+
*
|
|
1438
|
+
* Fronius hybrids list the battery as two extra Model 160 modules after the PV
|
|
1439
|
+
* MPPTs: `StCha <n>` (charge power) and `StDisCha <n+1>` (discharge power). The
|
|
1440
|
+
* number is the module position, so it depends on how many PV trackers the
|
|
1441
|
+
* device has: a GEN24 Plus (2 MPPTs) reports `StCha 3` / `StDisCha 4`, a
|
|
1442
|
+
* Verto (3 MPPTs) `StCha 4` / `StDisCha 5`. Match the prefix, never the full
|
|
1443
|
+
* label, or a battery module is counted as a PV string.
|
|
1444
|
+
*
|
|
1445
|
+
* Returns `undefined` for a PV string.
|
|
1446
|
+
*/
|
|
1447
|
+
export function mpptStorageStringKind(stringId) {
|
|
1448
|
+
const id = stringId?.trim() ?? '';
|
|
1449
|
+
if (/^StCha\b/i.test(id)) {
|
|
1450
|
+
return 'charge';
|
|
1451
|
+
}
|
|
1452
|
+
if (/^StDisCha\b/i.test(id)) {
|
|
1453
|
+
return 'discharge';
|
|
1454
|
+
}
|
|
1455
|
+
return undefined;
|
|
1456
|
+
}
|
|
1434
1457
|
/**
|
|
1435
1458
|
* Sum battery charge/discharge power from Model 160 MPPT strings.
|
|
1436
1459
|
*
|
|
1437
|
-
* - `StCha
|
|
1438
|
-
* - `StDisCha
|
|
1460
|
+
* - `StCha n` → charging power (added, positive)
|
|
1461
|
+
* - `StDisCha n+1` → discharging power (subtracted)
|
|
1439
1462
|
*
|
|
1440
1463
|
* The result follows the battery-power sign convention used across this file:
|
|
1441
1464
|
* positive = charging, negative = discharging. Returns `undefined` when neither
|
|
@@ -1447,10 +1470,11 @@ export function ratedDischargePowerW(batteryData) {
|
|
|
1447
1470
|
export function sumMpptBatteryPowerW(mpptDataList) {
|
|
1448
1471
|
let batteryPowerW;
|
|
1449
1472
|
for (const mppt of mpptDataList) {
|
|
1450
|
-
|
|
1473
|
+
const kind = mpptStorageStringKind(mppt.stringId);
|
|
1474
|
+
if (kind === 'charge' && mppt.dcPower !== undefined) {
|
|
1451
1475
|
batteryPowerW = (batteryPowerW ?? 0) + mppt.dcPower;
|
|
1452
1476
|
}
|
|
1453
|
-
else if (
|
|
1477
|
+
else if (kind === 'discharge' && mppt.dcPower !== undefined) {
|
|
1454
1478
|
batteryPowerW = (batteryPowerW ?? 0) - mppt.dcPower;
|
|
1455
1479
|
}
|
|
1456
1480
|
}
|
|
@@ -1961,8 +1985,8 @@ export class SunspecBattery extends BaseSunspecDevice {
|
|
|
1961
1985
|
}
|
|
1962
1986
|
/**
|
|
1963
1987
|
* Extract battery power from MPPT strings with specific IDs
|
|
1964
|
-
* StCha
|
|
1965
|
-
* StDisCha
|
|
1988
|
+
* StCha n: Battery charging power (positive)
|
|
1989
|
+
* StDisCha n+1: Battery discharging power (negative)
|
|
1966
1990
|
*/
|
|
1967
1991
|
extractBatteryPowerFromMPPT(mpptDataList) {
|
|
1968
1992
|
return sumMpptBatteryPowerW(mpptDataList);
|
|
@@ -1974,10 +1998,11 @@ export class SunspecBattery extends BaseSunspecDevice {
|
|
|
1974
1998
|
let hasCharge = false;
|
|
1975
1999
|
let hasDischarge = false;
|
|
1976
2000
|
mpptDataList.forEach((mppt) => {
|
|
1977
|
-
|
|
2001
|
+
const kind = mpptStorageStringKind(mppt.stringId);
|
|
2002
|
+
if (kind === 'charge' && mppt.dcPower !== undefined && mppt.dcPower > 0) {
|
|
1978
2003
|
hasCharge = true;
|
|
1979
2004
|
}
|
|
1980
|
-
else if (
|
|
2005
|
+
else if (kind === 'discharge' && mppt.dcPower !== undefined && mppt.dcPower > 0) {
|
|
1981
2006
|
hasDischarge = true;
|
|
1982
2007
|
}
|
|
1983
2008
|
});
|
|
@@ -892,7 +892,7 @@ export declare enum SunspecPvPowerSource {
|
|
|
892
892
|
* consumer can see which telemetry produced the number.
|
|
893
893
|
*
|
|
894
894
|
* - `MpptStrings`: summed per-string DC power from Model 160 (battery strings
|
|
895
|
-
* `StCha
|
|
895
|
+
* `StCha n` / `StDisCha n+1` excluded). Already pure PV — never battery-adjusted.
|
|
896
896
|
* - `InverterDc`: the inverter's total DC power (Model 101 `DCW`). Pure PV — never
|
|
897
897
|
* battery-adjusted.
|
|
898
898
|
* - `InverterAc`: the inverter's total AC power (Model 101 `W`). On a hybrid this
|
|
@@ -932,7 +932,7 @@ export interface SunspecInverterReading {
|
|
|
932
932
|
inverterPowerWRaw: number;
|
|
933
933
|
/**
|
|
934
934
|
* Summed per-string MPPT DC power (W) from Model 160 (battery strings
|
|
935
|
-
* `StCha
|
|
935
|
+
* `StCha n` / `StDisCha n+1` excluded), clamped to ≥ 0. Always computed and
|
|
936
936
|
* reported independently of `powerOrigin` — `0` when no PV strings are readable.
|
|
937
937
|
*/
|
|
938
938
|
inverterPowerWDcStrings: number;
|
|
@@ -329,7 +329,7 @@ export var SunspecPvPowerSource;
|
|
|
329
329
|
* consumer can see which telemetry produced the number.
|
|
330
330
|
*
|
|
331
331
|
* - `MpptStrings`: summed per-string DC power from Model 160 (battery strings
|
|
332
|
-
* `StCha
|
|
332
|
+
* `StCha n` / `StDisCha n+1` excluded). Already pure PV — never battery-adjusted.
|
|
333
333
|
* - `InverterDc`: the inverter's total DC power (Model 101 `DCW`). Pure PV — never
|
|
334
334
|
* battery-adjusted.
|
|
335
335
|
* - `InverterAc`: the inverter's total AC power (Model 101 `W`). On a hybrid this
|
|
@@ -2485,7 +2485,7 @@ export class SunspecModbusClient {
|
|
|
2485
2485
|
// a live measurement — and produces e.g. 5000 W of "charging"
|
|
2486
2486
|
// for an idle battery with inWRte = 100 % and a 5 kW nameplate.
|
|
2487
2487
|
// Live battery power must come from a real source: Model 160
|
|
2488
|
-
// StCha
|
|
2488
|
+
// StCha n / StDisCha n+1 (see SunspecBattery.extractBatteryPower
|
|
2489
2489
|
// FromMPPT) or Model 802 `w` at offset 47 (the Model 802 branch
|
|
2490
2490
|
// of this method, just below). Model-124-only devices should
|
|
2491
2491
|
// publish "no signal" rather than the commanded cap.
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enyo-energy/sunspec-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "enyo Energy Sunspec SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
+
"prepare": "git config core.hooksPath .githooks || true",
|
|
9
10
|
"extract-version": "node scripts/extract-version.js",
|
|
10
11
|
"build": "npm run extract-version && duel",
|
|
11
12
|
"test": "vitest run",
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
},
|
|
22
23
|
"repository": {
|
|
23
24
|
"type": "git",
|
|
24
|
-
"url": "git+https://github.com/enyo-energy/
|
|
25
|
+
"url": "git+https://github.com/enyo-energy/sunspec-sdk.git"
|
|
25
26
|
},
|
|
26
27
|
"keywords": [
|
|
27
28
|
"enyo"
|
|
@@ -29,9 +30,9 @@
|
|
|
29
30
|
"author": "enyo",
|
|
30
31
|
"license": "ISC",
|
|
31
32
|
"bugs": {
|
|
32
|
-
"url": "https://github.com/enyo-energy/
|
|
33
|
+
"url": "https://github.com/enyo-energy/sunspec-sdk/issues"
|
|
33
34
|
},
|
|
34
|
-
"homepage": "https://github.com/enyo-energy/
|
|
35
|
+
"homepage": "https://github.com/enyo-energy/sunspec-sdk",
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@knighted/duel": "2.1.4",
|
|
37
38
|
"@types/express": "^5.0.3",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"@enyo-energy/appliance-calibration": "0.0.3",
|
|
44
|
-
"@enyo-energy/energy-app-sdk": "1.
|
|
45
|
+
"@enyo-energy/energy-app-sdk": "1.70.0"
|
|
45
46
|
},
|
|
46
47
|
"volta": {
|
|
47
48
|
"node": "22.17.0"
|