iobroker.zendure-solarflow 1.1.9 → 1.1.12
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 +8 -1
- package/admin/build/index.js +9 -9
- package/admin/build/index.js.map +2 -2
- package/build/helpers/createCalculationStates.js +275 -0
- package/build/helpers/createCalculationStates.js.map +7 -0
- package/build/helpers/createControlStates.js +111 -0
- package/build/helpers/createControlStates.js.map +7 -0
- package/build/helpers/createSolarFlowStates.js +298 -0
- package/build/helpers/createSolarFlowStates.js.map +7 -0
- package/build/helpers/deleteCalculationStates.js +51 -0
- package/build/helpers/deleteCalculationStates.js.map +7 -0
- package/build/main.js +49 -31
- package/build/main.js.map +3 -3
- package/build/services/adapterService.js +0 -724
- package/build/services/adapterService.js.map +2 -2
- package/build/services/calculationService.js +98 -0
- package/build/services/calculationService.js.map +7 -0
- package/build/services/jobSchedule.js +90 -0
- package/build/services/jobSchedule.js.map +7 -0
- package/build/services/mqttService.js +162 -55
- package/build/services/mqttService.js.map +2 -2
- package/build/services/webService.js +1 -1
- package/build/services/webService.js.map +2 -2
- package/io-package.json +40 -40
- package/package.json +1 -1
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var createSolarFlowStates_exports = {};
|
|
20
|
+
__export(createSolarFlowStates_exports, {
|
|
21
|
+
createSolarFlowStates: () => createSolarFlowStates
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(createSolarFlowStates_exports);
|
|
24
|
+
var import_createCalculationStates = require("./createCalculationStates");
|
|
25
|
+
var import_createControlStates = require("./createControlStates");
|
|
26
|
+
var import_deleteCalculationStates = require("./deleteCalculationStates");
|
|
27
|
+
const createSolarFlowStates = async (adapter, productKey, deviceKey) => {
|
|
28
|
+
productKey = productKey.replace(adapter.FORBIDDEN_CHARS, "");
|
|
29
|
+
deviceKey = deviceKey.replace(adapter.FORBIDDEN_CHARS, "");
|
|
30
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(productKey, {
|
|
31
|
+
type: "device",
|
|
32
|
+
common: {
|
|
33
|
+
name: { de: "Produkt " + productKey, en: "Product " + productKey }
|
|
34
|
+
},
|
|
35
|
+
native: {}
|
|
36
|
+
}));
|
|
37
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(productKey + "." + deviceKey, {
|
|
38
|
+
type: "channel",
|
|
39
|
+
common: {
|
|
40
|
+
name: { de: "Device Key " + deviceKey, en: "Device Key " + deviceKey }
|
|
41
|
+
},
|
|
42
|
+
native: {}
|
|
43
|
+
}));
|
|
44
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
45
|
+
productKey + "." + deviceKey + ".calculations",
|
|
46
|
+
{
|
|
47
|
+
type: "channel",
|
|
48
|
+
common: {
|
|
49
|
+
name: {
|
|
50
|
+
de: "Berechnungen f\xFCr Ger\xE4t " + deviceKey,
|
|
51
|
+
en: "Calculations for Device " + deviceKey
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
native: {}
|
|
55
|
+
}
|
|
56
|
+
));
|
|
57
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(productKey + "." + deviceKey + ".packData", {
|
|
58
|
+
type: "channel",
|
|
59
|
+
common: {
|
|
60
|
+
name: {
|
|
61
|
+
de: "Akku Packs",
|
|
62
|
+
en: "Battery packs"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
native: {}
|
|
66
|
+
}));
|
|
67
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
68
|
+
productKey + "." + deviceKey + ".lastUpdate",
|
|
69
|
+
{
|
|
70
|
+
type: "state",
|
|
71
|
+
common: {
|
|
72
|
+
name: { de: "Letztes Update", en: "Last Update" },
|
|
73
|
+
type: "number",
|
|
74
|
+
desc: "lastUpdate",
|
|
75
|
+
role: "value.time",
|
|
76
|
+
read: true,
|
|
77
|
+
write: false
|
|
78
|
+
},
|
|
79
|
+
native: {}
|
|
80
|
+
}
|
|
81
|
+
));
|
|
82
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
83
|
+
productKey + "." + deviceKey + ".electricLevel",
|
|
84
|
+
{
|
|
85
|
+
type: "state",
|
|
86
|
+
common: {
|
|
87
|
+
name: { de: "SOC Gesamtsystem", en: "SOC of the system" },
|
|
88
|
+
type: "number",
|
|
89
|
+
desc: "electricLevel",
|
|
90
|
+
role: "value.battery",
|
|
91
|
+
read: true,
|
|
92
|
+
write: false,
|
|
93
|
+
unit: "%"
|
|
94
|
+
},
|
|
95
|
+
native: {}
|
|
96
|
+
}
|
|
97
|
+
));
|
|
98
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
99
|
+
productKey + "." + deviceKey + ".outputHomePower",
|
|
100
|
+
{
|
|
101
|
+
type: "state",
|
|
102
|
+
common: {
|
|
103
|
+
name: { de: "Ausgangsleistung", en: "output power" },
|
|
104
|
+
type: "number",
|
|
105
|
+
desc: "outputHomePower",
|
|
106
|
+
role: "value.power",
|
|
107
|
+
read: true,
|
|
108
|
+
write: false,
|
|
109
|
+
unit: "W"
|
|
110
|
+
},
|
|
111
|
+
native: {}
|
|
112
|
+
}
|
|
113
|
+
));
|
|
114
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
115
|
+
productKey + "." + deviceKey + ".outputLimit",
|
|
116
|
+
{
|
|
117
|
+
type: "state",
|
|
118
|
+
common: {
|
|
119
|
+
name: { de: "Limit der Ausgangsleistung", en: "limit of output power" },
|
|
120
|
+
type: "number",
|
|
121
|
+
desc: "outputLimit",
|
|
122
|
+
role: "value.power",
|
|
123
|
+
read: true,
|
|
124
|
+
write: false,
|
|
125
|
+
unit: "W"
|
|
126
|
+
},
|
|
127
|
+
native: {}
|
|
128
|
+
}
|
|
129
|
+
));
|
|
130
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
131
|
+
productKey + "." + deviceKey + ".outputPackPower",
|
|
132
|
+
{
|
|
133
|
+
type: "state",
|
|
134
|
+
common: {
|
|
135
|
+
name: { de: "Ladeleistung zum Akku", en: "charge power" },
|
|
136
|
+
type: "number",
|
|
137
|
+
desc: "outputPackPower",
|
|
138
|
+
role: "value.power",
|
|
139
|
+
read: true,
|
|
140
|
+
write: false,
|
|
141
|
+
unit: "W"
|
|
142
|
+
},
|
|
143
|
+
native: {}
|
|
144
|
+
}
|
|
145
|
+
));
|
|
146
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
147
|
+
productKey + "." + deviceKey + ".packInputPower",
|
|
148
|
+
{
|
|
149
|
+
type: "state",
|
|
150
|
+
common: {
|
|
151
|
+
name: { de: "Entladeleistung zum Akku", en: "discharge power" },
|
|
152
|
+
type: "number",
|
|
153
|
+
desc: "packInputPower",
|
|
154
|
+
role: "value.power",
|
|
155
|
+
read: true,
|
|
156
|
+
write: false,
|
|
157
|
+
unit: "W"
|
|
158
|
+
},
|
|
159
|
+
native: {}
|
|
160
|
+
}
|
|
161
|
+
));
|
|
162
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
163
|
+
productKey + "." + deviceKey + ".solarInputPower",
|
|
164
|
+
{
|
|
165
|
+
type: "state",
|
|
166
|
+
common: {
|
|
167
|
+
name: { de: "Leistung der Solarmodule", en: "solar power" },
|
|
168
|
+
type: "number",
|
|
169
|
+
desc: "solarInputPower",
|
|
170
|
+
role: "value.power",
|
|
171
|
+
read: true,
|
|
172
|
+
write: false,
|
|
173
|
+
unit: "W"
|
|
174
|
+
},
|
|
175
|
+
native: {}
|
|
176
|
+
}
|
|
177
|
+
));
|
|
178
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
179
|
+
productKey + "." + deviceKey + ".pvPower1",
|
|
180
|
+
{
|
|
181
|
+
type: "state",
|
|
182
|
+
common: {
|
|
183
|
+
name: { de: "Leistung PV 1", en: "solar power channel 1" },
|
|
184
|
+
type: "number",
|
|
185
|
+
desc: "pvPower1",
|
|
186
|
+
role: "value.power",
|
|
187
|
+
read: true,
|
|
188
|
+
write: false,
|
|
189
|
+
unit: "W"
|
|
190
|
+
},
|
|
191
|
+
native: {}
|
|
192
|
+
}
|
|
193
|
+
));
|
|
194
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
195
|
+
productKey + "." + deviceKey + ".pvPower2",
|
|
196
|
+
{
|
|
197
|
+
type: "state",
|
|
198
|
+
common: {
|
|
199
|
+
name: { de: "Leistung PV 2", en: "solar power channel 2" },
|
|
200
|
+
type: "number",
|
|
201
|
+
desc: "pvPower2",
|
|
202
|
+
role: "value.power",
|
|
203
|
+
read: true,
|
|
204
|
+
write: false,
|
|
205
|
+
unit: "W"
|
|
206
|
+
},
|
|
207
|
+
native: {}
|
|
208
|
+
}
|
|
209
|
+
));
|
|
210
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
211
|
+
productKey + "." + deviceKey + ".remainInputTime",
|
|
212
|
+
{
|
|
213
|
+
type: "state",
|
|
214
|
+
common: {
|
|
215
|
+
name: { de: "Erwartete Ladedauer", en: "remaining charge time" },
|
|
216
|
+
type: "number",
|
|
217
|
+
desc: "remainInputTime",
|
|
218
|
+
role: "value.interval",
|
|
219
|
+
read: true,
|
|
220
|
+
write: false
|
|
221
|
+
},
|
|
222
|
+
native: {}
|
|
223
|
+
}
|
|
224
|
+
));
|
|
225
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
226
|
+
productKey + "." + deviceKey + ".remainOutTime",
|
|
227
|
+
{
|
|
228
|
+
type: "state",
|
|
229
|
+
common: {
|
|
230
|
+
name: {
|
|
231
|
+
de: "Erwartete Entladedauer (Minuten)",
|
|
232
|
+
en: "remaining discharge time (minutes)"
|
|
233
|
+
},
|
|
234
|
+
type: "number",
|
|
235
|
+
desc: "remainOutTime",
|
|
236
|
+
role: "value.interval",
|
|
237
|
+
read: true,
|
|
238
|
+
write: false
|
|
239
|
+
},
|
|
240
|
+
native: {}
|
|
241
|
+
}
|
|
242
|
+
));
|
|
243
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
244
|
+
productKey + "." + deviceKey + ".socSet",
|
|
245
|
+
{
|
|
246
|
+
type: "state",
|
|
247
|
+
common: {
|
|
248
|
+
name: { de: "Max. SOC", en: "max. SOC" },
|
|
249
|
+
type: "number",
|
|
250
|
+
desc: "socSet",
|
|
251
|
+
role: "value.battery",
|
|
252
|
+
read: true,
|
|
253
|
+
write: false,
|
|
254
|
+
unit: "%"
|
|
255
|
+
},
|
|
256
|
+
native: {}
|
|
257
|
+
}
|
|
258
|
+
));
|
|
259
|
+
await (adapter == null ? void 0 : adapter.extendObjectAsync(
|
|
260
|
+
productKey + "." + deviceKey + ".minSoc",
|
|
261
|
+
{
|
|
262
|
+
type: "state",
|
|
263
|
+
common: {
|
|
264
|
+
name: { de: "Min. SOC", en: "min. SOC" },
|
|
265
|
+
type: "number",
|
|
266
|
+
desc: "minSoc",
|
|
267
|
+
role: "value.battery",
|
|
268
|
+
read: true,
|
|
269
|
+
write: false,
|
|
270
|
+
unit: "%"
|
|
271
|
+
},
|
|
272
|
+
native: {}
|
|
273
|
+
}
|
|
274
|
+
));
|
|
275
|
+
adapter == null ? void 0 : adapter.subscribeStates(
|
|
276
|
+
productKey + "." + deviceKey + ".solarInputPower"
|
|
277
|
+
);
|
|
278
|
+
adapter == null ? void 0 : adapter.subscribeStates(
|
|
279
|
+
productKey + "." + deviceKey + ".outputPackPower"
|
|
280
|
+
);
|
|
281
|
+
adapter == null ? void 0 : adapter.subscribeStates(
|
|
282
|
+
productKey + "." + deviceKey + ".packInputPower"
|
|
283
|
+
);
|
|
284
|
+
adapter == null ? void 0 : adapter.subscribeStates(
|
|
285
|
+
productKey + "." + deviceKey + ".outputHomePower"
|
|
286
|
+
);
|
|
287
|
+
await (0, import_createControlStates.createControlStates)(adapter, productKey, deviceKey);
|
|
288
|
+
if (adapter.config.useCalculation) {
|
|
289
|
+
await (0, import_createCalculationStates.createCalculationStates)(adapter, productKey, deviceKey);
|
|
290
|
+
} else {
|
|
291
|
+
await (0, import_deleteCalculationStates.deleteCalculationStates)(adapter, productKey, deviceKey);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
295
|
+
0 && (module.exports = {
|
|
296
|
+
createSolarFlowStates
|
|
297
|
+
});
|
|
298
|
+
//# sourceMappingURL=createSolarFlowStates.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/helpers/createSolarFlowStates.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/indent */\r\n\r\nimport { ZendureSolarflow } from \"../main\";\r\nimport { createCalculationStates } from \"./createCalculationStates\";\r\nimport { createControlStates } from \"./createControlStates\";\r\nimport { deleteCalculationStates } from \"./deleteCalculationStates\";\r\n\r\nexport const createSolarFlowStates = async (\r\n adapter: ZendureSolarflow,\r\n productKey: string,\r\n deviceKey: string,\r\n): Promise<void> => {\r\n productKey = productKey.replace(adapter.FORBIDDEN_CHARS, \"\");\r\n deviceKey = deviceKey.replace(adapter.FORBIDDEN_CHARS, \"\");\r\n\r\n // Create device (e.g. the product type -> SolarFlow)\r\n await adapter?.extendObjectAsync(productKey, {\r\n type: \"device\",\r\n common: {\r\n name: { de: \"Produkt \" + productKey, en: \"Product \" + productKey },\r\n },\r\n native: {},\r\n });\r\n\r\n // Create channel (e.g. the device specific key)\r\n await adapter?.extendObjectAsync(productKey + \".\" + deviceKey, {\r\n type: \"channel\",\r\n common: {\r\n name: { de: \"Device Key \" + deviceKey, en: \"Device Key \" + deviceKey },\r\n },\r\n native: {},\r\n });\r\n\r\n // Create calculations folder\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".calculations\",\r\n {\r\n type: \"channel\",\r\n common: {\r\n name: {\r\n de: \"Berechnungen f\u00FCr Ger\u00E4t \" + deviceKey,\r\n en: \"Calculations for Device \" + deviceKey,\r\n },\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n // Create pack data folder\r\n await adapter?.extendObjectAsync(productKey + \".\" + deviceKey + \".packData\", {\r\n type: \"channel\",\r\n common: {\r\n name: {\r\n de: \"Akku Packs\",\r\n en: \"Battery packs\",\r\n },\r\n },\r\n native: {},\r\n });\r\n\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".\" + \"lastUpdate\",\r\n {\r\n type: \"state\",\r\n common: {\r\n name: { de: \"Letztes Update\", en: \"Last Update\" },\r\n type: \"number\",\r\n desc: \"lastUpdate\",\r\n role: \"value.time\",\r\n read: true,\r\n write: false,\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".\" + \"electricLevel\",\r\n {\r\n type: \"state\",\r\n common: {\r\n name: { de: \"SOC Gesamtsystem\", en: \"SOC of the system\" },\r\n type: \"number\",\r\n desc: \"electricLevel\",\r\n role: \"value.battery\",\r\n read: true,\r\n write: false,\r\n unit: \"%\",\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".\" + \"outputHomePower\",\r\n {\r\n type: \"state\",\r\n common: {\r\n name: { de: \"Ausgangsleistung\", en: \"output power\" },\r\n type: \"number\",\r\n desc: \"outputHomePower\",\r\n role: \"value.power\",\r\n read: true,\r\n write: false,\r\n unit: \"W\",\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".\" + \"outputLimit\",\r\n {\r\n type: \"state\",\r\n common: {\r\n name: { de: \"Limit der Ausgangsleistung\", en: \"limit of output power\" },\r\n type: \"number\",\r\n desc: \"outputLimit\",\r\n role: \"value.power\",\r\n read: true,\r\n write: false,\r\n unit: \"W\",\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".\" + \"outputPackPower\",\r\n {\r\n type: \"state\",\r\n common: {\r\n name: { de: \"Ladeleistung zum Akku\", en: \"charge power\" },\r\n type: \"number\",\r\n desc: \"outputPackPower\",\r\n role: \"value.power\",\r\n read: true,\r\n write: false,\r\n unit: \"W\",\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".\" + \"packInputPower\",\r\n {\r\n type: \"state\",\r\n common: {\r\n name: { de: \"Entladeleistung zum Akku\", en: \"discharge power\" },\r\n type: \"number\",\r\n desc: \"packInputPower\",\r\n role: \"value.power\",\r\n read: true,\r\n write: false,\r\n unit: \"W\",\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".\" + \"solarInputPower\",\r\n {\r\n type: \"state\",\r\n common: {\r\n name: { de: \"Leistung der Solarmodule\", en: \"solar power\" },\r\n type: \"number\",\r\n desc: \"solarInputPower\",\r\n role: \"value.power\",\r\n read: true,\r\n write: false,\r\n unit: \"W\",\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".\" + \"pvPower1\",\r\n {\r\n type: \"state\",\r\n common: {\r\n name: { de: \"Leistung PV 1\", en: \"solar power channel 1\" },\r\n type: \"number\",\r\n desc: \"pvPower1\",\r\n role: \"value.power\",\r\n read: true,\r\n write: false,\r\n unit: \"W\",\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".\" + \"pvPower2\",\r\n {\r\n type: \"state\",\r\n common: {\r\n name: { de: \"Leistung PV 2\", en: \"solar power channel 2\" },\r\n type: \"number\",\r\n desc: \"pvPower2\",\r\n role: \"value.power\",\r\n read: true,\r\n write: false,\r\n unit: \"W\",\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".\" + \"remainInputTime\",\r\n {\r\n type: \"state\",\r\n common: {\r\n name: { de: \"Erwartete Ladedauer\", en: \"remaining charge time\" },\r\n type: \"number\",\r\n desc: \"remainInputTime\",\r\n role: \"value.interval\",\r\n read: true,\r\n write: false,\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".\" + \"remainOutTime\",\r\n {\r\n type: \"state\",\r\n common: {\r\n name: {\r\n de: \"Erwartete Entladedauer (Minuten)\",\r\n en: \"remaining discharge time (minutes)\",\r\n },\r\n type: \"number\",\r\n desc: \"remainOutTime\",\r\n role: \"value.interval\",\r\n read: true,\r\n write: false,\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".\" + \"socSet\",\r\n {\r\n type: \"state\",\r\n common: {\r\n name: { de: \"Max. SOC\", en: \"max. SOC\" },\r\n type: \"number\",\r\n desc: \"socSet\",\r\n role: \"value.battery\",\r\n read: true,\r\n write: false,\r\n unit: \"%\",\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n await adapter?.extendObjectAsync(\r\n productKey + \".\" + deviceKey + \".\" + \"minSoc\",\r\n {\r\n type: \"state\",\r\n common: {\r\n name: { de: \"Min. SOC\", en: \"min. SOC\" },\r\n type: \"number\",\r\n desc: \"minSoc\",\r\n role: \"value.battery\",\r\n read: true,\r\n write: false,\r\n unit: \"%\",\r\n },\r\n native: {},\r\n },\r\n );\r\n\r\n // Subscibe to State updates to listen to changes\r\n adapter?.subscribeStates(\r\n productKey + \".\" + deviceKey + \".\" + \"solarInputPower\",\r\n );\r\n\r\n adapter?.subscribeStates(\r\n productKey + \".\" + deviceKey + \".\" + \"outputPackPower\",\r\n );\r\n\r\n adapter?.subscribeStates(\r\n productKey + \".\" + deviceKey + \".\" + \"packInputPower\",\r\n );\r\n\r\n adapter?.subscribeStates(\r\n productKey + \".\" + deviceKey + \".\" + \"outputHomePower\",\r\n );\r\n\r\n await createControlStates(adapter, productKey, deviceKey);\r\n\r\n if (adapter.config.useCalculation) {\r\n await createCalculationStates(adapter, productKey, deviceKey);\r\n } else {\r\n await deleteCalculationStates(adapter, productKey, deviceKey);\r\n }\r\n};\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qCAAwC;AACxC,iCAAoC;AACpC,qCAAwC;AAEjC,MAAM,wBAAwB,OACnC,SACA,YACA,cACkB;AAClB,eAAa,WAAW,QAAQ,QAAQ,iBAAiB,EAAE;AAC3D,cAAY,UAAU,QAAQ,QAAQ,iBAAiB,EAAE;AAGzD,SAAM,mCAAS,kBAAkB,YAAY;AAAA,IAC3C,MAAM;AAAA,IACN,QAAQ;AAAA,MACN,MAAM,EAAE,IAAI,aAAa,YAAY,IAAI,aAAa,WAAW;AAAA,IACnE;AAAA,IACA,QAAQ,CAAC;AAAA,EACX;AAGA,SAAM,mCAAS,kBAAkB,aAAa,M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|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var deleteCalculationStates_exports = {};
|
|
20
|
+
__export(deleteCalculationStates_exports, {
|
|
21
|
+
deleteCalculationStates: () => deleteCalculationStates
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(deleteCalculationStates_exports);
|
|
24
|
+
const deleteCalculationStates = async (adapter, productKey, deviceKey) => {
|
|
25
|
+
const stateNames = [
|
|
26
|
+
"energyWhMax",
|
|
27
|
+
"energyWh",
|
|
28
|
+
"soc",
|
|
29
|
+
"remainOutTime",
|
|
30
|
+
"remainInputTime",
|
|
31
|
+
"outputHomeEnergyTodaykWh",
|
|
32
|
+
"outputHomeEnergyTodayWh",
|
|
33
|
+
"packInputEnergyTodaykWh",
|
|
34
|
+
"packInputEnergyTodayWh",
|
|
35
|
+
"outputPackEnergyTodaykWh",
|
|
36
|
+
"outputPackEnergyTodayWh",
|
|
37
|
+
"solarInputEnergyTodaykWh",
|
|
38
|
+
"solarInputEnergyTodayWh"
|
|
39
|
+
];
|
|
40
|
+
stateNames.forEach(async (stateName) => {
|
|
41
|
+
const key = productKey + "." + deviceKey + ".calculations." + stateName;
|
|
42
|
+
if (await adapter.objectExists(key)) {
|
|
43
|
+
await (adapter == null ? void 0 : adapter.delObjectAsync(key));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
deleteCalculationStates
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=deleteCalculationStates.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/helpers/deleteCalculationStates.ts"],
|
|
4
|
+
"sourcesContent": ["import { ZendureSolarflow } from \"../main\";\r\n\r\n/* eslint-disable @typescript-eslint/indent */\r\n\r\nexport const deleteCalculationStates = async (\r\n adapter: ZendureSolarflow,\r\n productKey: string,\r\n deviceKey: string,\r\n): Promise<void> => {\r\n const stateNames = [\r\n \"energyWhMax\",\r\n \"energyWh\",\r\n \"soc\",\r\n \"remainOutTime\",\r\n \"remainInputTime\",\r\n \"outputHomeEnergyTodaykWh\",\r\n \"outputHomeEnergyTodayWh\",\r\n \"packInputEnergyTodaykWh\",\r\n \"packInputEnergyTodayWh\",\r\n \"outputPackEnergyTodaykWh\",\r\n \"outputPackEnergyTodayWh\",\r\n \"solarInputEnergyTodaykWh\",\r\n \"solarInputEnergyTodayWh\",\r\n ];\r\n\r\n stateNames.forEach(async (stateName) => {\r\n const key = productKey + \".\" + deviceKey + \".calculations.\" + stateName;\r\n if (await adapter.objectExists(key)) {\r\n await adapter?.delObjectAsync(key);\r\n }\r\n });\r\n};\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,0BAA0B,OACrC,SACA,YACA,cACkB;AAClB,QAAM,aAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,aAAW,QAAQ,OAAO,cAAc;AACtC,UAAM,MAAM,aAAa,MAAM,YAAY,mBAAmB;AAC9D,QAAI,MAAM,QAAQ,aAAa,GAAG,GAAG;AACnC,aAAM,mCAAS,eAAe;AAAA,IAChC;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/main.js
CHANGED
|
@@ -35,8 +35,8 @@ var utils = __toESM(require("@iobroker/adapter-core"));
|
|
|
35
35
|
var import_mqttService = require("./services/mqttService");
|
|
36
36
|
var import_webService = require("./services/webService");
|
|
37
37
|
var import_paths = require("./constants/paths");
|
|
38
|
-
var
|
|
39
|
-
var
|
|
38
|
+
var import_jobSchedule = require("./services/jobSchedule");
|
|
39
|
+
var import_calculationService = require("./services/calculationService");
|
|
40
40
|
class ZendureSolarflow extends utils.Adapter {
|
|
41
41
|
constructor(options = {}) {
|
|
42
42
|
super({
|
|
@@ -50,6 +50,7 @@ class ZendureSolarflow extends utils.Adapter {
|
|
|
50
50
|
this.interval = void 0;
|
|
51
51
|
this.lastLogin = void 0;
|
|
52
52
|
this.resetValuesJob = void 0;
|
|
53
|
+
this.checkStatesJob = void 0;
|
|
53
54
|
this.on("ready", this.onReady.bind(this));
|
|
54
55
|
this.on("stateChange", this.onStateChange.bind(this));
|
|
55
56
|
this.on("unload", this.onUnload.bind(this));
|
|
@@ -65,23 +66,12 @@ class ZendureSolarflow extends utils.Adapter {
|
|
|
65
66
|
this.accessToken = _accessToken;
|
|
66
67
|
this.connected = true;
|
|
67
68
|
this.lastLogin = /* @__PURE__ */ new Date();
|
|
68
|
-
this.resetValuesJob = (0, import_node_schedule.scheduleJob)("0 0 * * *", () => {
|
|
69
|
-
var _a2;
|
|
70
|
-
this.log.debug(`Refreshing accessToken!`);
|
|
71
|
-
if (this.config.userName && this.config.password) {
|
|
72
|
-
(_a2 = (0, import_webService.login)(this)) == null ? void 0 : _a2.then((_accessToken2) => {
|
|
73
|
-
this.accessToken = _accessToken2;
|
|
74
|
-
this.lastLogin = /* @__PURE__ */ new Date();
|
|
75
|
-
this.connected = true;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
(0, import_adapterService.resetTodaysValues)(this);
|
|
79
|
-
});
|
|
80
69
|
(0, import_webService.getDeviceList)(this).then((result) => {
|
|
81
70
|
if (result) {
|
|
82
71
|
this.deviceList = result;
|
|
83
72
|
(0, import_mqttService.connectMqttClient)(this);
|
|
84
|
-
(0,
|
|
73
|
+
(0, import_jobSchedule.startReloginAndResetValuesJob)(this);
|
|
74
|
+
(0, import_jobSchedule.startCheckStatesJob)(this);
|
|
85
75
|
}
|
|
86
76
|
}).catch(() => {
|
|
87
77
|
var _a2;
|
|
@@ -103,12 +93,18 @@ class ZendureSolarflow extends utils.Adapter {
|
|
|
103
93
|
* Is called when adapter shuts down - callback has to be called under any circumstances!
|
|
104
94
|
*/
|
|
105
95
|
onUnload(callback) {
|
|
96
|
+
var _a;
|
|
106
97
|
try {
|
|
107
98
|
if (this.interval) {
|
|
108
99
|
this.clearInterval(this.interval);
|
|
109
100
|
}
|
|
110
101
|
if (this.resetValuesJob) {
|
|
111
102
|
this.resetValuesJob.cancel();
|
|
103
|
+
this.resetValuesJob = void 0;
|
|
104
|
+
}
|
|
105
|
+
if (this.checkStatesJob) {
|
|
106
|
+
(_a = this.checkStatesJob) == null ? void 0 : _a.cancel();
|
|
107
|
+
this.checkStatesJob = void 0;
|
|
112
108
|
}
|
|
113
109
|
callback();
|
|
114
110
|
} catch (e) {
|
|
@@ -123,23 +119,45 @@ class ZendureSolarflow extends utils.Adapter {
|
|
|
123
119
|
const splitted = id.split(".");
|
|
124
120
|
const productKey = splitted[2];
|
|
125
121
|
const deviceKey = splitted[3];
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
122
|
+
const stateName1 = splitted[4];
|
|
123
|
+
const stateName2 = splitted[4];
|
|
124
|
+
if (state.val != void 0 && state.val != null) {
|
|
125
|
+
switch (stateName1) {
|
|
126
|
+
case "control":
|
|
127
|
+
if (stateName2 == "setOutputLimit") {
|
|
128
|
+
(0, import_mqttService.setOutputLimit)(this, productKey, deviceKey, Number(state.val));
|
|
129
|
+
} else if (stateName2 == "dischargeLimit") {
|
|
130
|
+
(0, import_mqttService.setDischargeLimit)(this, productKey, deviceKey, Number(state.val));
|
|
131
|
+
} else if (stateName2 == "chargeLimit") {
|
|
132
|
+
(0, import_mqttService.setChargeLimit)(this, productKey, deviceKey, Number(state.val));
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
case "solarInput":
|
|
136
|
+
if (this.config.useCalculation) {
|
|
137
|
+
(0, import_calculationService.calculateEnergy)(this, productKey, deviceKey, "solarInput", state);
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
case "outputPackPower":
|
|
141
|
+
if (this.config.useCalculation) {
|
|
142
|
+
(0, import_calculationService.calculateEnergy)(this, productKey, deviceKey, "outputPack", state);
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
case "packInputPower":
|
|
146
|
+
if (this.config.useCalculation) {
|
|
147
|
+
(0, import_calculationService.calculateEnergy)(this, productKey, deviceKey, "packInput", state);
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
case "outputHomePower":
|
|
151
|
+
if (this.config.useCalculation) {
|
|
152
|
+
(0, import_calculationService.calculateEnergy)(this, productKey, deviceKey, "outputHome", state);
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
default:
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
this.log.debug(`state ${id} deleted`);
|
|
140
160
|
}
|
|
141
|
-
} else {
|
|
142
|
-
this.log.debug(`state ${id} deleted`);
|
|
143
161
|
}
|
|
144
162
|
}
|
|
145
163
|
}
|
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 connectMqttClient,\r\n setChargeLimit,\r\n setDischargeLimit,\r\n setOutputLimit,\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 { pathsGlobal } from \"./constants/paths\";\r\nimport {\r\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,YAAuB;AACvB,yBAKO;AACP,wBAAqC;AAGrC,mBAA4B;
|
|
6
|
-
"names": ["_a"
|
|
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 connectMqttClient,\r\n setChargeLimit,\r\n setDischargeLimit,\r\n setOutputLimit,\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 { pathsGlobal } from \"./constants/paths\";\r\nimport { Job } from \"node-schedule\";\r\nimport {\r\n startCheckStatesJob,\r\n startReloginAndResetValuesJob,\r\n} from \"./services/jobSchedule\";\r\nimport { calculateEnergy } from \"./services/calculationService\";\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 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 interval: ioBroker.Interval | undefined = undefined;\r\n public lastLogin: Date | undefined = undefined;\r\n\r\n public resetValuesJob: Job | undefined = undefined;\r\n public checkStatesJob: Job | undefined = undefined;\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 // Currently only global Zendure Server are supported!\r\n this.paths = pathsGlobal;\r\n\r\n // If Username and Password is provided, try to login and get the access token.\r\n if (this.config.userName && this.config.password) {\r\n login(this)\r\n ?.then((_accessToken: string) => {\r\n this.accessToken = _accessToken;\r\n\r\n this.connected = true;\r\n this.lastLogin = new Date();\r\n\r\n // Try to get the device list\r\n getDeviceList(this)\r\n .then((result: ISolarFlowDeviceDetails[]) => {\r\n if (result) {\r\n // Device List found. Save in the adapter properties and connect to MQTT\r\n this.deviceList = result;\r\n connectMqttClient(this);\r\n\r\n // Schedule Job\r\n startReloginAndResetValuesJob(this);\r\n startCheckStatesJob(this);\r\n }\r\n })\r\n .catch(() => {\r\n this.connected = false;\r\n this.log?.error(\"Retrieving device failed!\");\r\n });\r\n })\r\n .catch((error) => {\r\n this.connected = false;\r\n this.log.error(\r\n \"Logon error at Zendure cloud service! Error: \" + error.toString(),\r\n );\r\n });\r\n } else {\r\n this.connected = false;\r\n this.log.error(\"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 onUnload(callback: () => void): void {\r\n try {\r\n if (this.interval) {\r\n this.clearInterval(this.interval);\r\n }\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 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];\r\n const deviceKey = splitted[3];\r\n const stateName1 = splitted[4];\r\n const stateName2 = splitted[4];\r\n\r\n if (state.val != undefined && state.val != null) {\r\n switch (stateName1) {\r\n case \"control\":\r\n if (stateName2 == \"setOutputLimit\") {\r\n setOutputLimit(this, productKey, deviceKey, Number(state.val));\r\n } else if (stateName2 == \"dischargeLimit\") {\r\n setDischargeLimit(this, productKey, deviceKey, Number(state.val));\r\n } else if (stateName2 == \"chargeLimit\") {\r\n setChargeLimit(this, productKey, deviceKey, Number(state.val));\r\n }\r\n break;\r\n case \"solarInput\":\r\n if (this.config.useCalculation) {\r\n // Calculate todays solar input\r\n calculateEnergy(this, productKey, deviceKey, \"solarInput\", state);\r\n }\r\n break;\r\n case \"outputPackPower\":\r\n if (this.config.useCalculation) {\r\n // Calculate todays output pack power (energy to battery)\r\n calculateEnergy(this, productKey, deviceKey, \"outputPack\", state);\r\n }\r\n break;\r\n case \"packInputPower\":\r\n if (this.config.useCalculation) {\r\n // Calculate todays pack input power (energy from battery)\r\n calculateEnergy(this, productKey, deviceKey, \"packInput\", state);\r\n }\r\n break;\r\n case \"outputHomePower\":\r\n if (this.config.useCalculation) {\r\n // Calculate todays pack input power (energy from system to home)\r\n calculateEnergy(this, productKey, deviceKey, \"outputHome\", state);\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;AACvB,yBAKO;AACP,wBAAqC;AAGrC,mBAA4B;AAE5B,yBAGO;AACP,gCAAgC;AAEzB,MAAM,yBAAyB,MAAM,QAAQ;AAAA,EAC3C,YAAY,UAAyC,CAAC,GAAG;AAC9D,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,MAAM;AAAA,IACR,CAAC;AAMH,SAAO,cAAkC;AACzC;AAAA,SAAO,aAAwC,CAAC;AAChD,SAAO,QAAqC;AAC5C,SAAO,WAA0C;AACjD,SAAO,YAA8B;AAErC,SAAO,iBAAkC;AACzC,SAAO,iBAAkC;AAZvC,SAAK,GAAG,SAAS,KAAK,QAAQ,KAAK,IAAI,CAAC;AACxC,SAAK,GAAG,eAAe,KAAK,cAAc,KAAK,IAAI,CAAC;AACpD,SAAK,GAAG,UAAU,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA,EAcA,MAAc,UAAyB;AAhDzC;AAkDI,SAAK,QAAQ;AAGb,QAAI,KAAK,OAAO,YAAY,KAAK,OAAO,UAAU;AAChD,yCAAM,IAAI,MAAV,m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