iobroker.sun2000 2.4.0 → 2.4.3
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 +15 -262
- package/admin/i18n/de/translations.json +27 -27
- package/admin/i18n/es/translations.json +27 -27
- package/admin/i18n/fr/translations.json +27 -27
- package/admin/i18n/it/translations.json +27 -27
- package/admin/i18n/nl/translations.json +27 -27
- package/admin/i18n/pl/translations.json +27 -27
- package/admin/i18n/pt/translations.json +27 -27
- package/admin/i18n/ru/translations.json +27 -27
- package/admin/i18n/uk/translations.json +27 -27
- package/admin/i18n/zh-cn/translations.json +27 -27
- package/io-package.json +41 -40
- package/lib/modbus/modbus_server.js +27 -4
- package/lib/register.js +4 -1
- package/lib/statistics.js +1027 -286
- package/lib/types.js +1 -0
- package/main.js +88 -0
- package/package.json +5 -4
package/lib/types.js
CHANGED
package/main.js
CHANGED
|
@@ -280,6 +280,86 @@ class Sun2000 extends utils.Adapter {
|
|
|
280
280
|
}
|
|
281
281
|
*/
|
|
282
282
|
|
|
283
|
+
/**
|
|
284
|
+
* Sends anonymous usage statistics via the Sentry plugin.
|
|
285
|
+
* Only fires if the Sentry plugin is available and the user has
|
|
286
|
+
* opted in via adapter config (sendStatistics: true).
|
|
287
|
+
*
|
|
288
|
+
* No personal data, no IPs, no identifiers — only aggregated
|
|
289
|
+
* feature flags and hardware counts.
|
|
290
|
+
*/
|
|
291
|
+
sendAnonymousStatistics() {
|
|
292
|
+
try {
|
|
293
|
+
if (!this.config.sendStatistics) return;
|
|
294
|
+
|
|
295
|
+
if (!this.supportsFeature?.('PLUGINS')) return;
|
|
296
|
+
|
|
297
|
+
const sentryInstance = this.getPluginInstance('sentry');
|
|
298
|
+
if (!sentryInstance) return;
|
|
299
|
+
|
|
300
|
+
const Sentry = sentryInstance.getSentryObject();
|
|
301
|
+
if (!Sentry) return;
|
|
302
|
+
|
|
303
|
+
// --- Device counts from this.devices ---
|
|
304
|
+
const inverterCount = this.devices.filter(d => d.driverClass === driverClasses.inverter).length;
|
|
305
|
+
const emmaCharger = this.devices.filter(d => d.driverClass === driverClasses.emmacharger).length;
|
|
306
|
+
|
|
307
|
+
// --- Integration type as readable string ---
|
|
308
|
+
const integrationMap = { 0: 'sDongle', 1: 'smartLogger', 2: 'emma' };
|
|
309
|
+
const integration = integrationMap[this.settings.integration] ?? 'unknown';
|
|
310
|
+
|
|
311
|
+
const payload = {
|
|
312
|
+
// Adapter
|
|
313
|
+
adapterVersion: this.version,
|
|
314
|
+
|
|
315
|
+
// Platform / environment
|
|
316
|
+
platform: process.platform, // 'linux', 'win32', 'darwin'
|
|
317
|
+
nodeVersion: process.version, // 'v20.x.x'
|
|
318
|
+
arch: process.arch, // 'arm', 'x64'
|
|
319
|
+
|
|
320
|
+
// Integration type
|
|
321
|
+
integration, // 'sDongle' | 'smartLogger' | 'emma'
|
|
322
|
+
|
|
323
|
+
emmaCharger,
|
|
324
|
+
|
|
325
|
+
// Device counts and types
|
|
326
|
+
inverterCount,
|
|
327
|
+
|
|
328
|
+
// Features
|
|
329
|
+
modbusProxy: this.settings.ms?.active ?? false,
|
|
330
|
+
batteryTOU: this.settings.cb?.tou ?? false,
|
|
331
|
+
|
|
332
|
+
// Timing (gives insight into installation size / load)
|
|
333
|
+
highInterval: Math.round(this.settings.highInterval / 1000), // seconds
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
Sentry.withScope(scope => {
|
|
337
|
+
scope.setLevel('info');
|
|
338
|
+
|
|
339
|
+
// Each payload field as a separate Sentry extra — visible in Sentry dashboard
|
|
340
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
341
|
+
scope.setExtra(key, value);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Most important fields as filterable tags
|
|
345
|
+
scope.setTag('adapterVersion', payload.adapterVersion);
|
|
346
|
+
scope.setTag('platform', payload.platform);
|
|
347
|
+
scope.setTag('arch', payload.arch);
|
|
348
|
+
scope.setTag('integration', payload.integration);
|
|
349
|
+
scope.setTag('inverterCount', String(payload.inverterCount));
|
|
350
|
+
scope.setTag('emmaCharger', String(payload.emmaCharger));
|
|
351
|
+
scope.setTag('modbusProxy', String(payload.modbusProxy));
|
|
352
|
+
|
|
353
|
+
Sentry.captureMessage('sun2000.adapterStatistics', 'info');
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
this.logger.debug('sun2000: anonymous statistics sent via Sentry');
|
|
357
|
+
} catch (e) {
|
|
358
|
+
// Never let statistics reporting affect adapter operation
|
|
359
|
+
this.logger.debug(`sun2000: statistics reporting failed silently: ${e.message}`);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
283
363
|
async endOfmodbusAdjust(info) {
|
|
284
364
|
if (!info.modbusAdjust) {
|
|
285
365
|
this.settings.modbusAdjust = info.modbusAdjust;
|
|
@@ -659,6 +739,14 @@ class Sun2000 extends utils.Adapter {
|
|
|
659
739
|
emma.instance.control.set(serviceId, state);
|
|
660
740
|
}
|
|
661
741
|
}
|
|
742
|
+
|
|
743
|
+
//sun2000.0.statistics.flexCharts.template
|
|
744
|
+
if (idArray[2] == 'statistics' && idArray[3] == 'flexCharts' && idArray[4] == 'template') {
|
|
745
|
+
const chartType = idArray[5];
|
|
746
|
+
if (this.state.statistics && typeof this.state.statistics.handleTemplateChange === 'function') {
|
|
747
|
+
this.state.statistics.handleTemplateChange(chartType, state);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
662
750
|
} else {
|
|
663
751
|
// The state was deleted
|
|
664
752
|
this.logger.info(`state ${id} deleted`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.sun2000",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
4
4
|
"description": "sun2000",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "bolliy",
|
|
@@ -28,9 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@iobroker/adapter-core": "^3.3.2",
|
|
31
|
-
"modbus-serial": "^8.0.
|
|
31
|
+
"modbus-serial": "^8.0.25",
|
|
32
32
|
"suncalc2": "^1.8.1",
|
|
33
|
-
"tcp-port-used": "^1.0.2"
|
|
33
|
+
"tcp-port-used": "^1.0.2",
|
|
34
|
+
"javascript-stringify": "^2.1.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@alcalzone/release-script": "^5.1.1",
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"@iobroker/adapter-dev": "^1.5.0",
|
|
41
42
|
"@iobroker/eslint-config": "^2.2.0",
|
|
42
43
|
"@iobroker/testing": "^5.2.2",
|
|
43
|
-
"@tsconfig/
|
|
44
|
+
"@tsconfig/node22": "^22.0.5",
|
|
44
45
|
"@types/node": "^25.5.0",
|
|
45
46
|
"globals": "^16.5.0",
|
|
46
47
|
"typescript": "~5.9.3"
|