@enyo-energy/sunspec-sdk 0.0.68 → 0.0.69

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/README.md CHANGED
@@ -4,6 +4,7 @@ SunSpec Modbus client for reading data from solar inverters, batteries, meters,
4
4
 
5
5
  ## Table of Contents
6
6
 
7
+ - [Appliance Manager Integration](#appliance-manager-integration)
7
8
  - [How Addressing Works](#how-addressing-works)
8
9
  - [Bulk Register Reading](#bulk-register-reading)
9
10
  - [Data Types](#data-types)
@@ -22,6 +23,29 @@ SunSpec Modbus client for reading data from solar inverters, batteries, meters,
22
23
 
23
24
  ---
24
25
 
26
+ ## Appliance Manager Integration
27
+
28
+ `SunspecInverter`, `SunspecBattery`, and `SunspecMeter` take an `ApplianceManager` from `@enyo-energy/energy-app-sdk` and call `createOrUpdateAppliance` with the device's `networkDevice` plus the common block's `serialNumber` (which may be empty for some firmware revisions).
29
+
30
+ Since `@enyo-energy/energy-app-sdk` 0.0.135 the default identifier strategy is `SerialNumberStrategy`. If a device's common block has no serial number, `createOrUpdateAppliance` throws `MissingIdentifierError` and the SDK logs the error and skips appliance creation.
31
+
32
+ Consumers whose devices may not expose a serial number should configure a fallback when initializing the `ApplianceManager`, e.g.:
33
+
34
+ ```ts
35
+ import { ApplianceManager, FallbackIdentifierStrategy, SerialNumberStrategy, HostnameStrategy } from '@enyo-energy/energy-app-sdk';
36
+
37
+ const applianceManager = await ApplianceManager.initialize(energyApp, {
38
+ identifierStrategy: new FallbackIdentifierStrategy([
39
+ new SerialNumberStrategy(),
40
+ new HostnameStrategy(),
41
+ ]),
42
+ });
43
+ ```
44
+
45
+ This SDK does not configure the strategy itself — it is the consumer app's responsibility.
46
+
47
+ ---
48
+
25
49
  ## How Addressing Works
26
50
 
27
51
  ### Base Address Detection
@@ -342,7 +342,12 @@ class SunspecInverter extends BaseSunspecDevice {
342
342
  async disconnect() {
343
343
  this.stopDataBusListening();
344
344
  if (this.applianceId) {
345
- await this.applianceManager.updateApplianceState(this.applianceId, enyo_appliance_js_1.EnyoApplianceConnectionType.Connector, enyo_appliance_js_1.EnyoApplianceStateEnum.Offline);
345
+ try {
346
+ await this.applianceManager.updateApplianceState(this.applianceId, enyo_appliance_js_1.EnyoApplianceConnectionType.Connector, enyo_appliance_js_1.EnyoApplianceStateEnum.Offline);
347
+ }
348
+ catch (error) {
349
+ console.error(`Failed to mark inverter offline on disconnect: ${error}`);
350
+ }
346
351
  }
347
352
  // Note: We don't disconnect the sunspecClient as it may be shared
348
353
  }
@@ -819,7 +824,12 @@ class SunspecBattery extends BaseSunspecDevice {
819
824
  async disconnect() {
820
825
  this.stopDataBusListening();
821
826
  if (this.applianceId) {
822
- await this.applianceManager.updateApplianceState(this.applianceId, enyo_appliance_js_1.EnyoApplianceConnectionType.Connector, enyo_appliance_js_1.EnyoApplianceStateEnum.Offline);
827
+ try {
828
+ await this.applianceManager.updateApplianceState(this.applianceId, enyo_appliance_js_1.EnyoApplianceConnectionType.Connector, enyo_appliance_js_1.EnyoApplianceStateEnum.Offline);
829
+ }
830
+ catch (error) {
831
+ console.error(`Failed to mark battery offline on disconnect: ${error}`);
832
+ }
823
833
  }
824
834
  }
825
835
  /**
@@ -1393,7 +1403,12 @@ class SunspecMeter extends BaseSunspecDevice {
1393
1403
  */
1394
1404
  async disconnect() {
1395
1405
  if (this.applianceId) {
1396
- await this.applianceManager.updateApplianceState(this.applianceId, enyo_appliance_js_1.EnyoApplianceConnectionType.Connector, enyo_appliance_js_1.EnyoApplianceStateEnum.Offline);
1406
+ try {
1407
+ await this.applianceManager.updateApplianceState(this.applianceId, enyo_appliance_js_1.EnyoApplianceConnectionType.Connector, enyo_appliance_js_1.EnyoApplianceStateEnum.Offline);
1408
+ }
1409
+ catch (error) {
1410
+ console.error(`Failed to mark meter offline on disconnect: ${error}`);
1411
+ }
1397
1412
  }
1398
1413
  // Close just this meter's unit; other devices on the same network device stay open.
1399
1414
  await this.sunspecClient.disconnectUnit(this.unitId);
@@ -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.68';
12
+ exports.SDK_VERSION = '0.0.69';
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.68";
8
+ export declare const SDK_VERSION = "0.0.69";
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
@@ -338,7 +338,12 @@ export class SunspecInverter extends BaseSunspecDevice {
338
338
  async disconnect() {
339
339
  this.stopDataBusListening();
340
340
  if (this.applianceId) {
341
- await this.applianceManager.updateApplianceState(this.applianceId, EnyoApplianceConnectionType.Connector, EnyoApplianceStateEnum.Offline);
341
+ try {
342
+ await this.applianceManager.updateApplianceState(this.applianceId, EnyoApplianceConnectionType.Connector, EnyoApplianceStateEnum.Offline);
343
+ }
344
+ catch (error) {
345
+ console.error(`Failed to mark inverter offline on disconnect: ${error}`);
346
+ }
342
347
  }
343
348
  // Note: We don't disconnect the sunspecClient as it may be shared
344
349
  }
@@ -814,7 +819,12 @@ export class SunspecBattery extends BaseSunspecDevice {
814
819
  async disconnect() {
815
820
  this.stopDataBusListening();
816
821
  if (this.applianceId) {
817
- await this.applianceManager.updateApplianceState(this.applianceId, EnyoApplianceConnectionType.Connector, EnyoApplianceStateEnum.Offline);
822
+ try {
823
+ await this.applianceManager.updateApplianceState(this.applianceId, EnyoApplianceConnectionType.Connector, EnyoApplianceStateEnum.Offline);
824
+ }
825
+ catch (error) {
826
+ console.error(`Failed to mark battery offline on disconnect: ${error}`);
827
+ }
818
828
  }
819
829
  }
820
830
  /**
@@ -1387,7 +1397,12 @@ export class SunspecMeter extends BaseSunspecDevice {
1387
1397
  */
1388
1398
  async disconnect() {
1389
1399
  if (this.applianceId) {
1390
- await this.applianceManager.updateApplianceState(this.applianceId, EnyoApplianceConnectionType.Connector, EnyoApplianceStateEnum.Offline);
1400
+ try {
1401
+ await this.applianceManager.updateApplianceState(this.applianceId, EnyoApplianceConnectionType.Connector, EnyoApplianceStateEnum.Offline);
1402
+ }
1403
+ catch (error) {
1404
+ console.error(`Failed to mark meter offline on disconnect: ${error}`);
1405
+ }
1391
1406
  }
1392
1407
  // Close just this meter's unit; other devices on the same network device stay open.
1393
1408
  await this.sunspecClient.disconnectUnit(this.unitId);
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.68";
8
+ export declare const SDK_VERSION = "0.0.69";
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.68';
8
+ export const SDK_VERSION = '0.0.69';
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.68",
3
+ "version": "0.0.69",
4
4
  "description": "enyo Energy Sunspec SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "typescript": "^5.8.3"
38
38
  },
39
39
  "dependencies": {
40
- "@enyo-energy/energy-app-sdk": "^0.0.132"
40
+ "@enyo-energy/energy-app-sdk": "^0.0.135"
41
41
  },
42
42
  "volta": {
43
43
  "node": "22.17.0"