iobroker.smartm 0.0.2 → 0.0.4

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
@@ -13,7 +13,7 @@
13
13
 
14
14
  ## smartm adapter for ioBroker
15
15
 
16
- reads Data of Slenergy-Photovoltaic-Plants over SmartM
16
+ This Adapter reads Data of [Photovoltaik SLEnergy Plats](https://www.slenergy.com) out of their Cloud named [SmartM](https://global.slenergytech.com/#/user/login).
17
17
 
18
18
  ## Changelog
19
19
 
@@ -21,6 +21,15 @@ reads Data of Slenergy-Photovoltaic-Plants over SmartM
21
21
  Placeholder for the next version (at the beginning of the line):
22
22
  ### **WORK IN PROGRESS**
23
23
  -->
24
+ ### 0.0.4 (2025-12-22)
25
+
26
+ - incorporated reviews
27
+
28
+ ### 0.0.3 (2025-11-19)
29
+
30
+ - claried readme
31
+ - added some sizes to controls in admin page
32
+
24
33
  ### 0.0.2 (2025-11-14)
25
34
 
26
35
  - (Christian Müller) initial release
@@ -10,22 +10,31 @@
10
10
  { "value": "global.slenergytech.com", "label": "International" },
11
11
  { "value": "eu.slenergytech.com", "label": "Europa" }
12
12
  ],
13
- "default": "eu.slenergytech.com"
13
+ "default": "eu.slenergytech.com",
14
+ "xs": 12,
15
+ "sm": 12,
16
+ "md": 12,
17
+ "lg": 12,
18
+ "xl": 12
14
19
  },
15
20
  "username": {
16
21
  "type": "text",
17
22
  "label": "Benutzername",
18
23
  "newLine": true,
24
+ "xs": 12,
19
25
  "sm": 12,
20
26
  "md": 6,
21
- "lg": 6
27
+ "lg": 6,
28
+ "xl": 6
22
29
  },
23
30
  "password": {
24
31
  "type": "password",
25
32
  "label": "Passwort",
33
+ "xs": 12,
26
34
  "sm": 12,
27
35
  "md": 6,
28
- "lg": 6
36
+ "lg": 6,
37
+ "xl": 6
29
38
  }
30
39
  }
31
40
  }
package/io-package.json CHANGED
@@ -1,8 +1,34 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "smartm",
4
- "version": "0.0.2",
4
+ "version": "0.0.4",
5
5
  "news": {
6
+ "0.0.4": {
7
+ "en": "incorporated reviews",
8
+ "de": "in den warenkorb",
9
+ "ru": "включенные обзоры",
10
+ "pt": "revisões incorporadas",
11
+ "nl": "opgenomen onderzoeken",
12
+ "fr": "examens intégrés",
13
+ "it": "recensioni incorporate",
14
+ "es": "revisiones incorporadas",
15
+ "pl": "włączone przeglądy",
16
+ "uk": "відгуки",
17
+ "zh-cn": "综合审查"
18
+ },
19
+ "0.0.3": {
20
+ "en": "claried readme\nadded some sizes to controls in admin page",
21
+ "de": "klares lesezeichen\neinige größen zu den kontrollen in admin-seite hinzugefügt",
22
+ "ru": "ясновидящий readme\nдобавлены некоторые размеры для элементов управления на странице администратора",
23
+ "pt": "claried readme\nadicionou alguns tamanhos aos controles na página de administração",
24
+ "nl": "claried readme\nenkele maten toegevoegd aan controles in admin pagina",
25
+ "fr": "lecture clariée\najouté quelques tailles aux contrôles dans la page d'administration",
26
+ "it": "lettura clarinese\naggiunto alcune dimensioni per i controlli nella pagina admin",
27
+ "es": "readme clarividente\nañadido algunos tamaños a controles en la página de administración",
28
+ "pl": "klarowany readme\ndodano niektóre rozmiary do kontroli na stronie admin",
29
+ "uk": "кларі читме\nдодано деякі розміри для управління на сторінці адміністратора",
30
+ "zh-cn": "闪闪发光\n在管理页面中添加一些大小的控件"
31
+ },
6
32
  "0.0.2": {
7
33
  "en": "initial release",
8
34
  "de": "erstausstrahlung",
@@ -15,19 +41,6 @@
15
41
  "pl": "początkowe zwolnienie",
16
42
  "uk": "початковий реліз",
17
43
  "zh-cn": "初步释放"
18
- },
19
- "0.0.1": {
20
- "en": "initial release",
21
- "de": "Erstveröffentlichung",
22
- "ru": "Начальная версия",
23
- "pt": "lançamento inicial",
24
- "nl": "Eerste uitgave",
25
- "fr": "Première version",
26
- "it": "Versione iniziale",
27
- "es": "Versión inicial",
28
- "pl": "Pierwsze wydanie",
29
- "uk": "Початкова версія",
30
- "zh-cn": "首次出版"
31
44
  }
32
45
  },
33
46
  "titleLang": {
package/main.js CHANGED
@@ -19,6 +19,7 @@ class Smartm extends utils.Adapter {
19
19
  name: "smartm",
20
20
  });
21
21
 
22
+ axios.defaults.timeout = 120000;
22
23
  this.accessToken = null;
23
24
  this.powerStationIds = [];
24
25
 
@@ -114,7 +115,7 @@ class Smartm extends utils.Adapter {
114
115
  this.setState("info.connection", false, true);
115
116
  this.log.error(`Login failed: ${JSON.stringify(response.data, null, 2)}`);
116
117
  //retry login in 1 minute
117
- this.reLoginTimeout = setTimeout(() => {
118
+ this.reLoginTimeout = this.setTimeout(() => {
118
119
  this.login();
119
120
  }, 1000 * 60);
120
121
  }
@@ -122,7 +123,7 @@ class Smartm extends utils.Adapter {
122
123
  this.setState("info.connection", false, true);
123
124
  this.log.error(`Error obtaining access token: ${error}`);
124
125
  //retry login in 1 minute
125
- this.reLoginTimeout = setTimeout(() => {
126
+ this.reLoginTimeout = this.setTimeout(() => {
126
127
  this.login();
127
128
  }, 1000 * 60);
128
129
  }
@@ -132,11 +133,11 @@ class Smartm extends utils.Adapter {
132
133
  * parse UserInfo from login response
133
134
  * @param {object} userInfo - user info object from login response
134
135
  */
135
- parseUserInfo(userInfo) {
136
+ async parseUserInfo(userInfo) {
136
137
  this.log.debug("Parsing user info");
137
138
 
138
139
  //create subtree for userInfo
139
- this.setObjectNotExists("userInfo", {
140
+ await this.setObjectNotExists("userInfo", {
140
141
  type: "channel",
141
142
  common: {
142
143
  name: "Benutzerinformationen",
@@ -151,11 +152,11 @@ class Smartm extends utils.Adapter {
151
152
  * parse PowerStationList from login response
152
153
  * @param {array} powerStationList - array of power station objects from login response
153
154
  */
154
- parsePowerStationList(powerStationList) {
155
+ async parsePowerStationList(powerStationList) {
155
156
  this.log.debug("Parsing power station list");
156
157
 
157
158
  //create subtree for powerStationList
158
- this.setObjectNotExists("powerStationList", {
159
+ await this.setObjectNotExists("powerStationList", {
159
160
  type: "channel",
160
161
  common: {
161
162
  name: "Anlageninformationen",
@@ -167,8 +168,8 @@ class Smartm extends utils.Adapter {
167
168
  this.powerStationIds = [];
168
169
  for (const powerStation of powerStationList) {
169
170
  this.powerStationIds.push(powerStation.id);
170
- this.setObjectNotExists(`powerStationList.${powerStation.id}`, {
171
- type: "channel",
171
+ await this.setObjectNotExists(`powerStationList.${powerStation.id}`, {
172
+ type: "device",
172
173
  common: {
173
174
  name: powerStation.powerStationName,
174
175
  },
@@ -207,19 +208,20 @@ class Smartm extends utils.Adapter {
207
208
  if (response.data.success) {
208
209
  this.log.debug(`flow data request successful${JSON.stringify(response.data, null, 2)}`);
209
210
 
210
- this.setObjectNotExists(`powerStationList.${powerStationId}.flow`, {
211
+ const flowId = this.name2id(`powerStationList.${powerStationId}.flow`);
212
+ await this.setObjectNotExists(flowId, {
211
213
  type: "channel",
212
214
  common: {
213
- name: `powerStationList.${powerStationId}.flow`,
215
+ name: flowId,
214
216
  },
215
217
  native: {},
216
218
  });
217
219
 
218
- this.parseData(`powerStationList.${powerStationId}.flow`, response.data.result);
220
+ this.parseData(flowId, response.data.result);
219
221
  } else {
220
222
  this.log.error(`reading flow data failed: ${JSON.stringify(response.data, null, 2)}`);
221
223
  //retry login in 1 minute
222
- this.reLoginTimeout = setTimeout(() => {
224
+ this.reLoginTimeout = this.setTimeout(() => {
223
225
  this.login();
224
226
  }, 1000 * 60);
225
227
  return;
@@ -227,7 +229,7 @@ class Smartm extends utils.Adapter {
227
229
  } catch (error) {
228
230
  this.log.error(`reading flow data failed: ${error}`);
229
231
  //retry login in 1 minute
230
- this.reLoginTimeout = setTimeout(() => {
232
+ this.reLoginTimeout = this.setTimeout(() => {
231
233
  this.login();
232
234
  }, 1000 * 60);
233
235
  return;
@@ -257,19 +259,20 @@ class Smartm extends utils.Adapter {
257
259
  if (response.data.success) {
258
260
  this.log.debug(`statistic data request successful${JSON.stringify(response.data, null, 2)}`);
259
261
 
260
- this.setObjectNotExists(`powerStationList.${powerStationId}.statistics`, {
262
+ const powerstationStatisticsId = this.name2id(`powerStationList.${powerStationId}.statistics`);
263
+ await this.setObjectNotExists(powerstationStatisticsId, {
261
264
  type: "channel",
262
265
  common: {
263
- name: `powerStationList.${powerStationId}.statistics`,
266
+ name: powerstationStatisticsId,
264
267
  },
265
268
  native: {},
266
269
  });
267
270
 
268
- this.parseData(`powerStationList.${powerStationId}.statistics`, response.data.result);
271
+ this.parseData(powerstationStatisticsId, response.data.result);
269
272
  } else {
270
273
  this.log.error(`reading statistics failed: ${JSON.stringify(response.data, null, 2)}`);
271
274
  //retry login in 1 minute
272
- this.reLoginTimeout = setTimeout(() => {
275
+ this.reLoginTimeout = this.setTimeout(() => {
273
276
  this.login();
274
277
  }, 1000 * 60);
275
278
  return;
@@ -277,7 +280,7 @@ class Smartm extends utils.Adapter {
277
280
  } catch (error) {
278
281
  this.log.error(`reading statistics data failed: ${error}`);
279
282
  //retry login in 1 minute
280
- this.reLoginTimeout = setTimeout(() => {
283
+ this.reLoginTimeout = this.setTimeout(() => {
281
284
  this.login();
282
285
  }, 1000 * 60);
283
286
  return;
@@ -285,15 +288,15 @@ class Smartm extends utils.Adapter {
285
288
  }
286
289
  }
287
290
 
288
- parseData(parentIoBrokerId, jsonObject) {
291
+ async parseData(parentIoBrokerId, jsonObject) {
289
292
  const objectKeys = Object.keys(jsonObject);
290
293
  for (const key of objectKeys) {
291
294
  const jsType = typeof jsonObject[key];
292
- const iobId = `${parentIoBrokerId}.${key}`;
295
+ const iobId = this.name2id(`${parentIoBrokerId}.${key}`);
293
296
 
294
297
  if (jsType === "object") {
295
298
  if (jsonObject[key] !== null) {
296
- this.setObjectNotExists(iobId, {
299
+ await this.setObjectNotExists(iobId, {
297
300
  type: "channel",
298
301
  common: {
299
302
  name: iobId,
@@ -304,37 +307,56 @@ class Smartm extends utils.Adapter {
304
307
  }
305
308
  } else {
306
309
  //create state
307
- let iobType;
308
310
  switch (jsType) {
309
311
  case "number":
310
- iobType = "number";
311
- break;
312
- case "string":
313
- iobType = "string";
312
+ await this.setObjectNotExists(iobId, {
313
+ type: "state",
314
+ common: {
315
+ name: iobId,
316
+ type: "number",
317
+ role: "value",
318
+ read: true,
319
+ write: false,
320
+ },
321
+ native: {},
322
+ });
314
323
  break;
315
324
  case "boolean":
316
- iobType = "boolean";
325
+ await this.setObjectNotExists(iobId, {
326
+ type: "state",
327
+ common: {
328
+ name: iobId,
329
+ type: "boolean",
330
+ role: "indicator",
331
+ read: true,
332
+ write: false,
333
+ },
334
+ native: {},
335
+ });
317
336
  break;
337
+ case "string":
318
338
  default:
319
- iobType = "string";
339
+ await this.setObjectNotExists(iobId, {
340
+ type: "state",
341
+ common: {
342
+ name: iobId,
343
+ type: "string",
344
+ role: "text",
345
+ read: true,
346
+ write: false,
347
+ },
348
+ native: {},
349
+ });
320
350
  }
321
351
 
322
- this.setObjectNotExists(iobId, {
323
- type: "state",
324
- common: {
325
- name: iobId,
326
- type: iobType,
327
- role: "state",
328
- read: true,
329
- write: false,
330
- },
331
- native: {},
332
- });
333
-
334
352
  this.setStateChanged(iobId, jsonObject[key], true);
335
353
  }
336
354
  }
337
355
  }
356
+
357
+ name2id(pName) {
358
+ return (pName || "").replace(this.FORBIDDEN_CHARS, "_");
359
+ }
338
360
  }
339
361
 
340
362
  if (require.main !== module) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.smartm",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "This Adapter reads Data of Slenergy-Photovoltaic-Plants over SmartM",
5
5
  "author": {
6
6
  "name": "Christian Müller",
@@ -23,7 +23,8 @@
23
23
  "node": ">= 22"
24
24
  },
25
25
  "dependencies": {
26
- "@iobroker/adapter-core": "^3.3.2"
26
+ "@iobroker/adapter-core": "^3.3.2",
27
+ "axios": "^1.13.2"
27
28
  },
28
29
  "devDependencies": {
29
30
  "@alcalzone/release-script": "^5.0.0",