@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.
@@ -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>;
@@ -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.78';
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
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Current version of the enyo Energy App SDK.
7
7
  */
8
- export declare const SDK_VERSION = "0.0.78";
8
+ export declare const SDK_VERSION = "0.0.79";
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
@@ -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>;
@@ -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
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Current version of the enyo Energy App SDK.
7
7
  */
8
- export declare const SDK_VERSION = "0.0.78";
8
+ export declare const SDK_VERSION = "0.0.79";
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
package/dist/version.js CHANGED
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Current version of the enyo Energy App SDK.
7
7
  */
8
- export const SDK_VERSION = '0.0.78';
8
+ export const SDK_VERSION = '0.0.79';
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enyo-energy/sunspec-sdk",
3
- "version": "0.0.78",
3
+ "version": "0.0.79",
4
4
  "description": "enyo Energy Sunspec SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",