@enyo-energy/sunspec-sdk 0.0.79 → 0.0.81

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.
@@ -444,10 +444,7 @@ class SunspecInverter extends BaseSunspecDevice {
444
444
  }
445
445
  };
446
446
  messages.push(inverterMessage);
447
- const statusMessage = await this.detectAndEmitStatusTransition(inverterData, timestamp);
448
- if (statusMessage) {
449
- messages.push(statusMessage);
450
- }
447
+ await this.detectAndEmitStatusTransition(inverterData, timestamp);
451
448
  }
452
449
  this.consecutiveReconnectFailures = 0;
453
450
  if (this.applianceId) {
@@ -590,16 +587,19 @@ class SunspecInverter extends BaseSunspecDevice {
590
587
  }
591
588
  }
592
589
  async detectAndEmitStatusTransition(data, timestamp) {
593
- if (!this.applianceId)
594
- return undefined;
590
+ if (!this.applianceId || !this.dataBus)
591
+ return;
595
592
  const { codes, codeIds } = this.decodeActiveErrors(data);
596
593
  const recoveringFromConnectionLoss = this.errorState.lastStatus === 'connection_lost';
597
594
  if (!recoveringFromConnectionLoss && !this.hasErrorSetChanged(codeIds)) {
598
- return undefined;
595
+ return;
599
596
  }
600
597
  const newStatus = codeIds.length === 0
601
598
  ? enyo_appliance_js_1.EnyoApplianceStatusEnum.Healthy
602
599
  : enyo_appliance_js_1.EnyoApplianceStatusEnum.Faulted;
600
+ const message = this.buildStatusMessage(newStatus, codes, timestamp);
601
+ console.log(`Inverter ${this.applianceId}: status transition -> ${newStatus} (codes=[${codeIds.join(', ')}])`);
602
+ this.dataBus.sendMessage([message]);
603
603
  this.errorState = {
604
604
  evt1: data.events,
605
605
  evt2: data.events2,
@@ -611,8 +611,6 @@ class SunspecInverter extends BaseSunspecDevice {
611
611
  lastStatus: newStatus === enyo_appliance_js_1.EnyoApplianceStatusEnum.Healthy ? 'healthy' : 'faulted',
612
612
  };
613
613
  await this.persistErrorState();
614
- console.log(`Inverter ${this.applianceId}: status transition -> ${newStatus} (codes=[${codeIds.join(', ')}])`);
615
- return this.buildStatusMessage(newStatus, codes, timestamp);
616
614
  }
617
615
  async onConnectionFailure(consecutiveFailures) {
618
616
  if (!this.applianceId || !this.dataBus)
@@ -629,13 +627,13 @@ class SunspecInverter extends BaseSunspecDevice {
629
627
  ]
630
628
  }];
631
629
  const message = this.buildStatusMessage(enyo_appliance_js_1.EnyoApplianceStatusEnum.Faulted, errorCodes, new Date());
630
+ console.log(`Inverter ${this.applianceId}: emitting faulted (${sunspec_interfaces_js_1.SUNSPEC_CONNECTION_LOST_CODE}) after ${consecutiveFailures} consecutive reconnect failures`);
631
+ this.dataBus.sendMessage([message]);
632
632
  this.errorState = {
633
633
  activeCodes: [sunspec_interfaces_js_1.SUNSPEC_CONNECTION_LOST_CODE],
634
634
  lastStatus: 'connection_lost',
635
635
  };
636
636
  await this.persistErrorState();
637
- console.log(`Inverter ${this.applianceId}: emitting faulted (${sunspec_interfaces_js_1.SUNSPEC_CONNECTION_LOST_CODE}) after ${consecutiveFailures} consecutive reconnect failures`);
638
- this.dataBus.sendMessage([message]);
639
637
  }
640
638
  async onConnectionRestored() {
641
639
  if (!this.applianceId || !this.dataBus)
@@ -643,13 +641,13 @@ class SunspecInverter extends BaseSunspecDevice {
643
641
  if (this.errorState.lastStatus !== 'connection_lost')
644
642
  return;
645
643
  const message = this.buildStatusMessage(enyo_appliance_js_1.EnyoApplianceStatusEnum.Healthy, [], new Date());
644
+ console.log(`Inverter ${this.applianceId}: emitting healthy after reconnect`);
645
+ this.dataBus.sendMessage([message]);
646
646
  this.errorState = {
647
647
  activeCodes: [],
648
648
  lastStatus: 'healthy',
649
649
  };
650
650
  await this.persistErrorState();
651
- console.log(`Inverter ${this.applianceId}: emitting healthy after reconnect`);
652
- this.dataBus.sendMessage([message]);
653
651
  }
654
652
  /**
655
653
  * Compute the currently active feed-in / production limit in Watts from the
@@ -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.79';
12
+ exports.SDK_VERSION = '0.0.81';
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.79";
8
+ export declare const SDK_VERSION = "0.0.81";
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
@@ -437,10 +437,7 @@ export class SunspecInverter extends BaseSunspecDevice {
437
437
  }
438
438
  };
439
439
  messages.push(inverterMessage);
440
- const statusMessage = await this.detectAndEmitStatusTransition(inverterData, timestamp);
441
- if (statusMessage) {
442
- messages.push(statusMessage);
443
- }
440
+ await this.detectAndEmitStatusTransition(inverterData, timestamp);
444
441
  }
445
442
  this.consecutiveReconnectFailures = 0;
446
443
  if (this.applianceId) {
@@ -583,16 +580,19 @@ export class SunspecInverter extends BaseSunspecDevice {
583
580
  }
584
581
  }
585
582
  async detectAndEmitStatusTransition(data, timestamp) {
586
- if (!this.applianceId)
587
- return undefined;
583
+ if (!this.applianceId || !this.dataBus)
584
+ return;
588
585
  const { codes, codeIds } = this.decodeActiveErrors(data);
589
586
  const recoveringFromConnectionLoss = this.errorState.lastStatus === 'connection_lost';
590
587
  if (!recoveringFromConnectionLoss && !this.hasErrorSetChanged(codeIds)) {
591
- return undefined;
588
+ return;
592
589
  }
593
590
  const newStatus = codeIds.length === 0
594
591
  ? EnyoApplianceStatusEnum.Healthy
595
592
  : EnyoApplianceStatusEnum.Faulted;
593
+ const message = this.buildStatusMessage(newStatus, codes, timestamp);
594
+ console.log(`Inverter ${this.applianceId}: status transition -> ${newStatus} (codes=[${codeIds.join(', ')}])`);
595
+ this.dataBus.sendMessage([message]);
596
596
  this.errorState = {
597
597
  evt1: data.events,
598
598
  evt2: data.events2,
@@ -604,8 +604,6 @@ export class SunspecInverter extends BaseSunspecDevice {
604
604
  lastStatus: newStatus === EnyoApplianceStatusEnum.Healthy ? 'healthy' : 'faulted',
605
605
  };
606
606
  await this.persistErrorState();
607
- console.log(`Inverter ${this.applianceId}: status transition -> ${newStatus} (codes=[${codeIds.join(', ')}])`);
608
- return this.buildStatusMessage(newStatus, codes, timestamp);
609
607
  }
610
608
  async onConnectionFailure(consecutiveFailures) {
611
609
  if (!this.applianceId || !this.dataBus)
@@ -622,13 +620,13 @@ export class SunspecInverter extends BaseSunspecDevice {
622
620
  ]
623
621
  }];
624
622
  const message = this.buildStatusMessage(EnyoApplianceStatusEnum.Faulted, errorCodes, new Date());
623
+ console.log(`Inverter ${this.applianceId}: emitting faulted (${SUNSPEC_CONNECTION_LOST_CODE}) after ${consecutiveFailures} consecutive reconnect failures`);
624
+ this.dataBus.sendMessage([message]);
625
625
  this.errorState = {
626
626
  activeCodes: [SUNSPEC_CONNECTION_LOST_CODE],
627
627
  lastStatus: 'connection_lost',
628
628
  };
629
629
  await this.persistErrorState();
630
- console.log(`Inverter ${this.applianceId}: emitting faulted (${SUNSPEC_CONNECTION_LOST_CODE}) after ${consecutiveFailures} consecutive reconnect failures`);
631
- this.dataBus.sendMessage([message]);
632
630
  }
633
631
  async onConnectionRestored() {
634
632
  if (!this.applianceId || !this.dataBus)
@@ -636,13 +634,13 @@ export class SunspecInverter extends BaseSunspecDevice {
636
634
  if (this.errorState.lastStatus !== 'connection_lost')
637
635
  return;
638
636
  const message = this.buildStatusMessage(EnyoApplianceStatusEnum.Healthy, [], new Date());
637
+ console.log(`Inverter ${this.applianceId}: emitting healthy after reconnect`);
638
+ this.dataBus.sendMessage([message]);
639
639
  this.errorState = {
640
640
  activeCodes: [],
641
641
  lastStatus: 'healthy',
642
642
  };
643
643
  await this.persistErrorState();
644
- console.log(`Inverter ${this.applianceId}: emitting healthy after reconnect`);
645
- this.dataBus.sendMessage([message]);
646
644
  }
647
645
  /**
648
646
  * Compute the currently active feed-in / production limit in Watts from the
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.79";
8
+ export declare const SDK_VERSION = "0.0.81";
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.79';
8
+ export const SDK_VERSION = '0.0.81';
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.79",
3
+ "version": "0.0.81",
4
4
  "description": "enyo Energy Sunspec SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@enyo-energy/appliance-calibration": "0.0.2",
44
- "@enyo-energy/energy-app-sdk": "^0.0.149"
44
+ "@enyo-energy/energy-app-sdk": "^0.0.159"
45
45
  },
46
46
  "volta": {
47
47
  "node": "22.17.0"