iobroker.zendure-solarflow 1.2.5 → 1.2.7
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 +14 -1
- package/admin/build/index.js.map +2 -2
- package/build/helpers/createCalculationStates.js +1 -1
- package/build/helpers/createCalculationStates.js.map +1 -1
- package/build/helpers/createControlStates.js +62 -0
- package/build/helpers/createControlStates.js.map +2 -2
- package/build/helpers/createSolarFlowStates.js +52 -1
- package/build/helpers/createSolarFlowStates.js.map +2 -2
- package/build/main.js +43 -4
- package/build/main.js.map +2 -2
- package/build/services/adapterService.js +11 -11
- package/build/services/adapterService.js.map +2 -2
- package/build/services/calculationService.js +58 -27
- package/build/services/calculationService.js.map +2 -2
- package/build/services/jobSchedule.js +2 -2
- package/build/services/jobSchedule.js.map +2 -2
- package/build/services/mqttService.js +231 -175
- package/build/services/mqttService.js.map +2 -2
- package/io-package.json +27 -27
- package/package.json +1 -1
|
@@ -30,144 +30,133 @@ var mqttService_exports = {};
|
|
|
30
30
|
__export(mqttService_exports, {
|
|
31
31
|
addOrUpdatePackData: () => addOrUpdatePackData,
|
|
32
32
|
connectMqttClient: () => connectMqttClient,
|
|
33
|
+
setAutoRecover: () => setAutoRecover,
|
|
34
|
+
setBuzzerSwitch: () => setBuzzerSwitch,
|
|
33
35
|
setChargeLimit: () => setChargeLimit,
|
|
34
36
|
setDischargeLimit: () => setDischargeLimit,
|
|
35
|
-
setOutputLimit: () => setOutputLimit
|
|
37
|
+
setOutputLimit: () => setOutputLimit,
|
|
38
|
+
setPassMode: () => setPassMode,
|
|
39
|
+
triggerFullTelemetryUpdate: () => triggerFullTelemetryUpdate
|
|
36
40
|
});
|
|
37
41
|
module.exports = __toCommonJS(mqttService_exports);
|
|
38
42
|
var mqtt = __toESM(require("mqtt"));
|
|
39
43
|
var import_adapterService = require("./adapterService");
|
|
40
|
-
var import_timeHelper = require("../helpers/timeHelper");
|
|
41
44
|
var import_calculationService = require("./calculationService");
|
|
42
45
|
let adapter = void 0;
|
|
43
|
-
const
|
|
44
|
-
adapter
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const onSubscribe = (error) => {
|
|
50
|
-
if (error) {
|
|
51
|
-
adapter == null ? void 0 : adapter.log.error("Subscription to MQTT failed! Error: " + error);
|
|
52
|
-
} else {
|
|
53
|
-
adapter == null ? void 0 : adapter.log.debug("Subscription successful!");
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const addOrUpdatePackData = async (adapter2, productKey, deviceKey, packData) => {
|
|
57
|
-
await packData.forEach(async (x) => {
|
|
58
|
-
if (x.sn) {
|
|
59
|
-
const key = (productKey + "." + deviceKey + ".packData." + x.sn).replace(
|
|
60
|
-
adapter2.FORBIDDEN_CHARS,
|
|
61
|
-
""
|
|
62
|
-
);
|
|
63
|
-
await (adapter2 == null ? void 0 : adapter2.extendObjectAsync(key + ".sn", {
|
|
64
|
-
type: "state",
|
|
65
|
-
common: {
|
|
66
|
-
name: {
|
|
67
|
-
de: "Seriennummer",
|
|
68
|
-
en: "Serial id"
|
|
69
|
-
},
|
|
70
|
-
type: "string",
|
|
71
|
-
desc: "Serial ID",
|
|
72
|
-
role: "value",
|
|
73
|
-
read: true,
|
|
74
|
-
write: false
|
|
75
|
-
},
|
|
76
|
-
native: {}
|
|
77
|
-
}));
|
|
78
|
-
await (adapter2 == null ? void 0 : adapter2.setStateAsync(key + ".sn", x.sn, true));
|
|
79
|
-
if (x.socLevel) {
|
|
80
|
-
await (adapter2 == null ? void 0 : adapter2.extendObjectAsync(key + ".socLevel", {
|
|
46
|
+
const addOrUpdatePackData = async (productKey, deviceKey, packData) => {
|
|
47
|
+
if (adapter && productKey && deviceKey) {
|
|
48
|
+
await packData.forEach(async (x) => {
|
|
49
|
+
if (x.sn && adapter) {
|
|
50
|
+
const key = (productKey + "." + deviceKey + ".packData." + x.sn).replace(adapter.FORBIDDEN_CHARS, "");
|
|
51
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(key + ".sn", {
|
|
81
52
|
type: "state",
|
|
82
53
|
common: {
|
|
83
54
|
name: {
|
|
84
|
-
de: "
|
|
85
|
-
en: "
|
|
55
|
+
de: "Seriennummer",
|
|
56
|
+
en: "Serial id"
|
|
86
57
|
},
|
|
87
|
-
type: "
|
|
88
|
-
desc: "
|
|
58
|
+
type: "string",
|
|
59
|
+
desc: "Serial ID",
|
|
89
60
|
role: "value",
|
|
90
61
|
read: true,
|
|
91
62
|
write: false
|
|
92
63
|
},
|
|
93
64
|
native: {}
|
|
94
65
|
}));
|
|
95
|
-
await (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
66
|
+
await (adapter == null ? void 0 : adapter.setStateAsync(key + ".sn", x.sn, true));
|
|
67
|
+
if (x.socLevel) {
|
|
68
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(key + ".socLevel", {
|
|
69
|
+
type: "state",
|
|
70
|
+
common: {
|
|
71
|
+
name: {
|
|
72
|
+
de: "SOC der Batterie",
|
|
73
|
+
en: "soc of battery"
|
|
74
|
+
},
|
|
75
|
+
type: "number",
|
|
76
|
+
desc: "SOC Level",
|
|
77
|
+
role: "value",
|
|
78
|
+
read: true,
|
|
79
|
+
write: false
|
|
104
80
|
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
81
|
+
native: {}
|
|
82
|
+
}));
|
|
83
|
+
await (adapter == null ? void 0 : adapter.setStateAsync(key + ".socLevel", x.socLevel, true));
|
|
84
|
+
}
|
|
85
|
+
if (x.maxTemp) {
|
|
86
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(key + ".maxTemp", {
|
|
87
|
+
type: "state",
|
|
88
|
+
common: {
|
|
89
|
+
name: {
|
|
90
|
+
de: "Max. Temperatur der Batterie",
|
|
91
|
+
en: "max temp. of battery"
|
|
92
|
+
},
|
|
93
|
+
type: "number",
|
|
94
|
+
desc: "Max. Temp",
|
|
95
|
+
role: "value",
|
|
96
|
+
read: true,
|
|
97
|
+
write: false
|
|
98
|
+
},
|
|
99
|
+
native: {}
|
|
100
|
+
}));
|
|
101
|
+
await (adapter == null ? void 0 : adapter.setStateAsync(
|
|
102
|
+
key + ".maxTemp",
|
|
103
|
+
x.maxTemp / 10 - 273.15,
|
|
104
|
+
true
|
|
105
|
+
));
|
|
106
|
+
}
|
|
107
|
+
if (x.minVol) {
|
|
108
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(key + ".minVol", {
|
|
109
|
+
type: "state",
|
|
110
|
+
common: {
|
|
111
|
+
name: "minVol",
|
|
112
|
+
type: "number",
|
|
113
|
+
desc: "minVol",
|
|
114
|
+
role: "value",
|
|
115
|
+
read: true,
|
|
116
|
+
write: false
|
|
117
|
+
},
|
|
118
|
+
native: {}
|
|
119
|
+
}));
|
|
120
|
+
await (adapter == null ? void 0 : adapter.setStateAsync(key + ".minVol", x.minVol / 100, true));
|
|
121
|
+
}
|
|
122
|
+
if (x.maxVol) {
|
|
123
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(key + ".maxVol", {
|
|
124
|
+
type: "state",
|
|
125
|
+
common: {
|
|
126
|
+
name: "maxVol",
|
|
127
|
+
type: "number",
|
|
128
|
+
desc: "maxVol",
|
|
129
|
+
role: "value",
|
|
130
|
+
read: true,
|
|
131
|
+
write: false
|
|
132
|
+
},
|
|
133
|
+
native: {}
|
|
134
|
+
}));
|
|
135
|
+
await (adapter == null ? void 0 : adapter.setStateAsync(key + ".maxVol", x.maxVol / 100, true));
|
|
136
|
+
}
|
|
137
|
+
if (x.totalVol) {
|
|
138
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(key + ".totalVol", {
|
|
139
|
+
type: "state",
|
|
140
|
+
common: {
|
|
141
|
+
name: "totalVol",
|
|
142
|
+
type: "number",
|
|
143
|
+
desc: "totalVol",
|
|
144
|
+
role: "value",
|
|
145
|
+
read: true,
|
|
146
|
+
write: false
|
|
147
|
+
},
|
|
148
|
+
native: {}
|
|
149
|
+
}));
|
|
150
|
+
const totalVol = x.totalVol / 100;
|
|
151
|
+
await (adapter == null ? void 0 : adapter.setStateAsync(key + ".totalVol", totalVol, true));
|
|
152
|
+
(0, import_adapterService.checkVoltage)(adapter, productKey, deviceKey, totalVol);
|
|
153
|
+
}
|
|
165
154
|
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
168
157
|
};
|
|
169
158
|
const onMessage = async (topic, message) => {
|
|
170
|
-
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;
|
|
159
|
+
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;
|
|
171
160
|
if (adapter) {
|
|
172
161
|
const splitted = topic.split("/");
|
|
173
162
|
const productKey = splitted[1];
|
|
@@ -196,7 +185,25 @@ const onMessage = async (topic, message) => {
|
|
|
196
185
|
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";
|
|
197
186
|
(0, import_adapterService.updateSolarFlowState)(adapter, productKey, deviceKey, "packState", value);
|
|
198
187
|
}
|
|
199
|
-
if (((_h = obj.properties) == null ? void 0 : _h.
|
|
188
|
+
if (((_h = obj.properties) == null ? void 0 : _h.passMode) != null && ((_i = obj.properties) == null ? void 0 : _i.passMode) != void 0) {
|
|
189
|
+
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";
|
|
190
|
+
(0, import_adapterService.updateSolarFlowState)(adapter, productKey, deviceKey, "passMode", value);
|
|
191
|
+
}
|
|
192
|
+
if (((_m = obj.properties) == null ? void 0 : _m.pass) != null && ((_n = obj.properties) == null ? void 0 : _n.pass) != void 0) {
|
|
193
|
+
const value = ((_o = obj.properties) == null ? void 0 : _o.pass) == 0 ? false : true;
|
|
194
|
+
(0, import_adapterService.updateSolarFlowState)(adapter, productKey, deviceKey, "pass", value);
|
|
195
|
+
}
|
|
196
|
+
if (((_p = obj.properties) == null ? void 0 : _p.autoRecover) != null && ((_q = obj.properties) == null ? void 0 : _q.autoRecover) != void 0) {
|
|
197
|
+
const value = ((_r = obj.properties) == null ? void 0 : _r.autoRecover) == 0 ? false : true;
|
|
198
|
+
(0, import_adapterService.updateSolarFlowState)(
|
|
199
|
+
adapter,
|
|
200
|
+
productKey,
|
|
201
|
+
deviceKey,
|
|
202
|
+
"autoRecover",
|
|
203
|
+
value
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
if (((_s = obj.properties) == null ? void 0 : _s.outputHomePower) != null && ((_t = obj.properties) == null ? void 0 : _t.outputHomePower) != void 0) {
|
|
200
207
|
(0, import_adapterService.updateSolarFlowState)(
|
|
201
208
|
adapter,
|
|
202
209
|
productKey,
|
|
@@ -205,7 +212,7 @@ const onMessage = async (topic, message) => {
|
|
|
205
212
|
obj.properties.outputHomePower
|
|
206
213
|
);
|
|
207
214
|
}
|
|
208
|
-
if (((
|
|
215
|
+
if (((_u = obj.properties) == null ? void 0 : _u.outputLimit) != null && ((_v = obj.properties) == null ? void 0 : _v.outputLimit) != void 0) {
|
|
209
216
|
(0, import_adapterService.updateSolarFlowState)(
|
|
210
217
|
adapter,
|
|
211
218
|
productKey,
|
|
@@ -214,7 +221,17 @@ const onMessage = async (topic, message) => {
|
|
|
214
221
|
obj.properties.outputLimit
|
|
215
222
|
);
|
|
216
223
|
}
|
|
217
|
-
if (((
|
|
224
|
+
if (((_w = obj.properties) == null ? void 0 : _w.buzzerSwitch) != null && ((_x = obj.properties) == null ? void 0 : _x.buzzerSwitch) != void 0) {
|
|
225
|
+
const value = ((_y = obj.properties) == null ? void 0 : _y.buzzerSwitch) == 0 ? false : true;
|
|
226
|
+
(0, import_adapterService.updateSolarFlowState)(
|
|
227
|
+
adapter,
|
|
228
|
+
productKey,
|
|
229
|
+
deviceKey,
|
|
230
|
+
"buzzerSwitch",
|
|
231
|
+
value
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
if (((_z = obj.properties) == null ? void 0 : _z.outputPackPower) != null && ((_A = obj.properties) == null ? void 0 : _A.outputPackPower) != void 0) {
|
|
218
235
|
(0, import_adapterService.updateSolarFlowState)(
|
|
219
236
|
adapter,
|
|
220
237
|
productKey,
|
|
@@ -224,7 +241,7 @@ const onMessage = async (topic, message) => {
|
|
|
224
241
|
);
|
|
225
242
|
(0, import_adapterService.updateSolarFlowState)(adapter, productKey, deviceKey, "packInputPower", 0);
|
|
226
243
|
}
|
|
227
|
-
if (((
|
|
244
|
+
if (((_B = obj.properties) == null ? void 0 : _B.packInputPower) != null && ((_C = obj.properties) == null ? void 0 : _C.packInputPower) != void 0) {
|
|
228
245
|
(0, import_adapterService.updateSolarFlowState)(
|
|
229
246
|
adapter,
|
|
230
247
|
productKey,
|
|
@@ -240,7 +257,7 @@ const onMessage = async (topic, message) => {
|
|
|
240
257
|
0
|
|
241
258
|
);
|
|
242
259
|
}
|
|
243
|
-
if (((
|
|
260
|
+
if (((_D = obj.properties) == null ? void 0 : _D.solarInputPower) != null && ((_E = obj.properties) == null ? void 0 : _E.solarInputPower) != void 0) {
|
|
244
261
|
(0, import_adapterService.updateSolarFlowState)(
|
|
245
262
|
adapter,
|
|
246
263
|
productKey,
|
|
@@ -249,7 +266,7 @@ const onMessage = async (topic, message) => {
|
|
|
249
266
|
obj.properties.solarInputPower
|
|
250
267
|
);
|
|
251
268
|
}
|
|
252
|
-
if (((
|
|
269
|
+
if (((_F = obj.properties) == null ? void 0 : _F.pvPower1) != null && ((_G = obj.properties) == null ? void 0 : _G.pvPower1) != void 0) {
|
|
253
270
|
(0, import_adapterService.updateSolarFlowState)(
|
|
254
271
|
adapter,
|
|
255
272
|
productKey,
|
|
@@ -259,7 +276,7 @@ const onMessage = async (topic, message) => {
|
|
|
259
276
|
obj.properties.pvPower1
|
|
260
277
|
);
|
|
261
278
|
}
|
|
262
|
-
if (((
|
|
279
|
+
if (((_H = obj.properties) == null ? void 0 : _H.pvPower2) != null && ((_I = obj.properties) == null ? void 0 : _I.pvPower2) != void 0) {
|
|
263
280
|
(0, import_adapterService.updateSolarFlowState)(
|
|
264
281
|
adapter,
|
|
265
282
|
productKey,
|
|
@@ -269,7 +286,7 @@ const onMessage = async (topic, message) => {
|
|
|
269
286
|
obj.properties.pvPower2
|
|
270
287
|
);
|
|
271
288
|
}
|
|
272
|
-
if (((
|
|
289
|
+
if (((_J = obj.properties) == null ? void 0 : _J.solarPower1) != null && ((_K = obj.properties) == null ? void 0 : _K.solarPower1) != void 0) {
|
|
273
290
|
(0, import_adapterService.updateSolarFlowState)(
|
|
274
291
|
adapter,
|
|
275
292
|
productKey,
|
|
@@ -278,7 +295,7 @@ const onMessage = async (topic, message) => {
|
|
|
278
295
|
obj.properties.solarPower1
|
|
279
296
|
);
|
|
280
297
|
}
|
|
281
|
-
if (((
|
|
298
|
+
if (((_L = obj.properties) == null ? void 0 : _L.solarPower2) != null && ((_M = obj.properties) == null ? void 0 : _M.solarPower2) != void 0) {
|
|
282
299
|
(0, import_adapterService.updateSolarFlowState)(
|
|
283
300
|
adapter,
|
|
284
301
|
productKey,
|
|
@@ -287,7 +304,7 @@ const onMessage = async (topic, message) => {
|
|
|
287
304
|
obj.properties.solarPower2
|
|
288
305
|
);
|
|
289
306
|
}
|
|
290
|
-
if (((
|
|
307
|
+
if (((_N = obj.properties) == null ? void 0 : _N.remainOutTime) != null && ((_O = obj.properties) == null ? void 0 : _O.remainOutTime) != void 0) {
|
|
291
308
|
(0, import_adapterService.updateSolarFlowState)(
|
|
292
309
|
adapter,
|
|
293
310
|
productKey,
|
|
@@ -295,51 +312,17 @@ const onMessage = async (topic, message) => {
|
|
|
295
312
|
"remainOutTime",
|
|
296
313
|
obj.properties.remainOutTime
|
|
297
314
|
);
|
|
298
|
-
if (adapter.config.useCalculation) {
|
|
299
|
-
const packInputPower = Number(
|
|
300
|
-
(_B = await adapter.getStateAsync(
|
|
301
|
-
productKey + "." + deviceKey + ".packInputPower"
|
|
302
|
-
)) == null ? void 0 : _B.val
|
|
303
|
-
);
|
|
304
|
-
const outputPackPower = Number(
|
|
305
|
-
(_C = await adapter.getStateAsync(
|
|
306
|
-
productKey + "." + deviceKey + ".outputPackPower"
|
|
307
|
-
)) == null ? void 0 : _C.val
|
|
308
|
-
);
|
|
309
|
-
if (packInputPower && packInputPower > 0) {
|
|
310
|
-
(0, import_adapterService.updateSolarFlowState)(
|
|
311
|
-
adapter,
|
|
312
|
-
productKey,
|
|
313
|
-
deviceKey,
|
|
314
|
-
"calculations.remainOutTime",
|
|
315
|
-
obj.properties.remainOutTime < 59940 ? (0, import_timeHelper.toHoursAndMinutes)(obj.properties.remainOutTime) : ""
|
|
316
|
-
);
|
|
317
|
-
(0, import_adapterService.updateSolarFlowState)(
|
|
318
|
-
adapter,
|
|
319
|
-
productKey,
|
|
320
|
-
deviceKey,
|
|
321
|
-
"calculations.remainInputTime",
|
|
322
|
-
""
|
|
323
|
-
);
|
|
324
|
-
} else if (outputPackPower && outputPackPower > 0) {
|
|
325
|
-
(0, import_adapterService.updateSolarFlowState)(
|
|
326
|
-
adapter,
|
|
327
|
-
productKey,
|
|
328
|
-
deviceKey,
|
|
329
|
-
"calculations.remainInputTime",
|
|
330
|
-
obj.properties.remainInputTime < 59940 ? (0, import_timeHelper.toHoursAndMinutes)(obj.properties.remainInputTime) : ""
|
|
331
|
-
);
|
|
332
|
-
(0, import_adapterService.updateSolarFlowState)(
|
|
333
|
-
adapter,
|
|
334
|
-
productKey,
|
|
335
|
-
deviceKey,
|
|
336
|
-
"calculations.remainOutTime",
|
|
337
|
-
""
|
|
338
|
-
);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
315
|
}
|
|
342
|
-
if (((
|
|
316
|
+
if (((_P = obj.properties) == null ? void 0 : _P.remainInputTime) != null && ((_Q = obj.properties) == null ? void 0 : _Q.remainInputTime) != void 0) {
|
|
317
|
+
(0, import_adapterService.updateSolarFlowState)(
|
|
318
|
+
adapter,
|
|
319
|
+
productKey,
|
|
320
|
+
deviceKey,
|
|
321
|
+
"remainInputTime",
|
|
322
|
+
obj.properties.remainInputTime
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
if (((_R = obj.properties) == null ? void 0 : _R.socSet) != null && ((_S = obj.properties) == null ? void 0 : _S.socSet) != void 0) {
|
|
343
326
|
(0, import_adapterService.updateSolarFlowState)(
|
|
344
327
|
adapter,
|
|
345
328
|
productKey,
|
|
@@ -348,7 +331,7 @@ const onMessage = async (topic, message) => {
|
|
|
348
331
|
Number(obj.properties.socSet) / 10
|
|
349
332
|
);
|
|
350
333
|
}
|
|
351
|
-
if (((
|
|
334
|
+
if (((_T = obj.properties) == null ? void 0 : _T.minSoc) != null && ((_U = obj.properties) == null ? void 0 : _U.minSoc) != void 0) {
|
|
352
335
|
(0, import_adapterService.updateSolarFlowState)(
|
|
353
336
|
adapter,
|
|
354
337
|
productKey,
|
|
@@ -358,7 +341,7 @@ const onMessage = async (topic, message) => {
|
|
|
358
341
|
);
|
|
359
342
|
}
|
|
360
343
|
if (obj.packData) {
|
|
361
|
-
addOrUpdatePackData(
|
|
344
|
+
addOrUpdatePackData(productKey, deviceKey, obj.packData);
|
|
362
345
|
}
|
|
363
346
|
}
|
|
364
347
|
if (adapter == null ? void 0 : adapter.mqttClient) {
|
|
@@ -431,6 +414,73 @@ const setOutputLimit = async (adapter2, productKey, deviceKey, limit) => {
|
|
|
431
414
|
}
|
|
432
415
|
}
|
|
433
416
|
};
|
|
417
|
+
const setBuzzerSwitch = async (adapter2, productKey, deviceKey, buzzerOn) => {
|
|
418
|
+
var _a;
|
|
419
|
+
if (adapter2.mqttClient && productKey && deviceKey) {
|
|
420
|
+
const topic = `iot/${productKey}/${deviceKey}/properties/write`;
|
|
421
|
+
const socSetLimit = { properties: { buzzerSwitch: buzzerOn ? 1 : 0 } };
|
|
422
|
+
adapter2.log.debug(
|
|
423
|
+
`[setBuzzer] Setting Buzzer for device key ${deviceKey} to ${buzzerOn}!`
|
|
424
|
+
);
|
|
425
|
+
(_a = adapter2.mqttClient) == null ? void 0 : _a.publish(topic, JSON.stringify(socSetLimit));
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
const triggerFullTelemetryUpdate = async (adapter2, productKey, deviceKey) => {
|
|
429
|
+
var _a;
|
|
430
|
+
if (adapter2.mqttClient && productKey && deviceKey) {
|
|
431
|
+
const topic = `iot/${productKey}/${deviceKey}/properties/read`;
|
|
432
|
+
const getAllContent = { properties: ["getAll"] };
|
|
433
|
+
adapter2.log.debug(
|
|
434
|
+
`[triggerFullTelemetryUpdate] Triggering full telemetry update for device key ${deviceKey}!`
|
|
435
|
+
);
|
|
436
|
+
(_a = adapter2.mqttClient) == null ? void 0 : _a.publish(topic, JSON.stringify(getAllContent));
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
const setPassMode = async (adapter2, productKey, deviceKey, passMode) => {
|
|
440
|
+
var _a;
|
|
441
|
+
if (adapter2.mqttClient && productKey && deviceKey) {
|
|
442
|
+
const topic = `iot/${productKey}/${deviceKey}/properties/write`;
|
|
443
|
+
const setPassModeContent = { properties: { passMode } };
|
|
444
|
+
adapter2.log.debug(
|
|
445
|
+
`[setPassMode] Set passMode for device ${deviceKey} to ${passMode}!`
|
|
446
|
+
);
|
|
447
|
+
(_a = adapter2.mqttClient) == null ? void 0 : _a.publish(topic, JSON.stringify(setPassModeContent));
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
const setAutoRecover = async (adapter2, productKey, deviceKey, autoRecover) => {
|
|
451
|
+
var _a;
|
|
452
|
+
if (adapter2.mqttClient && productKey && deviceKey) {
|
|
453
|
+
const topic = `iot/${productKey}/${deviceKey}/properties/write`;
|
|
454
|
+
const setAutoRecoverContent = {
|
|
455
|
+
properties: { autoRecover: autoRecover ? 1 : 0 }
|
|
456
|
+
};
|
|
457
|
+
adapter2.log.debug(
|
|
458
|
+
`[setPassMode] Set autoRecover for device ${deviceKey} to ${autoRecover}!`
|
|
459
|
+
);
|
|
460
|
+
(_a = adapter2.mqttClient) == null ? void 0 : _a.publish(topic, JSON.stringify(setAutoRecoverContent));
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
const onConnected = () => {
|
|
464
|
+
adapter == null ? void 0 : adapter.log.info("[onConnected] Connected with MQTT!");
|
|
465
|
+
};
|
|
466
|
+
const onError = (error) => {
|
|
467
|
+
adapter == null ? void 0 : adapter.log.error("Connection to MQTT failed! Error: " + error);
|
|
468
|
+
};
|
|
469
|
+
const onSubscriberReportTopic = (error) => {
|
|
470
|
+
if (error) {
|
|
471
|
+
adapter == null ? void 0 : adapter.log.error("Subscription to MQTT failed! Error: " + error);
|
|
472
|
+
} else {
|
|
473
|
+
adapter == null ? void 0 : adapter.log.debug("Subscription of Report Topic successful!");
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
const onSubscribeIotTopic = (error, productKey, deviceKey) => {
|
|
477
|
+
if (error) {
|
|
478
|
+
adapter == null ? void 0 : adapter.log.error("Subscription to MQTT failed! Error: " + error);
|
|
479
|
+
} else if (adapter) {
|
|
480
|
+
adapter == null ? void 0 : adapter.log.debug("Subscription of IOT Topic successful!");
|
|
481
|
+
triggerFullTelemetryUpdate(adapter, productKey, deviceKey);
|
|
482
|
+
}
|
|
483
|
+
};
|
|
434
484
|
const connectMqttClient = (_adapter) => {
|
|
435
485
|
adapter = _adapter;
|
|
436
486
|
const options = {
|
|
@@ -457,11 +507,13 @@ const connectMqttClient = (_adapter) => {
|
|
|
457
507
|
adapter.log.debug(
|
|
458
508
|
`[connectMqttClient] Subscribing to MQTT Topic: ${reportTopic}`
|
|
459
509
|
);
|
|
460
|
-
(_a = adapter.mqttClient) == null ? void 0 : _a.subscribe(reportTopic,
|
|
510
|
+
(_a = adapter.mqttClient) == null ? void 0 : _a.subscribe(reportTopic, onSubscriberReportTopic);
|
|
461
511
|
adapter.log.debug(
|
|
462
512
|
`[connectMqttClient] Subscribing to MQTT Topic: ${iotTopic}`
|
|
463
513
|
);
|
|
464
|
-
(_b = adapter.mqttClient) == null ? void 0 : _b.subscribe(iotTopic,
|
|
514
|
+
(_b = adapter.mqttClient) == null ? void 0 : _b.subscribe(iotTopic, (error) => {
|
|
515
|
+
onSubscribeIotTopic(error, device.productKey, device.deviceKey);
|
|
516
|
+
});
|
|
465
517
|
}
|
|
466
518
|
});
|
|
467
519
|
adapter.mqttClient.on("message", onMessage);
|
|
@@ -472,8 +524,12 @@ const connectMqttClient = (_adapter) => {
|
|
|
472
524
|
0 && (module.exports = {
|
|
473
525
|
addOrUpdatePackData,
|
|
474
526
|
connectMqttClient,
|
|
527
|
+
setAutoRecover,
|
|
528
|
+
setBuzzerSwitch,
|
|
475
529
|
setChargeLimit,
|
|
476
530
|
setDischargeLimit,
|
|
477
|
-
setOutputLimit
|
|
531
|
+
setOutputLimit,
|
|
532
|
+
setPassMode,
|
|
533
|
+
triggerFullTelemetryUpdate
|
|
478
534
|
});
|
|
479
535
|
//# sourceMappingURL=mqttService.js.map
|