iobroker.sbfspot 5.0.0 → 5.0.1

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
@@ -65,6 +65,9 @@ sometimes npm intall must be called more then one time to successfully install a
65
65
  Placeholder for the next version (at the beginning of the line):
66
66
  ### **WORK IN PROGRESS**
67
67
  -->
68
+ ### 5.0.1 (2025-06-29)
69
+ * (René) new testing
70
+
68
71
  ### 5.0.0 (2025-06-07)
69
72
  * (René) ATTENTION breaking change: adapter type changed from scheduled to daemon
70
73
  * (René) update hints added to admin
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "sbfspot",
4
- "version": "5.0.0",
4
+ "version": "5.0.1",
5
5
  "news": {
6
+ "5.0.1": {
7
+ "en": "new testing",
8
+ "de": "neue tests",
9
+ "ru": "новые испытания",
10
+ "pt": "novos testes",
11
+ "nl": "nieuwe tests",
12
+ "fr": "nouveaux essais",
13
+ "it": "nuovi test",
14
+ "es": "nuevas pruebas",
15
+ "pl": "nowe badania",
16
+ "uk": "новий тест",
17
+ "zh-cn": "新测试"
18
+ },
6
19
  "5.0.0": {
7
20
  "en": "ATTENTION breaking change: adapter type changed from scheduled to daemon\nupdate hints added to admin\nsuggestions from adapter checker",
8
21
  "de": "ATTENTION Brechwechsel: Adaptertyp geändert von geplant nach Daemon\nupdate-hinweise zu admin hinzugefügt\nvorschläge von adapter checker",
@@ -80,19 +93,6 @@
80
93
  "pl": "aktualizacji zależności\npoprawki błędów oparte na rekomendacji sprawdzania adaptera",
81
94
  "uk": "оновлення залежності\nвиправлення помилок на основі рекомендації адаптера",
82
95
  "zh-cn": "更新依赖关系\n根据适配器检查器建议修正错误"
83
- },
84
- "4.3.3": {
85
- "en": "(René) change of dependencies\n(René) mySql dependency update",
86
- "de": "(René) Veränderung der Abhängigkeiten\n(René) mySql Abhängigkeitsupdate",
87
- "ru": "(René) изменение зависимостей\n(René) обновление зависимости mySql",
88
- "pt": "(René) mudança de dependências\n(René) atualização de dependência mySql",
89
- "nl": "(René) verandering van afhankelijkheden\n(René) mySql afhankelijkheidsupdate",
90
- "fr": "(René) changement de dépendances\n(René) Mise à jour de la dépendance mySql",
91
- "it": "(René) cambiamento delle dipendenze\n(René) aggiornamento di dipendenza mySql",
92
- "es": "(René) cambio de dependencia\n(René) mySql dependency update",
93
- "pl": "(René) zmiana zależności\nAktualizacja zależności mySql",
94
- "uk": "(Рене) зміна залежностей\n(René) mySql оновлення залежності",
95
- "zh-cn": "(René) 属地变化\n(René) MySql 依赖性更新"
96
96
  }
97
97
  },
98
98
  "titleLang": {
package/lib/tools.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const axios = require('axios').default;
2
2
 
3
+ //Tests whether the given variable is a real object and not an Array
3
4
  /**
4
- * Tests whether the given variable is a real object and not an Array
5
5
  * @param {any} it The variable to test
6
6
  * @returns {it is Record<string, any>}
7
7
  */
@@ -13,18 +13,20 @@ function isObject(it) {
13
13
  return Object.prototype.toString.call(it) === '[object Object]';
14
14
  }
15
15
 
16
+ //Tests whether the given variable is really an Array
16
17
  /**
17
- * Tests whether the given variable is really an Array
18
18
  * @param {any} it The variable to test
19
19
  * @returns {it is any[]}
20
20
  */
21
21
  function isArray(it) {
22
- if (typeof Array.isArray === 'function') return Array.isArray(it);
22
+ if (typeof Array.isArray === 'function') {
23
+ return Array.isArray(it);
24
+ }
23
25
  return Object.prototype.toString.call(it) === '[object Array]';
24
26
  }
25
27
 
28
+ //Translates text to the target language. Automatically chooses the right translation API.
26
29
  /**
27
- * Translates text to the target language. Automatically chooses the right translation API.
28
30
  * @param {string} text The text to translate
29
31
  * @param {string} targetLang The target languate
30
32
  * @param {string} [yandexApiKey] The yandex API key. You can create one for free at https://translate.yandex.com/developers
@@ -43,8 +45,8 @@ async function translateText(text, targetLang, yandexApiKey) {
43
45
  }
44
46
  }
45
47
 
48
+ //Translates text with Yandex API
46
49
  /**
47
- * Translates text with Yandex API
48
50
  * @param {string} text The text to translate
49
51
  * @param {string} targetLang The target languate
50
52
  * @param {string} apiKey The yandex API key. You can create one for free at https://translate.yandex.com/developers
@@ -66,8 +68,8 @@ async function translateYandex(text, targetLang, apiKey) {
66
68
  }
67
69
  }
68
70
 
71
+ //Translates text with Google API
69
72
  /**
70
- * Translates text with Google API
71
73
  * @param {string} text The text to translate
72
74
  * @param {string} targetLang The target languate
73
75
  * @returns {Promise<string>}
package/main.js CHANGED
@@ -1,10 +1,11 @@
1
- /*
1
+ /* eslint-disable prefer-template */
2
+ /*
2
3
  * sbfspot adapter für iobroker
3
4
  *
4
5
  * Created: 15.09.2016 21:31:28
5
6
  * Author: Rene
6
7
 
7
- Copyright(C)[2016-2020][René Glaß]
8
+ Copyright(C)[2016-2025][René Glaß]
8
9
 
9
10
 
10
11
 
@@ -24,7 +25,9 @@ const os = require('os');
24
25
 
25
26
  //const bluetooth_test = require("./lib/SMA_Bluetooth").test;
26
27
 
27
- const supportedVersion="3.9.12"
28
+ const supportedVersion = "3.9.12"
29
+
30
+ let updateTimerID = null;
28
31
 
29
32
  let adapter;
30
33
  function startAdapter(options) {
@@ -55,13 +58,14 @@ function startAdapter(options) {
55
58
  //to do stop intervall
56
59
  callback();
57
60
  } catch (e) {
61
+ adapter.log.error("exception catch after unload [" + e + "]");
58
62
  callback();
59
63
  }
60
64
  },
61
65
 
62
- stateChange: async (id, state) => {
66
+ //stateChange: async (id, state) => {
63
67
  //await HandleStateChange(id, state);
64
- },
68
+ //},
65
69
 
66
70
  //#######################################
67
71
  //
@@ -110,7 +114,7 @@ let sqlite_db;
110
114
  //---------- mySQL
111
115
  let mysql_connection;
112
116
 
113
- let killTimer;
117
+ //let killTimer;
114
118
  let intervalID = null;
115
119
 
116
120
 
@@ -172,8 +176,7 @@ async function Do() {
172
176
  && (now.getHours() < times.sunset.getHours() || (now.getHours() == times.sunset.getHours() && now.getMinutes() < times.sunset.getMinutes()))) {
173
177
  daylight = true;
174
178
  }
175
- }
176
- else {
179
+ } else {
177
180
  //always
178
181
  daylight = true;
179
182
  }
@@ -248,8 +251,7 @@ async function Do() {
248
251
  }
249
252
  }
250
253
  DB_Disconnect();
251
- }
252
- else {
254
+ } else {
253
255
  adapter.log.info("nothing to do, because no daylight ... ");
254
256
 
255
257
  }
@@ -274,14 +276,12 @@ async function GetSystemDateformat() {
274
276
  longitude = ret.common.longitude;
275
277
  latitude = ret.common.latitude;
276
278
  adapter.log.debug("system: longitude " + longitude + " latitude " + latitude);
277
- }
278
- else {
279
+ } else {
279
280
  adapter.log.error("system.config not available. longitude and latitude set to Berlin");
280
281
  longitude = 52.520008;
281
282
  latitude = 13.404954;
282
283
  }
283
- }
284
- catch (e) {
284
+ } catch (e) {
285
285
  adapter.log.error("exception in GetSystemDateformat [" + e + "]");
286
286
  }
287
287
  }
@@ -368,8 +368,7 @@ async function CreateObject(key, obj) {
368
368
  }
369
369
  });
370
370
  }
371
- }
372
- else {
371
+ } else {
373
372
  await adapter.setObjectNotExistsAsync(key, obj);
374
373
  }
375
374
  }
@@ -463,8 +462,7 @@ async function DB_Connect() {
463
462
 
464
463
  }
465
464
 
466
- }
467
- catch (e) {
465
+ } catch (e) {
468
466
  adapter.log.error("exception in DB_Connect [" + e + "]");
469
467
  ret = false;
470
468
  }
@@ -479,7 +477,7 @@ async function DB_Query(query) {
479
477
 
480
478
  if (adapter.config.databasetype == "mySQL" || adapter.config.databasetype == "MariaDB") {
481
479
 
482
- const [rows, fields] = await mysql_connection.execute(query);
480
+ const [rows] = await mysql_connection.execute(query);
483
481
  retRows = rows;
484
482
 
485
483
  } else {
@@ -525,8 +523,7 @@ async function DB_CheckLastUploads(serial) {
525
523
 
526
524
  await adapter.setStateAsync(serial + ".sbfspot.LastUpload", { ack: true, val: lastUpload });
527
525
  }
528
- }
529
- catch (e) {
526
+ } catch (e) {
530
527
  adapter.log.error("exception in DB_CheckLastUploads [" + e + "]");
531
528
  }
532
529
  }
@@ -539,8 +536,7 @@ async function DB_GetInverters() {
539
536
  try {
540
537
  const query = "SELECT * from Inverters";
541
538
  retRows = await DB_Query(query);
542
- }
543
- catch (e) {
539
+ } catch (e) {
544
540
  adapter.log.error("exception in DB_GetInverters [" + e + "]");
545
541
  }
546
542
 
@@ -609,8 +605,7 @@ async function DB_GetInvertersData(serial) {
609
605
  //SELECT * from SpotData where Serial ='2000562095' ORDER BY TimeStamp DESC LIMIT 1
610
606
  const query = "SELECT * from SpotData where Serial =" + serial + " ORDER BY TimeStamp DESC LIMIT 1";
611
607
  retRows = await DB_Query(query);
612
- }
613
- catch (e) {
608
+ } catch (e) {
614
609
  adapter.log.error("exception in DB_GetInvertersData [" + e + "]");
615
610
  }
616
611
 
@@ -715,8 +710,7 @@ async function DB_CalcHistory_LastMonth(serial) {
715
710
  query = "SELECT strftime('%Y-%m-%d', datetime(TimeStamp, 'unixepoch')) as date, Max(`EToday`) as ertrag FROM `SpotData` WHERE `Serial` = '" + serial + "' AND TimeStamp>= " + datefrom.getTime() / 1000 + " AND TimeStamp<= " + dateto.getTime() / 1000 + " Group By strftime('%Y-%m-%d', datetime(TimeStamp, 'unixepoch'))";
716
711
  }
717
712
  retRows = await DB_Query(query);
718
- }
719
- catch (e) {
713
+ } catch (e) {
720
714
  adapter.log.error("exception in DB_CalcHistory_LastMonth [" + e + "]");
721
715
  }
722
716
 
@@ -765,11 +759,10 @@ async function CalcHistory_LastMonth(err, rows, serial) {
765
759
 
766
760
  */
767
761
 
768
- }
769
- else {
762
+ } else {
770
763
  oLastDays.push({
771
- "date": data["date"],
772
- "value": data["ertrag"]
764
+ date: data["date"],
765
+ value: data["ertrag"]
773
766
  });
774
767
  }
775
768
 
@@ -806,8 +799,7 @@ async function DB_CalcHistory_Prepare(serial) {
806
799
  query = "SELECT strftime('%Y-%m-%d', datetime(TimeStamp, 'unixepoch')) as date, ETotal FROM `SpotData` WHERE `Serial` = '" + serial + "' ORDER by `TimeStamp` ASC LIMIT 1";
807
800
  }
808
801
  retRows = await DB_Query(query);
809
- }
810
- catch (e) {
802
+ } catch (e) {
811
803
  adapter.log.error("exception in DB_CalcHistory_Prepare [" + e + "]");
812
804
  }
813
805
 
@@ -863,8 +855,7 @@ async function DB_CalcHistory_Today(serial) {
863
855
  query = "SELECT strftime('%H:%m', datetime(TimeStamp, 'unixepoch')) as time, Max(`EToday`) as ertrag FROM `SpotData` WHERE `Serial` = '" + serial + "' AND TimeStamp>= " + datefrom.getTime() / 1000 + " AND TimeStamp<= " + dateto.getTime() / 1000 + " Group By strftime('%H-%m', datetime(TimeStamp, 'unixepoch'))";
864
856
  }
865
857
  retRows = await DB_Query(query);
866
- }
867
- catch (e) {
858
+ } catch (e) {
868
859
  adapter.log.error("exception in DB_CalcHistory_Today [" + e + "]");
869
860
  }
870
861
 
@@ -920,11 +911,10 @@ async function CalcHistory_Today(err, rows, serial) {
920
911
 
921
912
  */
922
913
 
923
- }
924
- else {
914
+ } else {
925
915
  oLastDays.push({
926
- "time": data["time"],
927
- "value": data["ertrag"]
916
+ time: data["time"],
917
+ value: data["ertrag"]
928
918
  });
929
919
 
930
920
  }
@@ -957,8 +947,7 @@ async function DB_CalcHistory_Years(serial) {
957
947
  query = "SELECT strftime('%Y', datetime(TimeStamp, 'unixepoch')) as date, Max(`ETotal`) as ertrag, Min(`ETotal`) as startertrag FROM `SpotData` WHERE `Serial` = '" + serial + "' Group By strftime('%Y', datetime(TimeStamp, 'unixepoch'))";
958
948
  }
959
949
  retRows = await DB_Query(query);
960
- }
961
- catch (e) {
950
+ } catch (e) {
962
951
  adapter.log.error("exception in DB_CalcHistory_Years [" + e + "]");
963
952
  }
964
953
 
@@ -1049,11 +1038,10 @@ async function CalcHistory_Years(err, rows, serial) {
1049
1038
 
1050
1039
  */
1051
1040
 
1052
- }
1053
- else {
1041
+ } else {
1054
1042
  oLastYears.push({
1055
- "year": installyear + n,
1056
- "value": parseInt(yearvalue)
1043
+ year: installyear + n,
1044
+ value: parseInt(yearvalue)
1057
1045
  });
1058
1046
  }
1059
1047
  }
@@ -1075,12 +1063,11 @@ async function CalcHistory_Years(err, rows, serial) {
1075
1063
  oDate,
1076
1064
  yearvalue
1077
1065
  ]);
1078
- }
1079
- else {
1066
+ } else {
1080
1067
 
1081
1068
  oLastYears.push({
1082
- "year": data["date"],
1083
- "value": yearvalue
1069
+ year: data["date"],
1070
+ value: yearvalue
1084
1071
  });
1085
1072
  }
1086
1073
 
@@ -1125,8 +1112,7 @@ async function DB_CalcHistory_Months(serial) {
1125
1112
  query = "SELECT strftime('%Y-%m', datetime(TimeStamp, 'unixepoch')) as date, Max(`ETotal`) as ertrag FROM `SpotData` WHERE `Serial` = '" + serial + "' AND TimeStamp>= " + datefrom.getTime() / 1000 + " AND TimeStamp<= " + dateto.getTime() / 1000 + " Group By strftime('%Y-%m', datetime(TimeStamp, 'unixepoch'))";
1126
1113
  }
1127
1114
  retRows = await DB_Query(query);
1128
- }
1129
- catch (e) {
1115
+ } catch (e) {
1130
1116
  adapter.log.error("exception in DB_CalcHistory_Months [" + e + "]");
1131
1117
  }
1132
1118
 
@@ -1167,11 +1153,10 @@ async function CalcHistory_Months(err, rows, serial) {
1167
1153
 
1168
1154
  */
1169
1155
 
1170
- }
1171
- else {
1156
+ } else {
1172
1157
  oLastMonth.push({
1173
- "month": data["date"],
1174
- "value": data["ertrag"]
1158
+ month: data["date"],
1159
+ value: data["ertrag"]
1175
1160
  });
1176
1161
  }
1177
1162
  }
@@ -1217,8 +1202,7 @@ async function DB_AddDummyData() {
1217
1202
 
1218
1203
 
1219
1204
  }
1220
- }
1221
- catch (e) {
1205
+ } catch (e) {
1222
1206
  adapter.log.error("exception in DB_AddDummyData [" + e + "]");
1223
1207
  }
1224
1208
 
@@ -1251,14 +1235,12 @@ async function CheckVersion(version, msg) {
1251
1235
  const version = await GetLatestVersionGithub();
1252
1236
 
1253
1237
  adapter.sendTo(msg.from, msg.command, version, msg.callback);
1254
- }
1255
- else if (version == "current") {
1238
+ } else if (version == "current") {
1256
1239
 
1257
1240
  const version = await GetInstalledVersion();
1258
1241
 
1259
1242
  adapter.sendTo(msg.from, msg.command, version, msg.callback);
1260
- }
1261
- else if (version == "supported") {
1243
+ } else if (version == "supported") {
1262
1244
  adapter.sendTo(msg.from, msg.command, supportedVersion, msg.callback);
1263
1245
  }
1264
1246
 
@@ -1270,7 +1252,7 @@ async function GetLatestVersionGithub() {
1270
1252
  let latestVersion = "unknown";
1271
1253
 
1272
1254
  try {
1273
- const url = " https://api.github.com/repos/SBFspot/SBFspot/releases/latest";
1255
+ const url = "https://api.github.com/repos/SBFspot/SBFspot/releases/latest";
1274
1256
  adapter.log.debug("call " + url);
1275
1257
 
1276
1258
  let result = await axios.get(url, { timeout: 5000 });
@@ -1279,12 +1261,10 @@ async function GetLatestVersionGithub() {
1279
1261
  adapter.log.info("installable version " + JSON.stringify(result.data.name));
1280
1262
 
1281
1263
  latestVersion = result.data.name;
1282
- }
1283
- else {
1264
+ } else {
1284
1265
  latestVersion = "unknown / no result";
1285
1266
  }
1286
- }
1287
- catch (e) {
1267
+ } catch (e) {
1288
1268
  adapter.log.error("exception in GetLatestVersionGithub [" + e + "]");
1289
1269
  latestVersion = "unknown / error";
1290
1270
  }
@@ -1310,13 +1290,11 @@ async function GetInstalledVersion() {
1310
1290
  Version = res.stdout;
1311
1291
 
1312
1292
  adapter.log.info("result " + Version);
1313
- }
1314
- else {
1293
+ } else {
1315
1294
  adapter.log.error("sbfspot version cannot be detected on " + os.type());
1316
1295
  Version = "unknown on " + os.type();
1317
1296
  }
1318
- }
1319
- catch (e) {
1297
+ } catch (e) {
1320
1298
  adapter.log.error("exception in GetInstalledVersion [" + e + "]");
1321
1299
  Version = "unknown / error"
1322
1300
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.sbfspot",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "sbfspot (SMA inverter) Adapter",
5
5
  "author": {
6
6
  "name": "René G.",
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@iobroker/adapter-core": "^3.2.3",
25
- "axios": "^1.9.0",
26
- "better-sqlite3": "^11.10.0",
25
+ "axios": "^1.10.0",
26
+ "better-sqlite3": "^12.2.0",
27
27
  "mysql2": "^3.14.1",
28
28
  "suncalc2": "^1.8.1"
29
29
  },
@@ -33,10 +33,10 @@
33
33
  "@alcalzone/release-script-plugin-license": "^3.7.0",
34
34
  "@alcalzone/release-script-plugin-manual-review": "^3.7.0",
35
35
  "@iobroker/adapter-dev": "^1.4.0",
36
+ "@iobroker/eslint-config": "^2.0.2",
36
37
  "@iobroker/testing": "^5.0.4",
37
38
  "chai": "^5.2.0",
38
- "eslint": "^9.28.0",
39
- "mocha": "^11.5.0"
39
+ "mocha": "^11.7.1"
40
40
  },
41
41
  "main": "main.js",
42
42
  "bugs": {