iobroker.zendure-solarflow 2.0.0-alpha.0 → 2.0.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.
Files changed (33) hide show
  1. package/README.md +14 -6
  2. package/build/constants/ac2400ControlStates.js +1 -10
  3. package/build/constants/ac2400ControlStates.js.map +2 -2
  4. package/build/constants/aceControlStates.js +1 -1
  5. package/build/constants/aceControlStates.js.map +1 -1
  6. package/build/constants/aioControlStates.js +12 -29
  7. package/build/constants/aioControlStates.js.map +2 -2
  8. package/build/constants/aioStates.js +7 -0
  9. package/build/constants/aioStates.js.map +2 -2
  10. package/build/constants/hubControlStates.js +10 -10
  11. package/build/constants/hubControlStates.js.map +2 -2
  12. package/build/constants/hubStates.js +7 -0
  13. package/build/constants/hubStates.js.map +2 -2
  14. package/build/constants/hyperControlStates.js +1 -10
  15. package/build/constants/hyperControlStates.js.map +2 -2
  16. package/build/constants/sharedStates.js +0 -7
  17. package/build/constants/sharedStates.js.map +2 -2
  18. package/build/constants/solarflow800ControlStates.js +1 -10
  19. package/build/constants/solarflow800ControlStates.js.map +2 -2
  20. package/build/constants/solarflow800ProControlStates.js +1 -10
  21. package/build/constants/solarflow800ProControlStates.js.map +2 -2
  22. package/build/helpers/helpers.js +26 -0
  23. package/build/helpers/helpers.js.map +2 -2
  24. package/build/main.js +5 -2
  25. package/build/main.js.map +2 -2
  26. package/build/models/IPackData.js.map +1 -1
  27. package/build/models/ISolarFlowMqttProperties.js.map +2 -2
  28. package/build/services/adapterService.js +1 -1
  29. package/build/services/adapterService.js.map +2 -2
  30. package/build/services/mqttService.js +149 -122
  31. package/build/services/mqttService.js.map +2 -2
  32. package/io-package.json +27 -27
  33. package/package.json +1 -1
@@ -38,7 +38,7 @@ __export(mqttService_exports, {
38
38
  setBuzzerSwitch: () => setBuzzerSwitch,
39
39
  setChargeLimit: () => setChargeLimit,
40
40
  setDcSwitch: () => setDcSwitch,
41
- setDeviceAutomationLimit: () => setDeviceAutomationLimit,
41
+ setDeviceAutomationInOutLimit: () => setDeviceAutomationInOutLimit,
42
42
  setDischargeLimit: () => setDischargeLimit,
43
43
  setHubState: () => setHubState,
44
44
  setInputLimit: () => setInputLimit,
@@ -271,6 +271,25 @@ const addOrUpdatePackData = async (productKey, deviceKey, packData, isSolarFlow)
271
271
  }));
272
272
  await (adapter == null ? void 0 : adapter.setState(key + ".soh", x.soh / 10, true));
273
273
  }
274
+ if (x.power) {
275
+ await (adapter == null ? void 0 : adapter.extendObject(key + ".power", {
276
+ type: "state",
277
+ common: {
278
+ name: {
279
+ de: "Energie",
280
+ en: "Power"
281
+ },
282
+ type: "number",
283
+ desc: "Power",
284
+ read: true,
285
+ write: false,
286
+ role: "value.power",
287
+ unit: "W"
288
+ },
289
+ native: {}
290
+ }));
291
+ await (adapter == null ? void 0 : adapter.setState(key + ".power", x.power, true));
292
+ }
274
293
  let found = false;
275
294
  Object.entries(x).forEach(([key2, value]) => {
276
295
  knownPackDataProperties.forEach((property) => {
@@ -345,6 +364,22 @@ const onMessage = async (topic, message) => {
345
364
  "lastUpdate",
346
365
  (/* @__PURE__ */ new Date()).getTime()
347
366
  );
367
+ if (obj.function == "deviceAutomation" && obj.success == 1) {
368
+ const currentValue = await adapter.getStateAsync(
369
+ productKey + "." + deviceKey + ".control.setDeviceAutomationInOutLimit"
370
+ );
371
+ (0, import_adapterService.updateSolarFlowControlState)(
372
+ adapter,
373
+ productKey,
374
+ deviceKey,
375
+ "setDeviceAutomationInOutLimit",
376
+ (currentValue == null ? void 0 : currentValue.val) ? currentValue.val : 0
377
+ );
378
+ } else if (obj.function == "deviceAutomation" && obj.success == 0) {
379
+ adapter == null ? void 0 : adapter.log.warn(
380
+ `[onMessage] device automation failed for ${productName == null ? void 0 : productName.val}: ${productKey}/${deviceKey}!`
381
+ );
382
+ }
348
383
  if (((_a = obj.properties) == null ? void 0 : _a.autoModel) != null && ((_b = obj.properties) == null ? void 0 : _b.autoModel) != void 0) {
349
384
  (0, import_adapterService.updateSolarFlowState)(
350
385
  adapter,
@@ -861,13 +896,21 @@ const onMessage = async (topic, message) => {
861
896
  const setAcMode = async (adapter2, productKey, deviceKey, acMode) => {
862
897
  var _a;
863
898
  if (adapter2.mqttClient && productKey && deviceKey) {
864
- if (acMode >= 0 && acMode <= 2) {
899
+ if (acMode >= 0 && acMode <= 3) {
865
900
  const topic = `iot/${productKey}/${deviceKey}/properties/write`;
866
901
  const setAcMode2 = { properties: { acMode } };
867
902
  adapter2.log.debug(`[setAcMode] Set AC mode to ${acMode}!`);
868
903
  (_a = adapter2.mqttClient) == null ? void 0 : _a.publish(topic, JSON.stringify(setAcMode2));
904
+ const smartMode = await adapter2.getStateAsync(
905
+ productKey + "." + deviceKey + ".control.smartMode"
906
+ );
907
+ if (smartMode && !smartMode.val) {
908
+ adapter2.log.warn(
909
+ `[setAcMode] AC mode was switched and smartMode is false - changes will be written to flash memory. In the worst case, the device may break or changes may no longer be saved!`
910
+ );
911
+ }
869
912
  } else {
870
- adapter2.log.error(`[setAcMode] AC mode must be a value between 0 and 2!`);
913
+ adapter2.log.error(`[setAcMode] AC mode must be a value between 0 and 3!`);
871
914
  }
872
915
  }
873
916
  };
@@ -920,11 +963,11 @@ const setHubState = async (adapter2, productKey, deviceKey, hubState) => {
920
963
  }
921
964
  }
922
965
  };
923
- const setDeviceAutomationLimit = async (adapter2, productKey, deviceKey, limit) => {
966
+ const setDeviceAutomationInOutLimit = async (adapter2, productKey, deviceKey, limit) => {
924
967
  var _a, _b;
925
968
  if (adapter2.mqttClient && productKey && deviceKey) {
926
969
  adapter2.log.debug(
927
- `[setDeviceAutomationLimit] Set device Automation limit to ${limit}!`
970
+ `[setDeviceAutomationInOutLimit] Set device Automation limit to ${limit}!`
928
971
  );
929
972
  if (limit) {
930
973
  limit = Math.round(limit);
@@ -935,118 +978,127 @@ const setDeviceAutomationLimit = async (adapter2, productKey, deviceKey, limit)
935
978
  const lowVoltageBlockState = await adapter2.getStateAsync(
936
979
  productKey + "." + deviceKey + ".control.lowVoltageBlock"
937
980
  );
938
- if (lowVoltageBlockState && lowVoltageBlockState.val && lowVoltageBlockState.val == true) {
981
+ if (lowVoltageBlockState && lowVoltageBlockState.val && lowVoltageBlockState.val == true && limit > 0) {
939
982
  limit = 0;
940
983
  }
941
984
  const fullChargeNeeded = await adapter2.getStateAsync(
942
985
  productKey + "." + deviceKey + ".control.fullChargeNeeded"
943
986
  );
944
- if (fullChargeNeeded && fullChargeNeeded.val && fullChargeNeeded.val == true) {
987
+ if (fullChargeNeeded && fullChargeNeeded.val && fullChargeNeeded.val == true && limit > 0) {
945
988
  limit = 0;
946
989
  }
947
990
  }
948
- limit = (0, import_helpers.getMinAndMaxOutputLimitForProductKey)(productKey, limit);
991
+ if (limit < 0) {
992
+ limit = -(0, import_helpers.getMinAndMaxInputLimitForProductKey)(productKey, -limit);
993
+ } else {
994
+ limit = (0, import_helpers.getMinAndMaxOutputLimitForProductKey)(productKey, limit);
995
+ }
949
996
  const topic = `iot/${productKey}/${deviceKey}/function/invoke`;
950
997
  adapter2.msgCounter += 1;
951
998
  const timestamp = /* @__PURE__ */ new Date();
952
999
  timestamp.setMilliseconds(0);
953
- let _arguments = [
954
- {
955
- autoModelProgram: 2,
956
- autoModelValue: limit,
957
- msgType: 1,
958
- autoModel: 8
959
- }
960
- ];
1000
+ let _arguments = [];
961
1001
  const productName = (0, import_helpers.getProductNameFromProductKey)(productKey);
962
1002
  if (productName.toLowerCase().includes("2400 ac") || productName.toLowerCase().includes("solarflow 800")) {
1003
+ adapter2.log.debug(
1004
+ `[setDeviceAutomationInOutLimit] Using HEMS Variant of device automation, as device '${productName}' detected!`
1005
+ );
963
1006
  const outputlimit = {
964
1007
  arguments: {
965
- outputPower: limit,
1008
+ outputPower: limit > 0 ? limit : 0,
966
1009
  chargeState: limit > 0 ? 0 : 1,
967
1010
  chargePower: limit > 0 ? 0 : -limit,
968
1011
  mode: 9
969
1012
  },
970
- function: "deviceAutomation",
1013
+ function: "hemsEP",
971
1014
  messageId: adapter2.msgCounter,
972
1015
  deviceKey,
973
1016
  timestamp: timestamp.getTime() / 1e3
974
1017
  };
975
1018
  (_a = adapter2.mqttClient) == null ? void 0 : _a.publish(topic, JSON.stringify(outputlimit));
976
- } else if (productName.toLowerCase().includes("ace")) {
977
- _arguments = [
978
- {
979
- autoModelProgram: 2,
980
- autoModelValue: {
981
- chargingType: limit > 0 ? 0 : 1,
982
- chargingPower: limit > 0 ? 0 : -limit,
983
- freq: 0,
984
- outPower: limit
985
- },
986
- msgType: 1,
987
- autoModel: 8
988
- }
989
- ];
1019
+ return;
1020
+ } else if (productName.toLowerCase().includes("hyper")) {
1021
+ if (limit < 0) {
1022
+ adapter2.log.debug(
1023
+ `[setDeviceAutomationInOutLimit] Using CHARGE variant of HYPER device automation, as device '${productName}' detected and limit is negative!`
1024
+ );
1025
+ _arguments = [
1026
+ {
1027
+ autoModelProgram: 1,
1028
+ autoModelValue: {
1029
+ upTime: 0,
1030
+ chargingType: 1,
1031
+ pullTime: 1800,
1032
+ price: 2,
1033
+ chargingPower: -limit,
1034
+ prices: [
1035
+ 1,
1036
+ 1,
1037
+ 1,
1038
+ 1,
1039
+ 1,
1040
+ 1,
1041
+ 1,
1042
+ 1,
1043
+ 1,
1044
+ 1,
1045
+ 1,
1046
+ 1,
1047
+ 1,
1048
+ 1,
1049
+ 1,
1050
+ 1,
1051
+ 1,
1052
+ 1,
1053
+ 1,
1054
+ 1,
1055
+ 1,
1056
+ 1,
1057
+ 1,
1058
+ 1
1059
+ ],
1060
+ outPower: 0,
1061
+ freq: 0
1062
+ },
1063
+ msgType: 1,
1064
+ autoModel: 8
1065
+ }
1066
+ ];
1067
+ } else {
1068
+ adapter2.log.debug(
1069
+ `[setDeviceAutomationInOutLimit] Using FEED IN variant of HYPER device automation, as device '${productName}' detected and limit is positive!`
1070
+ );
1071
+ _arguments = [
1072
+ {
1073
+ autoModelProgram: 2,
1074
+ autoModelValue: {
1075
+ chargingType: 0,
1076
+ chargingPower: 0,
1077
+ freq: 0,
1078
+ outPower: limit
1079
+ },
1080
+ msgType: 1,
1081
+ autoModel: 8
1082
+ }
1083
+ ];
1084
+ }
990
1085
  } else {
991
- if (productName.toLowerCase().includes("hyper")) {
992
- if (limit < 0) {
993
- _arguments = [
994
- {
995
- autoModelProgram: 1,
996
- autoModelValue: {
997
- upTime: 0,
998
- chargingType: 1,
999
- pullTime: 1800,
1000
- price: 2,
1001
- chargingPower: -limit,
1002
- prices: [
1003
- 1,
1004
- 1,
1005
- 1,
1006
- 1,
1007
- 1,
1008
- 1,
1009
- 1,
1010
- 1,
1011
- 1,
1012
- 1,
1013
- 1,
1014
- 1,
1015
- 1,
1016
- 1,
1017
- 1,
1018
- 1,
1019
- 1,
1020
- 1,
1021
- 1,
1022
- 1,
1023
- 1,
1024
- 1,
1025
- 1,
1026
- 1
1027
- ],
1028
- outPower: 0,
1029
- freq: 0
1030
- },
1031
- msgType: 1,
1032
- autoModel: 8
1033
- }
1034
- ];
1035
- } else {
1036
- _arguments = [
1037
- {
1038
- autoModelProgram: 2,
1039
- autoModelValue: {
1040
- chargingType: 0,
1041
- chargingPower: 0,
1042
- freq: 0,
1043
- outPower: limit
1044
- },
1045
- msgType: 1,
1046
- autoModel: 8
1047
- }
1048
- ];
1049
- }
1086
+ if (limit < 0) {
1087
+ adapter2.log.warn(
1088
+ `[setDeviceAutomationInOutLimit] Using CHARGE variant of Hub device automation is currently not working! You have to manualy switch acMode and inputLimit!`
1089
+ );
1090
+ } else {
1091
+ adapter2.log.debug(
1092
+ `[setDeviceAutomationInOutLimit] Using FEED IN variant of Hub device automation, as device '${productName}' detected and limit is positive!`
1093
+ );
1094
+ _arguments = [
1095
+ {
1096
+ autoModelProgram: 2,
1097
+ autoModelValue: limit,
1098
+ msgType: 1,
1099
+ autoModel: 8
1100
+ }
1101
+ ];
1050
1102
  }
1051
1103
  const outputlimit = {
1052
1104
  arguments: _arguments,
@@ -1103,42 +1155,17 @@ const setOutputLimit = async (adapter2, productKey, deviceKey, limit) => {
1103
1155
  }
1104
1156
  };
1105
1157
  const setInputLimit = async (adapter2, productKey, deviceKey, limit) => {
1106
- var _a, _b;
1158
+ var _a;
1107
1159
  if (adapter2.mqttClient && productKey && deviceKey) {
1108
1160
  if (limit) {
1109
1161
  limit = Math.round(limit);
1110
1162
  } else {
1111
1163
  limit = 0;
1112
1164
  }
1113
- let maxLimit = 900;
1114
- const currentLimit = (_a = await adapter2.getStateAsync(productKey + "." + deviceKey + ".inputLimit")) == null ? void 0 : _a.val;
1115
- const productName = (0, import_helpers.getProductNameFromProductKey)(productKey);
1116
- if (productName == null ? void 0 : productName.includes("hyper")) {
1117
- maxLimit = 1200;
1118
- }
1119
- if (productName == null ? void 0 : productName.includes("2400 ac")) {
1120
- maxLimit = 2400;
1121
- }
1122
- if (productName == null ? void 0 : productName.includes("solarflow 800")) {
1123
- maxLimit = 800;
1124
- }
1125
- if (productName == null ? void 0 : productName.includes("ace")) {
1126
- limit = Math.ceil(limit / 100) * 100;
1127
- }
1128
- if (limit < 0) {
1129
- limit = 0;
1130
- } else if (limit > 0 && limit <= 30) {
1131
- limit = 30;
1132
- } else if (limit > maxLimit) {
1133
- limit = maxLimit;
1134
- }
1135
- if (currentLimit != null && currentLimit != void 0) {
1136
- if (currentLimit != limit) {
1137
- const topic = `iot/${productKey}/${deviceKey}/properties/write`;
1138
- const inputLimitContent = { properties: { inputLimit: limit } };
1139
- (_b = adapter2.mqttClient) == null ? void 0 : _b.publish(topic, JSON.stringify(inputLimitContent));
1140
- }
1141
- }
1165
+ limit = (0, import_helpers.getMinAndMaxInputLimitForProductKey)(productKey, limit);
1166
+ const topic = `iot/${productKey}/${deviceKey}/properties/write`;
1167
+ const inputLimitContent = { properties: { inputLimit: limit } };
1168
+ (_a = adapter2.mqttClient) == null ? void 0 : _a.publish(topic, JSON.stringify(inputLimitContent));
1142
1169
  }
1143
1170
  };
1144
1171
  const setSmartMode = async (adapter2, productKey, deviceKey, smartModeOn) => {
@@ -1491,7 +1518,7 @@ const connectLocalMqttClient = (_adapter) => {
1491
1518
  setBuzzerSwitch,
1492
1519
  setChargeLimit,
1493
1520
  setDcSwitch,
1494
- setDeviceAutomationLimit,
1521
+ setDeviceAutomationInOutLimit,
1495
1522
  setDischargeLimit,
1496
1523
  setHubState,
1497
1524
  setInputLimit,