iobroker.zendure-solarflow 2.0.3 → 3.0.0-alpha.2
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 +12 -1
- package/admin/build/index.js +35 -35
- package/admin/build/index.js.map +2 -2
- package/build/constants/constants.js +41 -0
- package/build/constants/constants.js.map +7 -0
- package/build/helpers/helpers.js +84 -96
- package/build/helpers/helpers.js.map +2 -2
- package/build/main.js +108 -180
- package/build/main.js.map +2 -2
- package/build/models/IDeviceAutomationPayload.js.map +1 -1
- package/build/models/{IPack2Device.js → IDevicePack.js} +3 -3
- package/build/models/IDevicePack.js.map +7 -0
- package/build/models/{ISolarFlowDeviceDetails.js → IHaDeviceListData.js} +3 -3
- package/build/models/IHaDeviceListData.js.map +7 -0
- package/build/models/{ISolarflowDevRegisterResponse.js → IZenHaDeviceDetails.js} +3 -3
- package/build/models/IZenHaDeviceDetails.js.map +7 -0
- package/build/models/{ISolarFlowPaths.js → IZenHaMqttData.js} +3 -3
- package/build/models/IZenHaMqttData.js.map +7 -0
- package/build/models/deviceModels/Ace1500.js +77 -0
- package/build/models/deviceModels/Ace1500.js.map +7 -0
- package/build/models/deviceModels/Aio2400.js +121 -0
- package/build/models/deviceModels/Aio2400.js.map +7 -0
- package/build/models/deviceModels/Hyper2000.js +200 -0
- package/build/models/deviceModels/Hyper2000.js.map +7 -0
- package/build/models/deviceModels/Sf2400Ac.js +146 -0
- package/build/models/deviceModels/Sf2400Ac.js.map +7 -0
- package/build/models/deviceModels/Sf800.js +144 -0
- package/build/models/deviceModels/Sf800.js.map +7 -0
- package/build/models/deviceModels/SfHub1200.js +179 -0
- package/build/models/deviceModels/SfHub1200.js.map +7 -0
- package/build/models/deviceModels/SfHub2000.js +177 -0
- package/build/models/deviceModels/SfHub2000.js.map +7 -0
- package/build/models/deviceModels/ZenHaDevice.js +1093 -0
- package/build/models/deviceModels/ZenHaDevice.js.map +7 -0
- package/build/services/jobSchedule.js +19 -58
- package/build/services/jobSchedule.js.map +2 -2
- package/build/services/mqttCloudZenService.js +79 -0
- package/build/services/mqttCloudZenService.js.map +7 -0
- package/build/services/mqttLocalService.js +70 -0
- package/build/services/mqttLocalService.js.map +7 -0
- package/build/services/mqttSharedService.js +432 -0
- package/build/services/mqttSharedService.js.map +7 -0
- package/build/services/zenWebService.js +84 -0
- package/build/services/zenWebService.js.map +7 -0
- package/io-package.json +83 -40
- package/package.json +1 -1
- package/build/constants/paths.js +0 -52
- package/build/constants/paths.js.map +0 -7
- package/build/helpers/createSolarFlowLocalStates.js +0 -113
- package/build/helpers/createSolarFlowLocalStates.js.map +0 -7
- package/build/helpers/createSolarFlowStates.js +0 -196
- package/build/helpers/createSolarFlowStates.js.map +0 -7
- package/build/models/IPack2Device.js.map +0 -7
- package/build/models/ISolarFlowDeviceDetails.js.map +0 -7
- package/build/models/ISolarFlowPaths.js.map +0 -7
- package/build/models/ISolarflowDevRegisterResponse.js.map +0 -7
- package/build/services/adapterService.js +0 -142
- package/build/services/adapterService.js.map +0 -7
- package/build/services/calculationService.js +0 -350
- package/build/services/calculationService.js.map +0 -7
- package/build/services/fallbackMqttService.js +0 -461
- package/build/services/fallbackMqttService.js.map +0 -7
- package/build/services/fallbackWebService.js +0 -80
- package/build/services/fallbackWebService.js.map +0 -7
- package/build/services/mqttService.js +0 -1545
- package/build/services/mqttService.js.map +0 -7
- package/build/services/webService.js +0 -119
- package/build/services/webService.js.map +0 -7
package/build/main.js
CHANGED
|
@@ -32,27 +32,20 @@ __export(main_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(main_exports);
|
|
34
34
|
var utils = __toESM(require("@iobroker/adapter-core"));
|
|
35
|
-
var
|
|
36
|
-
var import_webService = require("./services/webService");
|
|
37
|
-
var import_paths = require("./constants/paths");
|
|
38
|
-
var import_adapterService = require("./services/adapterService");
|
|
39
|
-
var import_createSolarFlowStates = require("./helpers/createSolarFlowStates");
|
|
40
|
-
var import_fallbackWebService = require("./services/fallbackWebService");
|
|
41
|
-
var import_fallbackMqttService = require("./services/fallbackMqttService");
|
|
35
|
+
var import_zenWebService = require("./services/zenWebService");
|
|
42
36
|
var import_jobSchedule = require("./services/jobSchedule");
|
|
37
|
+
var import_mqttLocalService = require("./services/mqttLocalService");
|
|
38
|
+
var import_mqttCloudZenService = require("./services/mqttCloudZenService");
|
|
39
|
+
var import_helpers = require("./helpers/helpers");
|
|
43
40
|
class ZendureSolarflow extends utils.Adapter {
|
|
44
41
|
constructor(options = {}) {
|
|
45
42
|
super({
|
|
46
43
|
...options,
|
|
47
44
|
name: "zendure-solarflow"
|
|
48
45
|
});
|
|
49
|
-
this.
|
|
50
|
-
//
|
|
51
|
-
this.
|
|
52
|
-
// Access Token for Zendure Rest API
|
|
53
|
-
this.deviceList = [];
|
|
54
|
-
this.paths = void 0;
|
|
55
|
-
this.pack2Devices = [];
|
|
46
|
+
this.zenHaDeviceList = [];
|
|
47
|
+
// All found devices for this instance will be in this array
|
|
48
|
+
this.mqttSettings = void 0;
|
|
56
49
|
this.msgCounter = 7e5;
|
|
57
50
|
this.lastLogin = void 0;
|
|
58
51
|
this.mqttClient = void 0;
|
|
@@ -107,128 +100,93 @@ class ZendureSolarflow extends utils.Adapter {
|
|
|
107
100
|
},
|
|
108
101
|
native: {}
|
|
109
102
|
});
|
|
110
|
-
if (this.config.server && this.config.server == "eu") {
|
|
111
|
-
this.paths = import_paths.pathsEu;
|
|
112
|
-
} else {
|
|
113
|
-
this.paths = import_paths.pathsGlobal;
|
|
114
|
-
}
|
|
115
|
-
this.log.debug("[onReady] Using server " + this.config.server);
|
|
116
103
|
this.setState("info.errorMessage", "", true);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.log.debug("[onReady] Using Fallback Mode (Dev-Server)");
|
|
125
|
-
(0, import_fallbackWebService.createDeveloperAccount)(this).then((data) => {
|
|
126
|
-
if (data.appKey && data.mqttUrl && data.port && data.secret) {
|
|
127
|
-
(0, import_fallbackMqttService.connectFallbackMqttClient)(
|
|
128
|
-
this,
|
|
129
|
-
data.appKey,
|
|
130
|
-
data.secret,
|
|
131
|
-
data.mqttUrl,
|
|
132
|
-
data.port
|
|
104
|
+
this.setState("info.connection", false, true);
|
|
105
|
+
switch (this.config.connectionMode) {
|
|
106
|
+
case "authKey":
|
|
107
|
+
this.log.debug("[onReady] Using Authorization Cloud Key");
|
|
108
|
+
if (!this.config.authorizationCloudKey) {
|
|
109
|
+
this.log.error(
|
|
110
|
+
"[zenWebService.login] authorization cloud key is missing!"
|
|
133
111
|
);
|
|
112
|
+
break;
|
|
134
113
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
} else {
|
|
153
|
-
this.log.error(
|
|
154
|
-
`[onReady] Error connecting to Zendure Cloud. Error: ${ex.message}`
|
|
114
|
+
const data = await (0, import_zenWebService.zenLogin)(this);
|
|
115
|
+
if (typeof data === "string" || data == void 0) {
|
|
116
|
+
this.setState("info.connection", false, true);
|
|
117
|
+
} else {
|
|
118
|
+
this.mqttSettings = data.mqtt;
|
|
119
|
+
if (!(0, import_mqttCloudZenService.connectCloudZenMqttClient)(this)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
this.log.debug(
|
|
123
|
+
`[onReady] Creating ${data.deviceList.length} devices...`
|
|
124
|
+
);
|
|
125
|
+
await data.deviceList.forEach(async (device) => {
|
|
126
|
+
const deviceModel = (0, import_helpers.createDeviceModel)(
|
|
127
|
+
this,
|
|
128
|
+
device.productKey,
|
|
129
|
+
device.deviceKey,
|
|
130
|
+
device
|
|
155
131
|
);
|
|
132
|
+
if (deviceModel) {
|
|
133
|
+
this.zenHaDeviceList.push(deviceModel);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
case "local": {
|
|
139
|
+
this.log.debug("[onReady] Using local MQTT server");
|
|
140
|
+
(0, import_mqttLocalService.connectLocalMqttClient)(this);
|
|
141
|
+
if (this.config.localDevice1ProductKey && this.config.localDevice1DeviceKey) {
|
|
142
|
+
const deviceModel = (0, import_helpers.createDeviceModel)(
|
|
143
|
+
this,
|
|
144
|
+
this.config.localDevice1ProductKey,
|
|
145
|
+
this.config.localDevice1DeviceKey
|
|
146
|
+
);
|
|
147
|
+
if (deviceModel) {
|
|
148
|
+
this.zenHaDeviceList.push(deviceModel);
|
|
156
149
|
}
|
|
157
150
|
}
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
|
|
151
|
+
if (this.config.localDevice2ProductKey && this.config.localDevice2DeviceKey) {
|
|
152
|
+
const deviceModel = (0, import_helpers.createDeviceModel)(
|
|
153
|
+
this,
|
|
154
|
+
this.config.localDevice2ProductKey,
|
|
155
|
+
this.config.localDevice2DeviceKey
|
|
156
|
+
);
|
|
157
|
+
if (deviceModel) {
|
|
158
|
+
this.zenHaDeviceList.push(deviceModel);
|
|
159
|
+
}
|
|
161
160
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
(
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
if (_accessToken != void 0) {
|
|
172
|
-
this.setState("info.connection", true, true);
|
|
173
|
-
this.lastLogin = /* @__PURE__ */ new Date();
|
|
174
|
-
(0, import_webService.getDeviceList)(this).then(async (result) => {
|
|
175
|
-
if (result) {
|
|
176
|
-
this.deviceList = result.filter(
|
|
177
|
-
(device) => device.productName.toLowerCase().includes("solarflow") || device.productName.toLowerCase().includes("hyper") || device.productName.toLowerCase() == "ace 1500" || device.productName.toLowerCase().includes("smart plug")
|
|
178
|
-
);
|
|
179
|
-
await (0, import_adapterService.checkDevicesServer)(this);
|
|
180
|
-
this.log.info(
|
|
181
|
-
`[onReady] Found ${this.deviceList.length} SolarFlow device(s).`
|
|
182
|
-
);
|
|
183
|
-
await this.deviceList.forEach(
|
|
184
|
-
async (device) => {
|
|
185
|
-
var _a;
|
|
186
|
-
if (device.packList && device.packList.length > 0) {
|
|
187
|
-
device.packList.forEach(async (subDevice) => {
|
|
188
|
-
if (subDevice.productName.toLocaleLowerCase() == "ace 1500") {
|
|
189
|
-
device._connectedWithAce = true;
|
|
190
|
-
await (0, import_createSolarFlowStates.createSolarFlowStates)(this, subDevice);
|
|
191
|
-
await (0, import_adapterService.updateSolarFlowState)(
|
|
192
|
-
this,
|
|
193
|
-
subDevice.productKey,
|
|
194
|
-
subDevice.deviceKey,
|
|
195
|
-
"registeredServer",
|
|
196
|
-
this.config.server
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
await (0, import_createSolarFlowStates.createSolarFlowStates)(this, device);
|
|
202
|
-
if (!device.productName.toLowerCase().includes("smart plug")) {
|
|
203
|
-
await (0, import_adapterService.updateSolarFlowState)(
|
|
204
|
-
this,
|
|
205
|
-
device.productKey,
|
|
206
|
-
device.deviceKey,
|
|
207
|
-
"registeredServer",
|
|
208
|
-
this.config.server
|
|
209
|
-
);
|
|
210
|
-
} else if ((this == null ? void 0 : this.userId) && device.id) {
|
|
211
|
-
await (0, import_adapterService.updateSolarFlowState)(
|
|
212
|
-
this,
|
|
213
|
-
this.userId,
|
|
214
|
-
(_a = device.id) == null ? void 0 : _a.toString(),
|
|
215
|
-
"registeredServer",
|
|
216
|
-
this.config.server
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
);
|
|
221
|
-
(0, import_mqttService.connectCloudMqttClient)(this);
|
|
161
|
+
if (this.config.localDevice3ProductKey && this.config.localDevice3DeviceKey) {
|
|
162
|
+
const deviceModel = (0, import_helpers.createDeviceModel)(
|
|
163
|
+
this,
|
|
164
|
+
this.config.localDevice3ProductKey,
|
|
165
|
+
this.config.localDevice3DeviceKey
|
|
166
|
+
);
|
|
167
|
+
if (deviceModel) {
|
|
168
|
+
this.zenHaDeviceList.push(deviceModel);
|
|
222
169
|
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
170
|
+
}
|
|
171
|
+
if (this.config.localDevice4ProductKey && this.config.localDevice4DeviceKey) {
|
|
172
|
+
const deviceModel = (0, import_helpers.createDeviceModel)(
|
|
173
|
+
this,
|
|
174
|
+
this.config.localDevice4ProductKey,
|
|
175
|
+
this.config.localDevice4DeviceKey
|
|
176
|
+
);
|
|
177
|
+
if (deviceModel) {
|
|
178
|
+
this.zenHaDeviceList.push(deviceModel);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (this.config.useRestart) {
|
|
182
|
+
(0, import_jobSchedule.startRefreshAccessTokenTimerJob)(this);
|
|
183
|
+
}
|
|
184
|
+
break;
|
|
228
185
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
186
|
+
default:
|
|
187
|
+
this.setState("info.connection", false, true);
|
|
188
|
+
this.log.error("[onReady] No connection mode found or mode invalid!");
|
|
189
|
+
break;
|
|
232
190
|
}
|
|
233
191
|
}
|
|
234
192
|
/**
|
|
@@ -278,11 +236,16 @@ class ZendureSolarflow extends utils.Adapter {
|
|
|
278
236
|
const deviceKey = splitted[3];
|
|
279
237
|
const stateName1 = splitted[4];
|
|
280
238
|
const stateName2 = splitted[5];
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
239
|
+
const _device = this.zenHaDeviceList.find(
|
|
240
|
+
(x) => x.productKey == productKey && x.deviceKey == deviceKey
|
|
241
|
+
);
|
|
242
|
+
if (!_device) {
|
|
243
|
+
this.log.error(
|
|
244
|
+
`[onStateChange] Device '${deviceKey}' not found in zenHaDeviceList!`
|
|
284
245
|
);
|
|
285
|
-
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (state.val != void 0 && state.val != null && !state.ack) {
|
|
286
249
|
switch (stateName1) {
|
|
287
250
|
case "control":
|
|
288
251
|
this.log.debug(
|
|
@@ -290,81 +253,46 @@ class ZendureSolarflow extends utils.Adapter {
|
|
|
290
253
|
);
|
|
291
254
|
switch (stateName2) {
|
|
292
255
|
case "setOutputLimit":
|
|
293
|
-
|
|
256
|
+
_device.setOutputLimit(Number(state.val));
|
|
294
257
|
break;
|
|
295
258
|
case "setInputLimit":
|
|
296
|
-
|
|
259
|
+
_device.setInputLimit(Number(state.val));
|
|
297
260
|
break;
|
|
298
261
|
case "chargeLimit":
|
|
299
|
-
|
|
262
|
+
_device.setChargeLimit(Number(state.val));
|
|
300
263
|
break;
|
|
301
264
|
case "dischargeLimit":
|
|
302
|
-
(
|
|
303
|
-
this,
|
|
304
|
-
productKey,
|
|
305
|
-
deviceKey,
|
|
306
|
-
Number(state.val)
|
|
307
|
-
);
|
|
265
|
+
_device.setDischargeLimit(Number(state.val));
|
|
308
266
|
break;
|
|
309
267
|
case "passMode":
|
|
310
|
-
|
|
268
|
+
_device.setPassMode(Number(state.val));
|
|
311
269
|
break;
|
|
312
270
|
case "dcSwitch":
|
|
313
|
-
(
|
|
314
|
-
this,
|
|
315
|
-
productKey,
|
|
316
|
-
deviceKey,
|
|
317
|
-
state.val ? true : false
|
|
318
|
-
);
|
|
271
|
+
_device.setDcSwitch(state.val ? true : false);
|
|
319
272
|
break;
|
|
320
273
|
case "acSwitch":
|
|
321
|
-
(
|
|
322
|
-
this,
|
|
323
|
-
productKey,
|
|
324
|
-
deviceKey,
|
|
325
|
-
state.val ? true : false
|
|
326
|
-
);
|
|
274
|
+
_device.setAcSwitch(state.val ? true : false);
|
|
327
275
|
break;
|
|
328
276
|
case "acMode":
|
|
329
|
-
|
|
277
|
+
_device.setAcMode(Number(state.val));
|
|
330
278
|
break;
|
|
331
279
|
case "hubState":
|
|
332
|
-
|
|
280
|
+
_device.setHubState(Number(state.val));
|
|
333
281
|
break;
|
|
334
282
|
case "autoModel":
|
|
335
|
-
|
|
283
|
+
_device.setAutoModel(Number(state.val));
|
|
336
284
|
break;
|
|
337
285
|
case "autoRecover":
|
|
338
|
-
(
|
|
339
|
-
this,
|
|
340
|
-
productKey,
|
|
341
|
-
deviceKey,
|
|
342
|
-
state.val ? true : false
|
|
343
|
-
);
|
|
286
|
+
_device.setAutoRecover(state.val ? true : false);
|
|
344
287
|
break;
|
|
345
288
|
case "buzzerSwitch":
|
|
346
|
-
(
|
|
347
|
-
this,
|
|
348
|
-
productKey,
|
|
349
|
-
deviceKey,
|
|
350
|
-
state.val ? true : false
|
|
351
|
-
);
|
|
289
|
+
_device.setBuzzerSwitch(state.val ? true : false);
|
|
352
290
|
break;
|
|
353
291
|
case "smartMode":
|
|
354
|
-
(
|
|
355
|
-
this,
|
|
356
|
-
productKey,
|
|
357
|
-
deviceKey,
|
|
358
|
-
state.val ? true : false
|
|
359
|
-
);
|
|
292
|
+
_device.setSmartMode(state.val ? true : false);
|
|
360
293
|
break;
|
|
361
294
|
case "setDeviceAutomationInOutLimit":
|
|
362
|
-
(
|
|
363
|
-
this,
|
|
364
|
-
productKey,
|
|
365
|
-
deviceKey,
|
|
366
|
-
Number(state.val)
|
|
367
|
-
);
|
|
295
|
+
_device.setDeviceAutomationInOutLimit(Number(state.val));
|
|
368
296
|
break;
|
|
369
297
|
}
|
|
370
298
|
break;
|
package/build/main.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/indent */\r\n/*\r\n * Created with @iobroker/create-adapter v2.5.0\r\n */\r\n\r\n// The adapter-core module gives you access to the core ioBroker functions\r\n// you need to create an adapter\r\nimport * as utils from \"@iobroker/adapter-core\";\r\nimport {\r\n connectCloudMqttClient,\r\n connectLocalMqttClient,\r\n setAcMode,\r\n setAcSwitch,\r\n setAutoModel,\r\n setAutoRecover,\r\n setBuzzerSwitch,\r\n setChargeLimit,\r\n setDcSwitch,\r\n setDeviceAutomationInOutLimit,\r\n setDischargeLimit,\r\n setHubState,\r\n setInputLimit,\r\n setOutputLimit,\r\n setPassMode,\r\n setSmartMode,\r\n} from \"./services/mqttService\";\r\nimport { getDeviceList, login } from \"./services/webService\";\r\nimport { ISolarFlowDeviceDetails } from \"./models/ISolarFlowDeviceDetails\";\r\nimport { ISolarFlowPaths } from \"./models/ISolarFlowPaths\";\r\nimport { pathsEu, pathsGlobal } from \"./constants/paths\";\r\nimport { Job } from \"node-schedule\";\r\nimport { MqttClient } from \"mqtt\";\r\nimport {\r\n checkDevicesServer,\r\n updateSolarFlowState,\r\n} from \"./services/adapterService\";\r\nimport { createSolarFlowStates } from \"./helpers/createSolarFlowStates\";\r\nimport { createDeveloperAccount } from \"./services/fallbackWebService\";\r\nimport { ISolarFlowDevRegisterData } from \"./models/ISolarflowDevRegisterResponse\";\r\nimport { connectFallbackMqttClient } from \"./services/fallbackMqttService\";\r\nimport { IPack2Device } from \"./models/IPack2Device\";\r\nimport { startRefreshAccessTokenTimerJob } from \"./services/jobSchedule\";\r\n\r\nexport class ZendureSolarflow extends utils.Adapter {\r\n public constructor(options: Partial<utils.AdapterOptions> = {}) {\r\n super({\r\n ...options,\r\n name: \"zendure-solarflow\",\r\n });\r\n this.on(\"ready\", this.onReady.bind(this));\r\n this.on(\"stateChange\", this.onStateChange.bind(this));\r\n this.on(\"unload\", this.onUnload.bind(this));\r\n }\r\n\r\n public userId: string | undefined = undefined; // User ID, needed for connection with Smart Plug\r\n public accessToken: string | undefined = undefined; // Access Token for Zendure Rest API\r\n public deviceList: ISolarFlowDeviceDetails[] = [];\r\n public paths: ISolarFlowPaths | undefined = undefined;\r\n public pack2Devices: IPack2Device[] = [];\r\n\r\n public msgCounter: number = 700000;\r\n\r\n public lastLogin: Date | undefined = undefined;\r\n\r\n public mqttClient: MqttClient | undefined = undefined;\r\n\r\n public resetValuesJob: Job | undefined = undefined;\r\n public checkStatesJob: Job | undefined = undefined;\r\n public calculationJob: Job | undefined = undefined;\r\n public refreshAccessTokenInterval: ioBroker.Interval | undefined = undefined;\r\n public retryTimeout: ioBroker.Timeout | undefined = undefined;\r\n\r\n public createdSnNumberSolarflowStates: string[] = [];\r\n\r\n /**\r\n * Is called when databases are connected and adapter received configuration.\r\n */\r\n private async onReady(): Promise<void> {\r\n await this.extendObject(\"info\", {\r\n type: \"channel\",\r\n common: {\r\n name: \"Information\",\r\n },\r\n native: {},\r\n });\r\n\r\n await this.extendObject(`info.connection`, {\r\n type: \"state\",\r\n common: {\r\n name: {\r\n de: \"Mit Zendure Cloud verbunden\",\r\n en: \"Connected to Zendure cloud\",\r\n },\r\n type: \"boolean\",\r\n desc: \"connection\",\r\n role: \"indicator.connected\",\r\n read: true,\r\n write: false,\r\n },\r\n native: {},\r\n });\r\n\r\n await this.extendObject(`info.errorMessage`, {\r\n type: \"state\",\r\n common: {\r\n name: {\r\n de: \"Fehlermeldung der Verbindung zur Zendure Cloud\",\r\n en: \"Error message from Zendure Cloud\",\r\n },\r\n type: \"string\",\r\n desc: \"errorMessage\",\r\n role: \"value\",\r\n read: true,\r\n write: false,\r\n },\r\n native: {},\r\n });\r\n\r\n // Select paths by config value\r\n if (this.config.server && this.config.server == \"eu\") {\r\n this.paths = pathsEu;\r\n } else {\r\n this.paths = pathsGlobal;\r\n }\r\n\r\n this.log.debug(\"[onReady] Using server \" + this.config.server);\r\n\r\n this.setState(\"info.errorMessage\", \"\", true);\r\n\r\n if (this.config.server == \"local\") {\r\n this.log.debug(\"[onReady] Using local MQTT server\");\r\n\r\n connectLocalMqttClient(this);\r\n\r\n if (this.config.useRestart) {\r\n // Add interval to restart adapter every 3 hours\r\n startRefreshAccessTokenTimerJob(this);\r\n }\r\n } else if (this.config.useFallbackService && this.config.snNumber) {\r\n this.log.debug(\"[onReady] Using Fallback Mode (Dev-Server)\");\r\n // Use Fallback service. Using the developer version of the MQTT and Webservice from zendure\r\n createDeveloperAccount(this).then((data: ISolarFlowDevRegisterData) => {\r\n //console.log(data);\r\n if (data.appKey && data.mqttUrl && data.port && data.secret) {\r\n connectFallbackMqttClient(\r\n this,\r\n data.appKey,\r\n data.secret,\r\n data.mqttUrl,\r\n data.port\r\n );\r\n }\r\n });\r\n } else if (\r\n !this.config.useFallbackService &&\r\n this.config.userName &&\r\n this.config.password\r\n ) {\r\n // App mode: If Username and Password is provided, try to login and get the access token.\r\n let _accessToken: string | undefined = undefined;\r\n let retryCounter = 0;\r\n\r\n if (this.config.useRestart) {\r\n // Add interval to restart adapter every 3 hours\r\n startRefreshAccessTokenTimerJob(this);\r\n }\r\n\r\n while (retryCounter <= 10) {\r\n try {\r\n _accessToken = await login(this);\r\n } catch (ex: any) {\r\n this.setState(\"info.message\", ex.message, true);\r\n if (ex.message.includes(\"Request failed with status code 400\")) {\r\n this.log.warn(\r\n `[onReady] Error 400, maybe your credentials are invalid!`\r\n );\r\n break;\r\n } else {\r\n this.log.error(\r\n `[onReady] Error connecting to Zendure Cloud. Error: ${ex.message}`\r\n );\r\n }\r\n }\r\n\r\n if (_accessToken != undefined) {\r\n this.accessToken = _accessToken;\r\n break;\r\n }\r\n\r\n retryCounter++;\r\n\r\n const milliseconds = 4000 * retryCounter;\r\n\r\n this.log.warn(\r\n `[onReady] Retrying to connect to Zendure Cloud in ${milliseconds / 1000} seconds (Retry #${retryCounter} of 10).`\r\n );\r\n\r\n // Add a small sleep\r\n await new Promise(\r\n (r) =>\r\n (this.retryTimeout = this.setTimeout(r, milliseconds, undefined))\r\n );\r\n }\r\n\r\n if (_accessToken != undefined) {\r\n this.setState(\"info.connection\", true, true);\r\n this.lastLogin = new Date();\r\n\r\n // Try to get the device list\r\n getDeviceList(this)\r\n .then(async (result: ISolarFlowDeviceDetails[]) => {\r\n if (result) {\r\n // Device List found. Save in the adapter properties and connect to MQTT\r\n\r\n // Filtering to SolarFlow devices\r\n this.deviceList = result.filter(\r\n (device) =>\r\n device.productName.toLowerCase().includes(\"solarflow\") ||\r\n device.productName.toLowerCase().includes(\"hyper\") ||\r\n device.productName.toLowerCase() == \"ace 1500\" ||\r\n device.productName.toLowerCase().includes(\"smart plug\")\r\n );\r\n\r\n await checkDevicesServer(this);\r\n\r\n this.log.info(\r\n `[onReady] Found ${this.deviceList.length} SolarFlow device(s).`\r\n );\r\n\r\n await this.deviceList.forEach(\r\n async (device: ISolarFlowDeviceDetails) => {\r\n // Check if has subdevice e.g. ACE?\r\n if (device.packList && device.packList.length > 0) {\r\n device.packList.forEach(async (subDevice) => {\r\n if (\r\n subDevice.productName.toLocaleLowerCase() == \"ace 1500\"\r\n ) {\r\n device._connectedWithAce = true;\r\n // States erstellen\r\n await createSolarFlowStates(this, subDevice);\r\n\r\n await updateSolarFlowState(\r\n this,\r\n subDevice.productKey,\r\n subDevice.deviceKey,\r\n \"registeredServer\",\r\n this.config.server\r\n );\r\n }\r\n });\r\n }\r\n\r\n // States erstellen\r\n await createSolarFlowStates(this, device);\r\n\r\n if (\r\n !device.productName.toLowerCase().includes(\"smart plug\")\r\n ) {\r\n await updateSolarFlowState(\r\n this,\r\n device.productKey,\r\n device.deviceKey,\r\n \"registeredServer\",\r\n this.config.server\r\n );\r\n } else if (this?.userId && device.id) {\r\n await updateSolarFlowState(\r\n this,\r\n this.userId,\r\n device.id?.toString(),\r\n \"registeredServer\",\r\n this.config.server\r\n );\r\n }\r\n }\r\n );\r\n\r\n connectCloudMqttClient(this);\r\n }\r\n })\r\n .catch(() => {\r\n this.setState(\"info.connection\", false, true);\r\n this.log?.error(\"[onReady] Retrieving device failed!\");\r\n });\r\n }\r\n } else {\r\n this.setState(\"info.connection\", false, true);\r\n this.log.error(\"[onReady] No Login Information provided!\");\r\n //this.stop?.();\r\n }\r\n }\r\n\r\n /**\r\n * Is called when adapter shuts down - callback has to be called under any circumstances!\r\n */\r\n private async onUnload(callback: () => void): Promise<void> {\r\n try {\r\n if (this.refreshAccessTokenInterval) {\r\n this.clearInterval(this.refreshAccessTokenInterval);\r\n }\r\n\r\n try {\r\n await this.mqttClient?.endAsync();\r\n this.log.info(\"[onUnload] MQTT client stopped!\");\r\n this.mqttClient = undefined;\r\n } catch (ex: any) {\r\n this.log.error(\"[onUnload] Error stopping MQTT client: !\" + ex.message);\r\n }\r\n\r\n this.setState(\"info.connection\", false, true);\r\n\r\n // Scheduler beenden\r\n if (this.resetValuesJob) {\r\n this.resetValuesJob.cancel();\r\n this.resetValuesJob = undefined;\r\n }\r\n\r\n if (this.checkStatesJob) {\r\n this.checkStatesJob?.cancel();\r\n this.checkStatesJob = undefined;\r\n }\r\n\r\n if (this.calculationJob) {\r\n this.calculationJob.cancel();\r\n this.calculationJob = undefined;\r\n }\r\n\r\n if (this.retryTimeout) {\r\n this.clearTimeout(this.retryTimeout);\r\n }\r\n\r\n callback();\r\n } catch (e) {\r\n callback();\r\n }\r\n }\r\n\r\n /**\r\n * Is called if a subscribed state changes\r\n */\r\n private onStateChange(\r\n id: string,\r\n state: ioBroker.State | null | undefined\r\n ): void {\r\n if (state) {\r\n // The state was changed\r\n //this.log.debug(`state ${id} changed: ${state.val} (ack = ${state.ack})`);\r\n\r\n // Read product and device key from string\r\n const splitted = id.split(\".\");\r\n const productKey = splitted[2]; // Product Key\r\n const deviceKey = splitted[3]; // Device Key\r\n const stateName1 = splitted[4]; // Folder/State Name 1 (e.g. 'control')\r\n const stateName2 = splitted[5]; // State Name, like 'setOutputLimit'\r\n\r\n if (this.config.useFallbackService && stateName1 == \"control\") {\r\n this.log.warn(\r\n `[onStateChange] Using Fallback server, control of Solarflow device is not possible!`\r\n );\r\n }\r\n // !!! Only stateChanges with ack==false are allowed to be processed.\r\n else if (state.val != undefined && state.val != null && !state.ack) {\r\n switch (stateName1) {\r\n case \"control\":\r\n this.log.debug(\r\n `[onStateChange] Control state '${stateName2}' changed, new value is ${state.val}, ack = ${state.ack}!`\r\n );\r\n switch (stateName2) {\r\n case \"setOutputLimit\":\r\n setOutputLimit(this, productKey, deviceKey, Number(state.val));\r\n break;\r\n case \"setInputLimit\":\r\n setInputLimit(this, productKey, deviceKey, Number(state.val));\r\n break;\r\n case \"chargeLimit\":\r\n setChargeLimit(this, productKey, deviceKey, Number(state.val));\r\n break;\r\n case \"dischargeLimit\":\r\n setDischargeLimit(\r\n this,\r\n productKey,\r\n deviceKey,\r\n Number(state.val)\r\n );\r\n break;\r\n case \"passMode\":\r\n setPassMode(this, productKey, deviceKey, Number(state.val));\r\n break;\r\n case \"dcSwitch\":\r\n setDcSwitch(\r\n this,\r\n productKey,\r\n deviceKey,\r\n state.val ? true : false\r\n );\r\n break;\r\n case \"acSwitch\":\r\n setAcSwitch(\r\n this,\r\n productKey,\r\n deviceKey,\r\n state.val ? true : false\r\n );\r\n break;\r\n case \"acMode\":\r\n setAcMode(this, productKey, deviceKey, Number(state.val));\r\n break;\r\n case \"hubState\":\r\n setHubState(this, productKey, deviceKey, Number(state.val));\r\n break;\r\n case \"autoModel\":\r\n setAutoModel(this, productKey, deviceKey, Number(state.val));\r\n break;\r\n case \"autoRecover\":\r\n setAutoRecover(\r\n this,\r\n productKey,\r\n deviceKey,\r\n state.val ? true : false\r\n );\r\n break;\r\n case \"buzzerSwitch\":\r\n setBuzzerSwitch(\r\n this,\r\n productKey,\r\n deviceKey,\r\n state.val ? true : false\r\n );\r\n break;\r\n case \"smartMode\":\r\n setSmartMode(\r\n this,\r\n productKey,\r\n deviceKey,\r\n state.val ? true : false\r\n );\r\n break;\r\n case \"setDeviceAutomationInOutLimit\":\r\n setDeviceAutomationInOutLimit(\r\n this,\r\n productKey,\r\n deviceKey,\r\n Number(state.val)\r\n );\r\n break;\r\n }\r\n break;\r\n default:\r\n break;\r\n }\r\n } else {\r\n // The state was deleted\r\n //this.log.debug(`state ${id} deleted`);\r\n }\r\n }\r\n }\r\n}\r\n\r\nif (require.main !== module) {\r\n // Export the constructor in compact mode\r\n module.exports = (options: Partial<utils.AdapterOptions> | undefined) =>\r\n new ZendureSolarflow(options);\r\n} else {\r\n // otherwise start the instance directly\r\n (() => new ZendureSolarflow())();\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,YAAuB;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/indent */\r\n/*\r\n * Created with @iobroker/create-adapter v2.5.0\r\n */\r\n\r\n// The adapter-core module gives you access to the core ioBroker functions\r\n// you need to create an adapter\r\nimport * as utils from \"@iobroker/adapter-core\";\r\n\r\nimport { zenLogin } from \"./services/zenWebService\";\r\nimport { Job } from \"node-schedule\";\r\nimport { MqttClient } from \"mqtt\";\r\nimport { startRefreshAccessTokenTimerJob } from \"./services/jobSchedule\";\r\nimport { connectLocalMqttClient } from \"./services/mqttLocalService\";\r\nimport { IZenHaDeviceDetails } from \"./models/IZenHaDeviceDetails\";\r\nimport { connectCloudZenMqttClient } from \"./services/mqttCloudZenService\";\r\nimport { IZenHaMqttData } from \"./models/IZenHaMqttData\";\r\nimport { ZenHaDevice } from \"./models/deviceModels/ZenHaDevice\";\r\nimport { createDeviceModel } from \"./helpers/helpers\";\r\n\r\nexport class ZendureSolarflow extends utils.Adapter {\r\n public constructor(options: Partial<utils.AdapterOptions> = {}) {\r\n super({\r\n ...options,\r\n name: \"zendure-solarflow\",\r\n });\r\n this.on(\"ready\", this.onReady.bind(this));\r\n this.on(\"stateChange\", this.onStateChange.bind(this));\r\n this.on(\"unload\", this.onUnload.bind(this));\r\n }\r\n\r\n public zenHaDeviceList: ZenHaDevice[] = []; // All found devices for this instance will be in this array\r\n public mqttSettings: IZenHaMqttData | undefined = undefined;\r\n\r\n public msgCounter: number = 700000;\r\n public lastLogin: Date | undefined = undefined;\r\n\r\n public mqttClient: MqttClient | undefined = undefined;\r\n\r\n public resetValuesJob: Job | undefined = undefined;\r\n public checkStatesJob: Job | undefined = undefined;\r\n public calculationJob: Job | undefined = undefined;\r\n public refreshAccessTokenInterval: ioBroker.Interval | undefined = undefined;\r\n public retryTimeout: ioBroker.Timeout | undefined = undefined;\r\n\r\n public createdSnNumberSolarflowStates: string[] = [];\r\n\r\n /**\r\n * Is called when databases are connected and adapter received configuration.\r\n */\r\n private async onReady(): Promise<void> {\r\n await this.extendObject(\"info\", {\r\n type: \"channel\",\r\n common: {\r\n name: \"Information\",\r\n },\r\n native: {},\r\n });\r\n\r\n await this.extendObject(`info.connection`, {\r\n type: \"state\",\r\n common: {\r\n name: {\r\n de: \"Mit Zendure Cloud verbunden\",\r\n en: \"Connected to Zendure cloud\",\r\n },\r\n type: \"boolean\",\r\n desc: \"connection\",\r\n role: \"indicator.connected\",\r\n read: true,\r\n write: false,\r\n },\r\n native: {},\r\n });\r\n\r\n await this.extendObject(`info.errorMessage`, {\r\n type: \"state\",\r\n common: {\r\n name: {\r\n de: \"Fehlermeldung der Verbindung zur Zendure Cloud\",\r\n en: \"Error message from Zendure Cloud\",\r\n },\r\n type: \"string\",\r\n desc: \"errorMessage\",\r\n role: \"value\",\r\n read: true,\r\n write: false,\r\n },\r\n native: {},\r\n });\r\n\r\n this.setState(\"info.errorMessage\", \"\", true);\r\n this.setState(\"info.connection\", false, true);\r\n\r\n switch (this.config.connectionMode) {\r\n case \"authKey\":\r\n this.log.debug(\"[onReady] Using Authorization Cloud Key\");\r\n\r\n if (!this.config.authorizationCloudKey) {\r\n this.log.error(\r\n \"[zenWebService.login] authorization cloud key is missing!\"\r\n );\r\n break;\r\n }\r\n\r\n const data = await zenLogin(this);\r\n\r\n if (typeof data === \"string\" || data == undefined) {\r\n // Fehler\r\n this.setState(\"info.connection\", false, true);\r\n } else {\r\n this.mqttSettings = data.mqtt;\r\n\r\n if (!connectCloudZenMqttClient(this)) {\r\n return;\r\n }\r\n\r\n this.log.debug(\r\n `[onReady] Creating ${data.deviceList.length} devices...`\r\n );\r\n\r\n await data.deviceList.forEach(async (device: IZenHaDeviceDetails) => {\r\n // States erstellen\r\n const deviceModel = createDeviceModel(\r\n this,\r\n device.productKey,\r\n device.deviceKey,\r\n device\r\n );\r\n\r\n if (deviceModel) {\r\n this.zenHaDeviceList.push(deviceModel);\r\n }\r\n });\r\n }\r\n break;\r\n case \"local\": {\r\n this.log.debug(\"[onReady] Using local MQTT server\");\r\n\r\n connectLocalMqttClient(this);\r\n\r\n // Subscribe to 1. device from local settings\r\n if (\r\n this.config.localDevice1ProductKey &&\r\n this.config.localDevice1DeviceKey\r\n ) {\r\n // States erstellen\r\n const deviceModel = createDeviceModel(\r\n this,\r\n this.config.localDevice1ProductKey,\r\n this.config.localDevice1DeviceKey\r\n );\r\n\r\n if (deviceModel) {\r\n this.zenHaDeviceList.push(deviceModel);\r\n }\r\n }\r\n\r\n // Subscribe to 2. device from local settings\r\n if (\r\n this.config.localDevice2ProductKey &&\r\n this.config.localDevice2DeviceKey\r\n ) {\r\n // States erstellen\r\n const deviceModel = createDeviceModel(\r\n this,\r\n this.config.localDevice2ProductKey,\r\n this.config.localDevice2DeviceKey\r\n );\r\n\r\n if (deviceModel) {\r\n this.zenHaDeviceList.push(deviceModel);\r\n }\r\n }\r\n\r\n // Subscribe to 3. device from local settings\r\n if (\r\n this.config.localDevice3ProductKey &&\r\n this.config.localDevice3DeviceKey\r\n ) {\r\n // States erstellen\r\n const deviceModel = createDeviceModel(\r\n this,\r\n this.config.localDevice3ProductKey,\r\n this.config.localDevice3DeviceKey\r\n );\r\n\r\n if (deviceModel) {\r\n this.zenHaDeviceList.push(deviceModel);\r\n }\r\n }\r\n\r\n // Subscribe to 4. device from local settings\r\n if (\r\n this.config.localDevice4ProductKey &&\r\n this.config.localDevice4DeviceKey\r\n ) {\r\n // States erstellen\r\n const deviceModel = createDeviceModel(\r\n this,\r\n this.config.localDevice4ProductKey,\r\n this.config.localDevice4DeviceKey\r\n );\r\n\r\n if (deviceModel) {\r\n this.zenHaDeviceList.push(deviceModel);\r\n }\r\n }\r\n\r\n if (this.config.useRestart) {\r\n // Add interval to restart adapter every 3 hours\r\n startRefreshAccessTokenTimerJob(this);\r\n }\r\n break;\r\n }\r\n default:\r\n this.setState(\"info.connection\", false, true);\r\n this.log.error(\"[onReady] No connection mode found or mode invalid!\");\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Is called when adapter shuts down - callback has to be called under any circumstances!\r\n */\r\n private async onUnload(callback: () => void): Promise<void> {\r\n try {\r\n if (this.refreshAccessTokenInterval) {\r\n this.clearInterval(this.refreshAccessTokenInterval);\r\n }\r\n\r\n try {\r\n await this.mqttClient?.endAsync();\r\n this.log.info(\"[onUnload] MQTT client stopped!\");\r\n this.mqttClient = undefined;\r\n } catch (ex: any) {\r\n this.log.error(\"[onUnload] Error stopping MQTT client: !\" + ex.message);\r\n }\r\n\r\n this.setState(\"info.connection\", false, true);\r\n\r\n // Scheduler beenden\r\n if (this.resetValuesJob) {\r\n this.resetValuesJob.cancel();\r\n this.resetValuesJob = undefined;\r\n }\r\n\r\n if (this.checkStatesJob) {\r\n this.checkStatesJob?.cancel();\r\n this.checkStatesJob = undefined;\r\n }\r\n\r\n if (this.calculationJob) {\r\n this.calculationJob.cancel();\r\n this.calculationJob = undefined;\r\n }\r\n\r\n if (this.retryTimeout) {\r\n this.clearTimeout(this.retryTimeout);\r\n }\r\n\r\n callback();\r\n } catch (e) {\r\n callback();\r\n }\r\n }\r\n\r\n /**\r\n * Is called if a subscribed state changes\r\n */\r\n private onStateChange(\r\n id: string,\r\n state: ioBroker.State | null | undefined\r\n ): void {\r\n if (state) {\r\n // The state was changed\r\n\r\n // Read product and device key from string\r\n const splitted = id.split(\".\");\r\n const productKey = splitted[2]; // Product Key\r\n const deviceKey = splitted[3]; // Device Key\r\n const stateName1 = splitted[4]; // Folder/State Name 1 (e.g. 'control')\r\n const stateName2 = splitted[5]; // State Name, like 'setOutputLimit'\r\n\r\n const _device = this.zenHaDeviceList.find(\r\n (x) => x.productKey == productKey && x.deviceKey == deviceKey\r\n );\r\n\r\n if (!_device) {\r\n this.log.error(\r\n `[onStateChange] Device '${deviceKey}' not found in zenHaDeviceList!`\r\n );\r\n return;\r\n }\r\n\r\n // !!! Only stateChanges with ack==false are allowed to be processed.\r\n if (state.val != undefined && state.val != null && !state.ack) {\r\n switch (stateName1) {\r\n case \"control\":\r\n this.log.debug(\r\n `[onStateChange] Control state '${stateName2}' changed, new value is ${state.val}, ack = ${state.ack}!`\r\n );\r\n switch (stateName2) {\r\n case \"setOutputLimit\":\r\n _device.setOutputLimit(Number(state.val));\r\n break;\r\n case \"setInputLimit\":\r\n _device.setInputLimit(Number(state.val));\r\n break;\r\n case \"chargeLimit\":\r\n _device.setChargeLimit(Number(state.val));\r\n break;\r\n case \"dischargeLimit\":\r\n _device.setDischargeLimit(Number(state.val));\r\n break;\r\n case \"passMode\":\r\n _device.setPassMode(Number(state.val));\r\n break;\r\n case \"dcSwitch\":\r\n _device.setDcSwitch(state.val ? true : false);\r\n break;\r\n case \"acSwitch\":\r\n _device.setAcSwitch(state.val ? true : false);\r\n break;\r\n case \"acMode\":\r\n _device.setAcMode(Number(state.val));\r\n break;\r\n case \"hubState\":\r\n _device.setHubState(Number(state.val));\r\n break;\r\n case \"autoModel\":\r\n _device.setAutoModel(Number(state.val));\r\n break;\r\n case \"autoRecover\":\r\n _device.setAutoRecover(state.val ? true : false);\r\n break;\r\n case \"buzzerSwitch\":\r\n _device.setBuzzerSwitch(state.val ? true : false);\r\n break;\r\n case \"smartMode\":\r\n _device.setSmartMode(state.val ? true : false);\r\n break;\r\n case \"setDeviceAutomationInOutLimit\":\r\n _device.setDeviceAutomationInOutLimit(Number(state.val));\r\n break;\r\n }\r\n break;\r\n default:\r\n break;\r\n }\r\n } else {\r\n // The state was deleted\r\n //this.log.debug(`state ${id} deleted`);\r\n }\r\n }\r\n }\r\n}\r\n\r\nif (require.main !== module) {\r\n // Export the constructor in compact mode\r\n module.exports = (options: Partial<utils.AdapterOptions> | undefined) =>\r\n new ZendureSolarflow(options);\r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,cACF,KAAK;AACH,wBAAQ,eAAe,OAAO,MAAM,GAAG,CAAC;AACxC;AAAA,cACF,KAAK;AACH,wBAAQ,kBAAkB,OAAO,MAAM,GAAG,CAAC;AAC3C;AAAA,cACF,KAAK;AACH,wBAAQ,YAAY,OAAO,MAAM,GAAG,CAAC;AACrC;AAAA,cACF,KAAK;AACH,wBAAQ,YAAY,MAAM,MAAM,OAAO,KAAK;AAC5C;AAAA,cACF,KAAK;AACH,wBAAQ,YAAY,MAAM,MAAM,OAAO,KAAK;AAC5C;AAAA,cACF,KAAK;AACH,wBAAQ,UAAU,OAAO,MAAM,GAAG,CAAC;AACnC;AAAA,cACF,KAAK;AACH,wBAAQ,YAAY,OAAO,MAAM,GAAG,CAAC;AACrC;AAAA,cACF,KAAK;AACH,wBAAQ,aAAa,OAAO,MAAM,GAAG,CAAC;AACtC;AAAA,cACF,KAAK;AACH,wBAAQ,eAAe,MAAM,MAAM,OAAO,KAAK;AAC/C;AAAA,cACF,KAAK;AACH,wBAAQ,gBAAgB,MAAM,MAAM,OAAO,KAAK;AAChD;AAAA,cACF,KAAK;AACH,wBAAQ,aAAa,MAAM,MAAM,OAAO,KAAK;AAC7C;AAAA,cACF,KAAK;AACH,wBAAQ,8BAA8B,OAAO,MAAM,GAAG,CAAC;AACvD;AAAA,YACJ;AACA;AAAA,UACF;AACE;AAAA,QACJ;AAAA,MACF,OAAO;AAAA,MAGP;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAI,QAAQ,SAAS,QAAQ;AAE3B,SAAO,UAAU,CAAC,YAChB,IAAI,iBAAiB,OAAO;AAChC,OAAO;AAEL,GAAC,MAAM,IAAI,iBAAiB,GAAG;AACjC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/models/IDeviceAutomationPayload.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/indent */\nexport interface IDeviceAutomationPayload {\n autoModelProgram: number;\n autoModelValue: IAutoModelValue | number;\n msgType: number;\n autoModel: number;\n}\n\ninterface IAutoModelValue {\n upTime?: number;\n chargingType: number;\n pullTime?: number;\n price?: number;\n chargingPower: number;\n prices?: number[];\n outPower: number;\n freq: number;\n}\n"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/indent */\nexport interface IDeviceAutomationPayload {\n autoModelProgram: number;\n autoModelValue: IAutoModelValue | number;\n msgType: number;\n autoModel: number;\n}\n\nexport interface IHemsEpPayload {\n outputPower: number;\n chargeState: number;\n chargePower: number;\n mode: number;\n}\n\ninterface IAutoModelValue {\n upTime?: number;\n chargingType: number;\n pullTime?: number;\n price?: number;\n chargingPower: number;\n prices?: number[];\n outPower: number;\n freq: number;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -12,6 +12,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
12
12
|
return to;
|
|
13
13
|
};
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var
|
|
16
|
-
module.exports = __toCommonJS(
|
|
17
|
-
//# sourceMappingURL=
|
|
15
|
+
var IDevicePack_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(IDevicePack_exports);
|
|
17
|
+
//# sourceMappingURL=IDevicePack.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/models/IDevicePack.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/indent */\nexport interface IDevicePack {\n packSn: string;\n type: string;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -12,6 +12,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
12
12
|
return to;
|
|
13
13
|
};
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var
|
|
16
|
-
module.exports = __toCommonJS(
|
|
17
|
-
//# sourceMappingURL=
|
|
15
|
+
var IHaDeviceListData_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(IHaDeviceListData_exports);
|
|
17
|
+
//# sourceMappingURL=IHaDeviceListData.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/models/IHaDeviceListData.ts"],
|
|
4
|
+
"sourcesContent": ["import { IZenHaDeviceDetails } from \"./IZenHaDeviceDetails\";\nimport { IZenHaMqttData } from \"./IZenHaMqttData\";\n\n/* eslint-disable @typescript-eslint/indent */\nexport interface IHaDeviceListData {\n deviceList: IZenHaDeviceDetails[];\n mqtt: IZenHaMqttData;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -12,6 +12,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
12
12
|
return to;
|
|
13
13
|
};
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var
|
|
16
|
-
module.exports = __toCommonJS(
|
|
17
|
-
//# sourceMappingURL=
|
|
15
|
+
var IZenHaDeviceDetails_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(IZenHaDeviceDetails_exports);
|
|
17
|
+
//# sourceMappingURL=IZenHaDeviceDetails.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/models/IZenHaDeviceDetails.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/indent */\nexport interface IZenHaDeviceDetails {\n deviceKey: string;\n deviceName: string;\n enable: boolean;\n ip: string;\n lcnSupport: number;\n online: boolean;\n password: string;\n port: number;\n productKey: string;\n productModel: string;\n protocol: string;\n server: string;\n snNumber: string;\n username: string;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -12,6 +12,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
12
12
|
return to;
|
|
13
13
|
};
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var
|
|
16
|
-
module.exports = __toCommonJS(
|
|
17
|
-
//# sourceMappingURL=
|
|
15
|
+
var IZenHaMqttData_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(IZenHaMqttData_exports);
|
|
17
|
+
//# sourceMappingURL=IZenHaMqttData.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/models/IZenHaMqttData.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/indent */\nexport interface IZenHaMqttData {\n clientId: string;\n password: string;\n url: string;\n username: string;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|