@enyo-energy/sunspec-sdk 0.0.30 → 0.0.31

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.
@@ -230,6 +230,22 @@ class SunspecModbusClient {
230
230
  }
231
231
  // If custom base address provided, try it first (1-based, then 0-based variant)
232
232
  if (customBaseAddress !== undefined) {
233
+ console.log(`Detect models for custom base address '${customBaseAddress}' ...`);
234
+ // Try 0-based at custom address
235
+ try {
236
+ const sunspecId = await this.modbusClient.readRegisterStringValue(customBaseAddress, 2);
237
+ if (sunspecId.includes('SunS')) {
238
+ console.log(`Detected 0-based addressing mode (base address: ${customBaseAddress})`);
239
+ return {
240
+ baseAddress: customBaseAddress,
241
+ isZeroBased: true,
242
+ nextAddress: customBaseAddress + 2
243
+ };
244
+ }
245
+ }
246
+ catch (error) {
247
+ console.debug(`Could not read SunS at ${customBaseAddress}:`, error);
248
+ }
233
249
  // Try 1-based at custom address (customBaseAddress + 1)
234
250
  try {
235
251
  const sunspecId = await this.modbusClient.readRegisterStringValue(customBaseAddress + 1, 2);
@@ -245,52 +261,39 @@ class SunspecModbusClient {
245
261
  catch (error) {
246
262
  console.debug(`Could not read SunS at ${customBaseAddress + 1}:`, error);
247
263
  }
248
- // Try 0-based at custom address
264
+ }
265
+ else {
266
+ // Try 1-based addressing first (most common)
249
267
  try {
250
- const sunspecId = await this.modbusClient.readRegisterStringValue(customBaseAddress, 2);
268
+ const sunspecId = await this.modbusClient.readRegisterStringValue(40001, 2);
251
269
  if (sunspecId.includes('SunS')) {
252
- console.log(`Detected 0-based addressing mode (base address: ${customBaseAddress})`);
270
+ console.log('Detected 1-based addressing mode (base address: 40001)');
253
271
  return {
254
- baseAddress: customBaseAddress,
255
- isZeroBased: true,
256
- nextAddress: customBaseAddress + 2
272
+ baseAddress: 40001,
273
+ isZeroBased: false,
274
+ nextAddress: 40003
257
275
  };
258
276
  }
259
277
  }
260
278
  catch (error) {
261
- console.debug(`Could not read SunS at ${customBaseAddress}:`, error);
279
+ console.debug('Could not read SunS at 40001:', error);
262
280
  }
263
- }
264
- // Try 1-based addressing first (most common)
265
- try {
266
- const sunspecId = await this.modbusClient.readRegisterStringValue(40001, 2);
267
- if (sunspecId.includes('SunS')) {
268
- console.log('Detected 1-based addressing mode (base address: 40001)');
269
- return {
270
- baseAddress: 40001,
271
- isZeroBased: false,
272
- nextAddress: 40003
273
- };
281
+ // Try 0-based addressing
282
+ try {
283
+ const sunspecId = await this.modbusClient.readRegisterStringValue(40000, 2);
284
+ if (sunspecId.includes('SunS')) {
285
+ console.log('Detected 0-based addressing mode (base address: 40000)');
286
+ return {
287
+ baseAddress: 40000,
288
+ isZeroBased: true,
289
+ nextAddress: 40002
290
+ };
291
+ }
274
292
  }
275
- }
276
- catch (error) {
277
- console.debug('Could not read SunS at 40001:', error);
278
- }
279
- // Try 0-based addressing
280
- try {
281
- const sunspecId = await this.modbusClient.readRegisterStringValue(40000, 2);
282
- if (sunspecId.includes('SunS')) {
283
- console.log('Detected 0-based addressing mode (base address: 40000)');
284
- return {
285
- baseAddress: 40000,
286
- isZeroBased: true,
287
- nextAddress: 40002
288
- };
293
+ catch (error) {
294
+ console.debug('Could not read SunS at 40000:', error);
289
295
  }
290
296
  }
291
- catch (error) {
292
- console.debug('Could not read SunS at 40000:', error);
293
- }
294
297
  const addressesChecked = customBaseAddress !== undefined
295
298
  ? `${customBaseAddress}, ${customBaseAddress + 1}, 40000, or 40001`
296
299
  : '40000 or 40001';
@@ -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.30';
12
+ exports.SDK_VERSION = '0.0.31';
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.30";
8
+ export declare const SDK_VERSION = "0.0.31";
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
@@ -227,6 +227,22 @@ export class SunspecModbusClient {
227
227
  }
228
228
  // If custom base address provided, try it first (1-based, then 0-based variant)
229
229
  if (customBaseAddress !== undefined) {
230
+ console.log(`Detect models for custom base address '${customBaseAddress}' ...`);
231
+ // Try 0-based at custom address
232
+ try {
233
+ const sunspecId = await this.modbusClient.readRegisterStringValue(customBaseAddress, 2);
234
+ if (sunspecId.includes('SunS')) {
235
+ console.log(`Detected 0-based addressing mode (base address: ${customBaseAddress})`);
236
+ return {
237
+ baseAddress: customBaseAddress,
238
+ isZeroBased: true,
239
+ nextAddress: customBaseAddress + 2
240
+ };
241
+ }
242
+ }
243
+ catch (error) {
244
+ console.debug(`Could not read SunS at ${customBaseAddress}:`, error);
245
+ }
230
246
  // Try 1-based at custom address (customBaseAddress + 1)
231
247
  try {
232
248
  const sunspecId = await this.modbusClient.readRegisterStringValue(customBaseAddress + 1, 2);
@@ -242,52 +258,39 @@ export class SunspecModbusClient {
242
258
  catch (error) {
243
259
  console.debug(`Could not read SunS at ${customBaseAddress + 1}:`, error);
244
260
  }
245
- // Try 0-based at custom address
261
+ }
262
+ else {
263
+ // Try 1-based addressing first (most common)
246
264
  try {
247
- const sunspecId = await this.modbusClient.readRegisterStringValue(customBaseAddress, 2);
265
+ const sunspecId = await this.modbusClient.readRegisterStringValue(40001, 2);
248
266
  if (sunspecId.includes('SunS')) {
249
- console.log(`Detected 0-based addressing mode (base address: ${customBaseAddress})`);
267
+ console.log('Detected 1-based addressing mode (base address: 40001)');
250
268
  return {
251
- baseAddress: customBaseAddress,
252
- isZeroBased: true,
253
- nextAddress: customBaseAddress + 2
269
+ baseAddress: 40001,
270
+ isZeroBased: false,
271
+ nextAddress: 40003
254
272
  };
255
273
  }
256
274
  }
257
275
  catch (error) {
258
- console.debug(`Could not read SunS at ${customBaseAddress}:`, error);
276
+ console.debug('Could not read SunS at 40001:', error);
259
277
  }
260
- }
261
- // Try 1-based addressing first (most common)
262
- try {
263
- const sunspecId = await this.modbusClient.readRegisterStringValue(40001, 2);
264
- if (sunspecId.includes('SunS')) {
265
- console.log('Detected 1-based addressing mode (base address: 40001)');
266
- return {
267
- baseAddress: 40001,
268
- isZeroBased: false,
269
- nextAddress: 40003
270
- };
278
+ // Try 0-based addressing
279
+ try {
280
+ const sunspecId = await this.modbusClient.readRegisterStringValue(40000, 2);
281
+ if (sunspecId.includes('SunS')) {
282
+ console.log('Detected 0-based addressing mode (base address: 40000)');
283
+ return {
284
+ baseAddress: 40000,
285
+ isZeroBased: true,
286
+ nextAddress: 40002
287
+ };
288
+ }
271
289
  }
272
- }
273
- catch (error) {
274
- console.debug('Could not read SunS at 40001:', error);
275
- }
276
- // Try 0-based addressing
277
- try {
278
- const sunspecId = await this.modbusClient.readRegisterStringValue(40000, 2);
279
- if (sunspecId.includes('SunS')) {
280
- console.log('Detected 0-based addressing mode (base address: 40000)');
281
- return {
282
- baseAddress: 40000,
283
- isZeroBased: true,
284
- nextAddress: 40002
285
- };
290
+ catch (error) {
291
+ console.debug('Could not read SunS at 40000:', error);
286
292
  }
287
293
  }
288
- catch (error) {
289
- console.debug('Could not read SunS at 40000:', error);
290
- }
291
294
  const addressesChecked = customBaseAddress !== undefined
292
295
  ? `${customBaseAddress}, ${customBaseAddress + 1}, 40000, or 40001`
293
296
  : '40000 or 40001';
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.30";
8
+ export declare const SDK_VERSION = "0.0.31";
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.30';
8
+ export const SDK_VERSION = '0.0.31';
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.30",
3
+ "version": "0.0.31",
4
4
  "description": "enyo Energy Sunspec SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",