iobroker.zendure-solarflow 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -4
- package/admin/build/index.js +34 -34
- package/admin/build/index.js.map +3 -3
- package/build/helpers/createCalculationStates.js +1 -1
- package/build/helpers/createCalculationStates.js.map +2 -2
- package/build/helpers/createSolarFlowLocalStates.js +133 -0
- package/build/helpers/createSolarFlowLocalStates.js.map +7 -0
- package/build/main.js +5 -2
- package/build/main.js.map +2 -2
- package/build/models/ISolarFlowMqttProperties.js.map +2 -2
- package/build/services/calculationService.js +21 -13
- package/build/services/calculationService.js.map +2 -2
- package/build/services/jobSchedule.js +32 -15
- package/build/services/jobSchedule.js.map +2 -2
- package/build/services/mqttService.js +136 -65
- package/build/services/mqttService.js.map +3 -3
- package/io-package.json +15 -15
- package/package.json +4 -4
|
@@ -45,22 +45,39 @@ const startResetValuesJob = async (adapter) => {
|
|
|
45
45
|
};
|
|
46
46
|
const startCalculationJob = async (adapter) => {
|
|
47
47
|
adapter.calculationJob = (0, import_node_schedule.scheduleJob)("*/30 * * * * *", () => {
|
|
48
|
-
adapter.
|
|
49
|
-
if (
|
|
50
|
-
(0, import_calculationService.calculateEnergy)(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
adapter,
|
|
56
|
-
subDevice.productKey,
|
|
57
|
-
subDevice.deviceKey
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
48
|
+
if (adapter.config.server == "local") {
|
|
49
|
+
if (adapter.config.localDevice1ProductKey && adapter.config.localDevice1DeviceKey) {
|
|
50
|
+
(0, import_calculationService.calculateEnergy)(
|
|
51
|
+
adapter,
|
|
52
|
+
adapter.config.localDevice1ProductKey,
|
|
53
|
+
adapter.config.localDevice1DeviceKey
|
|
54
|
+
);
|
|
62
55
|
}
|
|
63
|
-
|
|
56
|
+
if (adapter.config.localDevice2ProductKey && adapter.config.localDevice2DeviceKey) {
|
|
57
|
+
(0, import_calculationService.calculateEnergy)(
|
|
58
|
+
adapter,
|
|
59
|
+
adapter.config.localDevice2ProductKey,
|
|
60
|
+
adapter.config.localDevice2DeviceKey
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
adapter.deviceList.forEach((device) => {
|
|
65
|
+
if (device.productKey != "s3Xk4x") {
|
|
66
|
+
(0, import_calculationService.calculateEnergy)(adapter, device.productKey, device.deviceKey);
|
|
67
|
+
if (device.packList && device.packList.length > 0) {
|
|
68
|
+
device.packList.forEach(async (subDevice) => {
|
|
69
|
+
if (subDevice.productName.toLocaleLowerCase() == "ace 1500") {
|
|
70
|
+
(0, import_calculationService.calculateEnergy)(
|
|
71
|
+
adapter,
|
|
72
|
+
subDevice.productKey,
|
|
73
|
+
subDevice.deviceKey
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
64
81
|
});
|
|
65
82
|
};
|
|
66
83
|
const startCheckStatesAndConnectionJob = async (adapter) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/services/jobSchedule.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/indent */\r\nimport { scheduleJob } from \"node-schedule\";\r\nimport { ZendureSolarflow } from \"../main\";\r\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,2BAA4B;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/indent */\r\nimport { scheduleJob } from \"node-schedule\";\r\nimport { ZendureSolarflow } from \"../main\";\r\nimport { ISolarFlowDeviceDetails } from \"../models/ISolarFlowDeviceDetails\";\r\nimport { calculateEnergy, resetTodaysValues } from \"./calculationService\";\r\n\r\nexport const startRefreshAccessTokenTimerJob = async (\r\n adapter: ZendureSolarflow\r\n): Promise<void> => {\r\n adapter.refreshAccessTokenInterval = adapter.setInterval(\r\n async () => {\r\n adapter.log.info(\r\n `Refresh Access Token - Adapter will restart in 20 seconds!`\r\n );\r\n\r\n await adapter.delay(20 * 1000);\r\n adapter.restart();\r\n },\r\n 3 * 60 * 60 * 1000\r\n );\r\n};\r\n\r\nexport const startResetValuesJob = async (\r\n adapter: ZendureSolarflow\r\n): Promise<void> => {\r\n adapter.resetValuesJob = scheduleJob(\"5 0 0 * * *\", () => {\r\n // Reset Values\r\n resetTodaysValues(adapter);\r\n });\r\n};\r\n\r\nexport const startCalculationJob = async (\r\n adapter: ZendureSolarflow\r\n): Promise<void> => {\r\n adapter.calculationJob = scheduleJob(\"*/30 * * * * *\", () => {\r\n if (adapter.config.server == \"local\") {\r\n if (\r\n adapter.config.localDevice1ProductKey &&\r\n adapter.config.localDevice1DeviceKey\r\n ) {\r\n calculateEnergy(\r\n adapter,\r\n adapter.config.localDevice1ProductKey,\r\n adapter.config.localDevice1DeviceKey\r\n );\r\n }\r\n\r\n if (\r\n adapter.config.localDevice2ProductKey &&\r\n adapter.config.localDevice2DeviceKey\r\n ) {\r\n calculateEnergy(\r\n adapter,\r\n adapter.config.localDevice2ProductKey,\r\n adapter.config.localDevice2DeviceKey\r\n );\r\n }\r\n } else {\r\n adapter.deviceList.forEach((device) => {\r\n if (device.productKey != \"s3Xk4x\") {\r\n calculateEnergy(adapter, device.productKey, device.deviceKey);\r\n\r\n // Check if connected with ACE, then calculate also for ACE device\r\n if (device.packList && device.packList.length > 0) {\r\n device.packList.forEach(async (subDevice) => {\r\n if (subDevice.productName.toLocaleLowerCase() == \"ace 1500\") {\r\n calculateEnergy(\r\n adapter,\r\n subDevice.productKey,\r\n subDevice.deviceKey\r\n );\r\n }\r\n });\r\n }\r\n }\r\n });\r\n }\r\n });\r\n};\r\n\r\nexport const startCheckStatesAndConnectionJob = async (\r\n adapter: ZendureSolarflow\r\n): Promise<void> => {\r\n // Check for states that has no updates in the last 5 minutes and set them to 0\r\n const statesToReset: string[] = [\r\n \"outputHomePower\",\r\n \"outputPackPower\",\r\n \"gridInputPower\",\r\n \"packInputPower\",\r\n \"solarInputPower\",\r\n ];\r\n\r\n let refreshAccessTokenNeeded = false;\r\n\r\n adapter.log.debug(\r\n `[checkStatesJob] Starting check of states and connection!`\r\n );\r\n\r\n adapter.checkStatesJob = scheduleJob(\"*/5 * * * *\", async () => {\r\n adapter.deviceList.forEach(async (device: ISolarFlowDeviceDetails) => {\r\n if (refreshAccessTokenNeeded) {\r\n return;\r\n }\r\n\r\n const lastUpdate = await adapter?.getStateAsync(\r\n device.productKey + \".\" + device.deviceKey + \".lastUpdate\"\r\n );\r\n\r\n const wifiState = await adapter?.getStateAsync(\r\n device.productKey + \".\" + device.deviceKey + \".wifiState\"\r\n );\r\n\r\n const fiveMinutesAgo = (Date.now() / 1000 - 5 * 60) * 1000; // Five minutes ago\r\n const tenMinutesAgo = (Date.now() / 1000 - 10 * 60) * 1000; // Ten minutes ago\r\n\r\n if (\r\n lastUpdate &&\r\n lastUpdate.val &&\r\n Number(lastUpdate.val) < fiveMinutesAgo &&\r\n wifiState?.val == \"Connected\"\r\n ) {\r\n adapter.log.warn(\r\n `[checkStatesJob] Last update for deviceKey ${\r\n device.deviceKey\r\n } was at ${new Date(\r\n Number(lastUpdate)\r\n )}, device seems to be online - so maybe connection is broken - restart adapter in 20 seconds!`\r\n );\r\n\r\n await adapter.delay(20 * 1000);\r\n adapter.restart();\r\n\r\n // set marker, so we discontinue the forEach Loop because of reconnect!\r\n refreshAccessTokenNeeded = true;\r\n }\r\n\r\n if (\r\n lastUpdate &&\r\n lastUpdate.val &&\r\n Number(lastUpdate.val) < tenMinutesAgo &&\r\n !refreshAccessTokenNeeded\r\n ) {\r\n adapter.log.debug(\r\n `[checkStatesJob] Last update for deviceKey ${\r\n device.deviceKey\r\n } was at ${new Date(\r\n Number(lastUpdate)\r\n )}, checking for pseudo power values!`\r\n );\r\n // State was not updated in the last 10 minutes... set states to 0\r\n await statesToReset.forEach(async (stateName: string) => {\r\n await adapter?.setState(\r\n device.productKey + \".\" + device.deviceKey + \".\" + stateName,\r\n 0,\r\n true\r\n );\r\n });\r\n\r\n // set electricLevel from deviceList\r\n if (device.electricity) {\r\n await adapter?.setState(\r\n device.productKey + \".\" + device.deviceKey + \".electricLevel\",\r\n device.electricity,\r\n true\r\n );\r\n }\r\n }\r\n });\r\n });\r\n};\r\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -29,7 +29,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var mqttService_exports = {};
|
|
30
30
|
__export(mqttService_exports, {
|
|
31
31
|
addOrUpdatePackData: () => addOrUpdatePackData,
|
|
32
|
-
|
|
32
|
+
connectCloudMqttClient: () => connectCloudMqttClient,
|
|
33
|
+
connectLocalMqttClient: () => connectLocalMqttClient,
|
|
33
34
|
setAcMode: () => setAcMode,
|
|
34
35
|
setAcSwitch: () => setAcSwitch,
|
|
35
36
|
setAutoModel: () => setAutoModel,
|
|
@@ -42,6 +43,8 @@ __export(mqttService_exports, {
|
|
|
42
43
|
setInputLimit: () => setInputLimit,
|
|
43
44
|
setOutputLimit: () => setOutputLimit,
|
|
44
45
|
setPassMode: () => setPassMode,
|
|
46
|
+
subscribeIotTopic: () => subscribeIotTopic,
|
|
47
|
+
subscribeReportTopic: () => subscribeReportTopic,
|
|
45
48
|
triggerFullTelemetryUpdate: () => triggerFullTelemetryUpdate
|
|
46
49
|
});
|
|
47
50
|
module.exports = __toCommonJS(mqttService_exports);
|
|
@@ -49,13 +52,16 @@ var mqtt = __toESM(require("mqtt"));
|
|
|
49
52
|
var import_adapterService = require("./adapterService");
|
|
50
53
|
var import_calculationService = require("./calculationService");
|
|
51
54
|
var import_jobSchedule = require("./jobSchedule");
|
|
55
|
+
var import_createSolarFlowLocalStates = require("../helpers/createSolarFlowLocalStates");
|
|
52
56
|
let adapter = void 0;
|
|
53
57
|
const addOrUpdatePackData = async (productKey, deviceKey, packData, isSolarFlow) => {
|
|
54
58
|
if (adapter && productKey && deviceKey) {
|
|
55
59
|
await packData.forEach(async (x) => {
|
|
56
60
|
if (x.sn && adapter) {
|
|
57
61
|
let batType = "";
|
|
58
|
-
if (
|
|
62
|
+
if (productKey == "yWF7hV") {
|
|
63
|
+
batType = "AIO2400";
|
|
64
|
+
} else if (x.sn.startsWith("C")) {
|
|
59
65
|
batType = "AB2000";
|
|
60
66
|
} else if (x.sn.startsWith("A")) {
|
|
61
67
|
batType = "AB1000";
|
|
@@ -226,6 +232,19 @@ const onMessage = async (topic, message) => {
|
|
|
226
232
|
const productName = await adapter.getStateAsync(
|
|
227
233
|
`${productKey}.${deviceKey}.productName`
|
|
228
234
|
);
|
|
235
|
+
if (obj.timestamp) {
|
|
236
|
+
const currentTimeStamp = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
237
|
+
const diff = currentTimeStamp - obj.timestamp;
|
|
238
|
+
if (diff > 600) {
|
|
239
|
+
(0, import_adapterService.updateSolarFlowState)(
|
|
240
|
+
adapter,
|
|
241
|
+
productKey,
|
|
242
|
+
deviceKey,
|
|
243
|
+
"wifiState",
|
|
244
|
+
"Disconnected"
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
229
248
|
if (((_a = productName == null ? void 0 : productName.val) == null ? void 0 : _a.toString().toLowerCase().includes("solarflow")) || ((_b = productName == null ? void 0 : productName.val) == null ? void 0 : _b.toString().toLowerCase().includes("hyper"))) {
|
|
230
249
|
isSolarFlow = true;
|
|
231
250
|
}
|
|
@@ -921,11 +940,35 @@ const onSubscribeIotTopic = (error, productKey, deviceKey) => {
|
|
|
921
940
|
triggerFullTelemetryUpdate(adapter, productKey, deviceKey);
|
|
922
941
|
}
|
|
923
942
|
};
|
|
924
|
-
const
|
|
943
|
+
const subscribeReportTopic = (productKey, deviceKey, timeout) => {
|
|
944
|
+
const reportTopic = `/${productKey}/${deviceKey}/#`;
|
|
945
|
+
setTimeout(() => {
|
|
946
|
+
var _a;
|
|
947
|
+
if (adapter) {
|
|
948
|
+
adapter.log.debug(
|
|
949
|
+
`[subscribeReportTopic] Subscribing to MQTT Topic: ${reportTopic}`
|
|
950
|
+
);
|
|
951
|
+
(_a = adapter.mqttClient) == null ? void 0 : _a.subscribe(reportTopic, onSubscribeReportTopic);
|
|
952
|
+
}
|
|
953
|
+
}, timeout);
|
|
954
|
+
};
|
|
955
|
+
const subscribeIotTopic = (productKey, deviceKey, timeout) => {
|
|
956
|
+
const iotTopic = `iot/${productKey}/${deviceKey}/`;
|
|
957
|
+
setTimeout(() => {
|
|
958
|
+
var _a;
|
|
959
|
+
adapter == null ? void 0 : adapter.log.debug(
|
|
960
|
+
`[subscribeIotTopic] Subscribing to MQTT Topic: ${iotTopic}`
|
|
961
|
+
);
|
|
962
|
+
(_a = adapter == null ? void 0 : adapter.mqttClient) == null ? void 0 : _a.subscribe(iotTopic, (error) => {
|
|
963
|
+
onSubscribeIotTopic(error, productKey, deviceKey);
|
|
964
|
+
});
|
|
965
|
+
}, timeout);
|
|
966
|
+
};
|
|
967
|
+
const connectCloudMqttClient = (_adapter) => {
|
|
925
968
|
var _a, _b;
|
|
926
969
|
adapter = _adapter;
|
|
927
970
|
if (!((_a = adapter.paths) == null ? void 0 : _a.mqttPassword)) {
|
|
928
|
-
adapter.log.error(`[
|
|
971
|
+
adapter.log.error(`[connectCloudMqttClient] MQTT Password is missing!`);
|
|
929
972
|
return;
|
|
930
973
|
}
|
|
931
974
|
const mqttPassword = atob((_b = adapter.paths) == null ? void 0 : _b.mqttPassword);
|
|
@@ -938,7 +981,7 @@ const connectMqttClient = (_adapter) => {
|
|
|
938
981
|
};
|
|
939
982
|
if (mqtt && adapter && adapter.paths && adapter.deviceList) {
|
|
940
983
|
adapter.log.debug(
|
|
941
|
-
`[
|
|
984
|
+
`[connectCloudMqttClient] Connecting to MQTT broker ${adapter.paths.mqttUrl + ":" + adapter.paths.mqttPort}...`
|
|
942
985
|
);
|
|
943
986
|
adapter.mqttClient = mqtt.connect(
|
|
944
987
|
"mqtt://" + adapter.paths.mqttUrl + ":" + adapter.paths.mqttPort,
|
|
@@ -949,77 +992,42 @@ const connectMqttClient = (_adapter) => {
|
|
|
949
992
|
adapter.mqttClient.on("error", onError);
|
|
950
993
|
adapter.deviceList.forEach(
|
|
951
994
|
(device, index) => {
|
|
995
|
+
var _a2;
|
|
952
996
|
if (adapter) {
|
|
953
997
|
let connectIot = true;
|
|
954
|
-
let reportTopic = `/${device.productKey}/${device.deviceKey}/#`;
|
|
955
|
-
const iotTopic = `iot/${device.productKey}/${device.deviceKey}/#`;
|
|
956
998
|
if (device.productKey == "s3Xk4x") {
|
|
957
|
-
|
|
999
|
+
const smartPlugReportTopic = `/server/app/${adapter.userId}/${device.id}/smart/power`;
|
|
1000
|
+
(_a2 = adapter.mqttClient) == null ? void 0 : _a2.subscribe(
|
|
1001
|
+
smartPlugReportTopic,
|
|
1002
|
+
onSubscribeReportTopic
|
|
1003
|
+
);
|
|
958
1004
|
connectIot = false;
|
|
959
1005
|
}
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
adapter.log.debug(
|
|
965
|
-
`[connectMqttClient] Subscribing to MQTT Topic: ${reportTopic}`
|
|
966
|
-
);
|
|
967
|
-
(_a2 = adapter.mqttClient) == null ? void 0 : _a2.subscribe(
|
|
968
|
-
reportTopic,
|
|
969
|
-
onSubscribeReportTopic
|
|
970
|
-
);
|
|
971
|
-
}
|
|
972
|
-
},
|
|
973
|
-
1e3 * index + 1
|
|
1006
|
+
subscribeReportTopic(
|
|
1007
|
+
device.productKey,
|
|
1008
|
+
device.deviceKey,
|
|
1009
|
+
1e3 * index
|
|
974
1010
|
);
|
|
975
1011
|
if (connectIot) {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
`[connectMqttClient] Subscribing to MQTT Topic: ${iotTopic}`
|
|
981
|
-
);
|
|
982
|
-
(_a2 = adapter == null ? void 0 : adapter.mqttClient) == null ? void 0 : _a2.subscribe(iotTopic, (error) => {
|
|
983
|
-
onSubscribeIotTopic(
|
|
984
|
-
error,
|
|
985
|
-
device.productKey,
|
|
986
|
-
device.deviceKey
|
|
987
|
-
);
|
|
988
|
-
});
|
|
989
|
-
},
|
|
990
|
-
1500 * index + 1
|
|
1012
|
+
subscribeIotTopic(
|
|
1013
|
+
device.productKey,
|
|
1014
|
+
device.deviceKey,
|
|
1015
|
+
1e3 * index
|
|
991
1016
|
);
|
|
992
1017
|
}
|
|
993
1018
|
if (device.packList && device.packList.length > 0) {
|
|
994
1019
|
device.packList.forEach(async (subDevice) => {
|
|
995
1020
|
if (subDevice.productName.toLocaleLowerCase() == "ace 1500") {
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
onSubscribeReportTopic
|
|
1007
|
-
);
|
|
1008
|
-
}
|
|
1009
|
-
}, 1e3 * index);
|
|
1010
|
-
setTimeout(() => {
|
|
1011
|
-
var _a2;
|
|
1012
|
-
adapter == null ? void 0 : adapter.log.debug(
|
|
1013
|
-
`[connectMqttClient] Subscribing to MQTT Topic: ${iotTopic2}`
|
|
1014
|
-
);
|
|
1015
|
-
(_a2 = adapter == null ? void 0 : adapter.mqttClient) == null ? void 0 : _a2.subscribe(iotTopic2, (error) => {
|
|
1016
|
-
onSubscribeIotTopic(
|
|
1017
|
-
error,
|
|
1018
|
-
subDevice.productKey,
|
|
1019
|
-
subDevice.deviceKey
|
|
1020
|
-
);
|
|
1021
|
-
});
|
|
1022
|
-
}, 1500 * index);
|
|
1021
|
+
subscribeReportTopic(
|
|
1022
|
+
subDevice.productKey,
|
|
1023
|
+
subDevice.deviceKey,
|
|
1024
|
+
1e3 * index
|
|
1025
|
+
);
|
|
1026
|
+
subscribeIotTopic(
|
|
1027
|
+
subDevice.productKey,
|
|
1028
|
+
subDevice.deviceKey,
|
|
1029
|
+
2e3 * index
|
|
1030
|
+
);
|
|
1023
1031
|
}
|
|
1024
1032
|
});
|
|
1025
1033
|
}
|
|
@@ -1035,10 +1043,71 @@ const connectMqttClient = (_adapter) => {
|
|
|
1035
1043
|
}
|
|
1036
1044
|
}
|
|
1037
1045
|
};
|
|
1046
|
+
const connectLocalMqttClient = (_adapter) => {
|
|
1047
|
+
adapter = _adapter;
|
|
1048
|
+
const options = {
|
|
1049
|
+
clientId: "ioBroker.zendure-solarflow." + adapter.instance
|
|
1050
|
+
};
|
|
1051
|
+
if (mqtt && adapter && adapter.config && adapter.config.localMqttUrl) {
|
|
1052
|
+
adapter.log.debug(
|
|
1053
|
+
`[connectLocalMqttClient] Connecting to MQTT broker ${adapter.config.localMqttUrl + ":1883"}...`
|
|
1054
|
+
);
|
|
1055
|
+
adapter.mqttClient = mqtt.connect(
|
|
1056
|
+
"mqtt://" + adapter.config.localMqttUrl + ":1883",
|
|
1057
|
+
options
|
|
1058
|
+
);
|
|
1059
|
+
if (adapter && adapter.mqttClient) {
|
|
1060
|
+
adapter.mqttClient.on("connect", onConnected);
|
|
1061
|
+
adapter.mqttClient.on("error", onError);
|
|
1062
|
+
adapter.setState("info.connection", true, true);
|
|
1063
|
+
if (adapter.config.localDevice1ProductKey && adapter.config.localDevice1DeviceKey) {
|
|
1064
|
+
(0, import_createSolarFlowLocalStates.createSolarFlowLocalStates)(
|
|
1065
|
+
adapter,
|
|
1066
|
+
adapter.config.localDevice1ProductKey,
|
|
1067
|
+
adapter.config.localDevice1DeviceKey
|
|
1068
|
+
);
|
|
1069
|
+
subscribeReportTopic(
|
|
1070
|
+
adapter.config.localDevice1ProductKey,
|
|
1071
|
+
adapter.config.localDevice1DeviceKey,
|
|
1072
|
+
1e3
|
|
1073
|
+
);
|
|
1074
|
+
subscribeIotTopic(
|
|
1075
|
+
adapter.config.localDevice1ProductKey,
|
|
1076
|
+
adapter.config.localDevice1DeviceKey,
|
|
1077
|
+
1e3
|
|
1078
|
+
);
|
|
1079
|
+
}
|
|
1080
|
+
if (adapter.config.localDevice2ProductKey && adapter.config.localDevice2DeviceKey) {
|
|
1081
|
+
(0, import_createSolarFlowLocalStates.createSolarFlowLocalStates)(
|
|
1082
|
+
adapter,
|
|
1083
|
+
adapter.config.localDevice2ProductKey,
|
|
1084
|
+
adapter.config.localDevice2DeviceKey
|
|
1085
|
+
);
|
|
1086
|
+
subscribeReportTopic(
|
|
1087
|
+
adapter.config.localDevice1ProductKey,
|
|
1088
|
+
adapter.config.localDevice1DeviceKey,
|
|
1089
|
+
2e3
|
|
1090
|
+
);
|
|
1091
|
+
subscribeIotTopic(
|
|
1092
|
+
adapter.config.localDevice1ProductKey,
|
|
1093
|
+
adapter.config.localDevice1DeviceKey,
|
|
1094
|
+
2e3
|
|
1095
|
+
);
|
|
1096
|
+
}
|
|
1097
|
+
adapter.mqttClient.on("message", onMessage);
|
|
1098
|
+
(0, import_jobSchedule.startResetValuesJob)(adapter);
|
|
1099
|
+
(0, import_jobSchedule.startCheckStatesAndConnectionJob)(adapter);
|
|
1100
|
+
if (adapter.config.useCalculation) {
|
|
1101
|
+
(0, import_jobSchedule.startCalculationJob)(adapter);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1038
1106
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1039
1107
|
0 && (module.exports = {
|
|
1040
1108
|
addOrUpdatePackData,
|
|
1041
|
-
|
|
1109
|
+
connectCloudMqttClient,
|
|
1110
|
+
connectLocalMqttClient,
|
|
1042
1111
|
setAcMode,
|
|
1043
1112
|
setAcSwitch,
|
|
1044
1113
|
setAutoModel,
|
|
@@ -1051,6 +1120,8 @@ const connectMqttClient = (_adapter) => {
|
|
|
1051
1120
|
setInputLimit,
|
|
1052
1121
|
setOutputLimit,
|
|
1053
1122
|
setPassMode,
|
|
1123
|
+
subscribeIotTopic,
|
|
1124
|
+
subscribeReportTopic,
|
|
1054
1125
|
triggerFullTelemetryUpdate
|
|
1055
1126
|
});
|
|
1056
1127
|
//# sourceMappingURL=mqttService.js.map
|