iobroker.senec 1.6.9 → 1.6.11

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
@@ -298,6 +298,15 @@ This channel contains values polled from SENEC App-API.
298
298
 
299
299
 
300
300
  ## Changelog
301
+
302
+ ### 1.6.11 (NoBl)
303
+ * Moving from Senec App API 3.12.0 to 4.3.3 (thanks to oakdesign@github for providing the new API!)
304
+ * This WILL invalidate all current API datapoints in the Statistik branch. Easiest solution to this: Delete the Statistik branch.
305
+ * Remember to force a rebuild of historic data in adapter settings!
306
+
307
+ ### 1.6.10 (NoBl)
308
+ * Bugfix for AllTimeHistory (should work again)
309
+
301
310
  ### 1.6.9 (NoBl)
302
311
  * Added switch in config to enable active control of appliance (you will need activate this, if you want to control the appliance via the adapter)
303
312
  * Improved handling of forced loading (please report if we need more appliance-states covered by this)
package/io-package.json CHANGED
@@ -1,8 +1,34 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "senec",
4
- "version": "1.6.9",
4
+ "version": "1.6.11",
5
5
  "news": {
6
+ "1.6.11": {
7
+ "en": "Moving from Senec App API 3.12.0 to 4.3.3 (thanks to oakdesign@github for providing the new API!). This WILL invalidate all current API datapoints in the Statistik branch. Easiest solution to this: Delete the Statistik branch. Remember to force a rebuild of historic data in adapter settings!",
8
+ "de": "Update der Senec App API 3.12.0 auf 4.3.3 (Dank an Oakdesign@github für die Analyse der neuen API.)! Dadurch werden leider alle aktuellen API-Datenpunkte im Statistik-Zweig ungültig. Einfachste Lösung hierfür: Den gesamten Statistik-Zweig löschen. Beachten: Die Gesamthistorie muss neu berechnet werden (Parameter in den Adaptereinstellungen)!",
9
+ "ru": "Переезд с Senec App API 3.12.0 до 4.3.3 (спасибо oakdesign@github для предоставления нового API.)! Это недействит все текущие точки API в филиале Statistik. Самое легкое решение для этого: Удалите филиал Statistik. Не забудьте заставить восстановить исторические данные в настройках адаптера!",
10
+ "pt": "Movendo de Senec App API 3.12.0 para 4.3.3 (graças para oakdesign@github para fornecer a nova API.)! Esta WILL invalida todos os datapoints API atuais no ramo Statistik. Solução mais fácil para isso: Excluir o ramo Statistik. Lembre-se de forçar uma reconstrução de dados históricos em configurações de adaptador!",
11
+ "nl": "Verhuizen van Senec App API 3.12.0 tot 4.3.3.3 uur tot Oakdesign @github voor de nieuwe API. Dit zal alle huidige API gegevens in de Statistik Branch invaliden. Verwijder de statistik tak. Vergeet niet een herbouw van historische gegevens te forceren in adapter settings!",
12
+ "fr": "Déplacement de Senec App API 3.12.0 à 4.3.3 (merci à Oakdesign@github pour fournir la nouvelle API.)! Ce WILL invalide tous les points de données API actuels dans la branche Statistik. Solution la plus facile à cela: Supprimer la branche Statistik. N'oubliez pas de forcer une reconstruction des données historiques dans les réglages d'adaptateur!",
13
+ "it": "Passando da Senec App API 3.12.0 a 4.3.3 (grazie a Oakdesign@github per fornire la nuova API.)! Questo WILL invalida tutti i datapoint API attuali nel ramo Statistik. Soluzione più semplice a questo: Elimina il ramo Statistik. Ricordatevi di forzare una ricostruzione dei dati storici nelle impostazioni dell'adattatore!",
14
+ "es": "Moving from Senec App API 3.12.0 to 4.3.3 (gracias a oakdesign@github para proporcionar la nueva API.)! Esto invalidará todos los puntos de datos actuales de la API en la rama Statistik. Solución más fácil: Eliminar la rama Statistik. Recuerde forzar una reconstrucción de datos históricos en la configuración del adaptador!",
15
+ "pl": "Przewidując się z interfejsu Senec App API 3,12.0 to 4.3.3 (dodatki do dębowego @github dla zapewnienia nowego API). WILL uszkodził wszystkie aktualne punkty danych API w oddziale Statistik. Najwięcej rozwiązań do tego: Dete the Statistik branch. Pamiętaj, aby odbudować historyczne dane w ustawieniach adapterów!",
16
+ "uk": "Переміщення від Senec App API 3.12.0 до 4.3.3 (завдяки до дубdesign@github для надання нового API.)! Це недійсне використання всіх поточних точок даних API у відділенні Statistik. Найсвіжіші рішення для цього: Видаліть статутне відділення. Пам'ятайте, що змусити перебудувати історичні дані в налаштуваннях адаптера!",
17
+ "zh-cn": "Moving from Senecapp API3.12.0 to 4.3.3 (as to oakdesign@github for the new API.!) 本协会在斯塔特斯科分处停止了目前所有阿联酋数据点。 最容易解决这一问题:删除斯塔特主义分支。 重新成员在适应环境中重建历史数据!"
18
+ },
19
+ "1.6.10": {
20
+ "en": "Bugfix for AllTimeHistory",
21
+ "de": "Bugfix für AllTimeHistory",
22
+ "ru": "Bugfix для AllTimeИстория",
23
+ "pt": "Bugfix para AllTimeHistory",
24
+ "nl": "Bugfix voor AllTimeHistory",
25
+ "fr": "Bugfix pour AllTimeHistory",
26
+ "it": "Bugfix per AllTimeHistory",
27
+ "es": "Bugfix para AllTimeHistory",
28
+ "pl": "Bugfix for AllTimeHistory (ang.)",
29
+ "uk": "Виправлення помилок для AllTimeHistory",
30
+ "zh-cn": "九. 一切制度"
31
+ },
6
32
  "1.6.9": {
7
33
  "en": "Improved battery forced loading, added switch in config to allow active control of appliance.",
8
34
  "de": "Manuelles Laden verbessert, zusätzlicher Schalter in Config, um aktive Steuerung des Gerätes zu erlauben.",
package/lib/api_trans.js CHANGED
@@ -1,26 +1,26 @@
1
1
  const api_trans = {
2
2
  'THIS_DAY': {
3
- api: 'TAG',
3
+ api: 'DAY',
4
4
  dp: 'Today'
5
5
  },
6
6
  'LAST_DAY': {
7
- api: 'TAG',
7
+ api: 'DAY',
8
8
  dp: 'Yesterday'
9
9
  },
10
10
  'THIS_MONTH': {
11
- api: 'MONAT',
11
+ api: 'MONTH',
12
12
  dp: 'This Month'
13
13
  },
14
14
  'LAST_MONTH': {
15
- api: 'MONAT',
15
+ api: 'MONTH',
16
16
  dp: 'Last Month'
17
17
  },
18
18
  'THIS_YEAR': {
19
- api: 'JAHR',
19
+ api: 'YEAR',
20
20
  dp: 'This Year'
21
21
  },
22
22
  'LAST_YEAR': {
23
- api: 'JAHR',
23
+ api: 'YEAR',
24
24
  dp: 'Last Year'
25
25
  }
26
26
 
package/main.js CHANGED
@@ -17,9 +17,10 @@ const state_trans = require(__dirname + '/lib/state_trans.js');
17
17
  const api_trans = require(__dirname + '/lib/api_trans.js');
18
18
  const kiloList = ["W", "Wh"];
19
19
 
20
- const apiUrl = "https://app-gateway-prod.senecops.com/v1/senec";
20
+ const apiUrl = "https://app-gateway.prod.senec.dev/v1/senec";
21
21
  const apiLoginUrl = apiUrl + "/login";
22
- const apiSystemsUrl = apiUrl + "/anlagen";
22
+ const apiSystemsUrl = apiUrl + "/systems";
23
+ const apiMonitorUrl = apiUrl + "/monitor";
23
24
  const apiKnownSystems = []
24
25
 
25
26
  const batteryOn = '{"ENERGY":{"SAFE_CHARGE_FORCE":"u8_01","SAFE_CHARGE_PROHIBIT":"","SAFE_CHARGE_RUNNING":"","LI_STORAGE_MODE_START":"","LI_STORAGE_MODE_STOP":"","LI_STORAGE_MODE_RUNNING":"","STAT_STATE":""}}';
@@ -473,6 +474,7 @@ class Senec extends utils.Adapter {
473
474
  try {
474
475
  for (let i = 0; i < apiKnownSystems.length; i++) {
475
476
  const baseUrl = apiSystemsUrl + "/" + apiKnownSystems[i];
477
+ const baseUrlMonitor = apiMonitorUrl + "/" + apiKnownSystems[i];
476
478
  var url = "";
477
479
  const tzObj = await this.getStateAsync("_api.Anlagen." + apiKnownSystems[i] + ".zeitzone");
478
480
  const tz = tzObj ? encodeURIComponent(tzObj.val) : encodeURIComponent("Europe/Berlin");
@@ -484,7 +486,8 @@ class Senec extends utils.Adapter {
484
486
 
485
487
  for (let[key, value] of dates.entries()) {
486
488
  // statistik for period
487
- url = baseUrl + "/statistik?periode=" + api_trans[key].api + "&datum=" + value + "&locale=de_DE&timezone=" + tz;
489
+ url = baseUrlMonitor + "/data?period=" + api_trans[key].api + "&date=" + value + "&locale=de_DE&timezone=" + tz;
490
+ this.log.debug("Calling: " + url);
488
491
  body = await this.doGet(url, "", this, this.config.pollingTimeout, false);
489
492
  await this.decodeStatistik(apiKnownSystems[i], JSON.parse(body), api_trans[key].dp);
490
493
  }
@@ -535,20 +538,20 @@ class Senec extends utils.Adapter {
535
538
  const pfx = "_api.Anlagen." + system + ".Statistik." + period + ".";
536
539
  for (const[key, value] of Object.entries(obj.aggregation)) {
537
540
  // only reading 'aggregation' - no interest in fine granular information
538
- if (key == "startzeitpunkt") {
541
+ if (key == "startDate") {
539
542
  await this.doState(pfx + key, value, "", "", false);
540
543
  } else {
541
544
  if (!this.config.api_alltimeRebuild) { // don't update DPs if we are AllTime-Rebuild-Process
542
- await this.doState(pfx + key, Number((value.wert).toFixed(2)), "", value.einheit, false);
543
- if (kiloList.includes(value.einheit)) {
544
- await this.doState(pfx + key + " (k"+ value.einheit + ")", Number((value.wert / 1000).toFixed(2)), "", "k" + value.einheit, false);
545
+ await this.doState(pfx + key, Number((value.value).toFixed(2)), "", value.unit, false);
546
+ if (kiloList.includes(value.unit)) {
547
+ await this.doState(pfx + key + " (k"+ value.unit + ")", Number((value.value / 1000).toFixed(2)), "", "k" + value.unit, false);
545
548
  }
546
549
  }
547
- if (period == api_trans["THIS_YEAR"].dp) await this.insertAllTimeHistory(system, key, new Date(obj.aggregation.startzeitpunkt).getFullYear(), Number((value.wert).toFixed(0)), value.einheit);
550
+ if (period == api_trans["THIS_YEAR"].dp) await this.insertAllTimeHistory(system, key, new Date(obj.aggregation.startDate).getFullYear(), Number((value.value).toFixed(0)), value.unit);
548
551
  }
549
552
  }
550
- if (obj.aggregation.stromverbrauch.wert != 0) {
551
- const autarky = Number((((obj.aggregation.stromerzeugung.wert - obj.aggregation.netzeinspeisung.wert - obj.aggregation.speicherbeladung.wert + obj.aggregation.speicherentnahme.wert) / obj.aggregation.stromverbrauch.wert) * 100).toFixed(2));
553
+ if (obj.aggregation.totalUsage.value != 0) {
554
+ const autarky = Number((((obj.aggregation.generation.value - obj.aggregation.gridFeedIn.value - obj.aggregation.storageLoad.value + obj.aggregation.storageConsumption.value) / obj.aggregation.totalUsage.value) * 100).toFixed(2));
552
555
  await this.doState(pfx + "Autarkie", autarky, "", "%", false);
553
556
  }
554
557
  await this.updateAllTimeHistory(system);
@@ -558,8 +561,9 @@ class Senec extends utils.Adapter {
558
561
  * inserts a value for a given key and year into AllTimeValueStore
559
562
  */
560
563
  async insertAllTimeHistory(system, key, year, value, einheit) {
564
+ this.log.debug("Insert AllTimeHistory: " + system + "/" + "key" + "/" + year + "/" + value + "/" + einheit);
561
565
  if (key === '__proto__' || key === 'constructor' || key === 'prototype') return; // Security fix
562
- if (!isNaN(year) || !isNaN(value)) return; // Security fix
566
+ if (isNaN(year) || isNaN(value)) return; // Security fix
563
567
  const pfx = "_api.Anlagen." + system + ".Statistik.AllTime.";
564
568
  const valueStore = pfx + "valueStore";
565
569
  const statsObj = await this.getStateAsync(valueStore);
@@ -597,8 +601,8 @@ class Senec extends utils.Adapter {
597
601
  await this.doState(pfx + key, Number(sum.toFixed(0)), "", einheit, false);
598
602
  }
599
603
  }
600
- if (sums.stromverbrauch != 0) {
601
- const autarky = Number((((sums.stromerzeugung - sums.netzeinspeisung - sums.speicherbeladung + sums.speicherentnahme) / sums.stromverbrauch) * 100).toFixed(0));
604
+ if (sums.totalUsage != 0) {
605
+ const autarky = Number((((sums.generation - sums.gridFeedIn - sums.storageLoad + sums.storageConsumption) / sums.totalUsage) * 100).toFixed(0));
602
606
  await this.doState(pfx + "Autarkie", autarky, "", "%", false);
603
607
  }
604
608
  }
@@ -618,11 +622,12 @@ class Senec extends utils.Adapter {
618
622
  try {
619
623
  while (new Date(year).getFullYear() > 2008) { // senec was founded in 2009 by Mathias Hammer as Deutsche Energieversorgung GmbH (DEV) - so no way we have older data :)
620
624
  this.log.info("Rebuilding AllTime History - Year: " + new Date(year).getFullYear());
621
- const baseUrl = apiSystemsUrl + "/" + system
625
+ const baseUrl = apiMonitorUrl + "/" + system;
622
626
  var url = "";
623
627
  const tzObj = await this.getStateAsync("_api.Anlagen." + system + ".zeitzone");
624
628
  const tz = tzObj ? encodeURIComponent(tzObj.val) : encodeURIComponent("Europe/Berlin");
625
- url = baseUrl + "/statistik?periode=JAHR&datum=" + year + "&locale=de_DE&timezone=" + tz;
629
+ url = baseUrl + "/data?period=YEAR&date=" + year + "&locale=de_DE&timezone=" + tz;
630
+ this.log.debug("Polling: " + url);
626
631
  body = await this.doGet(url, "", this, this.config.pollingTimeout, false);
627
632
  await this.decodeStatistik(system, JSON.parse(body), api_trans["THIS_YEAR"].dp);
628
633
  year = new Date(new Date(year).getFullYear() - 1, 1, 1).toISOString().split('T')[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.senec",
3
- "version": "1.6.9",
3
+ "version": "1.6.11",
4
4
  "description": "Senec Home",
5
5
  "author": {
6
6
  "name": "NoBl",
@@ -27,7 +27,7 @@
27
27
  "url": "https://github.com/nobl/ioBroker.senec.git"
28
28
  },
29
29
  "dependencies": {
30
- "axios": "^1.4.0",
30
+ "axios": "^1.6.0",
31
31
  "@iobroker/adapter-core": "^2.6.8"
32
32
  },
33
33
  "devDependencies": {
@@ -39,18 +39,18 @@
39
39
  "@iobroker/testing": "^4.1.0",
40
40
  "@tsconfig/node14": "^14.1.0",
41
41
  "@types/chai": "^4.3.6",
42
- "@types/chai-as-promised": "^7.1.6",
42
+ "@types/chai-as-promised": "^7.1.7",
43
43
  "@types/mocha": "^10.0.2",
44
- "@types/node": "^20.8.0",
45
- "@types/proxyquire": "^1.3.29",
44
+ "@types/node": "^20.8.10",
45
+ "@types/proxyquire": "^1.3.30",
46
46
  "@types/sinon": "^10.0.16",
47
- "@types/sinon-chai": "^3.2.9",
47
+ "@types/sinon-chai": "^3.2.11",
48
48
  "chai": "^4.3.10",
49
49
  "chai-as-promised": "^7.1.1",
50
50
  "eslint": "^8.50.0",
51
51
  "mocha": "^10.2.0",
52
52
  "proxyquire": "^2.1.3",
53
- "sinon": "^16.0.0",
53
+ "sinon": "^17.0.0",
54
54
  "sinon-chai": "^3.7.0",
55
55
  "typescript": "~5.2.2"
56
56
  },