@enyo-energy/sunspec-sdk 0.0.31 → 0.0.33
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/connection-retry-manager.cjs +63 -80
- package/dist/cjs/connection-retry-manager.d.cts +32 -27
- package/dist/cjs/sunspec-devices.cjs +201 -33
- package/dist/cjs/sunspec-devices.d.cts +56 -6
- package/dist/cjs/sunspec-interfaces.cjs +109 -5
- package/dist/cjs/sunspec-interfaces.d.cts +191 -5
- package/dist/cjs/sunspec-modbus-client.cjs +599 -290
- package/dist/cjs/sunspec-modbus-client.d.cts +43 -27
- package/dist/cjs/version.cjs +1 -1
- package/dist/cjs/version.d.cts +1 -1
- package/dist/connection-retry-manager.d.ts +32 -27
- package/dist/connection-retry-manager.js +63 -80
- package/dist/sunspec-devices.d.ts +56 -6
- package/dist/sunspec-devices.js +201 -33
- package/dist/sunspec-interfaces.d.ts +191 -5
- package/dist/sunspec-interfaces.js +108 -4
- package/dist/sunspec-modbus-client.d.ts +43 -27
- package/dist/sunspec-modbus-client.js +600 -291
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import { type SunspecBatteryControls, SunspecStorageMode } from "./sunspec-interfaces.cjs";
|
|
1
|
+
import { type SunspecBatteryBaseData, type SunspecBatteryControls, SunspecStorageMode, SunspecInverterCapability, SunspecBatteryCapability, SunspecMeterCapability } from "./sunspec-interfaces.cjs";
|
|
2
2
|
import { ApplianceManager, EnergyApp } from "@enyo-energy/energy-app-sdk";
|
|
3
3
|
import { 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";
|
|
5
5
|
import { SunspecModbusClient } from "./sunspec-modbus-client.cjs";
|
|
6
|
-
import {
|
|
6
|
+
import { ConnectionRetryManager } from "./connection-retry-manager.cjs";
|
|
7
|
+
import { type IRetryConfig } from "./sunspec-interfaces.cjs";
|
|
8
|
+
import { EnyoCommandAcknowledgeAnswerEnum, EnyoDataBusMessage, EnyoDataBusMessageEnum, EnyoDataBusMessageResolution } from "@enyo-energy/energy-app-sdk/dist/types/enyo-data-bus-value.js";
|
|
9
|
+
import { EnergyAppDataBus } from "@enyo-energy/energy-app-sdk/dist/packages/energy-app-data-bus.js";
|
|
10
|
+
export declare const ENYO_DATA_BUS_SET_INVERTER_FEED_IN_LIMIT_V1 = "SetInverterFeedInLimitV1";
|
|
11
|
+
export interface EnyoDataBusSetInverterFeedInLimitV1 {
|
|
12
|
+
id: string;
|
|
13
|
+
type: 'message';
|
|
14
|
+
message: string;
|
|
15
|
+
applianceId: string;
|
|
16
|
+
data: {
|
|
17
|
+
feedInLimitW: number | null;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
7
20
|
/**
|
|
8
21
|
* Base abstract class for all Sunspec devices
|
|
9
22
|
*/
|
|
@@ -18,7 +31,10 @@ export declare abstract class BaseSunspecDevice {
|
|
|
18
31
|
protected readonly baseAddress: number;
|
|
19
32
|
protected applianceId?: string;
|
|
20
33
|
protected lastUpdateTime: number;
|
|
21
|
-
|
|
34
|
+
protected dataBusListenerId?: string;
|
|
35
|
+
protected dataBus?: EnergyAppDataBus;
|
|
36
|
+
protected retryManager: ConnectionRetryManager;
|
|
37
|
+
constructor(energyApp: EnergyApp, name: EnyoApplianceName[], networkDevice: EnyoNetworkDevice, sunspecClient: SunspecModbusClient, applianceManager: ApplianceManager, unitId?: number, port?: number, baseAddress?: number, retryConfig?: IRetryConfig);
|
|
22
38
|
/**
|
|
23
39
|
* Connect to the device and create/update the appliance
|
|
24
40
|
*/
|
|
@@ -42,11 +58,24 @@ export declare abstract class BaseSunspecDevice {
|
|
|
42
58
|
* Ensure the Sunspec client is connected and models are discovered
|
|
43
59
|
*/
|
|
44
60
|
protected ensureConnected(): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Attempt a reconnection if the tiered retry schedule allows it.
|
|
63
|
+
* Called from readData() when the device is disconnected.
|
|
64
|
+
* Returns true if reconnection succeeded.
|
|
65
|
+
*/
|
|
66
|
+
protected tryReconnect(): Promise<boolean>;
|
|
67
|
+
/**
|
|
68
|
+
* Mark the device as offline: update appliance state and start tracking disconnection.
|
|
69
|
+
*/
|
|
70
|
+
protected markOffline(): Promise<void>;
|
|
71
|
+
protected sendCommandAcknowledge(messageId: string, acknowledgeMessage: EnyoDataBusMessageEnum | string, answer: EnyoCommandAcknowledgeAnswerEnum, rejectionReason?: string): void;
|
|
45
72
|
}
|
|
46
73
|
/**
|
|
47
74
|
* Sunspec Inverter implementation using dynamic model discovery
|
|
48
75
|
*/
|
|
49
76
|
export declare class SunspecInverter extends BaseSunspecDevice {
|
|
77
|
+
private readonly capabilities;
|
|
78
|
+
constructor(energyApp: EnergyApp, name: EnyoApplianceName[], networkDevice: EnyoNetworkDevice, sunspecClient: SunspecModbusClient, applianceManager: ApplianceManager, unitId?: number, port?: number, baseAddress?: number, capabilities?: SunspecInverterCapability[], retryConfig?: IRetryConfig);
|
|
50
79
|
connect(): Promise<void>;
|
|
51
80
|
disconnect(): Promise<void>;
|
|
52
81
|
isConnected(): boolean;
|
|
@@ -59,13 +88,24 @@ export declare class SunspecInverter extends BaseSunspecDevice {
|
|
|
59
88
|
private mapMPPTToStrings;
|
|
60
89
|
private mapMPPTOperatingState;
|
|
61
90
|
private mapDcStringToApplianceMetadata;
|
|
91
|
+
/**
|
|
92
|
+
* Start listening for inverter commands on the data bus.
|
|
93
|
+
* Idempotent — does nothing if already listening.
|
|
94
|
+
*/
|
|
95
|
+
startDataBusListening(): void;
|
|
96
|
+
/**
|
|
97
|
+
* Stop listening for inverter commands on the data bus.
|
|
98
|
+
*/
|
|
99
|
+
stopDataBusListening(): void;
|
|
100
|
+
private handleInverterCommand;
|
|
101
|
+
private handleSetFeedInLimit;
|
|
62
102
|
}
|
|
63
103
|
/**
|
|
64
104
|
* Sunspec Battery implementation
|
|
65
105
|
*/
|
|
66
106
|
export declare class SunspecBattery extends BaseSunspecDevice {
|
|
67
|
-
private
|
|
68
|
-
|
|
107
|
+
private readonly capabilities;
|
|
108
|
+
constructor(energyApp: EnergyApp, name: EnyoApplianceName[], networkDevice: EnyoNetworkDevice, sunspecClient: SunspecModbusClient, applianceManager: ApplianceManager, unitId?: number, port?: number, baseAddress?: number, capabilities?: SunspecBatteryCapability[], retryConfig?: IRetryConfig);
|
|
69
109
|
/**
|
|
70
110
|
* Connect to the battery and create/update the appliance
|
|
71
111
|
*/
|
|
@@ -130,6 +170,15 @@ export declare class SunspecBattery extends BaseSunspecDevice {
|
|
|
130
170
|
* @returns Promise<SunspecBatteryControls | null> - Current control settings or null if error
|
|
131
171
|
*/
|
|
132
172
|
getBatteryControls(): Promise<SunspecBatteryControls | null>;
|
|
173
|
+
/**
|
|
174
|
+
* Read full battery base data from Model 802
|
|
175
|
+
*
|
|
176
|
+
* Returns the complete Model 802 data structure with all fields,
|
|
177
|
+
* including nameplate, SoC/health, status, events, voltage, current, and power.
|
|
178
|
+
*
|
|
179
|
+
* @returns Promise<SunspecBatteryBaseData | null> - Full model 802 data or null if not available
|
|
180
|
+
*/
|
|
181
|
+
readBatteryBaseData(): Promise<SunspecBatteryBaseData | null>;
|
|
133
182
|
/**
|
|
134
183
|
* Write custom battery control settings
|
|
135
184
|
*
|
|
@@ -167,12 +216,13 @@ export declare class SunspecBattery extends BaseSunspecDevice {
|
|
|
167
216
|
private handleStartGridCharge;
|
|
168
217
|
private handleStopGridCharge;
|
|
169
218
|
private handleSetDischargeLimit;
|
|
170
|
-
private sendCommandAcknowledge;
|
|
171
219
|
}
|
|
172
220
|
/**
|
|
173
221
|
* Sunspec Meter implementation
|
|
174
222
|
*/
|
|
175
223
|
export declare class SunspecMeter extends BaseSunspecDevice {
|
|
224
|
+
private readonly capabilities;
|
|
225
|
+
constructor(energyApp: EnergyApp, name: EnyoApplianceName[], networkDevice: EnyoNetworkDevice, sunspecClient: SunspecModbusClient, applianceManager: ApplianceManager, unitId?: number, port?: number, baseAddress?: number, capabilities?: SunspecMeterCapability[], retryConfig?: IRetryConfig);
|
|
176
226
|
/**
|
|
177
227
|
* Connect to the meter and create/update the appliance
|
|
178
228
|
*/
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
* SunSpec block interfaces with block numbers
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SunspecStorageMode = exports.SunspecChargeSource = exports.SunspecVArPctMode = exports.SunspecEnableControl = exports.SunspecConnectionControl = exports.SunspecStorageControlMode = exports.SunspecBatteryChargeState = exports.SunspecMPPTOperatingState = exports.SunspecModelId = exports.DEFAULT_RETRY_CONFIG = void 0;
|
|
6
|
+
exports.SunspecMeterCapability = exports.SunspecBatteryCapability = exports.SunspecInverterCapability = exports.SunspecStorageMode = exports.SunspecChargeSource = exports.SunspecVArPctMode = exports.SunspecEnableControl = exports.SunspecConnectionControl = exports.SunspecStorageControlMode = exports.SunspecBatteryEvent1 = exports.SunspecBatteryBankState = exports.SunspecBatteryType = exports.SunspecBatteryControlMode = exports.SunspecBatteryChargeState = exports.SunspecMPPTOperatingState = exports.SunspecModelId = exports.DEFAULT_RETRY_CONFIG = void 0;
|
|
7
7
|
exports.DEFAULT_RETRY_CONFIG = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
phases: [
|
|
9
|
+
{ intervalMs: 10_000, durationMs: 60_000 }, // Phase 1: every 10s for 1 minute
|
|
10
|
+
{ intervalMs: 30_000, durationMs: 120_000 }, // Phase 2: every 30s for 2 minutes
|
|
11
|
+
{ intervalMs: 60_000, durationMs: 300_000 }, // Phase 3: every 1m for 5 minutes
|
|
12
|
+
{ intervalMs: 300_000, durationMs: 0 }, // Phase 4: every 5m forever
|
|
13
|
+
]
|
|
12
14
|
};
|
|
13
15
|
/**
|
|
14
16
|
* Common Sunspec Model IDs
|
|
@@ -61,6 +63,87 @@ var SunspecBatteryChargeState;
|
|
|
61
63
|
SunspecBatteryChargeState[SunspecBatteryChargeState["HOLDING"] = 6] = "HOLDING";
|
|
62
64
|
SunspecBatteryChargeState[SunspecBatteryChargeState["TESTING"] = 7] = "TESTING";
|
|
63
65
|
})(SunspecBatteryChargeState || (exports.SunspecBatteryChargeState = SunspecBatteryChargeState = {}));
|
|
66
|
+
/**
|
|
67
|
+
* Battery Control Mode values for Model 802
|
|
68
|
+
* Offset 17: LocRemCtl - Local/Remote control mode
|
|
69
|
+
*/
|
|
70
|
+
var SunspecBatteryControlMode;
|
|
71
|
+
(function (SunspecBatteryControlMode) {
|
|
72
|
+
SunspecBatteryControlMode[SunspecBatteryControlMode["REMOTE"] = 0] = "REMOTE";
|
|
73
|
+
SunspecBatteryControlMode[SunspecBatteryControlMode["LOCAL"] = 1] = "LOCAL";
|
|
74
|
+
})(SunspecBatteryControlMode || (exports.SunspecBatteryControlMode = SunspecBatteryControlMode = {}));
|
|
75
|
+
/**
|
|
76
|
+
* Battery Type values for Model 802
|
|
77
|
+
* Offset 21: Typ - Battery type
|
|
78
|
+
*/
|
|
79
|
+
var SunspecBatteryType;
|
|
80
|
+
(function (SunspecBatteryType) {
|
|
81
|
+
SunspecBatteryType[SunspecBatteryType["NOT_APPLICABLE_UNKNOWN"] = 0] = "NOT_APPLICABLE_UNKNOWN";
|
|
82
|
+
SunspecBatteryType[SunspecBatteryType["LEAD_ACID"] = 1] = "LEAD_ACID";
|
|
83
|
+
SunspecBatteryType[SunspecBatteryType["NICKEL_METAL_HYDRIDE"] = 2] = "NICKEL_METAL_HYDRIDE";
|
|
84
|
+
SunspecBatteryType[SunspecBatteryType["NICKEL_CADMIUM"] = 3] = "NICKEL_CADMIUM";
|
|
85
|
+
SunspecBatteryType[SunspecBatteryType["LITHIUM_ION"] = 4] = "LITHIUM_ION";
|
|
86
|
+
SunspecBatteryType[SunspecBatteryType["CARBON_ZINC"] = 5] = "CARBON_ZINC";
|
|
87
|
+
SunspecBatteryType[SunspecBatteryType["ZINC_CHLORIDE"] = 6] = "ZINC_CHLORIDE";
|
|
88
|
+
SunspecBatteryType[SunspecBatteryType["ALKALINE"] = 7] = "ALKALINE";
|
|
89
|
+
SunspecBatteryType[SunspecBatteryType["RECHARGEABLE_ALKALINE"] = 8] = "RECHARGEABLE_ALKALINE";
|
|
90
|
+
SunspecBatteryType[SunspecBatteryType["SODIUM_SULFUR"] = 9] = "SODIUM_SULFUR";
|
|
91
|
+
SunspecBatteryType[SunspecBatteryType["FLOW"] = 10] = "FLOW";
|
|
92
|
+
SunspecBatteryType[SunspecBatteryType["SUPER_CAPACITOR"] = 11] = "SUPER_CAPACITOR";
|
|
93
|
+
SunspecBatteryType[SunspecBatteryType["OTHER"] = 99] = "OTHER";
|
|
94
|
+
})(SunspecBatteryType || (exports.SunspecBatteryType = SunspecBatteryType = {}));
|
|
95
|
+
/**
|
|
96
|
+
* Battery Bank State values for Model 802
|
|
97
|
+
* Offset 22: State - Battery bank state
|
|
98
|
+
*/
|
|
99
|
+
var SunspecBatteryBankState;
|
|
100
|
+
(function (SunspecBatteryBankState) {
|
|
101
|
+
SunspecBatteryBankState[SunspecBatteryBankState["DISCONNECTED"] = 1] = "DISCONNECTED";
|
|
102
|
+
SunspecBatteryBankState[SunspecBatteryBankState["INITIALIZING"] = 2] = "INITIALIZING";
|
|
103
|
+
SunspecBatteryBankState[SunspecBatteryBankState["CONNECTED"] = 3] = "CONNECTED";
|
|
104
|
+
SunspecBatteryBankState[SunspecBatteryBankState["STANDBY"] = 4] = "STANDBY";
|
|
105
|
+
SunspecBatteryBankState[SunspecBatteryBankState["SOC_PROTECTION"] = 5] = "SOC_PROTECTION";
|
|
106
|
+
SunspecBatteryBankState[SunspecBatteryBankState["SUSPENDING"] = 6] = "SUSPENDING";
|
|
107
|
+
SunspecBatteryBankState[SunspecBatteryBankState["FAULT"] = 99] = "FAULT";
|
|
108
|
+
})(SunspecBatteryBankState || (exports.SunspecBatteryBankState = SunspecBatteryBankState = {}));
|
|
109
|
+
/**
|
|
110
|
+
* Battery Event 1 bit positions for Model 802
|
|
111
|
+
* Offset 26-27: Evt1 - Battery event bitfield
|
|
112
|
+
*/
|
|
113
|
+
var SunspecBatteryEvent1;
|
|
114
|
+
(function (SunspecBatteryEvent1) {
|
|
115
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["COMMUNICATION_ERROR"] = 0] = "COMMUNICATION_ERROR";
|
|
116
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["OVER_TEMP_ALARM"] = 1] = "OVER_TEMP_ALARM";
|
|
117
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["OVER_TEMP_WARNING"] = 2] = "OVER_TEMP_WARNING";
|
|
118
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["UNDER_TEMP_ALARM"] = 3] = "UNDER_TEMP_ALARM";
|
|
119
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["UNDER_TEMP_WARNING"] = 4] = "UNDER_TEMP_WARNING";
|
|
120
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["OVER_CHARGE_CURRENT_ALARM"] = 5] = "OVER_CHARGE_CURRENT_ALARM";
|
|
121
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["OVER_CHARGE_CURRENT_WARNING"] = 6] = "OVER_CHARGE_CURRENT_WARNING";
|
|
122
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["OVER_DISCHARGE_CURRENT_ALARM"] = 7] = "OVER_DISCHARGE_CURRENT_ALARM";
|
|
123
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["OVER_DISCHARGE_CURRENT_WARNING"] = 8] = "OVER_DISCHARGE_CURRENT_WARNING";
|
|
124
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["OVER_VOLT_ALARM"] = 9] = "OVER_VOLT_ALARM";
|
|
125
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["OVER_VOLT_WARNING"] = 10] = "OVER_VOLT_WARNING";
|
|
126
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["UNDER_VOLT_ALARM"] = 11] = "UNDER_VOLT_ALARM";
|
|
127
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["UNDER_VOLT_WARNING"] = 12] = "UNDER_VOLT_WARNING";
|
|
128
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["UNDER_SOC_MIN_ALARM"] = 13] = "UNDER_SOC_MIN_ALARM";
|
|
129
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["UNDER_SOC_MIN_WARNING"] = 14] = "UNDER_SOC_MIN_WARNING";
|
|
130
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["OVER_SOC_MAX_ALARM"] = 15] = "OVER_SOC_MAX_ALARM";
|
|
131
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["OVER_SOC_MAX_WARNING"] = 16] = "OVER_SOC_MAX_WARNING";
|
|
132
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["VOLTAGE_IMBALANCE_WARNING"] = 17] = "VOLTAGE_IMBALANCE_WARNING";
|
|
133
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["TEMPERATURE_IMBALANCE_ALARM"] = 18] = "TEMPERATURE_IMBALANCE_ALARM";
|
|
134
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["TEMPERATURE_IMBALANCE_WARNING"] = 19] = "TEMPERATURE_IMBALANCE_WARNING";
|
|
135
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["CONTACTOR_ERROR"] = 20] = "CONTACTOR_ERROR";
|
|
136
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["FAN_ERROR"] = 21] = "FAN_ERROR";
|
|
137
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["FUSE_ERROR"] = 22] = "FUSE_ERROR";
|
|
138
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["GROUND_FAULT"] = 23] = "GROUND_FAULT";
|
|
139
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["OPEN_DOOR_ERROR"] = 24] = "OPEN_DOOR_ERROR";
|
|
140
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["CURRENT_IMBALANCE_WARNING"] = 25] = "CURRENT_IMBALANCE_WARNING";
|
|
141
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["OTHER_ALARM"] = 26] = "OTHER_ALARM";
|
|
142
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["OTHER_WARNING"] = 27] = "OTHER_WARNING";
|
|
143
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["RESERVED_1"] = 28] = "RESERVED_1";
|
|
144
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["CONFIGURATION_ALARM"] = 29] = "CONFIGURATION_ALARM";
|
|
145
|
+
SunspecBatteryEvent1[SunspecBatteryEvent1["CONFIGURATION_WARNING"] = 30] = "CONFIGURATION_WARNING";
|
|
146
|
+
})(SunspecBatteryEvent1 || (exports.SunspecBatteryEvent1 = SunspecBatteryEvent1 = {}));
|
|
64
147
|
/**
|
|
65
148
|
* Storage Control Mode bitfield values for Model 124
|
|
66
149
|
*
|
|
@@ -119,3 +202,24 @@ var SunspecStorageMode;
|
|
|
119
202
|
SunspecStorageMode["HOLDING"] = "holding";
|
|
120
203
|
SunspecStorageMode["AUTO"] = "auto"; // Both charge and discharge allowed
|
|
121
204
|
})(SunspecStorageMode || (exports.SunspecStorageMode = SunspecStorageMode = {}));
|
|
205
|
+
/**
|
|
206
|
+
* Battery control structure for writing to Model 124
|
|
207
|
+
* Used for controlling battery charge/discharge behavior
|
|
208
|
+
*
|
|
209
|
+
* IMPORTANT: To enable grid charging with specific power:
|
|
210
|
+
* 1. Set storCtlMod with appropriate bits to enable external control
|
|
211
|
+
* 2. Set chaGriSet = 1 to allow grid charging
|
|
212
|
+
* 3. Set wChaMax to the desired charging power in Watts
|
|
213
|
+
*/
|
|
214
|
+
var SunspecInverterCapability;
|
|
215
|
+
(function (SunspecInverterCapability) {
|
|
216
|
+
SunspecInverterCapability["FeedInLimit"] = "feed-in-limit";
|
|
217
|
+
})(SunspecInverterCapability || (exports.SunspecInverterCapability = SunspecInverterCapability = {}));
|
|
218
|
+
var SunspecBatteryCapability;
|
|
219
|
+
(function (SunspecBatteryCapability) {
|
|
220
|
+
SunspecBatteryCapability["GridCharging"] = "grid-charging";
|
|
221
|
+
SunspecBatteryCapability["DischargeLimit"] = "discharge-limit";
|
|
222
|
+
})(SunspecBatteryCapability || (exports.SunspecBatteryCapability = SunspecBatteryCapability = {}));
|
|
223
|
+
var SunspecMeterCapability;
|
|
224
|
+
(function (SunspecMeterCapability) {
|
|
225
|
+
})(SunspecMeterCapability || (exports.SunspecMeterCapability = SunspecMeterCapability = {}));
|
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
* SunSpec block interfaces with block numbers
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* A single phase in the tiered retry schedule
|
|
6
|
+
*/
|
|
7
|
+
export interface IRetryPhase {
|
|
8
|
+
intervalMs: number;
|
|
9
|
+
durationMs: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for connection retry with tiered schedule
|
|
6
13
|
*/
|
|
7
14
|
export interface IRetryConfig {
|
|
8
|
-
|
|
9
|
-
maxDelayMs: number;
|
|
10
|
-
backoffFactor: number;
|
|
11
|
-
maxAttempts: number;
|
|
15
|
+
phases: IRetryPhase[];
|
|
12
16
|
}
|
|
13
17
|
export declare const DEFAULT_RETRY_CONFIG: IRetryConfig;
|
|
14
18
|
/**
|
|
@@ -178,6 +182,83 @@ export declare enum SunspecBatteryChargeState {
|
|
|
178
182
|
HOLDING = 6,
|
|
179
183
|
TESTING = 7
|
|
180
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Battery Control Mode values for Model 802
|
|
187
|
+
* Offset 17: LocRemCtl - Local/Remote control mode
|
|
188
|
+
*/
|
|
189
|
+
export declare enum SunspecBatteryControlMode {
|
|
190
|
+
REMOTE = 0,
|
|
191
|
+
LOCAL = 1
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Battery Type values for Model 802
|
|
195
|
+
* Offset 21: Typ - Battery type
|
|
196
|
+
*/
|
|
197
|
+
export declare enum SunspecBatteryType {
|
|
198
|
+
NOT_APPLICABLE_UNKNOWN = 0,
|
|
199
|
+
LEAD_ACID = 1,
|
|
200
|
+
NICKEL_METAL_HYDRIDE = 2,
|
|
201
|
+
NICKEL_CADMIUM = 3,
|
|
202
|
+
LITHIUM_ION = 4,
|
|
203
|
+
CARBON_ZINC = 5,
|
|
204
|
+
ZINC_CHLORIDE = 6,
|
|
205
|
+
ALKALINE = 7,
|
|
206
|
+
RECHARGEABLE_ALKALINE = 8,
|
|
207
|
+
SODIUM_SULFUR = 9,
|
|
208
|
+
FLOW = 10,
|
|
209
|
+
SUPER_CAPACITOR = 11,
|
|
210
|
+
OTHER = 99
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Battery Bank State values for Model 802
|
|
214
|
+
* Offset 22: State - Battery bank state
|
|
215
|
+
*/
|
|
216
|
+
export declare enum SunspecBatteryBankState {
|
|
217
|
+
DISCONNECTED = 1,
|
|
218
|
+
INITIALIZING = 2,
|
|
219
|
+
CONNECTED = 3,
|
|
220
|
+
STANDBY = 4,
|
|
221
|
+
SOC_PROTECTION = 5,
|
|
222
|
+
SUSPENDING = 6,
|
|
223
|
+
FAULT = 99
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Battery Event 1 bit positions for Model 802
|
|
227
|
+
* Offset 26-27: Evt1 - Battery event bitfield
|
|
228
|
+
*/
|
|
229
|
+
export declare enum SunspecBatteryEvent1 {
|
|
230
|
+
COMMUNICATION_ERROR = 0,
|
|
231
|
+
OVER_TEMP_ALARM = 1,
|
|
232
|
+
OVER_TEMP_WARNING = 2,
|
|
233
|
+
UNDER_TEMP_ALARM = 3,
|
|
234
|
+
UNDER_TEMP_WARNING = 4,
|
|
235
|
+
OVER_CHARGE_CURRENT_ALARM = 5,
|
|
236
|
+
OVER_CHARGE_CURRENT_WARNING = 6,
|
|
237
|
+
OVER_DISCHARGE_CURRENT_ALARM = 7,
|
|
238
|
+
OVER_DISCHARGE_CURRENT_WARNING = 8,
|
|
239
|
+
OVER_VOLT_ALARM = 9,
|
|
240
|
+
OVER_VOLT_WARNING = 10,
|
|
241
|
+
UNDER_VOLT_ALARM = 11,
|
|
242
|
+
UNDER_VOLT_WARNING = 12,
|
|
243
|
+
UNDER_SOC_MIN_ALARM = 13,
|
|
244
|
+
UNDER_SOC_MIN_WARNING = 14,
|
|
245
|
+
OVER_SOC_MAX_ALARM = 15,
|
|
246
|
+
OVER_SOC_MAX_WARNING = 16,
|
|
247
|
+
VOLTAGE_IMBALANCE_WARNING = 17,
|
|
248
|
+
TEMPERATURE_IMBALANCE_ALARM = 18,
|
|
249
|
+
TEMPERATURE_IMBALANCE_WARNING = 19,
|
|
250
|
+
CONTACTOR_ERROR = 20,
|
|
251
|
+
FAN_ERROR = 21,
|
|
252
|
+
FUSE_ERROR = 22,
|
|
253
|
+
GROUND_FAULT = 23,
|
|
254
|
+
OPEN_DOOR_ERROR = 24,
|
|
255
|
+
CURRENT_IMBALANCE_WARNING = 25,
|
|
256
|
+
OTHER_ALARM = 26,
|
|
257
|
+
OTHER_WARNING = 27,
|
|
258
|
+
RESERVED_1 = 28,
|
|
259
|
+
CONFIGURATION_ALARM = 29,
|
|
260
|
+
CONFIGURATION_WARNING = 30
|
|
261
|
+
}
|
|
181
262
|
/**
|
|
182
263
|
* Storage Control Mode bitfield values for Model 124
|
|
183
264
|
*
|
|
@@ -247,6 +328,102 @@ export interface SunspecBatteryData extends SunspecBlock {
|
|
|
247
328
|
temperature?: number;
|
|
248
329
|
status?: number;
|
|
249
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Battery Base data structure based on Model 802 (Battery Base Model)
|
|
333
|
+
*
|
|
334
|
+
* SunSpec Model 802 Register Map (offsets relative to model start):
|
|
335
|
+
* - 0-1: ID and Length
|
|
336
|
+
* - 2: AHRtg - Nameplate charge capacity (AH) (uint16)
|
|
337
|
+
* - 3: WHRtg - Nameplate energy capacity (WH) (uint16)
|
|
338
|
+
* - 4: WChaRteMax - Maximum rate of charge (W) (uint16)
|
|
339
|
+
* - 5: WDisChaRteMax - Maximum rate of discharge (W) (uint16)
|
|
340
|
+
* - 6: DisChaRte - Self discharge rate (%) (uint16)
|
|
341
|
+
* - 7: SoCMax - Maximum state of charge (%) (uint16)
|
|
342
|
+
* - 8: SoCMin - Minimum state of charge (%) (uint16)
|
|
343
|
+
* - 9: SoCRsvMax - Maximum reserve SOC (%) (uint16)
|
|
344
|
+
* - 10: SoCRsvMin - Minimum reserve SOC (%) (uint16)
|
|
345
|
+
* - 11: SoC - State of charge (%) (uint16)
|
|
346
|
+
* - 12: DoD - Depth of discharge (%) (uint16)
|
|
347
|
+
* - 13: SoH - State of health (%) (uint16)
|
|
348
|
+
* - 14-15: NCyc - Cycle count (uint32)
|
|
349
|
+
* - 16: ChaSt - Charge status (enum16)
|
|
350
|
+
* - 17: LocRemCtl - Local/Remote control (enum16)
|
|
351
|
+
* - 18: Hb - Heartbeat (uint16)
|
|
352
|
+
* - 19: CtrlHb - Controller heartbeat (uint16)
|
|
353
|
+
* - 20: AlmRst - Alarm reset (uint16)
|
|
354
|
+
* - 21: Typ - Battery type (enum16)
|
|
355
|
+
* - 22: State - Battery bank state (enum16)
|
|
356
|
+
* - 23: StateVnd - Vendor-specific state (enum16)
|
|
357
|
+
* - 24-25: WarrDt - Warranty date (uint32)
|
|
358
|
+
* - 26-27: Evt1 - Event bitfield 1 (bitfield32)
|
|
359
|
+
* - 28-29: Evt2 - Event bitfield 2 (bitfield32)
|
|
360
|
+
* - 30-31: EvtVnd1 - Vendor event bitfield 1 (bitfield32)
|
|
361
|
+
* - 32-33: EvtVnd2 - Vendor event bitfield 2 (bitfield32)
|
|
362
|
+
* - 34: V - Battery voltage (V) (uint16)
|
|
363
|
+
* - 35: VMax - Maximum battery voltage (V) (uint16)
|
|
364
|
+
* - 36: VMin - Minimum battery voltage (V) (uint16)
|
|
365
|
+
* - 37: CellVMax - Maximum cell voltage (V) (uint16)
|
|
366
|
+
* - 38: CellVMaxStr - String containing max cell voltage (uint16)
|
|
367
|
+
* - 39: CellVMaxMod - Module containing max cell voltage (uint16)
|
|
368
|
+
* - 40: CellVMin - Minimum cell voltage (V) (uint16)
|
|
369
|
+
* - 41: CellVMinStr - String containing min cell voltage (uint16)
|
|
370
|
+
* - 42: CellVMinMod - Module containing min cell voltage (uint16)
|
|
371
|
+
* - 43: CellVAvg - Average cell voltage (V) (uint16)
|
|
372
|
+
* - 44: A - Battery current (A) (int16)
|
|
373
|
+
* - 45: AChaMax - Maximum charge current (A) (uint16)
|
|
374
|
+
* - 46: ADisChaMax - Maximum discharge current (A) (uint16)
|
|
375
|
+
* - 47: W - Battery power (W) (int16)
|
|
376
|
+
* - 48: ReqInvState - Requested inverter state (enum16)
|
|
377
|
+
* - 49: ReqW - Requested power (W) (int16)
|
|
378
|
+
* - 50: SetOp - Set operation (enum16)
|
|
379
|
+
* - 51: SetInvState - Set inverter state (enum16)
|
|
380
|
+
* Scale factors at offsets 52-63
|
|
381
|
+
*/
|
|
382
|
+
export interface SunspecBatteryBaseData extends SunspecBlock {
|
|
383
|
+
blockNumber: 802;
|
|
384
|
+
ahRtg?: number;
|
|
385
|
+
whRtg?: number;
|
|
386
|
+
wChaRteMax?: number;
|
|
387
|
+
wDisChaRteMax?: number;
|
|
388
|
+
disChaRte?: number;
|
|
389
|
+
soCMax?: number;
|
|
390
|
+
soCMin?: number;
|
|
391
|
+
soCRsvMax?: number;
|
|
392
|
+
soCRsvMin?: number;
|
|
393
|
+
soC?: number;
|
|
394
|
+
doD?: number;
|
|
395
|
+
soH?: number;
|
|
396
|
+
nCyc?: number;
|
|
397
|
+
chaSt?: number;
|
|
398
|
+
chaStName?: string;
|
|
399
|
+
locRemCtl?: number;
|
|
400
|
+
typ?: number;
|
|
401
|
+
typName?: string;
|
|
402
|
+
state?: number;
|
|
403
|
+
stateName?: string;
|
|
404
|
+
evt1?: number;
|
|
405
|
+
evt2?: number;
|
|
406
|
+
evtVnd1?: number;
|
|
407
|
+
evtVnd2?: number;
|
|
408
|
+
v?: number;
|
|
409
|
+
vMax?: number;
|
|
410
|
+
vMin?: number;
|
|
411
|
+
cellVMax?: number;
|
|
412
|
+
cellVMaxStr?: number;
|
|
413
|
+
cellVMaxMod?: number;
|
|
414
|
+
cellVMin?: number;
|
|
415
|
+
cellVMinStr?: number;
|
|
416
|
+
cellVMinMod?: number;
|
|
417
|
+
cellVAvg?: number;
|
|
418
|
+
a?: number;
|
|
419
|
+
aChaMax?: number;
|
|
420
|
+
aDisChaMax?: number;
|
|
421
|
+
w?: number;
|
|
422
|
+
reqInvState?: number;
|
|
423
|
+
reqW?: number;
|
|
424
|
+
setOp?: number;
|
|
425
|
+
setInvState?: number;
|
|
426
|
+
}
|
|
250
427
|
/**
|
|
251
428
|
* Meter data structure
|
|
252
429
|
*/
|
|
@@ -378,6 +555,15 @@ export declare enum SunspecStorageMode {
|
|
|
378
555
|
* 2. Set chaGriSet = 1 to allow grid charging
|
|
379
556
|
* 3. Set wChaMax to the desired charging power in Watts
|
|
380
557
|
*/
|
|
558
|
+
export declare enum SunspecInverterCapability {
|
|
559
|
+
FeedInLimit = "feed-in-limit"
|
|
560
|
+
}
|
|
561
|
+
export declare enum SunspecBatteryCapability {
|
|
562
|
+
GridCharging = "grid-charging",
|
|
563
|
+
DischargeLimit = "discharge-limit"
|
|
564
|
+
}
|
|
565
|
+
export declare enum SunspecMeterCapability {
|
|
566
|
+
}
|
|
381
567
|
export interface SunspecBatteryControls {
|
|
382
568
|
storCtlMod?: number;
|
|
383
569
|
chaGriSet?: number;
|