@enyo-energy/sunspec-sdk 0.0.78 → 0.0.79
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 +18 -0
- package/dist/cjs/sunspec-devices.d.cts +1 -0
- package/dist/cjs/version.cjs +1 -1
- package/dist/cjs/version.d.cts +1 -1
- package/dist/sunspec-devices.d.ts +1 -0
- package/dist/sunspec-devices.js +18 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -377,9 +377,18 @@ class SunspecInverter extends BaseSunspecDevice {
|
|
|
377
377
|
}
|
|
378
378
|
await this.loadErrorState();
|
|
379
379
|
this.startDataBusListening();
|
|
380
|
+
// Cold-start recovery: if the persisted state says we were stuck in
|
|
381
|
+
// connection_lost but connect() just succeeded (we read commonBlock,
|
|
382
|
+
// settings, controls and MPPT above), the Modbus path is provably
|
|
383
|
+
// healthy. Clear the stale fault and emit Healthy via the same hook
|
|
384
|
+
// the in-process reconnect path uses.
|
|
385
|
+
if (this.errorState.lastStatus === 'connection_lost') {
|
|
386
|
+
await this.onConnectionRestored();
|
|
387
|
+
}
|
|
380
388
|
}
|
|
381
389
|
async disconnect() {
|
|
382
390
|
this.stopDataBusListening();
|
|
391
|
+
await this.removePersistedErrorState();
|
|
383
392
|
if (this.applianceId) {
|
|
384
393
|
try {
|
|
385
394
|
await this.applianceManager.updateApplianceState(this.applianceId, enyo_appliance_js_1.EnyoApplianceConnectionType.Connector, enyo_appliance_js_1.EnyoApplianceStateEnum.Offline);
|
|
@@ -571,6 +580,15 @@ class SunspecInverter extends BaseSunspecDevice {
|
|
|
571
580
|
console.error(`Inverter ${this.applianceId}: failed to persist error state: ${error}`);
|
|
572
581
|
}
|
|
573
582
|
}
|
|
583
|
+
async removePersistedErrorState() {
|
|
584
|
+
const storage = this.storage ?? this.energyApp.useStorage();
|
|
585
|
+
try {
|
|
586
|
+
await storage.remove(this.storageKey());
|
|
587
|
+
}
|
|
588
|
+
catch (error) {
|
|
589
|
+
console.error(`Inverter ${this.applianceId}: failed to remove persisted error state: ${error}`);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
574
592
|
async detectAndEmitStatusTransition(data, timestamp) {
|
|
575
593
|
if (!this.applianceId)
|
|
576
594
|
return undefined;
|
|
@@ -148,6 +148,7 @@ export declare class SunspecInverter extends BaseSunspecDevice {
|
|
|
148
148
|
private storageKey;
|
|
149
149
|
private loadErrorState;
|
|
150
150
|
private persistErrorState;
|
|
151
|
+
private removePersistedErrorState;
|
|
151
152
|
private detectAndEmitStatusTransition;
|
|
152
153
|
protected onConnectionFailure(consecutiveFailures: number): Promise<void>;
|
|
153
154
|
protected onConnectionRestored(): Promise<void>;
|
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 = '0.0.
|
|
12
|
+
exports.SDK_VERSION = '0.0.79';
|
|
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
|
@@ -148,6 +148,7 @@ export declare class SunspecInverter extends BaseSunspecDevice {
|
|
|
148
148
|
private storageKey;
|
|
149
149
|
private loadErrorState;
|
|
150
150
|
private persistErrorState;
|
|
151
|
+
private removePersistedErrorState;
|
|
151
152
|
private detectAndEmitStatusTransition;
|
|
152
153
|
protected onConnectionFailure(consecutiveFailures: number): Promise<void>;
|
|
153
154
|
protected onConnectionRestored(): Promise<void>;
|
package/dist/sunspec-devices.js
CHANGED
|
@@ -370,9 +370,18 @@ export class SunspecInverter extends BaseSunspecDevice {
|
|
|
370
370
|
}
|
|
371
371
|
await this.loadErrorState();
|
|
372
372
|
this.startDataBusListening();
|
|
373
|
+
// Cold-start recovery: if the persisted state says we were stuck in
|
|
374
|
+
// connection_lost but connect() just succeeded (we read commonBlock,
|
|
375
|
+
// settings, controls and MPPT above), the Modbus path is provably
|
|
376
|
+
// healthy. Clear the stale fault and emit Healthy via the same hook
|
|
377
|
+
// the in-process reconnect path uses.
|
|
378
|
+
if (this.errorState.lastStatus === 'connection_lost') {
|
|
379
|
+
await this.onConnectionRestored();
|
|
380
|
+
}
|
|
373
381
|
}
|
|
374
382
|
async disconnect() {
|
|
375
383
|
this.stopDataBusListening();
|
|
384
|
+
await this.removePersistedErrorState();
|
|
376
385
|
if (this.applianceId) {
|
|
377
386
|
try {
|
|
378
387
|
await this.applianceManager.updateApplianceState(this.applianceId, EnyoApplianceConnectionType.Connector, EnyoApplianceStateEnum.Offline);
|
|
@@ -564,6 +573,15 @@ export class SunspecInverter extends BaseSunspecDevice {
|
|
|
564
573
|
console.error(`Inverter ${this.applianceId}: failed to persist error state: ${error}`);
|
|
565
574
|
}
|
|
566
575
|
}
|
|
576
|
+
async removePersistedErrorState() {
|
|
577
|
+
const storage = this.storage ?? this.energyApp.useStorage();
|
|
578
|
+
try {
|
|
579
|
+
await storage.remove(this.storageKey());
|
|
580
|
+
}
|
|
581
|
+
catch (error) {
|
|
582
|
+
console.error(`Inverter ${this.applianceId}: failed to remove persisted error state: ${error}`);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
567
585
|
async detectAndEmitStatusTransition(data, timestamp) {
|
|
568
586
|
if (!this.applianceId)
|
|
569
587
|
return undefined;
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED