iobroker.smartm 0.0.3 → 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 +4 -0
- package/io-package.json +14 -1
- package/main.js +62 -40
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -21,6 +21,10 @@ This Adapter reads Data of [Photovoltaik SLEnergy Plats](https://www.slenergy.co
|
|
|
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
|
+
|
|
24
28
|
### 0.0.3 (2025-11-19)
|
|
25
29
|
|
|
26
30
|
- claried readme
|
package/io-package.json
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "smartm",
|
|
4
|
-
"version": "0.0.
|
|
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
|
+
},
|
|
6
19
|
"0.0.3": {
|
|
7
20
|
"en": "claried readme\nadded some sizes to controls in admin page",
|
|
8
21
|
"de": "klares lesezeichen\neinige größen zu den kontrollen in admin-seite hinzugefügt",
|
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: "
|
|
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.
|
|
211
|
+
const flowId = this.name2id(`powerStationList.${powerStationId}.flow`);
|
|
212
|
+
await this.setObjectNotExists(flowId, {
|
|
211
213
|
type: "channel",
|
|
212
214
|
common: {
|
|
213
|
-
name:
|
|
215
|
+
name: flowId,
|
|
214
216
|
},
|
|
215
217
|
native: {},
|
|
216
218
|
});
|
|
217
219
|
|
|
218
|
-
this.parseData(
|
|
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.
|
|
262
|
+
const powerstationStatisticsId = this.name2id(`powerStationList.${powerStationId}.statistics`);
|
|
263
|
+
await this.setObjectNotExists(powerstationStatisticsId, {
|
|
261
264
|
type: "channel",
|
|
262
265
|
common: {
|
|
263
|
-
name:
|
|
266
|
+
name: powerstationStatisticsId,
|
|
264
267
|
},
|
|
265
268
|
native: {},
|
|
266
269
|
});
|
|
267
270
|
|
|
268
|
-
this.parseData(
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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",
|