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,144 @@
|
|
|
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 Sf800_exports = {};
|
|
20
|
+
__export(Sf800_exports, {
|
|
21
|
+
Sf800: () => Sf800
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(Sf800_exports);
|
|
24
|
+
var import_solarflow800ControlStates = require("../../constants/solarflow800ControlStates");
|
|
25
|
+
var import_solarflow800States = require("../../constants/solarflow800States");
|
|
26
|
+
var import_ZenHaDevice = require("./ZenHaDevice");
|
|
27
|
+
class Sf800 extends import_ZenHaDevice.ZenHaDevice {
|
|
28
|
+
constructor(_adapter, _productKey, _deviceKey, _productName, _deviceName, _zenHaDeviceDetails) {
|
|
29
|
+
super(
|
|
30
|
+
_adapter,
|
|
31
|
+
_productKey,
|
|
32
|
+
_deviceKey,
|
|
33
|
+
_productName,
|
|
34
|
+
_deviceName,
|
|
35
|
+
_zenHaDeviceDetails
|
|
36
|
+
);
|
|
37
|
+
this.maxInputLimit = 800;
|
|
38
|
+
this.maxOutputLimit = 800;
|
|
39
|
+
this.states = import_solarflow800States.solarflow800States;
|
|
40
|
+
this.controlStates = import_solarflow800ControlStates.solarflow800ControlStates;
|
|
41
|
+
}
|
|
42
|
+
async setAcMode(acMode) {
|
|
43
|
+
var _a;
|
|
44
|
+
if (this.adapter.mqttClient && this.productKey && this.deviceKey) {
|
|
45
|
+
if (acMode >= 0 && acMode <= 3) {
|
|
46
|
+
const topic = `iot/${this.productKey}/${this.deviceKey}/properties/write`;
|
|
47
|
+
const setAcMode = { properties: { acMode } };
|
|
48
|
+
this.adapter.log.debug(`[setAcMode] Set AC mode to ${acMode}!`);
|
|
49
|
+
(_a = this.adapter.mqttClient) == null ? void 0 : _a.publish(topic, JSON.stringify(setAcMode));
|
|
50
|
+
const smartMode = await this.adapter.getStateAsync(
|
|
51
|
+
this.productKey + "." + this.deviceKey + ".control.smartMode"
|
|
52
|
+
);
|
|
53
|
+
if (smartMode && !smartMode.val) {
|
|
54
|
+
this.adapter.log.warn(
|
|
55
|
+
`[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!`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
this.adapter.log.error(
|
|
60
|
+
`[setAcMode] AC mode must be a value between 0 and 3!`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
setAcSwitch(acSwitch) {
|
|
66
|
+
var _a;
|
|
67
|
+
if (this.adapter.mqttClient && this.productKey && this.deviceKey) {
|
|
68
|
+
const setAcSwitchContent = {
|
|
69
|
+
properties: { acSwitch: acSwitch ? 1 : 0 }
|
|
70
|
+
};
|
|
71
|
+
this.adapter.log.debug(
|
|
72
|
+
`[setAcSwitch] Set AC Switch for device ${this.deviceKey} to ${acSwitch}!`
|
|
73
|
+
);
|
|
74
|
+
(_a = this.adapter.mqttClient) == null ? void 0 : _a.publish(
|
|
75
|
+
this.iotTopic,
|
|
76
|
+
JSON.stringify(setAcSwitchContent)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async setDeviceAutomationInOutLimit(limit) {
|
|
81
|
+
var _a;
|
|
82
|
+
if (this.adapter.mqttClient && this.productKey && this.deviceKey) {
|
|
83
|
+
this.adapter.log.debug(
|
|
84
|
+
`[setDeviceAutomationInOutLimit] Set device Automation limit to ${limit}!`
|
|
85
|
+
);
|
|
86
|
+
if (limit) {
|
|
87
|
+
limit = Math.round(limit);
|
|
88
|
+
} else {
|
|
89
|
+
limit = 0;
|
|
90
|
+
}
|
|
91
|
+
if (this.adapter.config.useLowVoltageBlock) {
|
|
92
|
+
const lowVoltageBlockState = await this.adapter.getStateAsync(
|
|
93
|
+
this.productKey + "." + this.deviceKey + ".control.lowVoltageBlock"
|
|
94
|
+
);
|
|
95
|
+
if (lowVoltageBlockState && lowVoltageBlockState.val && lowVoltageBlockState.val == true && limit > 0) {
|
|
96
|
+
limit = 0;
|
|
97
|
+
}
|
|
98
|
+
const fullChargeNeeded = await this.adapter.getStateAsync(
|
|
99
|
+
this.productKey + "." + this.deviceKey + ".control.fullChargeNeeded"
|
|
100
|
+
);
|
|
101
|
+
if (fullChargeNeeded && fullChargeNeeded.val && fullChargeNeeded.val == true && limit > 0) {
|
|
102
|
+
limit = 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (limit < 0) {
|
|
106
|
+
if (limit < this.maxInputLimit) {
|
|
107
|
+
limit = this.maxInputLimit;
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
if (limit > this.maxOutputLimit) {
|
|
111
|
+
limit = this.maxOutputLimit;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
this.adapter.msgCounter += 1;
|
|
115
|
+
const timestamp = /* @__PURE__ */ new Date();
|
|
116
|
+
timestamp.setMilliseconds(0);
|
|
117
|
+
this.adapter.log.debug(
|
|
118
|
+
`[setDeviceAutomationInOutLimit] Using HEMS Variant of device automation, as deviceKey '${this.deviceKey}' detected!`
|
|
119
|
+
);
|
|
120
|
+
const _arguments = {
|
|
121
|
+
outputPower: limit > 0 ? limit : 0,
|
|
122
|
+
chargeState: limit > 0 ? 0 : 1,
|
|
123
|
+
chargePower: limit > 0 ? 0 : -limit,
|
|
124
|
+
mode: 9
|
|
125
|
+
};
|
|
126
|
+
const hemsEP = {
|
|
127
|
+
arguments: _arguments,
|
|
128
|
+
function: "hemsEP",
|
|
129
|
+
messageId: this.adapter.msgCounter,
|
|
130
|
+
deviceKey: this.deviceKey,
|
|
131
|
+
timestamp: timestamp.getTime() / 1e3
|
|
132
|
+
};
|
|
133
|
+
(_a = this.adapter.mqttClient) == null ? void 0 : _a.publish(
|
|
134
|
+
this.functionTopic,
|
|
135
|
+
JSON.stringify(hemsEP)
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
141
|
+
0 && (module.exports = {
|
|
142
|
+
Sf800
|
|
143
|
+
});
|
|
144
|
+
//# sourceMappingURL=Sf800.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/models/deviceModels/Sf800.ts"],
|
|
4
|
+
"sourcesContent": ["import { solarflow800ControlStates } from \"../../constants/solarflow800ControlStates\";\nimport { solarflow800States } from \"../../constants/solarflow800States\";\nimport { ZendureSolarflow } from \"../../main\";\nimport { IHemsEpPayload } from \"../IDeviceAutomationPayload\";\nimport { IZenHaDeviceDetails } from \"../IZenHaDeviceDetails\";\nimport { ZenHaDevice } from \"./ZenHaDevice\";\n\nexport class Sf800 extends ZenHaDevice {\n maxInputLimit = 800;\n maxOutputLimit = 800;\n\n states = solarflow800States;\n controlStates = solarflow800ControlStates;\n\n public constructor(\n _adapter: ZendureSolarflow,\n _productKey: string,\n _deviceKey: string,\n _productName: string,\n _deviceName: string,\n _zenHaDeviceDetails?: IZenHaDeviceDetails\n ) {\n super(\n _adapter,\n _productKey,\n _deviceKey,\n _productName,\n _deviceName,\n _zenHaDeviceDetails\n );\n }\n\n public async setAcMode(acMode: number): Promise<void> {\n if (this.adapter.mqttClient && this.productKey && this.deviceKey) {\n if (acMode >= 0 && acMode <= 3) {\n const topic = `iot/${this.productKey}/${this.deviceKey}/properties/write`;\n\n const setAcMode = { properties: { acMode: acMode } };\n this.adapter.log.debug(`[setAcMode] Set AC mode to ${acMode}!`);\n this.adapter.mqttClient?.publish(topic, JSON.stringify(setAcMode));\n\n // Check if device is HUB, then check if smartMode is false - if so send a warning to log!\n const smartMode = await this.adapter.getStateAsync(\n this.productKey + \".\" + this.deviceKey + \".control.smartMode\"\n );\n\n if (smartMode && !smartMode.val) {\n this.adapter.log.warn(\n `[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!`\n );\n }\n } else {\n this.adapter.log.error(\n `[setAcMode] AC mode must be a value between 0 and 3!`\n );\n }\n }\n }\n\n public setAcSwitch(acSwitch: boolean): void {\n if (this.adapter.mqttClient && this.productKey && this.deviceKey) {\n const setAcSwitchContent = {\n properties: { acSwitch: acSwitch ? 1 : 0 },\n };\n this.adapter.log.debug(\n `[setAcSwitch] Set AC Switch for device ${this.deviceKey} to ${acSwitch}!`\n );\n this.adapter.mqttClient?.publish(\n this.iotTopic,\n JSON.stringify(setAcSwitchContent)\n );\n }\n }\n\n public async setDeviceAutomationInOutLimit(\n limit: number // can be negative, negative will trigger charging mode\n ): Promise<void> {\n if (this.adapter.mqttClient && this.productKey && this.deviceKey) {\n this.adapter.log.debug(\n `[setDeviceAutomationInOutLimit] Set device Automation limit to ${limit}!`\n );\n\n if (limit) {\n limit = Math.round(limit);\n } else {\n limit = 0;\n }\n\n if (this.adapter.config.useLowVoltageBlock) {\n const lowVoltageBlockState = await this.adapter.getStateAsync(\n this.productKey + \".\" + this.deviceKey + \".control.lowVoltageBlock\"\n );\n if (\n lowVoltageBlockState &&\n lowVoltageBlockState.val &&\n lowVoltageBlockState.val == true &&\n limit > 0\n ) {\n limit = 0;\n }\n\n const fullChargeNeeded = await this.adapter.getStateAsync(\n this.productKey + \".\" + this.deviceKey + \".control.fullChargeNeeded\"\n );\n\n if (\n fullChargeNeeded &&\n fullChargeNeeded.val &&\n fullChargeNeeded.val == true &&\n limit > 0\n ) {\n limit = 0;\n }\n }\n\n if (limit < 0) {\n // Get input limit, make number positive and the new value negative\n if (limit < this.maxInputLimit) {\n limit = this.maxInputLimit;\n }\n } else {\n if (limit > this.maxOutputLimit) {\n limit = this.maxOutputLimit;\n }\n }\n\n this.adapter.msgCounter += 1;\n\n const timestamp = new Date();\n timestamp.setMilliseconds(0);\n\n // Device Automation for Solarflow 2400 AC and Solarflow 800\n this.adapter.log.debug(\n `[setDeviceAutomationInOutLimit] Using HEMS Variant of device automation, as deviceKey '${this.deviceKey}' detected!`\n );\n\n // HEMS Variante\n const _arguments: IHemsEpPayload = {\n outputPower: limit > 0 ? limit : 0,\n chargeState: limit > 0 ? 0 : 1,\n chargePower: limit > 0 ? 0 : -limit,\n mode: 9,\n };\n\n const hemsEP = {\n arguments: _arguments,\n function: \"hemsEP\",\n messageId: this.adapter.msgCounter,\n deviceKey: this.deviceKey,\n timestamp: timestamp.getTime() / 1000,\n };\n this.adapter.mqttClient?.publish(\n this.functionTopic,\n JSON.stringify(hemsEP)\n );\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAA0C;AAC1C,gCAAmC;AAInC,yBAA4B;AAErB,MAAM,cAAc,+BAAY;AAAA,EAO9B,YACL,UACA,aACA,YACA,cACA,aACA,qBACA;AACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AArBF,yBAAgB;AAChB,0BAAiB;AAEjB,kBAAS;AACT,yBAAgB;AAAA,EAkBhB;AAAA,EAEA,MAAa,UAAU,QAA+B;AAhCxD;AAiCI,QAAI,KAAK,QAAQ,cAAc,KAAK,cAAc,KAAK,WAAW;AAChE,UAAI,UAAU,KAAK,UAAU,GAAG;AAC9B,cAAM,QAAQ,OAAO,KAAK,UAAU,IAAI,KAAK,SAAS;AAEtD,cAAM,YAAY,EAAE,YAAY,EAAE,OAAe,EAAE;AACnD,aAAK,QAAQ,IAAI,MAAM,8BAA8B,MAAM,GAAG;AAC9D,mBAAK,QAAQ,eAAb,mBAAyB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YAAY;AAAA,QAC3C;AAEA,YACE,oBACA,iBAAiB,OACjB,iBAAiB,OAAO,QACxB,QAAQ,GACR;AACA,kBAAQ;AAAA,QACV;AAAA,MACF;AAEA,UAAI,QAAQ,GAAG;AAEb,YAAI,QAAQ,KAAK,eAAe;AAC9B,kBAAQ,KAAK;AAAA,QACf;AAAA,MACF,OAAO;AACL,YAAI,QAAQ,KAAK,gBAAgB;AAC/B,kBAAQ,KAAK;AAAA,QACf;AAAA,MACF;AAEA,WAAK,QAAQ,cAAc;AAE3B,YAAM,YAAY,oBAAI,KAAK;AAC3B,gBAAU,gBAAgB,CAAC;AAG3B,WAAK,QAAQ,IAAI;AAAA,QACf,0FAA0F,KAAK,SAAS;AAAA,MAC1G;AAGA,YAAM,aAA6B;AAAA,QACjC,aAAa,QAAQ,IAAI,QAAQ;AAAA,QACjC,aAAa,QAAQ,IAAI,IAAI;AAAA,QAC7B,aAAa,QAAQ,IAAI,IAAI,CAAC;AAAA,QAC9B,MAAM;AAAA,MACR;AAEA,YAAM,SAAS;AAAA,QACb,WAAW;AAAA,QACX,UAAU;AAAA,QACV,WAAW,KAAK,QAAQ;AAAA,QACxB,WAAW,KAAK;AAAA,QAChB,WAAW,UAAU,QAAQ,IAAI;AAAA,MACnC;AACA,iBAAK,QAAQ,eAAb,mBAAyB;AAAA,QACvB,KAAK;AAAA,QACL,KAAK,UAAU,MAAM;AAAA;AAAA,IAEzB;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
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 SfHub1200_exports = {};
|
|
20
|
+
__export(SfHub1200_exports, {
|
|
21
|
+
SfHub1200: () => SfHub1200
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(SfHub1200_exports);
|
|
24
|
+
var import_hubControlStates = require("../../constants/hubControlStates");
|
|
25
|
+
var import_hubStates = require("../../constants/hubStates");
|
|
26
|
+
var import_ZenHaDevice = require("./ZenHaDevice");
|
|
27
|
+
class SfHub1200 extends import_ZenHaDevice.ZenHaDevice {
|
|
28
|
+
constructor(_adapter, _productKey, _deviceKey, _productName, _deviceName, _zenHaDeviceDetails) {
|
|
29
|
+
super(
|
|
30
|
+
_adapter,
|
|
31
|
+
_productKey,
|
|
32
|
+
_deviceKey,
|
|
33
|
+
_productName,
|
|
34
|
+
_deviceName,
|
|
35
|
+
_zenHaDeviceDetails
|
|
36
|
+
);
|
|
37
|
+
this.maxInputLimit = 900;
|
|
38
|
+
this.maxOutputLimit = 1200;
|
|
39
|
+
this.states = import_hubStates.hubStates;
|
|
40
|
+
this.controlStates = import_hubControlStates.hubControlStates;
|
|
41
|
+
}
|
|
42
|
+
async setAcMode(acMode) {
|
|
43
|
+
var _a;
|
|
44
|
+
if (this.adapter.mqttClient && this.productKey && this.deviceKey) {
|
|
45
|
+
if (acMode >= 0 && acMode <= 3) {
|
|
46
|
+
const setAcMode = { properties: { acMode } };
|
|
47
|
+
this.adapter.log.debug(`[setAcMode] Set AC mode to ${acMode}!`);
|
|
48
|
+
(_a = this.adapter.mqttClient) == null ? void 0 : _a.publish(
|
|
49
|
+
this.iotTopic,
|
|
50
|
+
JSON.stringify(setAcMode)
|
|
51
|
+
);
|
|
52
|
+
const smartMode = await this.adapter.getStateAsync(
|
|
53
|
+
this.productKey + "." + this.deviceKey + ".control.smartMode"
|
|
54
|
+
);
|
|
55
|
+
if (smartMode && !smartMode.val) {
|
|
56
|
+
this.adapter.log.warn(
|
|
57
|
+
`[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!`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
this.adapter.log.error(
|
|
62
|
+
`[setAcMode] AC mode must be a value between 0 and 3!`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
setAcSwitch(acSwitch) {
|
|
68
|
+
var _a;
|
|
69
|
+
if (this.adapter.mqttClient && this.productKey && this.deviceKey) {
|
|
70
|
+
const setAcSwitchContent = {
|
|
71
|
+
properties: { acSwitch: acSwitch ? 1 : 0 }
|
|
72
|
+
};
|
|
73
|
+
this.adapter.log.debug(
|
|
74
|
+
`[setAcSwitch] Set AC Switch for device ${this.deviceKey} to ${acSwitch}!`
|
|
75
|
+
);
|
|
76
|
+
(_a = this.adapter.mqttClient) == null ? void 0 : _a.publish(
|
|
77
|
+
this.iotTopic,
|
|
78
|
+
JSON.stringify(setAcSwitchContent)
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async setDeviceAutomationInOutLimit(limit) {
|
|
83
|
+
var _a;
|
|
84
|
+
if (this.adapter.mqttClient && this.productKey && this.deviceKey) {
|
|
85
|
+
this.adapter.log.debug(
|
|
86
|
+
`[setDeviceAutomationInOutLimit] Set device Automation limit to ${limit}!`
|
|
87
|
+
);
|
|
88
|
+
if (limit) {
|
|
89
|
+
limit = Math.round(limit);
|
|
90
|
+
} else {
|
|
91
|
+
limit = 0;
|
|
92
|
+
}
|
|
93
|
+
if (this.adapter.config.useLowVoltageBlock) {
|
|
94
|
+
const lowVoltageBlockState = await this.adapter.getStateAsync(
|
|
95
|
+
this.productKey + "." + this.deviceKey + ".control.lowVoltageBlock"
|
|
96
|
+
);
|
|
97
|
+
if (lowVoltageBlockState && lowVoltageBlockState.val && lowVoltageBlockState.val == true && limit > 0) {
|
|
98
|
+
limit = 0;
|
|
99
|
+
}
|
|
100
|
+
const fullChargeNeeded = await this.adapter.getStateAsync(
|
|
101
|
+
this.productKey + "." + this.deviceKey + ".control.fullChargeNeeded"
|
|
102
|
+
);
|
|
103
|
+
if (fullChargeNeeded && fullChargeNeeded.val && fullChargeNeeded.val == true && limit > 0) {
|
|
104
|
+
limit = 0;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (limit < 0) {
|
|
108
|
+
if (limit < this.maxInputLimit) {
|
|
109
|
+
limit = this.maxInputLimit;
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
if (limit > this.maxOutputLimit) {
|
|
113
|
+
limit = this.maxOutputLimit;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (limit < 100 && limit != 90 && limit != 60 && limit != 30 && limit != 0) {
|
|
117
|
+
if (limit < 100 && limit > 90) {
|
|
118
|
+
limit = 90;
|
|
119
|
+
} else if (limit > 60 && limit < 90) {
|
|
120
|
+
limit = 60;
|
|
121
|
+
} else if (limit > 30 && limit < 60) {
|
|
122
|
+
limit = 30;
|
|
123
|
+
} else if (limit < 30) {
|
|
124
|
+
limit = 30;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
this.adapter.msgCounter += 1;
|
|
128
|
+
const timestamp = /* @__PURE__ */ new Date();
|
|
129
|
+
timestamp.setMilliseconds(0);
|
|
130
|
+
let _arguments = [];
|
|
131
|
+
if (limit < 0) {
|
|
132
|
+
this.adapter.log.debug(
|
|
133
|
+
`[setDeviceAutomationInOutLimit] Using CHARGE variant of HUB device automation, as device '${this.productKey}' detected and limit is negative!`
|
|
134
|
+
);
|
|
135
|
+
_arguments = [
|
|
136
|
+
{
|
|
137
|
+
autoModelProgram: 2,
|
|
138
|
+
autoModelValue: {
|
|
139
|
+
chargingType: 1,
|
|
140
|
+
chargingPower: -limit,
|
|
141
|
+
freq: 0,
|
|
142
|
+
outPower: 0
|
|
143
|
+
},
|
|
144
|
+
msgType: 1,
|
|
145
|
+
autoModel: 8
|
|
146
|
+
}
|
|
147
|
+
];
|
|
148
|
+
} else {
|
|
149
|
+
this.adapter.log.debug(
|
|
150
|
+
`[setDeviceAutomationInOutLimit] Using FEED IN variant of Hub device automation, as device '${this.productKey}' detected and limit is positive!`
|
|
151
|
+
);
|
|
152
|
+
_arguments = [
|
|
153
|
+
{
|
|
154
|
+
autoModelProgram: 2,
|
|
155
|
+
autoModelValue: limit,
|
|
156
|
+
msgType: 1,
|
|
157
|
+
autoModel: 8
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
}
|
|
161
|
+
const deviceAutomation = {
|
|
162
|
+
arguments: _arguments,
|
|
163
|
+
function: "deviceAutomation",
|
|
164
|
+
messageId: this.adapter.msgCounter,
|
|
165
|
+
deviceKey: this.deviceKey,
|
|
166
|
+
timestamp: timestamp.getTime() / 1e3
|
|
167
|
+
};
|
|
168
|
+
(_a = this.adapter.mqttClient) == null ? void 0 : _a.publish(
|
|
169
|
+
this.functionTopic,
|
|
170
|
+
JSON.stringify(deviceAutomation)
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
176
|
+
0 && (module.exports = {
|
|
177
|
+
SfHub1200
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=SfHub1200.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/models/deviceModels/SfHub1200.ts"],
|
|
4
|
+
"sourcesContent": ["import { hubControlStates } from \"../../constants/hubControlStates\";\nimport { hubStates } from \"../../constants/hubStates\";\nimport { ZendureSolarflow } from \"../../main\";\nimport { IDeviceAutomationPayload } from \"../IDeviceAutomationPayload\";\nimport { IZenHaDeviceDetails } from \"../IZenHaDeviceDetails\";\nimport { ZenHaDevice } from \"./ZenHaDevice\";\n\nexport class SfHub1200 extends ZenHaDevice {\n maxInputLimit = 900;\n maxOutputLimit = 1200;\n\n states = hubStates;\n controlStates = hubControlStates;\n\n public constructor(\n _adapter: ZendureSolarflow,\n _productKey: string,\n _deviceKey: string,\n _productName: string,\n _deviceName: string,\n _zenHaDeviceDetails?: IZenHaDeviceDetails\n ) {\n super(\n _adapter,\n _productKey,\n _deviceKey,\n _productName,\n _deviceName,\n _zenHaDeviceDetails\n );\n\n // Hub 1200 specific methods\n }\n\n public async setAcMode(acMode: number): Promise<void> {\n if (this.adapter.mqttClient && this.productKey && this.deviceKey) {\n if (acMode >= 0 && acMode <= 3) {\n const setAcMode = { properties: { acMode: acMode } };\n this.adapter.log.debug(`[setAcMode] Set AC mode to ${acMode}!`);\n this.adapter.mqttClient?.publish(\n this.iotTopic,\n JSON.stringify(setAcMode)\n );\n\n // Check if device is HUB, then check if smartMode is false - if so send a warning to log!\n const smartMode = await this.adapter.getStateAsync(\n this.productKey + \".\" + this.deviceKey + \".control.smartMode\"\n );\n\n if (smartMode && !smartMode.val) {\n this.adapter.log.warn(\n `[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!`\n );\n }\n } else {\n this.adapter.log.error(\n `[setAcMode] AC mode must be a value between 0 and 3!`\n );\n }\n }\n }\n\n public setAcSwitch(acSwitch: boolean): void {\n if (this.adapter.mqttClient && this.productKey && this.deviceKey) {\n const setAcSwitchContent = {\n properties: { acSwitch: acSwitch ? 1 : 0 },\n };\n this.adapter.log.debug(\n `[setAcSwitch] Set AC Switch for device ${this.deviceKey} to ${acSwitch}!`\n );\n this.adapter.mqttClient?.publish(\n this.iotTopic,\n JSON.stringify(setAcSwitchContent)\n );\n }\n }\n\n public async setDeviceAutomationInOutLimit(\n limit: number // can be negative, negative will trigger charging mode\n ): Promise<void> {\n if (this.adapter.mqttClient && this.productKey && this.deviceKey) {\n this.adapter.log.debug(\n `[setDeviceAutomationInOutLimit] Set device Automation limit to ${limit}!`\n );\n\n if (limit) {\n limit = Math.round(limit);\n } else {\n limit = 0;\n }\n\n if (this.adapter.config.useLowVoltageBlock) {\n const lowVoltageBlockState = await this.adapter.getStateAsync(\n this.productKey + \".\" + this.deviceKey + \".control.lowVoltageBlock\"\n );\n if (\n lowVoltageBlockState &&\n lowVoltageBlockState.val &&\n lowVoltageBlockState.val == true &&\n limit > 0\n ) {\n limit = 0;\n }\n\n const fullChargeNeeded = await this.adapter.getStateAsync(\n this.productKey + \".\" + this.deviceKey + \".control.fullChargeNeeded\"\n );\n\n if (\n fullChargeNeeded &&\n fullChargeNeeded.val &&\n fullChargeNeeded.val == true &&\n limit > 0\n ) {\n limit = 0;\n }\n }\n\n if (limit < 0) {\n // Get input limit, make number positive and the new value negative\n if (limit < this.maxInputLimit) {\n limit = this.maxInputLimit;\n }\n } else {\n if (limit > this.maxOutputLimit) {\n limit = this.maxOutputLimit;\n }\n }\n\n if (\n limit < 100 &&\n limit != 90 &&\n limit != 60 &&\n limit != 30 &&\n limit != 0\n ) {\n // NUR Solarflow HUB: Das Limit kann unter 100 nur in 30er Schritten gesetzt werden, dH. 30/60/90/100, wir rechnen das also um\n if (limit < 100 && limit > 90) {\n limit = 90;\n } else if (limit > 60 && limit < 90) {\n limit = 60;\n } else if (limit > 30 && limit < 60) {\n limit = 30;\n } else if (limit < 30) {\n limit = 30;\n }\n }\n\n this.adapter.msgCounter += 1;\n\n const timestamp = new Date();\n timestamp.setMilliseconds(0);\n\n let _arguments: IDeviceAutomationPayload[] = [];\n\n if (limit < 0) {\n this.adapter.log.debug(\n `[setDeviceAutomationInOutLimit] Using CHARGE variant of HUB device automation, as device '${this.productKey}' detected and limit is negative!`\n );\n _arguments = [\n {\n autoModelProgram: 2,\n autoModelValue: {\n chargingType: 1,\n chargingPower: -limit,\n freq: 0,\n outPower: 0,\n },\n msgType: 1,\n autoModel: 8,\n },\n ];\n } else {\n // Output\n this.adapter.log.debug(\n `[setDeviceAutomationInOutLimit] Using FEED IN variant of Hub device automation, as device '${this.productKey}' detected and limit is positive!`\n );\n _arguments = [\n {\n autoModelProgram: 2,\n autoModelValue: limit,\n msgType: 1,\n autoModel: 8,\n },\n ];\n }\n\n const deviceAutomation = {\n arguments: _arguments,\n function: \"deviceAutomation\",\n messageId: this.adapter.msgCounter,\n deviceKey: this.deviceKey,\n timestamp: timestamp.getTime() / 1000,\n };\n this.adapter.mqttClient?.publish(\n this.functionTopic,\n JSON.stringify(deviceAutomation)\n );\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAiC;AACjC,uBAA0B;AAI1B,yBAA4B;AAErB,MAAM,kBAAkB,+BAAY;AAAA,EAOlC,YACL,UACA,aACA,YACA,cACA,aACA,qBACA;AACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AArBF,yBAAgB;AAChB,0BAAiB;AAEjB,kBAAS;AACT,yBAAgB;AAAA,EAoBhB;AAAA,EAEA,MAAa,UAAU,QAA+B;AAlCxD;AAmCI,QAAI,KAAK,QAAQ,cAAc,KAAK,cAAc,KAAK,WAAW;AAChE,UAAI,UAAU,KAAK,UAAU,GAAG;AAC9B,cAAM,YAAY,EAAE,YAAY,EAAE,OAAe,EAAE;AACnD,aAAK,QAAQ,IAAI,MAAM,8BAA8B,MAAM,GAAG;AAC9D,mBAAK,QAAQ,eAAb,mBAAyB;AAAA,UACvB,KAAK;AAAA,UACL,KAAK,UAAU,SAAS;AAAA;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AAW;AAAA,QACX,UAAU;AAAA,QACV,WAAW,KAAK,QAAQ;AAAA,QACxB,WAAW,KAAK;AAAA,QAChB,WAAW,UAAU,QAAQ,IAAI;AAAA,MACnC;AACA,iBAAK,QAAQ,eAAb,mBAAyB;AAAA,QACvB,KAAK;AAAA,QACL,KAAK,UAAU,gBAAgB;AAAA;AAAA,IAEnC;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
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 SfHub2000_exports = {};
|
|
20
|
+
__export(SfHub2000_exports, {
|
|
21
|
+
SfHub2000: () => SfHub2000
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(SfHub2000_exports);
|
|
24
|
+
var import_hubControlStates = require("../../constants/hubControlStates");
|
|
25
|
+
var import_hubStates = require("../../constants/hubStates");
|
|
26
|
+
var import_ZenHaDevice = require("./ZenHaDevice");
|
|
27
|
+
class SfHub2000 extends import_ZenHaDevice.ZenHaDevice {
|
|
28
|
+
constructor(_adapter, _productKey, _deviceKey, _productName, _deviceName, _zenHaDeviceDetails) {
|
|
29
|
+
super(
|
|
30
|
+
_adapter,
|
|
31
|
+
_productKey,
|
|
32
|
+
_deviceKey,
|
|
33
|
+
_productName,
|
|
34
|
+
_deviceName,
|
|
35
|
+
_zenHaDeviceDetails
|
|
36
|
+
);
|
|
37
|
+
this.maxInputLimit = 900;
|
|
38
|
+
this.maxOutputLimit = 1200;
|
|
39
|
+
this.states = import_hubStates.hubStates;
|
|
40
|
+
this.controlStates = import_hubControlStates.hubControlStates;
|
|
41
|
+
}
|
|
42
|
+
async setAcMode(acMode) {
|
|
43
|
+
var _a;
|
|
44
|
+
if (this.adapter.mqttClient && this.productKey && this.deviceKey) {
|
|
45
|
+
if (acMode >= 0 && acMode <= 3) {
|
|
46
|
+
const topic = `iot/${this.productKey}/${this.deviceKey}/properties/write`;
|
|
47
|
+
const setAcMode = { properties: { acMode } };
|
|
48
|
+
this.adapter.log.debug(`[setAcMode] Set AC mode to ${acMode}!`);
|
|
49
|
+
(_a = this.adapter.mqttClient) == null ? void 0 : _a.publish(topic, JSON.stringify(setAcMode));
|
|
50
|
+
const smartMode = await this.adapter.getStateAsync(
|
|
51
|
+
this.productKey + "." + this.deviceKey + ".control.smartMode"
|
|
52
|
+
);
|
|
53
|
+
if (smartMode && !smartMode.val) {
|
|
54
|
+
this.adapter.log.warn(
|
|
55
|
+
`[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!`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
this.adapter.log.error(
|
|
60
|
+
`[setAcMode] AC mode must be a value between 0 and 3!`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
setAcSwitch(acSwitch) {
|
|
66
|
+
var _a;
|
|
67
|
+
if (this.adapter.mqttClient && this.productKey && this.deviceKey) {
|
|
68
|
+
const setAcSwitchContent = {
|
|
69
|
+
properties: { acSwitch: acSwitch ? 1 : 0 }
|
|
70
|
+
};
|
|
71
|
+
this.adapter.log.debug(
|
|
72
|
+
`[setAcSwitch] Set AC Switch for device ${this.deviceKey} to ${acSwitch}!`
|
|
73
|
+
);
|
|
74
|
+
(_a = this.adapter.mqttClient) == null ? void 0 : _a.publish(
|
|
75
|
+
this.iotTopic,
|
|
76
|
+
JSON.stringify(setAcSwitchContent)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async setDeviceAutomationInOutLimit(limit) {
|
|
81
|
+
var _a;
|
|
82
|
+
if (this.adapter.mqttClient && this.productKey && this.deviceKey) {
|
|
83
|
+
this.adapter.log.debug(
|
|
84
|
+
`[setDeviceAutomationInOutLimit] Set device Automation limit to ${limit}!`
|
|
85
|
+
);
|
|
86
|
+
if (limit) {
|
|
87
|
+
limit = Math.round(limit);
|
|
88
|
+
} else {
|
|
89
|
+
limit = 0;
|
|
90
|
+
}
|
|
91
|
+
if (this.adapter.config.useLowVoltageBlock) {
|
|
92
|
+
const lowVoltageBlockState = await this.adapter.getStateAsync(
|
|
93
|
+
this.productKey + "." + this.deviceKey + ".control.lowVoltageBlock"
|
|
94
|
+
);
|
|
95
|
+
if (lowVoltageBlockState && lowVoltageBlockState.val && lowVoltageBlockState.val == true && limit > 0) {
|
|
96
|
+
limit = 0;
|
|
97
|
+
}
|
|
98
|
+
const fullChargeNeeded = await this.adapter.getStateAsync(
|
|
99
|
+
this.productKey + "." + this.deviceKey + ".control.fullChargeNeeded"
|
|
100
|
+
);
|
|
101
|
+
if (fullChargeNeeded && fullChargeNeeded.val && fullChargeNeeded.val == true && limit > 0) {
|
|
102
|
+
limit = 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (limit < 0) {
|
|
106
|
+
if (limit < this.maxInputLimit) {
|
|
107
|
+
limit = this.maxInputLimit;
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
if (limit > this.maxOutputLimit) {
|
|
111
|
+
limit = this.maxOutputLimit;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (limit < 100 && limit != 90 && limit != 60 && limit != 30 && limit != 0) {
|
|
115
|
+
if (limit < 100 && limit > 90) {
|
|
116
|
+
limit = 90;
|
|
117
|
+
} else if (limit > 60 && limit < 90) {
|
|
118
|
+
limit = 60;
|
|
119
|
+
} else if (limit > 30 && limit < 60) {
|
|
120
|
+
limit = 30;
|
|
121
|
+
} else if (limit < 30) {
|
|
122
|
+
limit = 30;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
this.adapter.msgCounter += 1;
|
|
126
|
+
const timestamp = /* @__PURE__ */ new Date();
|
|
127
|
+
timestamp.setMilliseconds(0);
|
|
128
|
+
let _arguments = [];
|
|
129
|
+
if (limit < 0) {
|
|
130
|
+
this.adapter.log.debug(
|
|
131
|
+
`[setDeviceAutomationInOutLimit] Using CHARGE variant of HUB device automation, as device '${this.productKey}' detected and limit is negative!`
|
|
132
|
+
);
|
|
133
|
+
_arguments = [
|
|
134
|
+
{
|
|
135
|
+
autoModelProgram: 2,
|
|
136
|
+
autoModelValue: {
|
|
137
|
+
chargingType: 1,
|
|
138
|
+
chargingPower: -limit,
|
|
139
|
+
freq: 0,
|
|
140
|
+
outPower: 0
|
|
141
|
+
},
|
|
142
|
+
msgType: 1,
|
|
143
|
+
autoModel: 8
|
|
144
|
+
}
|
|
145
|
+
];
|
|
146
|
+
} else {
|
|
147
|
+
this.adapter.log.debug(
|
|
148
|
+
`[setDeviceAutomationInOutLimit] Using FEED IN variant of Hub device automation, as device '${this.productKey}' detected and limit is positive!`
|
|
149
|
+
);
|
|
150
|
+
_arguments = [
|
|
151
|
+
{
|
|
152
|
+
autoModelProgram: 2,
|
|
153
|
+
autoModelValue: limit,
|
|
154
|
+
msgType: 1,
|
|
155
|
+
autoModel: 8
|
|
156
|
+
}
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
const deviceAutomation = {
|
|
160
|
+
arguments: _arguments,
|
|
161
|
+
function: "deviceAutomation",
|
|
162
|
+
messageId: this.adapter.msgCounter,
|
|
163
|
+
deviceKey: this.deviceKey,
|
|
164
|
+
timestamp: timestamp.getTime() / 1e3
|
|
165
|
+
};
|
|
166
|
+
(_a = this.adapter.mqttClient) == null ? void 0 : _a.publish(
|
|
167
|
+
this.functionTopic,
|
|
168
|
+
JSON.stringify(deviceAutomation)
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
174
|
+
0 && (module.exports = {
|
|
175
|
+
SfHub2000
|
|
176
|
+
});
|
|
177
|
+
//# sourceMappingURL=SfHub2000.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/models/deviceModels/SfHub2000.ts"],
|
|
4
|
+
"sourcesContent": ["import { hubControlStates } from \"../../constants/hubControlStates\";\nimport { hubStates } from \"../../constants/hubStates\";\nimport { ZendureSolarflow } from \"../../main\";\nimport { IDeviceAutomationPayload } from \"../IDeviceAutomationPayload\";\nimport { IZenHaDeviceDetails } from \"../IZenHaDeviceDetails\";\nimport { ZenHaDevice } from \"./ZenHaDevice\";\n\nexport class SfHub2000 extends ZenHaDevice {\n maxInputLimit = 900;\n maxOutputLimit = 1200;\n\n states = hubStates;\n controlStates = hubControlStates;\n\n public constructor(\n _adapter: ZendureSolarflow,\n _productKey: string,\n _deviceKey: string,\n _productName: string,\n _deviceName: string,\n _zenHaDeviceDetails?: IZenHaDeviceDetails\n ) {\n super(\n _adapter,\n _productKey,\n _deviceKey,\n _productName,\n _deviceName,\n _zenHaDeviceDetails\n );\n\n // Hub 2000 specific methods\n }\n\n public async setAcMode(acMode: number): Promise<void> {\n if (this.adapter.mqttClient && this.productKey && this.deviceKey) {\n if (acMode >= 0 && acMode <= 3) {\n const topic = `iot/${this.productKey}/${this.deviceKey}/properties/write`;\n\n const setAcMode = { properties: { acMode: acMode } };\n this.adapter.log.debug(`[setAcMode] Set AC mode to ${acMode}!`);\n this.adapter.mqttClient?.publish(topic, JSON.stringify(setAcMode));\n\n // Check if device is HUB, then check if smartMode is false - if so send a warning to log!\n const smartMode = await this.adapter.getStateAsync(\n this.productKey + \".\" + this.deviceKey + \".control.smartMode\"\n );\n\n if (smartMode && !smartMode.val) {\n this.adapter.log.warn(\n `[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!`\n );\n }\n } else {\n this.adapter.log.error(\n `[setAcMode] AC mode must be a value between 0 and 3!`\n );\n }\n }\n }\n\n public setAcSwitch(acSwitch: boolean): void {\n if (this.adapter.mqttClient && this.productKey && this.deviceKey) {\n const setAcSwitchContent = {\n properties: { acSwitch: acSwitch ? 1 : 0 },\n };\n this.adapter.log.debug(\n `[setAcSwitch] Set AC Switch for device ${this.deviceKey} to ${acSwitch}!`\n );\n this.adapter.mqttClient?.publish(\n this.iotTopic,\n JSON.stringify(setAcSwitchContent)\n );\n }\n }\n\n public async setDeviceAutomationInOutLimit(\n limit: number // can be negative, negative will trigger charging mode\n ): Promise<void> {\n if (this.adapter.mqttClient && this.productKey && this.deviceKey) {\n this.adapter.log.debug(\n `[setDeviceAutomationInOutLimit] Set device Automation limit to ${limit}!`\n );\n\n if (limit) {\n limit = Math.round(limit);\n } else {\n limit = 0;\n }\n\n if (this.adapter.config.useLowVoltageBlock) {\n const lowVoltageBlockState = await this.adapter.getStateAsync(\n this.productKey + \".\" + this.deviceKey + \".control.lowVoltageBlock\"\n );\n if (\n lowVoltageBlockState &&\n lowVoltageBlockState.val &&\n lowVoltageBlockState.val == true &&\n limit > 0\n ) {\n limit = 0;\n }\n\n const fullChargeNeeded = await this.adapter.getStateAsync(\n this.productKey + \".\" + this.deviceKey + \".control.fullChargeNeeded\"\n );\n\n if (\n fullChargeNeeded &&\n fullChargeNeeded.val &&\n fullChargeNeeded.val == true &&\n limit > 0\n ) {\n limit = 0;\n }\n }\n\n if (limit < 0) {\n // Get input limit, make number positive and the new value negative\n if (limit < this.maxInputLimit) {\n limit = this.maxInputLimit;\n }\n } else {\n if (limit > this.maxOutputLimit) {\n limit = this.maxOutputLimit;\n }\n }\n\n if (\n limit < 100 &&\n limit != 90 &&\n limit != 60 &&\n limit != 30 &&\n limit != 0\n ) {\n // NUR Solarflow HUB: Das Limit kann unter 100 nur in 30er Schritten gesetzt werden, dH. 30/60/90/100, wir rechnen das also um\n if (limit < 100 && limit > 90) {\n limit = 90;\n } else if (limit > 60 && limit < 90) {\n limit = 60;\n } else if (limit > 30 && limit < 60) {\n limit = 30;\n } else if (limit < 30) {\n limit = 30;\n }\n }\n\n this.adapter.msgCounter += 1;\n\n const timestamp = new Date();\n timestamp.setMilliseconds(0);\n\n let _arguments: IDeviceAutomationPayload[] = [];\n\n if (limit < 0) {\n this.adapter.log.debug(\n `[setDeviceAutomationInOutLimit] Using CHARGE variant of HUB device automation, as device '${this.productKey}' detected and limit is negative!`\n );\n _arguments = [\n {\n autoModelProgram: 2,\n autoModelValue: {\n chargingType: 1,\n chargingPower: -limit,\n freq: 0,\n outPower: 0,\n },\n msgType: 1,\n autoModel: 8,\n },\n ];\n } else {\n // Output\n this.adapter.log.debug(\n `[setDeviceAutomationInOutLimit] Using FEED IN variant of Hub device automation, as device '${this.productKey}' detected and limit is positive!`\n );\n _arguments = [\n {\n autoModelProgram: 2,\n autoModelValue: limit,\n msgType: 1,\n autoModel: 8,\n },\n ];\n }\n\n const deviceAutomation = {\n arguments: _arguments,\n function: \"deviceAutomation\",\n messageId: this.adapter.msgCounter,\n deviceKey: this.deviceKey,\n timestamp: timestamp.getTime() / 1000,\n };\n this.adapter.mqttClient?.publish(\n this.functionTopic,\n JSON.stringify(deviceAutomation)\n );\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;A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