iobroker.zendure-solarflow 2.0.4 → 3.0.0-alpha.3
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 -5
- 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 +93 -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 +70 -27
- package/package.json +2 -2
- 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 -193
- 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
|
@@ -0,0 +1,432 @@
|
|
|
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 mqttSharedService_exports = {};
|
|
20
|
+
__export(mqttSharedService_exports, {
|
|
21
|
+
adapter: () => adapter,
|
|
22
|
+
initAdapter: () => initAdapter,
|
|
23
|
+
knownPackDataProperties: () => knownPackDataProperties,
|
|
24
|
+
onConnected: () => onConnected,
|
|
25
|
+
onError: () => onError,
|
|
26
|
+
onMessage: () => onMessage,
|
|
27
|
+
onSubscribeIotTopic: () => onSubscribeIotTopic,
|
|
28
|
+
onSubscribeReportTopic: () => onSubscribeReportTopic
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(mqttSharedService_exports);
|
|
31
|
+
let adapter = void 0;
|
|
32
|
+
const knownPackDataProperties = [
|
|
33
|
+
"sn",
|
|
34
|
+
"totalVol",
|
|
35
|
+
"maxVol",
|
|
36
|
+
"minVol",
|
|
37
|
+
"socLevel",
|
|
38
|
+
"maxTemp",
|
|
39
|
+
"soh",
|
|
40
|
+
"power",
|
|
41
|
+
"batcur"
|
|
42
|
+
];
|
|
43
|
+
const initAdapter = (_adapter) => {
|
|
44
|
+
adapter = _adapter;
|
|
45
|
+
adapter.log.debug("[initAdapter] Init adapter in mqttSharedService!");
|
|
46
|
+
return true;
|
|
47
|
+
};
|
|
48
|
+
const onMessage = async (topic, message) => {
|
|
49
|
+
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, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa;
|
|
50
|
+
if (adapter) {
|
|
51
|
+
if (topic.toLowerCase().includes("loginOut/force")) {
|
|
52
|
+
}
|
|
53
|
+
const topicSplitted = topic.replace("/server/app", "").split("/");
|
|
54
|
+
const productKey = topicSplitted[1];
|
|
55
|
+
const deviceKey = topicSplitted[2];
|
|
56
|
+
let obj = {};
|
|
57
|
+
try {
|
|
58
|
+
obj = JSON.parse(message.toString());
|
|
59
|
+
} catch (e) {
|
|
60
|
+
const txt = message.toString();
|
|
61
|
+
adapter.log.error(`[onMessage] JSON Parse error!`);
|
|
62
|
+
adapter.log.debug(`[onMessage] JSON Parse error: ${txt}!`);
|
|
63
|
+
}
|
|
64
|
+
let isSolarFlow = false;
|
|
65
|
+
const _device = adapter == null ? void 0 : adapter.zenHaDeviceList.find(
|
|
66
|
+
(x) => x.deviceKey == deviceKey
|
|
67
|
+
);
|
|
68
|
+
if (!_device) {
|
|
69
|
+
adapter.log.error(
|
|
70
|
+
`[onMessage] DeviceKey '${deviceKey} not found in device list!'}`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
if (adapter.log.level == "debug") {
|
|
74
|
+
adapter.log.debug(
|
|
75
|
+
`[onMessage] MQTT message on topic '${topic}': ${message.toString()}`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (productKey != "8bM93H") {
|
|
79
|
+
isSolarFlow = true;
|
|
80
|
+
}
|
|
81
|
+
if (obj.function == "deviceAutomation" && obj.success == 1) {
|
|
82
|
+
const currentValue = await adapter.getStateAsync(
|
|
83
|
+
productKey + "." + deviceKey + ".control.setDeviceAutomationInOutLimit"
|
|
84
|
+
);
|
|
85
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState(
|
|
86
|
+
"setDeviceAutomationInOutLimit",
|
|
87
|
+
(currentValue == null ? void 0 : currentValue.val) ? currentValue.val : 0
|
|
88
|
+
);
|
|
89
|
+
} else if (obj.function == "deviceAutomation" && obj.success == 0) {
|
|
90
|
+
adapter == null ? void 0 : adapter.log.warn(
|
|
91
|
+
`[onMessage] device automation failed for ${_device == null ? void 0 : _device.productName}: ${productKey}/${deviceKey}!`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
if (((_a = obj.properties) == null ? void 0 : _a.autoModel) != null && ((_b = obj.properties) == null ? void 0 : _b.autoModel) != void 0) {
|
|
95
|
+
_device == null ? void 0 : _device.updateSolarFlowState("autoModel", obj.properties.autoModel);
|
|
96
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState(
|
|
97
|
+
"autoModel",
|
|
98
|
+
obj.properties.autoModel
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
if (((_c = obj.properties) == null ? void 0 : _c.heatState) != null && ((_d = obj.properties) == null ? void 0 : _d.heatState) != void 0) {
|
|
102
|
+
const value = ((_e = obj.properties) == null ? void 0 : _e.heatState) == 0 ? false : true;
|
|
103
|
+
_device == null ? void 0 : _device.updateSolarFlowState("heatState", value);
|
|
104
|
+
}
|
|
105
|
+
if (((_f = obj.properties) == null ? void 0 : _f.electricLevel) != null && ((_g = obj.properties) == null ? void 0 : _g.electricLevel) != void 0) {
|
|
106
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
107
|
+
"electricLevel",
|
|
108
|
+
obj.properties.electricLevel
|
|
109
|
+
);
|
|
110
|
+
if ((adapter == null ? void 0 : adapter.config.useCalculation) && obj.properties.electricLevel == 100 && isSolarFlow) {
|
|
111
|
+
_device == null ? void 0 : _device.setEnergyWhMax();
|
|
112
|
+
}
|
|
113
|
+
if (obj.properties.electricLevel == 100) {
|
|
114
|
+
const fullChargeNeeded = await adapter.getStateAsync(
|
|
115
|
+
productKey + "." + deviceKey + ".control.fullChargeNeeded"
|
|
116
|
+
);
|
|
117
|
+
if (fullChargeNeeded && fullChargeNeeded.val && fullChargeNeeded.val == true) {
|
|
118
|
+
await (adapter == null ? void 0 : adapter.setState(
|
|
119
|
+
`${productKey}.${deviceKey}.control.fullChargeNeeded`,
|
|
120
|
+
false,
|
|
121
|
+
true
|
|
122
|
+
));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const minSoc = await (adapter == null ? void 0 : adapter.getStateAsync(
|
|
126
|
+
`${productKey}.${deviceKey}.minSoc`
|
|
127
|
+
));
|
|
128
|
+
if ((adapter == null ? void 0 : adapter.config.useCalculation) && minSoc && minSoc.val && obj.properties.electricLevel == Number(minSoc.val) && isSolarFlow) {
|
|
129
|
+
_device == null ? void 0 : _device.setSocToZero();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (obj.power != null && obj.power != void 0) {
|
|
133
|
+
const value = obj.power / 10;
|
|
134
|
+
_device == null ? void 0 : _device.updateSolarFlowState("power", value);
|
|
135
|
+
}
|
|
136
|
+
if (((_h = obj.properties) == null ? void 0 : _h.packState) != null && ((_i = obj.properties) == null ? void 0 : _i.packState) != void 0) {
|
|
137
|
+
const value = ((_j = obj.properties) == null ? void 0 : _j.packState) == 0 ? "Idle" : ((_k = obj.properties) == null ? void 0 : _k.packState) == 1 ? "Charging" : ((_l = obj.properties) == null ? void 0 : _l.packState) == 2 ? "Discharging" : "Unknown";
|
|
138
|
+
_device == null ? void 0 : _device.updateSolarFlowState("packState", value);
|
|
139
|
+
if ((_m = obj.properties) == null ? void 0 : _m.packState) {
|
|
140
|
+
_device == null ? void 0 : _device.updateSolarFlowState("packPower", 0);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (((_n = obj.properties) == null ? void 0 : _n.passMode) != null && ((_o = obj.properties) == null ? void 0 : _o.passMode) != void 0) {
|
|
144
|
+
const value = ((_p = obj.properties) == null ? void 0 : _p.passMode) == 0 ? "Automatic" : ((_q = obj.properties) == null ? void 0 : _q.passMode) == 1 ? "Always off" : ((_r = obj.properties) == null ? void 0 : _r.passMode) == 2 ? "Always on" : "Unknown";
|
|
145
|
+
_device == null ? void 0 : _device.updateSolarFlowState("passMode", value);
|
|
146
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState(
|
|
147
|
+
"passMode",
|
|
148
|
+
(_s = obj.properties) == null ? void 0 : _s.passMode
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
if (((_t = obj.properties) == null ? void 0 : _t.pass) != null && ((_u = obj.properties) == null ? void 0 : _u.pass) != void 0) {
|
|
152
|
+
const value = ((_v = obj.properties) == null ? void 0 : _v.pass) == 0 ? false : true;
|
|
153
|
+
_device == null ? void 0 : _device.updateSolarFlowState("pass", value);
|
|
154
|
+
}
|
|
155
|
+
if (((_w = obj.properties) == null ? void 0 : _w.autoRecover) != null && ((_x = obj.properties) == null ? void 0 : _x.autoRecover) != void 0) {
|
|
156
|
+
const value = ((_y = obj.properties) == null ? void 0 : _y.autoRecover) == 0 ? false : true;
|
|
157
|
+
_device == null ? void 0 : _device.updateSolarFlowState("autoRecover", value);
|
|
158
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState("autoRecover", value);
|
|
159
|
+
}
|
|
160
|
+
if (((_z = obj.properties) == null ? void 0 : _z.outputHomePower) != null && ((_A = obj.properties) == null ? void 0 : _A.outputHomePower) != void 0) {
|
|
161
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
162
|
+
"outputHomePower",
|
|
163
|
+
obj.properties.outputHomePower
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
if (((_B = obj.properties) == null ? void 0 : _B.energyPower) != null && ((_C = obj.properties) == null ? void 0 : _C.energyPower) != void 0) {
|
|
167
|
+
_device == null ? void 0 : _device.updateSolarFlowState("energyPower", obj.properties.energyPower);
|
|
168
|
+
}
|
|
169
|
+
if (((_D = obj.properties) == null ? void 0 : _D.outputLimit) != null && ((_E = obj.properties) == null ? void 0 : _E.outputLimit) != void 0) {
|
|
170
|
+
_device == null ? void 0 : _device.updateSolarFlowState("outputLimit", obj.properties.outputLimit);
|
|
171
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState(
|
|
172
|
+
"setOutputLimit",
|
|
173
|
+
obj.properties.outputLimit
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
if (((_F = obj.properties) == null ? void 0 : _F.smartMode) != null && ((_G = obj.properties) == null ? void 0 : _G.smartMode) != void 0) {
|
|
177
|
+
const value = ((_H = obj.properties) == null ? void 0 : _H.smartMode) == 0 ? false : true;
|
|
178
|
+
_device == null ? void 0 : _device.updateSolarFlowState("smartMode", value);
|
|
179
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState("smartMode", value);
|
|
180
|
+
}
|
|
181
|
+
if (((_I = obj.properties) == null ? void 0 : _I.buzzerSwitch) != null && ((_J = obj.properties) == null ? void 0 : _J.buzzerSwitch) != void 0) {
|
|
182
|
+
const value = ((_K = obj.properties) == null ? void 0 : _K.buzzerSwitch) == 0 ? false : true;
|
|
183
|
+
_device == null ? void 0 : _device.updateSolarFlowState("buzzerSwitch", value);
|
|
184
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState("buzzerSwitch", value);
|
|
185
|
+
}
|
|
186
|
+
if (((_L = obj.properties) == null ? void 0 : _L.outputPackPower) != null && ((_M = obj.properties) == null ? void 0 : _M.outputPackPower) != void 0) {
|
|
187
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
188
|
+
"outputPackPower",
|
|
189
|
+
obj.properties.outputPackPower
|
|
190
|
+
);
|
|
191
|
+
if (((_N = obj.properties) == null ? void 0 : _N.outputPackPower) > 0) {
|
|
192
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
193
|
+
"packPower",
|
|
194
|
+
obj.properties.outputPackPower
|
|
195
|
+
);
|
|
196
|
+
} else if (((_O = obj.properties) == null ? void 0 : _O.outputPackPower) == 0) {
|
|
197
|
+
const packInputPower = await (adapter == null ? void 0 : adapter.getStateAsync(
|
|
198
|
+
productKey + "." + deviceKey + ".packInputPower"
|
|
199
|
+
));
|
|
200
|
+
if ((packInputPower == null ? void 0 : packInputPower.val) == 0) {
|
|
201
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
202
|
+
"packPower",
|
|
203
|
+
-Math.abs(obj.properties.outputPackPower)
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
_device == null ? void 0 : _device.updateSolarFlowState("packInputPower", 0);
|
|
208
|
+
}
|
|
209
|
+
if (((_P = obj.properties) == null ? void 0 : _P.packInputPower) != null && ((_Q = obj.properties) == null ? void 0 : _Q.packInputPower) != void 0) {
|
|
210
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
211
|
+
"packInputPower",
|
|
212
|
+
obj.properties.packInputPower
|
|
213
|
+
);
|
|
214
|
+
if (((_R = obj.properties) == null ? void 0 : _R.packInputPower) > 0) {
|
|
215
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
216
|
+
"packPower",
|
|
217
|
+
-Math.abs(obj.properties.packInputPower)
|
|
218
|
+
);
|
|
219
|
+
} else if (((_S = obj.properties) == null ? void 0 : _S.packInputPower) == 0) {
|
|
220
|
+
const outputPackPower = await (adapter == null ? void 0 : adapter.getStateAsync(
|
|
221
|
+
productKey + "." + deviceKey + ".outputPackPower"
|
|
222
|
+
));
|
|
223
|
+
if ((outputPackPower == null ? void 0 : outputPackPower.val) == 0) {
|
|
224
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
225
|
+
"packPower",
|
|
226
|
+
-Math.abs(obj.properties.packInputPower)
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
_device == null ? void 0 : _device.updateSolarFlowState("outputPackPower", 0);
|
|
231
|
+
}
|
|
232
|
+
if (((_T = obj.properties) == null ? void 0 : _T.solarInputPower) != null && ((_U = obj.properties) == null ? void 0 : _U.solarInputPower) != void 0) {
|
|
233
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
234
|
+
"solarInputPower",
|
|
235
|
+
obj.properties.solarInputPower
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
if (((_V = obj.properties) == null ? void 0 : _V.pvPower1) != null && ((_W = obj.properties) == null ? void 0 : _W.pvPower1) != void 0) {
|
|
239
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
240
|
+
"pvPower2",
|
|
241
|
+
// Reversed to adjust like offical app
|
|
242
|
+
obj.properties.pvPower1
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
if (((_X = obj.properties) == null ? void 0 : _X.pvPower2) != null && ((_Y = obj.properties) == null ? void 0 : _Y.pvPower2) != void 0) {
|
|
246
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
247
|
+
"pvPower1",
|
|
248
|
+
// Reversed to adjust like offical app
|
|
249
|
+
obj.properties.pvPower2
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
if (((_Z = obj.properties) == null ? void 0 : _Z.solarPower1) != null && ((__ = obj.properties) == null ? void 0 : __.solarPower1) != void 0) {
|
|
253
|
+
_device == null ? void 0 : _device.updateSolarFlowState("pvPower1", obj.properties.solarPower1);
|
|
254
|
+
}
|
|
255
|
+
if (((_$ = obj.properties) == null ? void 0 : _$.solarPower2) != null && ((_aa = obj.properties) == null ? void 0 : _aa.solarPower2) != void 0) {
|
|
256
|
+
_device == null ? void 0 : _device.updateSolarFlowState("pvPower2", obj.properties.solarPower2);
|
|
257
|
+
}
|
|
258
|
+
if (((_ba = obj.properties) == null ? void 0 : _ba.solarPower3) != null && ((_ca = obj.properties) == null ? void 0 : _ca.solarPower3) != void 0) {
|
|
259
|
+
_device == null ? void 0 : _device.updateSolarFlowState("pvPower3", obj.properties.solarPower3);
|
|
260
|
+
}
|
|
261
|
+
if (((_da = obj.properties) == null ? void 0 : _da.solarPower4) != null && ((_ea = obj.properties) == null ? void 0 : _ea.solarPower4) != void 0) {
|
|
262
|
+
_device == null ? void 0 : _device.updateSolarFlowState("pvPower4", obj.properties.solarPower4);
|
|
263
|
+
}
|
|
264
|
+
if (((_fa = obj.properties) == null ? void 0 : _fa.remainOutTime) != null && ((_ga = obj.properties) == null ? void 0 : _ga.remainOutTime) != void 0) {
|
|
265
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
266
|
+
"remainOutTime",
|
|
267
|
+
obj.properties.remainOutTime
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
if (((_ha = obj.properties) == null ? void 0 : _ha.remainInputTime) != null && ((_ia = obj.properties) == null ? void 0 : _ia.remainInputTime) != void 0) {
|
|
271
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
272
|
+
"remainInputTime",
|
|
273
|
+
obj.properties.remainInputTime
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
if (((_ja = obj.properties) == null ? void 0 : _ja.socSet) != null && ((_ka = obj.properties) == null ? void 0 : _ka.socSet) != void 0) {
|
|
277
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
278
|
+
"socSet",
|
|
279
|
+
Number(obj.properties.socSet) / 10
|
|
280
|
+
);
|
|
281
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState(
|
|
282
|
+
"chargeLimit",
|
|
283
|
+
Number(obj.properties.socSet) / 10
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
if (((_la = obj.properties) == null ? void 0 : _la.minSoc) != null && ((_ma = obj.properties) == null ? void 0 : _ma.minSoc) != void 0) {
|
|
287
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
288
|
+
"minSoc",
|
|
289
|
+
Number(obj.properties.minSoc) / 10
|
|
290
|
+
);
|
|
291
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState(
|
|
292
|
+
"dischargeLimit",
|
|
293
|
+
Number(obj.properties.minSoc) / 10
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
if (((_na = obj.properties) == null ? void 0 : _na.inputLimit) != null && ((_oa = obj.properties) == null ? void 0 : _oa.inputLimit) != void 0) {
|
|
297
|
+
_device == null ? void 0 : _device.updateSolarFlowState("inputLimit", obj.properties.inputLimit);
|
|
298
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState(
|
|
299
|
+
"setInputLimit",
|
|
300
|
+
obj.properties.inputLimit
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
if (((_pa = obj.properties) == null ? void 0 : _pa.gridInputPower) != null && ((_qa = obj.properties) == null ? void 0 : _qa.gridInputPower) != void 0) {
|
|
304
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
305
|
+
"gridInputPower",
|
|
306
|
+
obj.properties.gridInputPower
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
if (((_ra = obj.properties) == null ? void 0 : _ra.acMode) != null && ((_sa = obj.properties) == null ? void 0 : _sa.acMode) != void 0) {
|
|
310
|
+
_device == null ? void 0 : _device.updateSolarFlowState("acMode", obj.properties.acMode);
|
|
311
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState("acMode", obj.properties.acMode);
|
|
312
|
+
}
|
|
313
|
+
if (((_ta = obj.properties) == null ? void 0 : _ta.hyperTmp) != null && ((_ua = obj.properties) == null ? void 0 : _ua.hyperTmp) != void 0) {
|
|
314
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
315
|
+
"hyperTmp",
|
|
316
|
+
obj.properties.hyperTmp / 10 - 273.15
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
if (((_va = obj.properties) == null ? void 0 : _va.acOutputPower) != null && ((_wa = obj.properties) == null ? void 0 : _wa.acOutputPower) != void 0) {
|
|
320
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
321
|
+
"acOutputPower",
|
|
322
|
+
obj.properties.acOutputPower
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
if (((_xa = obj.properties) == null ? void 0 : _xa.gridPower) != null && ((_ya = obj.properties) == null ? void 0 : _ya.gridPower) != void 0) {
|
|
326
|
+
_device == null ? void 0 : _device.updateSolarFlowState("gridInputPower", obj.properties.gridPower);
|
|
327
|
+
}
|
|
328
|
+
if (((_za = obj.properties) == null ? void 0 : _za.acSwitch) != null && ((_Aa = obj.properties) == null ? void 0 : _Aa.acSwitch) != void 0) {
|
|
329
|
+
const value = ((_Ba = obj.properties) == null ? void 0 : _Ba.acSwitch) == 0 ? false : true;
|
|
330
|
+
_device == null ? void 0 : _device.updateSolarFlowState("acSwitch", value);
|
|
331
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState("acSwitch", value);
|
|
332
|
+
}
|
|
333
|
+
if (((_Ca = obj.properties) == null ? void 0 : _Ca.dcSwitch) != null && ((_Da = obj.properties) == null ? void 0 : _Da.dcSwitch) != void 0) {
|
|
334
|
+
const value = ((_Ea = obj.properties) == null ? void 0 : _Ea.dcSwitch) == 0 ? false : true;
|
|
335
|
+
_device == null ? void 0 : _device.updateSolarFlowState("dcSwitch", value);
|
|
336
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState("dcSwitch", value);
|
|
337
|
+
}
|
|
338
|
+
if (((_Fa = obj.properties) == null ? void 0 : _Fa.dcOutputPower) != null && ((_Ga = obj.properties) == null ? void 0 : _Ga.dcOutputPower) != void 0) {
|
|
339
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
340
|
+
"dcOutputPower",
|
|
341
|
+
obj.properties.dcOutputPower
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
if (((_Ha = obj.properties) == null ? void 0 : _Ha.pvBrand) != null && ((_Ia = obj.properties) == null ? void 0 : _Ia.pvBrand) != void 0) {
|
|
345
|
+
const value = ((_Ja = obj.properties) == null ? void 0 : _Ja.pvBrand) == 0 ? "Others" : ((_Ka = obj.properties) == null ? void 0 : _Ka.pvBrand) == 1 ? "Hoymiles" : ((_La = obj.properties) == null ? void 0 : _La.pvBrand) == 2 ? "Enphase" : ((_Ma = obj.properties) == null ? void 0 : _Ma.pvBrand) == 3 ? "APSystems" : ((_Na = obj.properties) == null ? void 0 : _Na.pvBrand) == 4 ? "Anker" : ((_Oa = obj.properties) == null ? void 0 : _Oa.pvBrand) == 5 ? "Deye" : ((_Pa = obj.properties) == null ? void 0 : _Pa.pvBrand) == 6 ? "Bosswerk" : "Unknown";
|
|
346
|
+
_device == null ? void 0 : _device.updateSolarFlowState("pvBrand", value);
|
|
347
|
+
}
|
|
348
|
+
if (((_Qa = obj.properties) == null ? void 0 : _Qa.inverseMaxPower) != null && ((_Ra = obj.properties) == null ? void 0 : _Ra.inverseMaxPower) != void 0) {
|
|
349
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
350
|
+
"inverseMaxPower",
|
|
351
|
+
obj.properties.inverseMaxPower
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
if (((_Sa = obj.properties) == null ? void 0 : _Sa.wifiState) != null && ((_Ta = obj.properties) == null ? void 0 : _Ta.wifiState) != void 0) {
|
|
355
|
+
_device == null ? void 0 : _device.updateSolarFlowState(
|
|
356
|
+
"wifiState",
|
|
357
|
+
obj.properties.wifiState == 1 ? "Connected" : "Disconnected"
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
if (((_Ua = obj.properties) == null ? void 0 : _Ua.packNum) != null && ((_Va = obj.properties) == null ? void 0 : _Va.packNum) != void 0) {
|
|
361
|
+
_device == null ? void 0 : _device.updateSolarFlowState("packNum", obj.properties.packNum);
|
|
362
|
+
}
|
|
363
|
+
if (((_Wa = obj.properties) == null ? void 0 : _Wa.hubState) != null && ((_Xa = obj.properties) == null ? void 0 : _Xa.hubState) != void 0) {
|
|
364
|
+
_device == null ? void 0 : _device.updateSolarFlowState("hubState", obj.properties.hubState);
|
|
365
|
+
_device == null ? void 0 : _device.updateSolarFlowControlState("hubState", obj.properties.hubState);
|
|
366
|
+
}
|
|
367
|
+
if (obj.packData) {
|
|
368
|
+
_device == null ? void 0 : _device.addOrUpdatePackData(obj.packData, isSolarFlow);
|
|
369
|
+
}
|
|
370
|
+
if (obj.properties && adapter.log.level == "debug") {
|
|
371
|
+
let found = false;
|
|
372
|
+
Object.entries(obj.properties).forEach(([key, value]) => {
|
|
373
|
+
_device == null ? void 0 : _device.states.forEach((state) => {
|
|
374
|
+
if (state.title == key) {
|
|
375
|
+
found = true;
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
if (found) {
|
|
379
|
+
} else {
|
|
380
|
+
adapter == null ? void 0 : adapter.log.debug(
|
|
381
|
+
`[onMessage] ${_device == null ? void 0 : _device.deviceKey}: ${key} with value ${JSON.stringify(value)} is a UNKNOWN Mqtt Property!`
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
const onConnected = () => {
|
|
389
|
+
if (adapter) {
|
|
390
|
+
adapter.lastLogin = /* @__PURE__ */ new Date();
|
|
391
|
+
adapter.setState("info.connection", true, true);
|
|
392
|
+
adapter.log.info("[onConnected] Connected with MQTT!");
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
const onError = (error) => {
|
|
396
|
+
if (adapter) {
|
|
397
|
+
adapter.setState("info.connection", false, true);
|
|
398
|
+
adapter.log.error("Connection to MQTT failed! Error: " + error);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
const onSubscribeReportTopic = (error) => {
|
|
402
|
+
if (error) {
|
|
403
|
+
adapter == null ? void 0 : adapter.log.error("Subscription to MQTT failed! Error: " + error);
|
|
404
|
+
} else {
|
|
405
|
+
adapter == null ? void 0 : adapter.log.debug("Subscription of Report Topic successful!");
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
const onSubscribeIotTopic = (error, productKey, deviceKey) => {
|
|
409
|
+
if (error) {
|
|
410
|
+
adapter == null ? void 0 : adapter.log.error("Subscription to MQTT failed! Error: " + error);
|
|
411
|
+
} else if (adapter) {
|
|
412
|
+
adapter == null ? void 0 : adapter.log.debug("Subscription of IOT Topic successful!");
|
|
413
|
+
const _device = adapter.zenHaDeviceList.find(
|
|
414
|
+
(x) => x.productKey == productKey && x.deviceKey == deviceKey
|
|
415
|
+
);
|
|
416
|
+
if (_device) {
|
|
417
|
+
_device.triggerFullTelemetryUpdate();
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
422
|
+
0 && (module.exports = {
|
|
423
|
+
adapter,
|
|
424
|
+
initAdapter,
|
|
425
|
+
knownPackDataProperties,
|
|
426
|
+
onConnected,
|
|
427
|
+
onError,
|
|
428
|
+
onMessage,
|
|
429
|
+
onSubscribeIotTopic,
|
|
430
|
+
onSubscribeReportTopic
|
|
431
|
+
});
|
|
432
|
+
//# sourceMappingURL=mqttSharedService.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/services/mqttSharedService.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/indent */\nimport { ZendureSolarflow } from \"../main\";\n\nimport { IMqttData } from \"../models/ISolarFlowMqttProperties\";\nimport { ISolarflowState } from \"../models/ISolarflowState\";\n\nexport let adapter: ZendureSolarflow | undefined = undefined;\n\nexport const knownPackDataProperties = [\n \"sn\",\n \"totalVol\",\n \"maxVol\",\n \"minVol\",\n \"socLevel\",\n \"maxTemp\",\n \"soh\",\n \"power\",\n \"batcur\",\n];\n\nexport const initAdapter = (_adapter: ZendureSolarflow): boolean => {\n adapter = _adapter;\n\n adapter.log.debug(\"[initAdapter] Init adapter in mqttSharedService!\");\n\n return true;\n};\n\nexport const onMessage = async (\n topic: string,\n message: Buffer\n): Promise<void> => {\n if (adapter) {\n if (topic.toLowerCase().includes(\"loginOut/force\")) {\n // TODO: Ausloggen???\n }\n\n const topicSplitted = topic.replace(\"/server/app\", \"\").split(\"/\");\n const productKey = topicSplitted[1];\n const deviceKey = topicSplitted[2];\n\n let obj: IMqttData = {};\n try {\n obj = JSON.parse(message.toString());\n } catch (e) {\n const txt = message.toString();\n adapter.log.error(`[onMessage] JSON Parse error!`);\n\n adapter.log.debug(`[onMessage] JSON Parse error: ${txt}!`);\n }\n\n let isSolarFlow = false;\n\n const _device = adapter?.zenHaDeviceList.find(\n (x) => x.deviceKey == deviceKey\n );\n\n if (!_device) {\n adapter.log.error(\n `[onMessage] DeviceKey '${deviceKey} not found in device list!'}`\n );\n }\n\n if (adapter.log.level == \"debug\") {\n adapter.log.debug(\n `[onMessage] MQTT message on topic '${topic}': ${message.toString()}`\n );\n }\n\n /* if (obj.timestamp) {\n const currentTimeStamp = new Date().getTime() / 1000;\n const diff = currentTimeStamp - obj.timestamp;\n\n if (diff > 600) {\n // Timestamp older than 5 Minutens, device is offline!\n _device?.updateSolarFlowState(\"wifiState\", \"Disconnected\");\n } else {\n // Timestamp older than 5 Minutens, device is offline!\n _device?.updateSolarFlowState(\"wifiState\", \"Connected\");\n }\n } */\n\n // Check if device is an solarflow or hyper device. Don't use LowVoltageBlock on an ACE device?\n if (productKey != \"8bM93H\") {\n isSolarFlow = true;\n }\n\n //\n if (obj.function == \"deviceAutomation\" && obj.success == 1) {\n // setDeviceAutomationInOutLimit ack = true setzen;\n const currentValue = await adapter.getStateAsync(\n productKey + \".\" + deviceKey + \".control.setDeviceAutomationInOutLimit\"\n );\n\n _device?.updateSolarFlowControlState(\n \"setDeviceAutomationInOutLimit\",\n currentValue?.val ? currentValue.val : 0\n );\n } else if (obj.function == \"deviceAutomation\" && obj.success == 0) {\n adapter?.log.warn(\n `[onMessage] device automation failed for ${_device?.productName}: ${productKey}/${deviceKey}!`\n );\n }\n\n if (\n obj.properties?.autoModel != null &&\n obj.properties?.autoModel != undefined\n ) {\n _device?.updateSolarFlowState(\"autoModel\", obj.properties.autoModel);\n\n _device?.updateSolarFlowControlState(\n \"autoModel\",\n obj.properties.autoModel\n );\n }\n\n if (\n obj.properties?.heatState != null &&\n obj.properties?.heatState != undefined\n ) {\n const value = obj.properties?.heatState == 0 ? false : true;\n\n _device?.updateSolarFlowState(\"heatState\", value);\n }\n\n if (\n obj.properties?.electricLevel != null &&\n obj.properties?.electricLevel != undefined\n ) {\n _device?.updateSolarFlowState(\n \"electricLevel\",\n obj.properties.electricLevel\n );\n\n if (\n adapter?.config.useCalculation &&\n obj.properties.electricLevel == 100 &&\n isSolarFlow\n ) {\n _device?.setEnergyWhMax();\n }\n\n if (obj.properties.electricLevel == 100) {\n const fullChargeNeeded = await adapter.getStateAsync(\n productKey + \".\" + deviceKey + \".control.fullChargeNeeded\"\n );\n\n if (\n fullChargeNeeded &&\n fullChargeNeeded.val &&\n fullChargeNeeded.val == true\n ) {\n await adapter?.setState(\n `${productKey}.${deviceKey}.control.fullChargeNeeded`,\n false,\n true\n );\n }\n }\n\n // if minSoc is reached, set the calculated soc to 0\n const minSoc = await adapter?.getStateAsync(\n `${productKey}.${deviceKey}.minSoc`\n );\n if (\n adapter?.config.useCalculation &&\n minSoc &&\n minSoc.val &&\n obj.properties.electricLevel == Number(minSoc.val) &&\n isSolarFlow\n ) {\n _device?.setSocToZero();\n }\n }\n\n if (obj.power != null && obj.power != undefined) {\n const value = obj.power / 10;\n _device?.updateSolarFlowState(\"power\", value);\n }\n\n if (\n obj.properties?.packState != null &&\n obj.properties?.packState != undefined\n ) {\n const value =\n obj.properties?.packState == 0\n ? \"Idle\"\n : obj.properties?.packState == 1\n ? \"Charging\"\n : obj.properties?.packState == 2\n ? \"Discharging\"\n : \"Unknown\";\n _device?.updateSolarFlowState(\"packState\", value);\n\n if (obj.properties?.packState) {\n // Update combined data point\n _device?.updateSolarFlowState(\"packPower\", 0);\n }\n }\n\n if (\n obj.properties?.passMode != null &&\n obj.properties?.passMode != undefined\n ) {\n const value =\n obj.properties?.passMode == 0\n ? \"Automatic\"\n : obj.properties?.passMode == 1\n ? \"Always off\"\n : obj.properties?.passMode == 2\n ? \"Always on\"\n : \"Unknown\";\n _device?.updateSolarFlowState(\"passMode\", value);\n\n _device?.updateSolarFlowControlState(\n \"passMode\",\n obj.properties?.passMode\n );\n }\n\n if (obj.properties?.pass != null && obj.properties?.pass != undefined) {\n const value = obj.properties?.pass == 0 ? false : true;\n\n _device?.updateSolarFlowState(\"pass\", value);\n }\n\n if (\n obj.properties?.autoRecover != null &&\n obj.properties?.autoRecover != undefined\n ) {\n const value = obj.properties?.autoRecover == 0 ? false : true;\n\n _device?.updateSolarFlowState(\"autoRecover\", value);\n\n _device?.updateSolarFlowControlState(\"autoRecover\", value);\n }\n\n if (\n obj.properties?.outputHomePower != null &&\n obj.properties?.outputHomePower != undefined\n ) {\n _device?.updateSolarFlowState(\n \"outputHomePower\",\n obj.properties.outputHomePower\n );\n }\n\n if (\n obj.properties?.energyPower != null &&\n obj.properties?.energyPower != undefined\n ) {\n _device?.updateSolarFlowState(\"energyPower\", obj.properties.energyPower);\n }\n\n if (\n obj.properties?.outputLimit != null &&\n obj.properties?.outputLimit != undefined\n ) {\n _device?.updateSolarFlowState(\"outputLimit\", obj.properties.outputLimit);\n\n _device?.updateSolarFlowControlState(\n \"setOutputLimit\",\n obj.properties.outputLimit\n );\n }\n\n if (\n obj.properties?.smartMode != null &&\n obj.properties?.smartMode != undefined\n ) {\n const value = obj.properties?.smartMode == 0 ? false : true;\n\n _device?.updateSolarFlowState(\"smartMode\", value);\n\n _device?.updateSolarFlowControlState(\"smartMode\", value);\n }\n\n if (\n obj.properties?.buzzerSwitch != null &&\n obj.properties?.buzzerSwitch != undefined\n ) {\n const value = obj.properties?.buzzerSwitch == 0 ? false : true;\n\n _device?.updateSolarFlowState(\"buzzerSwitch\", value);\n\n _device?.updateSolarFlowControlState(\"buzzerSwitch\", value);\n }\n\n if (\n obj.properties?.outputPackPower != null &&\n obj.properties?.outputPackPower != undefined\n ) {\n _device?.updateSolarFlowState(\n \"outputPackPower\",\n obj.properties.outputPackPower\n );\n\n if (obj.properties?.outputPackPower > 0) {\n // Update combined data point\n _device?.updateSolarFlowState(\n \"packPower\",\n obj.properties.outputPackPower\n );\n } else if (obj.properties?.outputPackPower == 0) {\n // Check if packInputPower is 0\n const packInputPower = await adapter?.getStateAsync(\n productKey + \".\" + deviceKey + \".packInputPower\"\n );\n\n if (packInputPower?.val == 0) {\n // Update combined data point to 0 as both are 0\n _device?.updateSolarFlowState(\n \"packPower\",\n -Math.abs(obj.properties.outputPackPower)\n );\n }\n }\n\n // if outPutPackPower set packInputPower to 0\n _device?.updateSolarFlowState(\"packInputPower\", 0);\n }\n\n if (\n obj.properties?.packInputPower != null &&\n obj.properties?.packInputPower != undefined\n ) {\n _device?.updateSolarFlowState(\n \"packInputPower\",\n obj.properties.packInputPower\n );\n\n if (obj.properties?.packInputPower > 0) {\n // Update combined data point\n _device?.updateSolarFlowState(\n \"packPower\",\n -Math.abs(obj.properties.packInputPower)\n );\n } else if (obj.properties?.packInputPower == 0) {\n // Check if outputPackPower is 0\n const outputPackPower = await adapter?.getStateAsync(\n productKey + \".\" + deviceKey + \".outputPackPower\"\n );\n\n if (outputPackPower?.val == 0) {\n // Update combined data point to 0 as both are 0\n _device?.updateSolarFlowState(\n \"packPower\",\n -Math.abs(obj.properties.packInputPower)\n );\n }\n }\n\n // if packInputPower set outputPackPower to 0\n _device?.updateSolarFlowState(\"outputPackPower\", 0);\n }\n\n if (\n obj.properties?.solarInputPower != null &&\n obj.properties?.solarInputPower != undefined\n ) {\n _device?.updateSolarFlowState(\n \"solarInputPower\",\n obj.properties.solarInputPower\n );\n }\n\n if (\n obj.properties?.pvPower1 != null &&\n obj.properties?.pvPower1 != undefined\n ) {\n _device?.updateSolarFlowState(\n \"pvPower2\", // Reversed to adjust like offical app\n obj.properties.pvPower1\n );\n }\n\n if (\n obj.properties?.pvPower2 != null &&\n obj.properties?.pvPower2 != undefined\n ) {\n _device?.updateSolarFlowState(\n \"pvPower1\", // Reversed to adjust like offical app\n obj.properties.pvPower2\n );\n }\n\n if (\n obj.properties?.solarPower1 != null &&\n obj.properties?.solarPower1 != undefined\n ) {\n _device?.updateSolarFlowState(\"pvPower1\", obj.properties.solarPower1);\n }\n\n if (\n obj.properties?.solarPower2 != null &&\n obj.properties?.solarPower2 != undefined\n ) {\n _device?.updateSolarFlowState(\"pvPower2\", obj.properties.solarPower2);\n }\n\n if (\n obj.properties?.solarPower3 != null &&\n obj.properties?.solarPower3 != undefined\n ) {\n _device?.updateSolarFlowState(\"pvPower3\", obj.properties.solarPower3);\n }\n\n if (\n obj.properties?.solarPower4 != null &&\n obj.properties?.solarPower4 != undefined\n ) {\n _device?.updateSolarFlowState(\"pvPower4\", obj.properties.solarPower4);\n }\n\n if (\n obj.properties?.remainOutTime != null &&\n obj.properties?.remainOutTime != undefined\n ) {\n _device?.updateSolarFlowState(\n \"remainOutTime\",\n obj.properties.remainOutTime\n );\n }\n\n if (\n obj.properties?.remainInputTime != null &&\n obj.properties?.remainInputTime != undefined\n ) {\n _device?.updateSolarFlowState(\n \"remainInputTime\",\n obj.properties.remainInputTime\n );\n }\n\n if (obj.properties?.socSet != null && obj.properties?.socSet != undefined) {\n _device?.updateSolarFlowState(\n \"socSet\",\n Number(obj.properties.socSet) / 10\n );\n\n _device?.updateSolarFlowControlState(\n \"chargeLimit\",\n Number(obj.properties.socSet) / 10\n );\n }\n\n if (obj.properties?.minSoc != null && obj.properties?.minSoc != undefined) {\n _device?.updateSolarFlowState(\n \"minSoc\",\n Number(obj.properties.minSoc) / 10\n );\n\n _device?.updateSolarFlowControlState(\n \"dischargeLimit\",\n Number(obj.properties.minSoc) / 10\n );\n }\n\n if (\n obj.properties?.inputLimit != null &&\n obj.properties?.inputLimit != undefined\n ) {\n _device?.updateSolarFlowState(\"inputLimit\", obj.properties.inputLimit);\n\n _device?.updateSolarFlowControlState(\n \"setInputLimit\",\n obj.properties.inputLimit\n );\n }\n\n if (\n obj.properties?.gridInputPower != null &&\n obj.properties?.gridInputPower != undefined\n ) {\n _device?.updateSolarFlowState(\n \"gridInputPower\",\n obj.properties.gridInputPower\n );\n }\n\n if (obj.properties?.acMode != null && obj.properties?.acMode != undefined) {\n _device?.updateSolarFlowState(\"acMode\", obj.properties.acMode);\n\n _device?.updateSolarFlowControlState(\"acMode\", obj.properties.acMode);\n }\n\n if (\n obj.properties?.hyperTmp != null &&\n obj.properties?.hyperTmp != undefined\n ) {\n _device?.updateSolarFlowState(\n \"hyperTmp\",\n obj.properties.hyperTmp / 10 - 273.15\n );\n }\n\n if (\n obj.properties?.acOutputPower != null &&\n obj.properties?.acOutputPower != undefined\n ) {\n _device?.updateSolarFlowState(\n \"acOutputPower\",\n obj.properties.acOutputPower\n );\n }\n\n if (\n obj.properties?.gridPower != null &&\n obj.properties?.gridPower != undefined\n ) {\n _device?.updateSolarFlowState(\"gridInputPower\", obj.properties.gridPower);\n }\n\n if (\n obj.properties?.acSwitch != null &&\n obj.properties?.acSwitch != undefined\n ) {\n const value = obj.properties?.acSwitch == 0 ? false : true;\n\n _device?.updateSolarFlowState(\"acSwitch\", value);\n\n _device?.updateSolarFlowControlState(\"acSwitch\", value);\n }\n\n if (\n obj.properties?.dcSwitch != null &&\n obj.properties?.dcSwitch != undefined\n ) {\n const value = obj.properties?.dcSwitch == 0 ? false : true;\n\n _device?.updateSolarFlowState(\"dcSwitch\", value);\n\n _device?.updateSolarFlowControlState(\"dcSwitch\", value);\n }\n\n if (\n obj.properties?.dcOutputPower != null &&\n obj.properties?.dcOutputPower != undefined\n ) {\n _device?.updateSolarFlowState(\n \"dcOutputPower\",\n obj.properties.dcOutputPower\n );\n }\n\n if (\n obj.properties?.pvBrand != null &&\n obj.properties?.pvBrand != undefined\n ) {\n const value =\n obj.properties?.pvBrand == 0\n ? \"Others\"\n : obj.properties?.pvBrand == 1\n ? \"Hoymiles\"\n : obj.properties?.pvBrand == 2\n ? \"Enphase\"\n : obj.properties?.pvBrand == 3\n ? \"APSystems\"\n : obj.properties?.pvBrand == 4\n ? \"Anker\"\n : obj.properties?.pvBrand == 5\n ? \"Deye\"\n : obj.properties?.pvBrand == 6\n ? \"Bosswerk\"\n : \"Unknown\";\n _device?.updateSolarFlowState(\"pvBrand\", value);\n }\n\n if (\n obj.properties?.inverseMaxPower != null &&\n obj.properties?.inverseMaxPower != undefined\n ) {\n _device?.updateSolarFlowState(\n \"inverseMaxPower\",\n obj.properties.inverseMaxPower\n );\n }\n\n if (\n obj.properties?.wifiState != null &&\n obj.properties?.wifiState != undefined\n ) {\n _device?.updateSolarFlowState(\n \"wifiState\",\n obj.properties.wifiState == 1 ? \"Connected\" : \"Disconnected\"\n );\n }\n\n if (\n obj.properties?.packNum != null &&\n obj.properties?.packNum != undefined\n ) {\n _device?.updateSolarFlowState(\"packNum\", obj.properties.packNum);\n }\n\n if (\n obj.properties?.hubState != null &&\n obj.properties?.hubState != undefined\n ) {\n _device?.updateSolarFlowState(\"hubState\", obj.properties.hubState);\n\n _device?.updateSolarFlowControlState(\"hubState\", obj.properties.hubState);\n }\n\n if (obj.packData) {\n _device?.addOrUpdatePackData(obj.packData, isSolarFlow);\n }\n\n if (obj.properties && adapter.log.level == \"debug\") {\n let found = false;\n\n Object.entries(obj.properties).forEach(([key, value]) => {\n _device?.states.forEach((state: ISolarflowState) => {\n if (state.title == key) {\n found = true;\n }\n });\n\n if (found) {\n //console.log(\n // `${productName?.val}: ${key} with value ${value} is a KNOWN Mqtt Prop!`\n //);\n } else {\n adapter?.log.debug(\n `[onMessage] ${_device?.deviceKey}: ${key} with value ${JSON.stringify(value)} is a UNKNOWN Mqtt Property!`\n );\n }\n });\n }\n }\n};\n\nexport const onConnected = (): void => {\n if (adapter) {\n adapter.lastLogin = new Date();\n adapter.setState(\"info.connection\", true, true);\n adapter.log.info(\"[onConnected] Connected with MQTT!\");\n }\n};\n\nexport const onError = (error: any): void => {\n if (adapter) {\n adapter.setState(\"info.connection\", false, true);\n adapter.log.error(\"Connection to MQTT failed! Error: \" + error);\n }\n};\n\nexport const onSubscribeReportTopic: any = (error: Error | null) => {\n if (error) {\n adapter?.log.error(\"Subscription to MQTT failed! Error: \" + error);\n } else {\n adapter?.log.debug(\"Subscription of Report Topic successful!\");\n }\n};\n\nexport const onSubscribeIotTopic: any = (\n error: Error | null,\n productKey: string,\n deviceKey: string\n) => {\n if (error) {\n adapter?.log.error(\"Subscription to MQTT failed! Error: \" + error);\n } else if (adapter) {\n adapter?.log.debug(\"Subscription of IOT Topic successful!\");\n\n const _device = adapter.zenHaDeviceList.find(\n (x) => x.productKey == productKey && x.deviceKey == deviceKey\n );\n\n if (_device) {\n _device.triggerFullTelemetryUpdate();\n }\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAI,UAAwC;AAE5C,MAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,cAAc,CAAC,aAAwC;AAClE,YAAU;AAEV,UAAQ,IAAI,MAAM,kDAAkD;AAEpE,SAAO;AACT;AAEO,MAAM,YAAY,OACvB,OACA,YACkB;AA/BpB;AAgCE,MAAI,SAAS;AACX,QAAI,MAAM,YAAY,EAAE,SAAS,gBAAgB,GAAG;AAAA,IAEpD;AAEA,UAAM,gBAAgB,MAAM,QAAQ,eAAe,EAAE,EAAE,MAAM,GAAG;AAChE,UAAM,aAAa,cAAc,CAAC;AAClC,UAAM,YAAY,cAAc,CAAC;AAEjC,QAAI,MAAiB,CAAC;AACtB,QAAI;AACF,YAAM,KAAK,MAAM,QAAQ,SAAS,CAAC;AAAA,IACrC,SAAS,GAAG;AACV,YAAM,MAAM,QAAQ,SAAS;AAC7B,cAAQ,IAAI,MAAM,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AM,cAAc,MAAY;AACrC,MAAI,SAAS;AACX,YAAQ,YAAY,oBAAI,KAAK;AAC7B,YAAQ,SAAS,mBAAmB,MAAM,IAAI;AAC9C,YAAQ,IAAI,KAAK,oCAAoC;AAAA,EACvD;AACF;AAEO,MAAM,UAAU,CAAC,UAAqB;AAC3C,MAAI,SAAS;AACX,YAAQ,SAAS,mBAAmB,OAAO,IAAI;AAC/C,YAAQ,IAAI,MAAM,uCAAuC,KAAK;AAAA,EAChE;AACF;AAEO,MAAM,yBAA8B,CAAC,UAAwB;AAClE,MAAI,OAAO;AACT,uCAAS,IAAI,MAAM,yCAAyC;AAAA,EAC9D,OAAO;AACL,uCAAS,IAAI,MAAM;AAAA,EACrB;AACF;AAEO,MAAM,sBAA2B,CACtC,OACA,YACA,cACG;AACH,MAAI,OAAO;AACT,uCAAS,IAAI,MAAM,yCAAyC;AAAA,EAC9D,WAAW,SAAS;AAClB,uCAAS,IAAI,MAAM;AAEnB,UAAM,UAAU,QAAQ,gBAAgB;AAAA,MACtC,CAAC,MAAM,EAAE,cAAc,cAAc,EAAE,aAAa;AAAA,IACtD;AAEA,QAAI,SAAS;AACX,cAAQ,2BAA2B;AAAA,IACrC;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var zenWebService_exports = {};
|
|
30
|
+
__export(zenWebService_exports, {
|
|
31
|
+
zenLogin: () => zenLogin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(zenWebService_exports);
|
|
34
|
+
var import_axios = __toESM(require("axios"));
|
|
35
|
+
var import_constants = require("../constants/constants");
|
|
36
|
+
var crypto = __toESM(require("crypto"));
|
|
37
|
+
const zenLogin = async (adapter) => {
|
|
38
|
+
const decodedAuthCloudKey = Buffer.from(
|
|
39
|
+
adapter.config.authorizationCloudKey,
|
|
40
|
+
"base64"
|
|
41
|
+
).toString("utf-8");
|
|
42
|
+
console.log("Decoded Key:" + decodedAuthCloudKey);
|
|
43
|
+
const lastDot = decodedAuthCloudKey.lastIndexOf(".");
|
|
44
|
+
if (lastDot === -1) {
|
|
45
|
+
}
|
|
46
|
+
const apiUrl = decodedAuthCloudKey.slice(0, lastDot);
|
|
47
|
+
const appKey = decodedAuthCloudKey.slice(lastDot + 1);
|
|
48
|
+
const body = {
|
|
49
|
+
appKey
|
|
50
|
+
};
|
|
51
|
+
const timestamp = Math.floor(Date.now() / 1e3);
|
|
52
|
+
const nonce = (Math.floor(Math.random() * 9e4) + 1e4).toString();
|
|
53
|
+
const signParams = {
|
|
54
|
+
...body,
|
|
55
|
+
timestamp,
|
|
56
|
+
nonce
|
|
57
|
+
};
|
|
58
|
+
const bodyStr = Object.keys(signParams).sort().map((k) => `${k}${signParams[k]}`).join("");
|
|
59
|
+
const signStr = `${import_constants.haKey}${bodyStr}${import_constants.haKey}`;
|
|
60
|
+
const sha1 = crypto.createHash("sha1");
|
|
61
|
+
sha1.update(signStr, "utf8");
|
|
62
|
+
const sign = sha1.digest("hex").toUpperCase();
|
|
63
|
+
const headers = {
|
|
64
|
+
"Content-Type": "application/json",
|
|
65
|
+
timestamp: timestamp.toString(),
|
|
66
|
+
nonce,
|
|
67
|
+
clientid: "zenHa",
|
|
68
|
+
sign
|
|
69
|
+
};
|
|
70
|
+
const config = {
|
|
71
|
+
headers,
|
|
72
|
+
timeout: 1e4
|
|
73
|
+
};
|
|
74
|
+
return import_axios.default.post(`${apiUrl}/api/ha/deviceList`, JSON.stringify(body), config).then(async function(response) {
|
|
75
|
+
const data = await response.data;
|
|
76
|
+
console.log(data);
|
|
77
|
+
return data.data;
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
zenLogin
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=zenWebService.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/services/zenWebService.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/indent */\nimport axios, { AxiosRequestConfig } from \"axios\";\nimport { haKey } from \"../constants/constants\";\nimport { ZendureSolarflow } from \"../main\";\nimport * as crypto from \"crypto\";\nimport { IHaDeviceListData } from \"../models/IHaDeviceListData\";\n\nexport const zenLogin = async (\n adapter: ZendureSolarflow\n): Promise<string | IHaDeviceListData | undefined> => {\n const decodedAuthCloudKey = Buffer.from(\n adapter.config.authorizationCloudKey,\n \"base64\"\n ).toString(\"utf-8\");\n\n console.log(\"Decoded Key:\" + decodedAuthCloudKey);\n\n const lastDot = decodedAuthCloudKey.lastIndexOf(\".\");\n if (lastDot === -1) {\n // Invalid\n }\n\n const apiUrl = decodedAuthCloudKey.slice(0, lastDot);\n const appKey = decodedAuthCloudKey.slice(lastDot + 1);\n\n const body = {\n appKey: appKey,\n };\n\n // Timestamp und Nonce\n const timestamp = Math.floor(Date.now() / 1000);\n const nonce = (Math.floor(Math.random() * 90000) + 10000).toString();\n\n // Signatur-Parameter\n const signParams: Record<string, string | number> = {\n ...body,\n timestamp: timestamp,\n nonce: nonce,\n };\n\n // Signatur-String erstellen\n const bodyStr = Object.keys(signParams)\n .sort()\n .map((k) => `${k}${signParams[k]}`)\n .join(\"\");\n\n const signStr = `${haKey}${bodyStr}${haKey}`;\n\n // SHA1-Hash berechnen\n const sha1 = crypto.createHash(\"sha1\");\n sha1.update(signStr, \"utf8\");\n const sign = sha1.digest(\"hex\").toUpperCase();\n\n // Header bauen\n const headers = {\n \"Content-Type\": \"application/json\",\n timestamp: timestamp.toString(),\n nonce: nonce,\n clientid: \"zenHa\",\n sign: sign,\n };\n\n const config: AxiosRequestConfig = {\n headers: headers,\n timeout: 10000,\n };\n\n // Request\n return axios\n .post(`${apiUrl}/api/ha/deviceList`, JSON.stringify(body), config)\n .then(async function (response) {\n const data = await response.data;\n\n console.log(data);\n\n return data.data;\n });\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA0C;AAC1C,uBAAsB;AAEtB,aAAwB;AAGjB,MAAM,WAAW,OACtB,YACoD;AACpD,QAAM,sBAAsB,OAAO;AAAA,IACjC,QA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