iobroker.zendure-solarflow 1.6.7 → 1.7.0

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.
@@ -30,10 +30,13 @@ var mqttService_exports = {};
30
30
  __export(mqttService_exports, {
31
31
  addOrUpdatePackData: () => addOrUpdatePackData,
32
32
  connectMqttClient: () => connectMqttClient,
33
+ setAcSwitch: () => setAcSwitch,
33
34
  setAutoRecover: () => setAutoRecover,
34
35
  setBuzzerSwitch: () => setBuzzerSwitch,
35
36
  setChargeLimit: () => setChargeLimit,
37
+ setDcSwitch: () => setDcSwitch,
36
38
  setDischargeLimit: () => setDischargeLimit,
39
+ setInputLimit: () => setInputLimit,
37
40
  setOutputLimit: () => setOutputLimit,
38
41
  setPassMode: () => setPassMode,
39
42
  triggerFullTelemetryUpdate: () => triggerFullTelemetryUpdate
@@ -44,12 +47,12 @@ var import_adapterService = require("./adapterService");
44
47
  var import_calculationService = require("./calculationService");
45
48
  var import_jobSchedule = require("./jobSchedule");
46
49
  let adapter = void 0;
47
- const addOrUpdatePackData = async (productKey, deviceKey, packData) => {
50
+ const addOrUpdatePackData = async (productKey, deviceKey, packData, isSolarFlow) => {
48
51
  if (adapter && productKey && deviceKey) {
49
52
  await packData.forEach(async (x) => {
50
53
  if (x.sn && adapter) {
51
54
  const key = (productKey + "." + deviceKey + ".packData." + x.sn).replace(adapter.FORBIDDEN_CHARS, "");
52
- await (adapter == null ? void 0 : adapter.extendObjectAsync(key + ".sn", {
55
+ await (adapter == null ? void 0 : adapter.extendObject(key + ".sn", {
53
56
  type: "state",
54
57
  common: {
55
58
  name: {
@@ -66,7 +69,7 @@ const addOrUpdatePackData = async (productKey, deviceKey, packData) => {
66
69
  }));
67
70
  await (adapter == null ? void 0 : adapter.setStateAsync(key + ".sn", x.sn, true));
68
71
  if (x.socLevel) {
69
- await (adapter == null ? void 0 : adapter.extendObjectAsync(key + ".socLevel", {
72
+ await (adapter == null ? void 0 : adapter.extendObject(key + ".socLevel", {
70
73
  type: "state",
71
74
  common: {
72
75
  name: {
@@ -84,7 +87,7 @@ const addOrUpdatePackData = async (productKey, deviceKey, packData) => {
84
87
  await (adapter == null ? void 0 : adapter.setStateAsync(key + ".socLevel", x.socLevel, true));
85
88
  }
86
89
  if (x.maxTemp) {
87
- await (adapter == null ? void 0 : adapter.extendObjectAsync(key + ".maxTemp", {
90
+ await (adapter == null ? void 0 : adapter.extendObject(key + ".maxTemp", {
88
91
  type: "state",
89
92
  common: {
90
93
  name: {
@@ -106,7 +109,7 @@ const addOrUpdatePackData = async (productKey, deviceKey, packData) => {
106
109
  ));
107
110
  }
108
111
  if (x.minVol) {
109
- await (adapter == null ? void 0 : adapter.extendObjectAsync(key + ".minVol", {
112
+ await (adapter == null ? void 0 : adapter.extendObject(key + ".minVol", {
110
113
  type: "state",
111
114
  common: {
112
115
  name: "minVol",
@@ -121,7 +124,7 @@ const addOrUpdatePackData = async (productKey, deviceKey, packData) => {
121
124
  await (adapter == null ? void 0 : adapter.setStateAsync(key + ".minVol", x.minVol / 100, true));
122
125
  }
123
126
  if (x.maxVol) {
124
- await (adapter == null ? void 0 : adapter.extendObjectAsync(key + ".maxVol", {
127
+ await (adapter == null ? void 0 : adapter.extendObject(key + ".maxVol", {
125
128
  type: "state",
126
129
  common: {
127
130
  name: "maxVol",
@@ -133,10 +136,10 @@ const addOrUpdatePackData = async (productKey, deviceKey, packData) => {
133
136
  },
134
137
  native: {}
135
138
  }));
136
- await (adapter == null ? void 0 : adapter.setStateAsync(key + ".maxVol", x.maxVol / 100, true));
139
+ await (adapter == null ? void 0 : adapter.setState(key + ".maxVol", x.maxVol / 100, true));
137
140
  }
138
141
  if (x.totalVol) {
139
- await (adapter == null ? void 0 : adapter.extendObjectAsync(key + ".totalVol", {
142
+ await (adapter == null ? void 0 : adapter.extendObject(key + ".totalVol", {
140
143
  type: "state",
141
144
  common: {
142
145
  name: "totalVol",
@@ -149,15 +152,17 @@ const addOrUpdatePackData = async (productKey, deviceKey, packData) => {
149
152
  native: {}
150
153
  }));
151
154
  const totalVol = x.totalVol / 100;
152
- await (adapter == null ? void 0 : adapter.setStateAsync(key + ".totalVol", totalVol, true));
153
- (0, import_adapterService.checkVoltage)(adapter, productKey, deviceKey, totalVol);
155
+ await (adapter == null ? void 0 : adapter.setState(key + ".totalVol", totalVol, true));
156
+ if (isSolarFlow) {
157
+ (0, import_adapterService.checkVoltage)(adapter, productKey, deviceKey, totalVol);
158
+ }
154
159
  }
155
160
  }
156
161
  });
157
162
  }
158
163
  };
159
164
  const onMessage = async (topic, message) => {
160
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia;
165
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya;
161
166
  if (adapter) {
162
167
  const topicSplitted = topic.split("/");
163
168
  const productKey = topicSplitted[1];
@@ -169,6 +174,13 @@ const onMessage = async (topic, message) => {
169
174
  const txt = message.toString();
170
175
  adapter.log.error(`[JSON PARSE ERROR] ${txt}`);
171
176
  }
177
+ let isSolarFlow = false;
178
+ const productName = await adapter.getStateAsync(
179
+ `${productKey}.${deviceKey}.productName`
180
+ );
181
+ if (((_a = productName == null ? void 0 : productName.val) == null ? void 0 : _a.toString().toLowerCase().includes("solarflow")) || ((_b = productName == null ? void 0 : productName.val) == null ? void 0 : _b.toString().toLowerCase().includes("hyper"))) {
182
+ isSolarFlow = true;
183
+ }
172
184
  (0, import_adapterService.updateSolarFlowState)(
173
185
  adapter,
174
186
  productKey,
@@ -176,7 +188,7 @@ const onMessage = async (topic, message) => {
176
188
  "lastUpdate",
177
189
  (/* @__PURE__ */ new Date()).getTime()
178
190
  );
179
- if (((_a = obj.properties) == null ? void 0 : _a.electricLevel) != null && ((_b = obj.properties) == null ? void 0 : _b.electricLevel) != void 0) {
191
+ if (((_c = obj.properties) == null ? void 0 : _c.electricLevel) != null && ((_d = obj.properties) == null ? void 0 : _d.electricLevel) != void 0) {
180
192
  (0, import_adapterService.updateSolarFlowState)(
181
193
  adapter,
182
194
  productKey,
@@ -184,37 +196,37 @@ const onMessage = async (topic, message) => {
184
196
  "electricLevel",
185
197
  obj.properties.electricLevel
186
198
  );
187
- if ((adapter == null ? void 0 : adapter.config.useCalculation) && obj.properties.electricLevel == 100) {
199
+ if ((adapter == null ? void 0 : adapter.config.useCalculation) && obj.properties.electricLevel == 100 && isSolarFlow) {
188
200
  (0, import_calculationService.setEnergyWhMax)(adapter, productKey, deviceKey);
189
201
  }
190
202
  const minSoc = await (adapter == null ? void 0 : adapter.getStateAsync(
191
203
  `${productKey}.${deviceKey}.minSoc`
192
204
  ));
193
- if ((adapter == null ? void 0 : adapter.config.useCalculation) && minSoc && minSoc.val && obj.properties.electricLevel <= Number(minSoc.val)) {
205
+ if ((adapter == null ? void 0 : adapter.config.useCalculation) && minSoc && minSoc.val && obj.properties.electricLevel <= Number(minSoc.val) && isSolarFlow) {
194
206
  (0, import_calculationService.setSocToZero)(adapter, productKey, deviceKey);
195
207
  }
196
208
  }
197
- if (((_c = obj.properties) == null ? void 0 : _c.packState) != null && ((_d = obj.properties) == null ? void 0 : _d.packState) != void 0) {
198
- const value = ((_e = obj.properties) == null ? void 0 : _e.packState) == 0 ? "Idle" : ((_f = obj.properties) == null ? void 0 : _f.packState) == 1 ? "Charging" : ((_g = obj.properties) == null ? void 0 : _g.packState) == 2 ? "Discharging" : "Unknown";
209
+ if (((_e = obj.properties) == null ? void 0 : _e.packState) != null && ((_f = obj.properties) == null ? void 0 : _f.packState) != void 0) {
210
+ const value = ((_g = obj.properties) == null ? void 0 : _g.packState) == 0 ? "Idle" : ((_h = obj.properties) == null ? void 0 : _h.packState) == 1 ? "Charging" : ((_i = obj.properties) == null ? void 0 : _i.packState) == 2 ? "Discharging" : "Unknown";
199
211
  (0, import_adapterService.updateSolarFlowState)(adapter, productKey, deviceKey, "packState", value);
200
212
  }
201
- if (((_h = obj.properties) == null ? void 0 : _h.passMode) != null && ((_i = obj.properties) == null ? void 0 : _i.passMode) != void 0) {
202
- const value = ((_j = obj.properties) == null ? void 0 : _j.passMode) == 0 ? "Automatic" : ((_k = obj.properties) == null ? void 0 : _k.passMode) == 1 ? "Always off" : ((_l = obj.properties) == null ? void 0 : _l.passMode) == 2 ? "Always on" : "Unknown";
213
+ if (((_j = obj.properties) == null ? void 0 : _j.passMode) != null && ((_k = obj.properties) == null ? void 0 : _k.passMode) != void 0) {
214
+ const value = ((_l = obj.properties) == null ? void 0 : _l.passMode) == 0 ? "Automatic" : ((_m = obj.properties) == null ? void 0 : _m.passMode) == 1 ? "Always off" : ((_n = obj.properties) == null ? void 0 : _n.passMode) == 2 ? "Always on" : "Unknown";
203
215
  (0, import_adapterService.updateSolarFlowState)(adapter, productKey, deviceKey, "passMode", value);
204
216
  (0, import_adapterService.updateSolarFlowControlState)(
205
217
  adapter,
206
218
  productKey,
207
219
  deviceKey,
208
220
  "passMode",
209
- (_m = obj.properties) == null ? void 0 : _m.passMode
221
+ (_o = obj.properties) == null ? void 0 : _o.passMode
210
222
  );
211
223
  }
212
- if (((_n = obj.properties) == null ? void 0 : _n.pass) != null && ((_o = obj.properties) == null ? void 0 : _o.pass) != void 0) {
213
- const value = ((_p = obj.properties) == null ? void 0 : _p.pass) == 0 ? false : true;
224
+ if (((_p = obj.properties) == null ? void 0 : _p.pass) != null && ((_q = obj.properties) == null ? void 0 : _q.pass) != void 0) {
225
+ const value = ((_r = obj.properties) == null ? void 0 : _r.pass) == 0 ? false : true;
214
226
  (0, import_adapterService.updateSolarFlowState)(adapter, productKey, deviceKey, "pass", value);
215
227
  }
216
- if (((_q = obj.properties) == null ? void 0 : _q.autoRecover) != null && ((_r = obj.properties) == null ? void 0 : _r.autoRecover) != void 0) {
217
- const value = ((_s = obj.properties) == null ? void 0 : _s.autoRecover) == 0 ? false : true;
228
+ if (((_s = obj.properties) == null ? void 0 : _s.autoRecover) != null && ((_t = obj.properties) == null ? void 0 : _t.autoRecover) != void 0) {
229
+ const value = ((_u = obj.properties) == null ? void 0 : _u.autoRecover) == 0 ? false : true;
218
230
  (0, import_adapterService.updateSolarFlowState)(
219
231
  adapter,
220
232
  productKey,
@@ -230,7 +242,7 @@ const onMessage = async (topic, message) => {
230
242
  value
231
243
  );
232
244
  }
233
- if (((_t = obj.properties) == null ? void 0 : _t.outputHomePower) != null && ((_u = obj.properties) == null ? void 0 : _u.outputHomePower) != void 0) {
245
+ if (((_v = obj.properties) == null ? void 0 : _v.outputHomePower) != null && ((_w = obj.properties) == null ? void 0 : _w.outputHomePower) != void 0) {
234
246
  (0, import_adapterService.updateSolarFlowState)(
235
247
  adapter,
236
248
  productKey,
@@ -239,7 +251,7 @@ const onMessage = async (topic, message) => {
239
251
  obj.properties.outputHomePower
240
252
  );
241
253
  }
242
- if (((_v = obj.properties) == null ? void 0 : _v.outputLimit) != null && ((_w = obj.properties) == null ? void 0 : _w.outputLimit) != void 0) {
254
+ if (((_x = obj.properties) == null ? void 0 : _x.outputLimit) != null && ((_y = obj.properties) == null ? void 0 : _y.outputLimit) != void 0) {
243
255
  (0, import_adapterService.updateSolarFlowState)(
244
256
  adapter,
245
257
  productKey,
@@ -255,8 +267,8 @@ const onMessage = async (topic, message) => {
255
267
  obj.properties.outputLimit
256
268
  );
257
269
  }
258
- if (((_x = obj.properties) == null ? void 0 : _x.buzzerSwitch) != null && ((_y = obj.properties) == null ? void 0 : _y.buzzerSwitch) != void 0) {
259
- const value = ((_z = obj.properties) == null ? void 0 : _z.buzzerSwitch) == 0 ? false : true;
270
+ if (((_z = obj.properties) == null ? void 0 : _z.buzzerSwitch) != null && ((_A = obj.properties) == null ? void 0 : _A.buzzerSwitch) != void 0) {
271
+ const value = ((_B = obj.properties) == null ? void 0 : _B.buzzerSwitch) == 0 ? false : true;
260
272
  (0, import_adapterService.updateSolarFlowState)(
261
273
  adapter,
262
274
  productKey,
@@ -272,7 +284,7 @@ const onMessage = async (topic, message) => {
272
284
  value
273
285
  );
274
286
  }
275
- if (((_A = obj.properties) == null ? void 0 : _A.outputPackPower) != null && ((_B = obj.properties) == null ? void 0 : _B.outputPackPower) != void 0) {
287
+ if (((_C = obj.properties) == null ? void 0 : _C.outputPackPower) != null && ((_D = obj.properties) == null ? void 0 : _D.outputPackPower) != void 0) {
276
288
  (0, import_adapterService.updateSolarFlowState)(
277
289
  adapter,
278
290
  productKey,
@@ -282,7 +294,7 @@ const onMessage = async (topic, message) => {
282
294
  );
283
295
  (0, import_adapterService.updateSolarFlowState)(adapter, productKey, deviceKey, "packInputPower", 0);
284
296
  }
285
- if (((_C = obj.properties) == null ? void 0 : _C.packInputPower) != null && ((_D = obj.properties) == null ? void 0 : _D.packInputPower) != void 0) {
297
+ if (((_E = obj.properties) == null ? void 0 : _E.packInputPower) != null && ((_F = obj.properties) == null ? void 0 : _F.packInputPower) != void 0) {
286
298
  let standbyUsage = 0;
287
299
  const solarInputPower = await (adapter == null ? void 0 : adapter.getStateAsync(
288
300
  `${productKey}.${deviceKey}.solarInputPower`
@@ -305,7 +317,7 @@ const onMessage = async (topic, message) => {
305
317
  0
306
318
  );
307
319
  }
308
- if (((_E = obj.properties) == null ? void 0 : _E.solarInputPower) != null && ((_F = obj.properties) == null ? void 0 : _F.solarInputPower) != void 0) {
320
+ if (((_G = obj.properties) == null ? void 0 : _G.solarInputPower) != null && ((_H = obj.properties) == null ? void 0 : _H.solarInputPower) != void 0) {
309
321
  (0, import_adapterService.updateSolarFlowState)(
310
322
  adapter,
311
323
  productKey,
@@ -314,7 +326,7 @@ const onMessage = async (topic, message) => {
314
326
  obj.properties.solarInputPower
315
327
  );
316
328
  }
317
- if (((_G = obj.properties) == null ? void 0 : _G.pvPower1) != null && ((_H = obj.properties) == null ? void 0 : _H.pvPower1) != void 0) {
329
+ if (((_I = obj.properties) == null ? void 0 : _I.pvPower1) != null && ((_J = obj.properties) == null ? void 0 : _J.pvPower1) != void 0) {
318
330
  (0, import_adapterService.updateSolarFlowState)(
319
331
  adapter,
320
332
  productKey,
@@ -324,7 +336,7 @@ const onMessage = async (topic, message) => {
324
336
  obj.properties.pvPower1
325
337
  );
326
338
  }
327
- if (((_I = obj.properties) == null ? void 0 : _I.pvPower2) != null && ((_J = obj.properties) == null ? void 0 : _J.pvPower2) != void 0) {
339
+ if (((_K = obj.properties) == null ? void 0 : _K.pvPower2) != null && ((_L = obj.properties) == null ? void 0 : _L.pvPower2) != void 0) {
328
340
  (0, import_adapterService.updateSolarFlowState)(
329
341
  adapter,
330
342
  productKey,
@@ -334,7 +346,7 @@ const onMessage = async (topic, message) => {
334
346
  obj.properties.pvPower2
335
347
  );
336
348
  }
337
- if (((_K = obj.properties) == null ? void 0 : _K.solarPower1) != null && ((_L = obj.properties) == null ? void 0 : _L.solarPower1) != void 0) {
349
+ if (((_M = obj.properties) == null ? void 0 : _M.solarPower1) != null && ((_N = obj.properties) == null ? void 0 : _N.solarPower1) != void 0) {
338
350
  (0, import_adapterService.updateSolarFlowState)(
339
351
  adapter,
340
352
  productKey,
@@ -343,7 +355,7 @@ const onMessage = async (topic, message) => {
343
355
  obj.properties.solarPower1
344
356
  );
345
357
  }
346
- if (((_M = obj.properties) == null ? void 0 : _M.solarPower2) != null && ((_N = obj.properties) == null ? void 0 : _N.solarPower2) != void 0) {
358
+ if (((_O = obj.properties) == null ? void 0 : _O.solarPower2) != null && ((_P = obj.properties) == null ? void 0 : _P.solarPower2) != void 0) {
347
359
  (0, import_adapterService.updateSolarFlowState)(
348
360
  adapter,
349
361
  productKey,
@@ -352,7 +364,7 @@ const onMessage = async (topic, message) => {
352
364
  obj.properties.solarPower2
353
365
  );
354
366
  }
355
- if (((_O = obj.properties) == null ? void 0 : _O.remainOutTime) != null && ((_P = obj.properties) == null ? void 0 : _P.remainOutTime) != void 0) {
367
+ if (((_Q = obj.properties) == null ? void 0 : _Q.remainOutTime) != null && ((_R = obj.properties) == null ? void 0 : _R.remainOutTime) != void 0) {
356
368
  (0, import_adapterService.updateSolarFlowState)(
357
369
  adapter,
358
370
  productKey,
@@ -361,7 +373,7 @@ const onMessage = async (topic, message) => {
361
373
  obj.properties.remainOutTime
362
374
  );
363
375
  }
364
- if (((_Q = obj.properties) == null ? void 0 : _Q.remainInputTime) != null && ((_R = obj.properties) == null ? void 0 : _R.remainInputTime) != void 0) {
376
+ if (((_S = obj.properties) == null ? void 0 : _S.remainInputTime) != null && ((_T = obj.properties) == null ? void 0 : _T.remainInputTime) != void 0) {
365
377
  (0, import_adapterService.updateSolarFlowState)(
366
378
  adapter,
367
379
  productKey,
@@ -370,7 +382,7 @@ const onMessage = async (topic, message) => {
370
382
  obj.properties.remainInputTime
371
383
  );
372
384
  }
373
- if (((_S = obj.properties) == null ? void 0 : _S.socSet) != null && ((_T = obj.properties) == null ? void 0 : _T.socSet) != void 0) {
385
+ if (((_U = obj.properties) == null ? void 0 : _U.socSet) != null && ((_V = obj.properties) == null ? void 0 : _V.socSet) != void 0) {
374
386
  (0, import_adapterService.updateSolarFlowState)(
375
387
  adapter,
376
388
  productKey,
@@ -386,7 +398,7 @@ const onMessage = async (topic, message) => {
386
398
  Number(obj.properties.socSet) / 10
387
399
  );
388
400
  }
389
- if (((_U = obj.properties) == null ? void 0 : _U.minSoc) != null && ((_V = obj.properties) == null ? void 0 : _V.minSoc) != void 0) {
401
+ if (((_W = obj.properties) == null ? void 0 : _W.minSoc) != null && ((_X = obj.properties) == null ? void 0 : _X.minSoc) != void 0) {
390
402
  (0, import_adapterService.updateSolarFlowState)(
391
403
  adapter,
392
404
  productKey,
@@ -402,11 +414,55 @@ const onMessage = async (topic, message) => {
402
414
  Number(obj.properties.minSoc) / 10
403
415
  );
404
416
  }
405
- if (((_W = obj.properties) == null ? void 0 : _W.pvBrand) != null && ((_X = obj.properties) == null ? void 0 : _X.pvBrand) != void 0) {
406
- const value = ((_Y = obj.properties) == null ? void 0 : _Y.pvBrand) == 0 ? "Others" : ((_Z = obj.properties) == null ? void 0 : _Z.pvBrand) == 1 ? "Hoymiles" : ((__ = obj.properties) == null ? void 0 : __.pvBrand) == 2 ? "Enphase" : ((_$ = obj.properties) == null ? void 0 : _$.pvBrand) == 3 ? "APSystems" : ((_aa = obj.properties) == null ? void 0 : _aa.pvBrand) == 4 ? "Anker" : ((_ba = obj.properties) == null ? void 0 : _ba.pvBrand) == 5 ? "Deye" : ((_ca = obj.properties) == null ? void 0 : _ca.pvBrand) == 6 ? "Bosswerk" : "Unknown";
417
+ if (((_Y = obj.properties) == null ? void 0 : _Y.inputLimit) != null && ((_Z = obj.properties) == null ? void 0 : _Z.inputLimit) != void 0) {
418
+ (0, import_adapterService.updateSolarFlowState)(
419
+ adapter,
420
+ productKey,
421
+ deviceKey,
422
+ "inputLimit",
423
+ obj.properties.inputLimit
424
+ );
425
+ }
426
+ if (((__ = obj.properties) == null ? void 0 : __.gridInputPower) != null && ((_$ = obj.properties) == null ? void 0 : _$.gridInputPower) != void 0) {
427
+ (0, import_adapterService.updateSolarFlowState)(
428
+ adapter,
429
+ productKey,
430
+ deviceKey,
431
+ "gridInputPower",
432
+ obj.properties.gridInputPower
433
+ );
434
+ }
435
+ if (((_aa = obj.properties) == null ? void 0 : _aa.acOutputPower) != null && ((_ba = obj.properties) == null ? void 0 : _ba.acOutputPower) != void 0) {
436
+ (0, import_adapterService.updateSolarFlowState)(
437
+ adapter,
438
+ productKey,
439
+ deviceKey,
440
+ "acOutputPower",
441
+ obj.properties.acOutputPower
442
+ );
443
+ }
444
+ if (((_ca = obj.properties) == null ? void 0 : _ca.acSwitch) != null && ((_da = obj.properties) == null ? void 0 : _da.acSwitch) != void 0) {
445
+ const value = ((_ea = obj.properties) == null ? void 0 : _ea.acSwitch) == 0 ? false : true;
446
+ (0, import_adapterService.updateSolarFlowState)(adapter, productKey, deviceKey, "acSwitch", value);
447
+ }
448
+ if (((_fa = obj.properties) == null ? void 0 : _fa.dcSwitch) != null && ((_ga = obj.properties) == null ? void 0 : _ga.dcSwitch) != void 0) {
449
+ const value = ((_ha = obj.properties) == null ? void 0 : _ha.dcSwitch) == 0 ? false : true;
450
+ (0, import_adapterService.updateSolarFlowState)(adapter, productKey, deviceKey, "dcSwitch", value);
451
+ }
452
+ if (((_ia = obj.properties) == null ? void 0 : _ia.dcOutputPower) != null && ((_ja = obj.properties) == null ? void 0 : _ja.dcOutputPower) != void 0) {
453
+ (0, import_adapterService.updateSolarFlowState)(
454
+ adapter,
455
+ productKey,
456
+ deviceKey,
457
+ "dcOutputPower",
458
+ obj.properties.dcOutputPower
459
+ );
460
+ }
461
+ if (((_ka = obj.properties) == null ? void 0 : _ka.pvBrand) != null && ((_la = obj.properties) == null ? void 0 : _la.pvBrand) != void 0) {
462
+ const value = ((_ma = obj.properties) == null ? void 0 : _ma.pvBrand) == 0 ? "Others" : ((_na = obj.properties) == null ? void 0 : _na.pvBrand) == 1 ? "Hoymiles" : ((_oa = obj.properties) == null ? void 0 : _oa.pvBrand) == 2 ? "Enphase" : ((_pa = obj.properties) == null ? void 0 : _pa.pvBrand) == 3 ? "APSystems" : ((_qa = obj.properties) == null ? void 0 : _qa.pvBrand) == 4 ? "Anker" : ((_ra = obj.properties) == null ? void 0 : _ra.pvBrand) == 5 ? "Deye" : ((_sa = obj.properties) == null ? void 0 : _sa.pvBrand) == 6 ? "Bosswerk" : "Unknown";
407
463
  (0, import_adapterService.updateSolarFlowState)(adapter, productKey, deviceKey, "pvBrand", value);
408
464
  }
409
- if (((_da = obj.properties) == null ? void 0 : _da.inverseMaxPower) != null && ((_ea = obj.properties) == null ? void 0 : _ea.inverseMaxPower) != void 0) {
465
+ if (((_ta = obj.properties) == null ? void 0 : _ta.inverseMaxPower) != null && ((_ua = obj.properties) == null ? void 0 : _ua.inverseMaxPower) != void 0) {
410
466
  (0, import_adapterService.updateSolarFlowState)(
411
467
  adapter,
412
468
  productKey,
@@ -415,7 +471,7 @@ const onMessage = async (topic, message) => {
415
471
  obj.properties.inverseMaxPower
416
472
  );
417
473
  }
418
- if (((_fa = obj.properties) == null ? void 0 : _fa.wifiState) != null && ((_ga = obj.properties) == null ? void 0 : _ga.wifiState) != void 0) {
474
+ if (((_va = obj.properties) == null ? void 0 : _va.wifiState) != null && ((_wa = obj.properties) == null ? void 0 : _wa.wifiState) != void 0) {
419
475
  (0, import_adapterService.updateSolarFlowState)(
420
476
  adapter,
421
477
  productKey,
@@ -424,7 +480,7 @@ const onMessage = async (topic, message) => {
424
480
  obj.properties.wifiState == 1 ? "Connected" : "Disconnected"
425
481
  );
426
482
  }
427
- if (((_ha = obj.properties) == null ? void 0 : _ha.hubState) != null && ((_ia = obj.properties) == null ? void 0 : _ia.hubState) != void 0) {
483
+ if (((_xa = obj.properties) == null ? void 0 : _xa.hubState) != null && ((_ya = obj.properties) == null ? void 0 : _ya.hubState) != void 0) {
428
484
  (0, import_adapterService.updateSolarFlowState)(
429
485
  adapter,
430
486
  productKey,
@@ -434,7 +490,7 @@ const onMessage = async (topic, message) => {
434
490
  );
435
491
  }
436
492
  if (obj.packData) {
437
- addOrUpdatePackData(productKey, deviceKey, obj.packData);
493
+ addOrUpdatePackData(productKey, deviceKey, obj.packData, isSolarFlow);
438
494
  }
439
495
  }
440
496
  };
@@ -500,7 +556,25 @@ const setOutputLimit = async (adapter2, productKey, deviceKey, limit) => {
500
556
  const topic = `iot/${productKey}/${deviceKey}/properties/write`;
501
557
  const outputlimit = { properties: { outputLimit: limit } };
502
558
  (_b = adapter2.mqttClient) == null ? void 0 : _b.publish(topic, JSON.stringify(outputlimit));
503
- } else {
559
+ }
560
+ }
561
+ }
562
+ };
563
+ const setInputLimit = async (adapter2, productKey, deviceKey, limit) => {
564
+ var _a, _b;
565
+ if (adapter2.mqttClient && productKey && deviceKey) {
566
+ const currentLimit = (_a = await adapter2.getStateAsync(productKey + "." + deviceKey + ".inputLimit")) == null ? void 0 : _a.val;
567
+ limit = Math.ceil(limit / 100) * 100;
568
+ if (limit < 0) {
569
+ limit = 0;
570
+ } else if (limit > 900) {
571
+ limit = 900;
572
+ }
573
+ if (currentLimit != null && currentLimit != void 0) {
574
+ if (currentLimit != limit) {
575
+ const topic = `iot/${productKey}/${deviceKey}/properties/write`;
576
+ const inputLimitContent = { properties: { inputLimit: limit } };
577
+ (_b = adapter2.mqttClient) == null ? void 0 : _b.publish(topic, JSON.stringify(inputLimitContent));
504
578
  }
505
579
  }
506
580
  }
@@ -551,6 +625,32 @@ const setAutoRecover = async (adapter2, productKey, deviceKey, autoRecover) => {
551
625
  (_a = adapter2.mqttClient) == null ? void 0 : _a.publish(topic, JSON.stringify(setAutoRecoverContent));
552
626
  }
553
627
  };
628
+ const setDcSwitch = async (adapter2, productKey, deviceKey, dcSwitch) => {
629
+ var _a;
630
+ if (adapter2.mqttClient && productKey && deviceKey) {
631
+ const topic = `iot/${productKey}/${deviceKey}/properties/write`;
632
+ const setDcSwitchContent = {
633
+ properties: { dcSwitch: dcSwitch ? 1 : 0 }
634
+ };
635
+ adapter2.log.debug(
636
+ `[setPassMode] Set DC Switch for device ${deviceKey} to ${dcSwitch}!`
637
+ );
638
+ (_a = adapter2.mqttClient) == null ? void 0 : _a.publish(topic, JSON.stringify(setDcSwitchContent));
639
+ }
640
+ };
641
+ const setAcSwitch = async (adapter2, productKey, deviceKey, dcSwitch) => {
642
+ var _a;
643
+ if (adapter2.mqttClient && productKey && deviceKey) {
644
+ const topic = `iot/${productKey}/${deviceKey}/properties/write`;
645
+ const setDcSwitchContent = {
646
+ properties: { dcSwitch: dcSwitch ? 1 : 0 }
647
+ };
648
+ adapter2.log.debug(
649
+ `[setPassMode] Set AC Switch for device ${deviceKey} to ${dcSwitch}!`
650
+ );
651
+ (_a = adapter2.mqttClient) == null ? void 0 : _a.publish(topic, JSON.stringify(setDcSwitchContent));
652
+ }
653
+ };
554
654
  const onConnected = () => {
555
655
  adapter == null ? void 0 : adapter.log.info("[onConnected] Connected with MQTT!");
556
656
  };
@@ -635,10 +735,13 @@ const connectMqttClient = (_adapter) => {
635
735
  0 && (module.exports = {
636
736
  addOrUpdatePackData,
637
737
  connectMqttClient,
738
+ setAcSwitch,
638
739
  setAutoRecover,
639
740
  setBuzzerSwitch,
640
741
  setChargeLimit,
742
+ setDcSwitch,
641
743
  setDischargeLimit,
744
+ setInputLimit,
642
745
  setOutputLimit,
643
746
  setPassMode,
644
747
  triggerFullTelemetryUpdate