NEWS
Huawei Sun2000 & ioBroker via JS script funktioniert
-
@alle
Wäre es möglich das aktuelle Script zentral, z.B. in #1 abzulegen.
(oder ist dies nicht vom TE)Ich habe momentan nicht mehr den Überblick wo ich das aktuelle finde.
Danke.
-
@r4 said in Huawei Sun2000 & ioBroker via JS script funktioniert:
@leonundjulie
Ne, das war ein Platzhalter.
Du kannst " + irgendEineVariable" z.B. an einer Stelle durch " + RegToReadPtr" ersetzen, so dass du die Nummer der aktuell ausgelesenen Werte siehst (die von RegToRead), oder auch weg lassen und statt "hier bin ich - " auch Zahlen oder auch sonstwas hinschreiben, so dass du im Log unten weißt, wo du gerade bist im Code.Ok, habe angefangen:
Und
Das Ergebnis im Protokoll so aus:
Ideen?
-
@leonundjulie
Äh, du hast doch keine Batterie? -
@r4 said in Huawei Sun2000 & ioBroker via JS script funktioniert:
@leonundjulie
Äh, du hast doch keine Batterie?Richtig. Da es mit der Version 2 und von mir heraus kommentierten Batt-Zeilen nicht funktionierte, habe ich die gestern veröffentlichte Version zunächst einmal unverändert gelassen …. muss wohl wieder Zeilen herauskicken … wird dann auch übersichtlicher
-
@leonundjulie
alsoconst BatteryUnits = [[0]];
und
const RegToRead = [ [32000, 116], // inverter status - read fast // [37000, 68], // battery information - read fast [37100, 114], // meter info - read fast // [37700, 100], // battery information - read fast // [38200, 100], // additional battery information - read fast [30000, 81], // model info, SN, max Power (static info) - read slow // [37800, 100], // additional battery information - read slow // [38300, 100], // additional battery information - read slow // [38400, 100], // additional battery information - read slow // [47081, 2] // additional battery information - read slow //[35300, 40] // inverter power adjustments - do not read ]; const RegFast = 2; // number of register spaces to read fast (must be < RegToRead.length)
und (hast du Optimizer?)
function ProcessData() //-------------------- { //console.debug("Processing new data..."); for ( var i = 1; i <= ModBusIDs.length; i++) { ProcessDeviceInfo(i); ProcessInverterStatus(i); //ProcessBattery(i); //ProcessInverterPowerAdjustments(i); //ProcessOptimizers(i); }
... aber Fehlermeldung beim Lesen von Register 30000 sollte nicht dauerhaft kommen
-
Hallo,
ich habe eine Frage zu folgendem Hinweis im Script:// Enter your battery stack setup. 2 dimensional array, e.g. [[3, 2], [3, 0]] means: // First inverter has two battery stacks with 3 + 2 battery modules // while second inverter has only one battery stack with 3 battery modules
dort steht: 1. Inverter mit 2 stacks und 2 modules, also [3,2]
und: 2. Inverter mit 1 stack und 3 modules; müsste dies dann nicht [1,3] heißen ?Irgendwie passt dies nicht so richtig, oder ich versteh es nicht.
-
@r4 said in Huawei Sun2000 & ioBroker via JS script funktioniert:
@leonundjulie
alsoconst BatteryUnits = [[0]];
und
const RegToRead = [ [32000, 116], // inverter status - read fast // [37000, 68], // battery information - read fast [37100, 114], // meter info - read fast // [37700, 100], // battery information - read fast // [38200, 100], // additional battery information - read fast [30000, 81], // model info, SN, max Power (static info) - read slow // [37800, 100], // additional battery information - read slow // [38300, 100], // additional battery information - read slow // [38400, 100], // additional battery information - read slow // [47081, 2] // additional battery information - read slow //[35300, 40] // inverter power adjustments - do not read ]; const RegFast = 2; // number of register spaces to read fast (must be < RegToRead.length)
und (hast du Optimizer?)
function ProcessData() //-------------------- { //console.debug("Processing new data..."); for ( var i = 1; i <= ModBusIDs.length; i++) { ProcessDeviceInfo(i); ProcessInverterStatus(i); //ProcessBattery(i); //ProcessInverterPowerAdjustments(i); //ProcessOptimizers(i); }
... aber Fehlermeldung beim Lesen von Register 30000 sollte nicht dauerhaft kommen
Habe mal eben zwischen Tür und Angel Deinen Ansatz umgesetzt - leider nicht ohne Fehler …. Kann denen aber erst heute Abend nachgehen.
-
@leonundjulie
Mit dem Script direkt hat das augenscheinlich nichts zu tun.
Ich bin da erst mal raus. -
Ich habe mal eine ganz andere Spekulation: welche Software Versionen habt Ihr den so auf dem WR respektive auf dem Dongle? Ich frage, weil - wenn es nicht zur erneuten Verschiebung kommt - am kommenden Donnerstag vom Solateur EnPAL ( ) ein neuer WR eingebaut wird (der alte fährt bis 150 Resets am Tag wegen „Isolationsfehler“ -> ich glaube zwar, dass die Fehler eine andere Ursache haben, aber die können das aus der Ferne ja besser beurteilen ).
Wie dem auch sei, ich will natürlich dafür Sorge tragen, dass dann auch die richtige Software auf den HUAWEI Komponenten drauf ist.
-
@leonundjulie
Für Versionsinfos auch hier schauen, man muss nur bisschen suchen...Beim SDongle sind V100R001C00SPC133 bzw. V200R022C10SPC107 derzeit aktuell.
-
Guten Tag zusammen,
ich bräuchte mal ein kleines bisschen Unterstützung. Ich möchte das Skript von @Chris_B etwas abspecken. Ich brauche das Zusammenrechnen der Verbrauche zum Beispiel nicht.
Dies ist mein Ausgangscode:
// From iobroker Forum: "Huawei Sun2000 & ioBroker via JS script funktioniert" // https://forum.iobroker.net/topic/53005/huawei-sun2000-iobroker-via-js-script-funktioniert // createState("javascript.0.Solarpower.Derived.BatteryOverview", "", {read: true, write: true, name: "Battery Overview SOC"}); createState("javascript.0.Solarpower.Derived.HouseConsumption", "", {read: true, write: true, name: "Consumption of House", unit: "W"}); createState("javascript.0.Solarpower.Derived.YieldToday", "", {read: true, write: true, name: "Yield Today", unit: "kW"}); createState("javascript.0.Solarpower.Derived.IsBatteryLoading", 0, {read: true, write: true, name: "Luna 2000 Battery is loading", type: "number"}); createState("javascript.0.Solarpower.Derived.IsGridExporting", 0, {read: true, write: true, name: "Exporting Power to Grid", type: "number"}); createState("javascript.0.Solarpower.Derived.PeakPanelPower", 0, {read: true, write: true, name: "Peak panel power today"}); createState("javascript.0.Solarpower.Derived.GridExportSum", 0, {read: true, write: true, name: "Total export to grid", unit: "kWh"}); createState("javascript.0.Solarpower.Derived.GridImportSum", 0, {read: true, write: true, name: "Total import from grid", unit: "kWh"}); createState("javascript.0.Solarpower.Derived.GridExportToday", 0, {read: true, write: true, name: "Export to grid today", unit: "kWh"}); createState("javascript.0.Solarpower.Derived.GridImportToday", 0, {read: true, write: true, name: "Import from grid today", unit: "kWh"}); createState("javascript.0.Solarpower.Derived.ConsumptionToday", 0, {read: true, write: true, name: "Consumption today", unit: "kWh"}); createState("javascript.0.Solarpower.Derived.ConsumptionSum", 0, {read: true, write: true, name: "Consumption total sum", unit: "kWh"}); createState("javascript.0.Solarpower.Derived.ConsumptionStart", 0, {read: true, write: true, name: "Consumption total sum at start of day", unit: "kWh"}); var ModbusRTU = require("modbus-serial"); var fs = require('fs'); var client = new ModbusRTU(); var testCreateState = 0; var currentinverter = 1; var modbusErrorMessages = [ "Unknown error", "Illegal function (device does not support this read/write function)", "Illegal data address (register not supported by device)", "Illegal data value (value cannot be written to this register)", "Slave device failure (device reports internal error)", "Acknowledge (requested data will be available later)", "Slave device busy (retry request again later)" ]; // open connection to a tcp line client.setTimeout(10000); // Enter your inverter modbus IP and port here: client.connectTCP("192.168.1.108", { port: 502 }); // Enter the Modbus-IDs of your Sun2000 inverters here (example for two inverters): const ModBusIDs = [16, 1]; const ModBusIDs = [1]; // On which Modbus-ID can we reach the power meter? (via Sun2000!) const PowerMeterID = 0; // Enter your battery stack setup. 2 dimensional array, e.g. [[3, 2], [3, 0]] means: // First inverter has two battery stacks with 3 + 2 battery modules // while second inverter has only one battery stack with 3 battery modules const BatteryUnits = [[1, 0]]; // These register spaces need to be read const RegToRead = [ [32000, 116], // inverter status - read fast [37000, 68], // battery information - read fast [37100, 114], // meter info - read fast [37700, 100], // battery information - read fast [38200, 100], // additional battery information - read fast [30000, 81], // model info, SN, max Power (static info) - read slow [37800, 100], // additional battery information - read slow [38300, 100], // additional battery information - read slow [38400, 100] // additional battery information - read slow //[35300, 40] // inverter power adjustments - do not read ]; const RegFast = 5; // number of register spaces to read fast (must be < RegToRead.length) const RegFastMod = 10; // read slow registers every n'th time (mod operator) var RegReadCnt = 0; // Loop counter var RegToReadPtr = 0; // pointer to register spaces var GlobalDataBuffer = new Array(2); for ( var i=0; i < ModBusIDs.length; i++) { GlobalDataBuffer[i] = new Array(50000); // not optimized.... } // Some helper functions function readUnsignedInt16(array) { return array[0]; } function readUnsignedInt32(array) { return array[0] * 256 * 256 + array[1]; } function readSignedInt16(array) { var value = 0; if (array[0] > 32767) value = array[0] - 65535; else value = array[0]; return value; } function readSignedInt32(array) { var value = 0; for (var i = 0; i < 2; i++) { value = (value << 16) | array[i]; } return value; } function getU16(dataarray, index) { return readUnsignedInt16(dataarray.slice(index, index+1)); } function getU32(dataarray, index) { return readUnsignedInt32(dataarray.slice(index, index+2)); } function getI16(dataarray, index) { return readSignedInt16(dataarray.slice(index, index+1)); } function getI32(dataarray, index) { return readSignedInt32(dataarray.slice(index, index+2)); } function getString(dataarray, index, length) { var shortarray = dataarray.slice(index, index+length); var bytearray = []; for (var i = 0; i < length; i++) { bytearray.push(dataarray[index+i] >> 8); bytearray.push(dataarray[index+i] & 0xff); } var value = String.fromCharCode.apply(null, bytearray); return value; } function getZeroTerminatedString(dataarray, index, length) { var shortarray = dataarray.slice(index, index+length); var bytearray = []; for(var i = 0; i < length; i++) { bytearray.push(dataarray[index+i] >> 8); bytearray.push(dataarray[index+i] & 0xff); } var value = String.fromCharCode.apply(null, bytearray); var value2 = new String(value).trim(); return value2; } function forcesetState(objectname, value, options) //------------------------------------------------ // perform createState() only if variable does not yet exist, and perform the check via existsState() only once for each processing round { if (testCreateState == 0) { if (!existsState("javascript.0." + objectname)) { createState(objectname, value, options); } else { setState(objectname, value); } } else { setState(objectname, value); } } // Functions to map registers into ioBreaker objects function ProcessOptimizers(id) //---------------------------- { forcesetState("Solarpower.Huawei.Inverter." + id + ".OptimizerTotalNumber", getU16(GlobalDataBuffer[id-1], 37200), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".OptimizerOnlineNumber", getU16(GlobalDataBuffer[id-1], 37201), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".OptimizerFeatureData", getU16(GlobalDataBuffer[id-1], 37202), {name: "", unit: ""}); } function ProcessInverterPowerAdjustments(id) //------------------------------------------ { forcesetState("Solarpower.Huawei.Inverter." + id + ".ActiveAdjustement.ActiveAdjustementMode", getU16(GlobalDataBuffer[id-1], 35300), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".ActiveAdjustement.ActiveAdjustementValue", getU32(GlobalDataBuffer[id-1], 35301), {name: "", unit: ""}); // Note: This might be an error in the manual. It says register 35302 with quantity 2, but on 35303 is already the next value. forcesetState("Solarpower.Huawei.Inverter." + id + ".ActiveAdjustement.ActiveAdjustementCommand", getU16(GlobalDataBuffer[id-1], 35303), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".ActiveAdjustement.ReactiveAdjustementMode", getU16(GlobalDataBuffer[id-1], 35304), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".ActiveAdjustement.ReactiveAdjustementValue", getU32(GlobalDataBuffer[id-1], 35305), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".ActiveAdjustement.ReactiveAdjustementCommand",getU16(GlobalDataBuffer[id-1], 35307), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".ActiveAdjustement.PowerMeterActivePower", getI32(GlobalDataBuffer[id-1], 35313), {name: "", unit: ""}); } function ProcessBattery(id) //------------------------- { // Battery registers 1-15 (Stack 1 related) if ( BatteryUnits[id-1][0] > 0) { forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.RunningStatus", getU16(GlobalDataBuffer[id-1], 37000), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.ChargeAndDischargePower", getI32(GlobalDataBuffer[id-1], 37001), {name: "Charge and Discharge Power", unit: "W"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.BusVoltage", getU16(GlobalDataBuffer[id-1], 37003) / 10, {name: "Busvoltage", unit: "V"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.BatterySOC", getU16(GlobalDataBuffer[id-1], 37004) / 10, {name: "Battery SOC", unit: "%"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.WorkingMode", getU16(GlobalDataBuffer[id-1], 37006), {name: "Working Mode", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.RatedChargePower", getU32(GlobalDataBuffer[id-1], 37007), {name: "", unit: "W"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.RatedDischargePower", getU32(GlobalDataBuffer[id-1], 37009), {name: "", unit: "W"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.FaultID", getU16(GlobalDataBuffer[id-1], 37014), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.CurrentDayChargeCapacity", getU32(GlobalDataBuffer[id-1], 37015) * 10, {name: "", unit: "Wh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.CurrentDayDischargeCapacity", getU32(GlobalDataBuffer[id-1], 37017) * 10, {name: "", unit: "Wh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.BusCurrent", getI16(GlobalDataBuffer[id-1], 37021) / 10, {name: "Buscurrent", unit: "A"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.BatteryTemperature", getI16(GlobalDataBuffer[id-1], 37022) / 10, {name: "Battery Temperatue", unit: "°C"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.RemainingChargeDischargeTime",getU16(GlobalDataBuffer[id-1], 37025), {name: "", unit: "mins"}); //forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.DCDCversion", getZeroTerminatedString(GlobalDataBuffer[id-1], 37026, 10), {name: "", unit: ""}); //forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.BMSversion", getZeroTerminatedString(GlobalDataBuffer[id-1], 37036, 10), {name: "", unit: ""}); } // Battery registers 16+17 (Storage-related) forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.MaximumChargePower", getU32(GlobalDataBuffer[id-1], 37046), {name: "", unit: "W"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.MaximumDischargePower", getU32(GlobalDataBuffer[id-1], 37048), {name: "", unit: "W"}); // Battery register 18-20 (Stack 1 related) if (BatteryUnits[id-1][0] > 0) { forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.SN", getZeroTerminatedString(GlobalDataBuffer[id-1], 37052, 10), {name: "Serialnumber", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.TotalCharge", getU32(GlobalDataBuffer[id-1], 37066) * 10, {name: "", unit: "Wh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.TotalDischarge", getU32(GlobalDataBuffer[id-1], 37068) * 10, {name: "", unit: "Wh"}); } // Battery register 21-31 (Stack 2 related) if ( BatteryUnits[id-1][1] > 0) { forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.2.SN", getZeroTerminatedString(GlobalDataBuffer[id-1], 37700, 10), {name: "Serialnumber", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.2.BatterySOC", getU16(GlobalDataBuffer[id-1], 37738) / 10, {name: "", unit: "%"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.2.RunningStatus", getU16(GlobalDataBuffer[id-1], 37741), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.2.ChargeAndDischargePower", getI32(GlobalDataBuffer[id-1], 37743), {name: "", unit: "W"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.2.CurrentDayChargeCapacity", getU32(GlobalDataBuffer[id-1], 37746) / 100, {name: "", unit: "kWh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.2.CurrentDayDischargeCapacity", getU32(GlobalDataBuffer[id-1], 37748) / 100, {name: "", unit: "kWh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.2.BusVoltage", getU16(GlobalDataBuffer[id-1], 37750) / 10, {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.2.BusCurrent", getI16(GlobalDataBuffer[id-1], 37751) / 10, {name: "", unit: "A"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.2.BatteryTemperature", getI16(GlobalDataBuffer[id-1], 37752) / 10, {name: "", unit: "°C"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.2.TotalCharge", getU32(GlobalDataBuffer[id-1], 37753) * 10, {name: "", unit: "Wh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.2.TotalDischarge", getU32(GlobalDataBuffer[id-1], 37755) * 10, {name: "", unit: "Wh"}); } // Battery register 32-41 (Storage related) forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.RatedCapacity", getU32(GlobalDataBuffer[id-1], 37758) / 1, {name: "", unit: "Wh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.SOC", getU16(GlobalDataBuffer[id-1], 37760) / 10, {name: "", unit: "%"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.RunningStatus", getU16(GlobalDataBuffer[id-1], 37762) / 1, {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.BusVoltage", getU16(GlobalDataBuffer[id-1], 37763) / 10, {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.BusCurrent", getI16(GlobalDataBuffer[id-1], 37764) / 10, {name: "", unit: "A"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.ChargeAndDischargePower", getI32(GlobalDataBuffer[id-1], 37765) / 1, {name: "", unit: "W"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.TotalCharge", getU32(GlobalDataBuffer[id-1], 37780) * 10, {name: "", unit: "Wh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.TotalDischarge", getU32(GlobalDataBuffer[id-1], 37782) * 10, {name: "", unit: "Wh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.CurrentDayChargeCapacity", getU32(GlobalDataBuffer[id-1], 37784) * 10, {name: "", unit: "Wh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.CurrentDayDischargeCapacity", getU32(GlobalDataBuffer[id-1], 37786) * 10, {name: "Current DayDiscarge ", unit: "Wh"}); // Battery registers 42+43 (Battery stack related) if (BatteryUnits[id-1][1] > 0) { forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.2.SoftwareVersion", getZeroTerminatedString(GlobalDataBuffer[id-1], 37814, 8), {name: "Softwareversion", unit: ""}); } if (BatteryUnits[id-1][0] > 0) { forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.SoftwareVersion", getZeroTerminatedString(GlobalDataBuffer[id-1], 37799, 8), {name: "Softwareversion", unit: ""}); } // Registers 44 to 98: (Battery pack related) for(var i = 1; i <= 2; i++) { if(BatteryUnits[id-1][i-1] >= 0) { for(var j = 1; j <= BatteryUnits[id-1][i-1]; j++) { //[[38200, 38242, 38284] [38326, 38368, 38410]]; (+42 for each battery pack, +126 for each stack) forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack." + i + ".Battery" + j + ".SN", getZeroTerminatedString(GlobalDataBuffer[id-1], 38200+(i-1)*126+(j-1)*42, 6), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack." + i + ".Battery" + j + ".FirmwareVersion", getZeroTerminatedString(GlobalDataBuffer[id-1], 38210+(i-1)*126+(j-1)*42, 8), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack." + i + ".Battery" + j + ".WorkingStatus", getU16(GlobalDataBuffer[id-1], 38228+(i-1)*126+(j-1)*42), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack." + i + ".Battery" + j + ".BatterySOC", getU16(GlobalDataBuffer[id-1], 38229+(i-1)*126+(j-1)*42) / 10, {name: "", unit: "%"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack." + i + ".Battery" + j + ".ChargeAndDischargePower", getI32(GlobalDataBuffer[id-1], 38233+(i-1)*126+(j-1)*42) / 1000, {name: "", unit: "kW"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack." + i + ".Battery" + j + ".Voltage", getU16(GlobalDataBuffer[id-1], 38235+(i-1)*126+(j-1)*42) / 10, {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack." + i + ".Battery" + j + ".Current", getI16(GlobalDataBuffer[id-1], 38236+(i-1)*126+(j-1)*42) / 10, {name: "", unit: "A"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack." + i + ".Battery" + j + ".TotalCharge", getU32(GlobalDataBuffer[id-1], 38238+(i-1)*126+(j-1)*42) * 10, {name: "", unit: "Wh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack." + i + ".Battery" + j + ".TotalDischarge", getU32(GlobalDataBuffer[id-1], 38240+(i-1)*126+(j-1)*42) * 10, {name: "", unit: "Wh"}); // [[38452, 38454, 38456][38458, 38460, 38462]] ( +2 for each pack, +6 for each stack) createState("Solarpower.Huawei.Inverter." + id + ".Batterystack." + i + ".Battery" + j + ".MaxTemperature", getI16(GlobalDataBuffer[id-1], 38452+(i-1)*6+(j-1)*2) / 10, {name: "", unit: "°C"}); createState("Solarpower.Huawei.Inverter." + id + ".Batterystack." + i + ".Battery" + j + ".MinTemperature", getI16(GlobalDataBuffer[id-1], 38453+(i-1)*6+(j-1)*2) / 10, {name: "", unit: "°C"}); } } } // Battery registers 110-141 are not supported by this script yet! } function ProcessPowerMeterStatus() //-------------------------------- { forcesetState("Solarpower.Huawei.Meter.Status", getU16(GlobalDataBuffer[PowerMeterID], 37100), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Meter.VoltageL1", getI32(GlobalDataBuffer[PowerMeterID], 37101) / 10, {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Meter.VoltageL2", getI32(GlobalDataBuffer[PowerMeterID], 37103) / 10, {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Meter.VoltageL3", getI32(GlobalDataBuffer[PowerMeterID], 37105) / 10, {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Meter.CurrentL1", getI32(GlobalDataBuffer[PowerMeterID], 37107) / 100, {name: "", unit: "A"}); forcesetState("Solarpower.Huawei.Meter.CurrentL2", getI32(GlobalDataBuffer[PowerMeterID], 37109) / 100, {name: "", unit: "A"}); forcesetState("Solarpower.Huawei.Meter.CurrentL3", getI32(GlobalDataBuffer[PowerMeterID], 37111) / 100, {name: "", unit: "A"}); forcesetState("Solarpower.Huawei.Meter.ActivePower", getI32(GlobalDataBuffer[PowerMeterID], 37113) / 1, {name: "", unit: "W"}); forcesetState("Solarpower.Huawei.Meter.ReactivePower", getI32(GlobalDataBuffer[PowerMeterID], 37115) / 1, {name: "", unit: "Var"}); forcesetState("Solarpower.Huawei.Meter.PowerFactor", getI16(GlobalDataBuffer[PowerMeterID], 37117) / 1000, {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Meter.GridFrequency", getI16(GlobalDataBuffer[PowerMeterID], 37118) / 100, {name: "", unit: "Hz"}); forcesetState("Solarpower.Huawei.Meter.PositiveActiveEnergy", getI32(GlobalDataBuffer[PowerMeterID], 37119) * 10, {name: "", unit: "Wh"}); forcesetState("Solarpower.Huawei.Meter.ReverseActiveEnergy", getI32(GlobalDataBuffer[PowerMeterID], 37121) * 10, {name: "", unit: "Wh"}); forcesetState("Solarpower.Huawei.Meter.AccumulatedReactivePower", getI32(GlobalDataBuffer[PowerMeterID], 37123) / 100, {name: "", unit: "kVarh"}); //forcesetState("Solarpower.Huawei.Meter.MeterType", getU16(GlobalDataBuffer[PowerMeterID], 37125), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Meter.VoltageL1-L2", getI32(GlobalDataBuffer[PowerMeterID], 37126) / 10, {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Meter.VoltageL2-L3", getI32(GlobalDataBuffer[PowerMeterID], 37128) / 10, {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Meter.VoltageL3-L1", getI32(GlobalDataBuffer[PowerMeterID], 37130) / 10, {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Meter.ActivePowerL1", getI32(GlobalDataBuffer[PowerMeterID], 37132) / 1, {name: "", unit: "W"}); forcesetState("Solarpower.Huawei.Meter.ActivePowerL2", getI32(GlobalDataBuffer[PowerMeterID], 37134) / 1, {name: "", unit: "W"}); forcesetState("Solarpower.Huawei.Meter.ActivePowerL3", getI32(GlobalDataBuffer[PowerMeterID], 37136) / 1, {name: "", unit: "W"}); //forcesetState("Solarpower.Huawei.Meter.MeterModel", getU16(GlobalDataBuffer[PowerMeterID], 37138), {name: "", unit: ""}); } function ProcessInverterStatus(id) //-------------------------------- { forcesetState("Solarpower.Huawei.Inverter." + id + ".State1", getU16(GlobalDataBuffer[id-1], 32000), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".State2", getU16(GlobalDataBuffer[id-1], 32001), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".State3", getU16(GlobalDataBuffer[id-1], 32002), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Alarm1", getU16(GlobalDataBuffer[id-1], 32008), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Alarm2", getU16(GlobalDataBuffer[id-1], 32009), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Alarm3", getU16(GlobalDataBuffer[id-1], 32010), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".String.1_Voltage", getI16(GlobalDataBuffer[id-1], 32016) / 10 , {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".String.1_Current", getI16(GlobalDataBuffer[id-1], 32017) / 100 , {name: "", unit: "A"}); //forcesetState("Solarpower.Huawei.Inverter." + id + ".String.2_Voltage", getI16(GlobalDataBuffer[id-1], 32018) / 10 , {name: "", unit: "V"}); //forcesetState("Solarpower.Huawei.Inverter." + id + ".String.2_Current", getI16(GlobalDataBuffer[id-1], 32019) / 100 , {name: "", unit: "A"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".InputPower", getI32(GlobalDataBuffer[id-1], 32064) / 1000, {name: "", unit: "kW"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Grid.L1-L2_Voltage", getU16(GlobalDataBuffer[id-1], 32066) / 10 , {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Grid.L2-L3_Voltage", getU16(GlobalDataBuffer[id-1], 32067) / 10 , {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Grid.L3-L1_Voltage", getU16(GlobalDataBuffer[id-1], 32068) / 10 , {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Grid.L1_Voltage", getU16(GlobalDataBuffer[id-1], 32069) / 10 , {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Grid.L2_Voltage", getU16(GlobalDataBuffer[id-1], 32070) / 10 , {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Grid.L3_Voltage", getU16(GlobalDataBuffer[id-1], 32071) / 10 , {name: "", unit: "V"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Grid.L1_Current", getI32(GlobalDataBuffer[id-1], 32072) / 1000, {name: "", unit: "A"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Grid.L2_Current", getI32(GlobalDataBuffer[id-1], 32074) / 1000, {name: "", unit: "A"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Grid.L3_Current", getI32(GlobalDataBuffer[id-1], 32076) / 1000, {name: "", unit: "A"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".PeakActivePowerDay", getI32(GlobalDataBuffer[id-1], 32078) / 1000, {name: "", unit: "kW"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".ActivePower", getI32(GlobalDataBuffer[id-1], 32080) / 1000, {name: "", unit: "kW"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".ReactivePower", getI32(GlobalDataBuffer[id-1], 32082) / 1000, {name: "", unit: "kVar"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".PowerFactor", getI16(GlobalDataBuffer[id-1], 32084) / 1000, {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".GridFrequency", getU16(GlobalDataBuffer[id-1], 32085) / 100 , {name: "", unit: "Hz"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Efficiency", getU16(GlobalDataBuffer[id-1], 32086) / 100 , {name: "", unit: "%"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".InternalTemperature", getI16(GlobalDataBuffer[id-1], 32087) / 10 , {name: "", unit: "°C"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".InsulationResistance", getU16(GlobalDataBuffer[id-1], 32088) / 1000, {name: "", unit: "MOhm"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".DeviceStatus", getU16(GlobalDataBuffer[id-1], 32089), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".FaultCode", getU16(GlobalDataBuffer[id-1], 32090), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".StartupTime", getU16(GlobalDataBuffer[id-1], 32091), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".ShutdownTime", getU16(GlobalDataBuffer[id-1], 32093), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".AccumulatedEnergyYield", getU32(GlobalDataBuffer[id-1], 32106) * 10, {name: "", unit: "Wh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".DailyEnergyYield", getU32(GlobalDataBuffer[id-1], 32114) * 10, {name: "", unit: "Wh"}); } function ProcessDeviceInfo(id) //---------------------------- { // Note: Manual says its quantitiy is 15, but that is the number (+1) of 8bit characters forcesetState("Solarpower.Huawei.Inverter." + id + ".Model", getZeroTerminatedString(GlobalDataBuffer[id-1], 30000, 8), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".SN", getZeroTerminatedString(GlobalDataBuffer[id-1], 30015, 6), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".PN", getZeroTerminatedString(GlobalDataBuffer[id-1], 30025, 6), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".ModelID", getU16(GlobalDataBuffer[id-1], 30070), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".PVStrings", getU16(GlobalDataBuffer[id-1], 30071), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".MPPTrackers", getU16(GlobalDataBuffer[id-1], 30072), {name: "", unit: ""}); forcesetState("Solarpower.Huawei.Inverter." + id + ".MaxRatedPower", getU32(GlobalDataBuffer[id-1], 30073) / 1000, {name: "", unit: "kW"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".MaxActivePower", getU32(GlobalDataBuffer[id-1], 30075) / 1000, {name: "", unit: "kW"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".MaxApparentPower", getU32(GlobalDataBuffer[id-1], 30077) / 1000, {name: "", unit: "kVA"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".MaxReactivePowerToGrid", getI32(GlobalDataBuffer[id-1], 30079) / 1000, {name: "", unit: "kVAr"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".MaxReactivePowerFromGrid",getI32(GlobalDataBuffer[id-1], 30081) / 1000, {name: "", unit: "kVAr"}); } function readRegisterSpace(id, address, length) //--------------------------------------------- { client.setID(ModBusIDs[id-1]); client.readHoldingRegisters(address, length, function(err, data) { if (err) { console.warn("Error received reading address " + address + " from id: " + ModBusIDs[id-1] + " with error: " + modbusErrorMessages[err.modbusCode]); } else { //console.debug("Read data from id/address " + ModBusIDs[id-1] + "/" + address + "\nData is: " + data.data); for (var i = 0; i < length; i++) GlobalDataBuffer[id-1][address+i] = data.data[i]; } }); } function ProcessData() //-------------------- { //console.debug("Processing new data..."); for ( var i = 1; i <= ModBusIDs.length; i++) { ProcessDeviceInfo(i); ProcessInverterStatus(i); ProcessBattery(i); //ProcessInverterPowerAdjustments(i); ProcessOptimizers(i); } ProcessPowerMeterStatus(); // get SOC of first battery stack and combine to one string var BatOverview = ""; for(var j = 1; j <= BatteryUnits[0][0]; j++) { if (j > 1) BatOverview += ", "; BatOverview += getState("javascript.0.Solarpower.Huawei.Inverter.1.Batterystack.1.Battery" + j + ".BatterySOC").val + "%"; } setState("javascript.0.Solarpower.Derived.BatteryOverview", BatOverview); // determine peak panel power var PanelPower = getState("javascript.0.Solarpower.Huawei.Inverter.1.InputPower").val; var PanelMax = getState("javascript.0.Solarpower.Derived.PeakPanelPower").val; if (PanelPower > PanelMax) setState("javascript.0.Solarpower.Derived.PeakPanelPower", PanelPower); // determine power used by house setState("javascript.0.Solarpower.Derived.HouseConsumption", getState("javascript.0.Solarpower.Huawei.Inverter.1.ActivePower").val * 1000 - getState("javascript.0.Solarpower.Huawei.Meter.ActivePower").val); // determine yield today setState("javascript.0.Solarpower.Derived.YieldToday", getState("javascript.0.Solarpower.Huawei.Inverter.1.DailyEnergyYield").val + getState("javascript.0.Solarpower.Huawei.Inverter.1.Batterystack.1.CurrentDayChargeCapacity").val - getState("javascript.0.Solarpower.Huawei.Inverter.1.Batterystack.1.CurrentDayDischargeCapacity").val) // determine if battery is loading setState("javascript.0.Solarpower.Derived.IsBatteryLoading", getState("javascript.0.Solarpower.Huawei.Inverter.1.Batterystack.1.ChargeAndDischargePower").val > 0 ? 0 : 1); // determine if power is imported or exported setState("javascript.0.Solarpower.Derived.IsGridExporting", getState("javascript.0.Solarpower.Huawei.Meter.ActivePower").val > 0 ? 1 : 0); // compute export and import today setState("javascript.0.Solarpower.Derived.GridExportToday", getState("javascript.0.Solarpower.Huawei.Meter.PositiveActiveEnergy").val - getState("javascript.0.Solarpower.Derived.GridExportSum").val); setState("javascript.0.Solarpower.Derived.GridImportToday", getState("javascript.0.Solarpower.Huawei.Meter.ReverseActiveEnergy").val - getState("javascript.0.Solarpower.Derived.GridImportSum").val); // compute consumption today setState("javascript.0.Solarpower.Derived.ConsumptionSum", getState("javascript.0.Solarpower.Huawei.Inverter.1.AccumulatedEnergyYield").val + getState("javascript.0.Solarpower.Huawei.Meter.ReverseActiveEnergy").val - getState("javascript.0.Solarpower.Huawei.Meter.PositiveActiveEnergy").val); setState("javascript.0.Solarpower.Derived.ConsumptionToday", getState("javascript.0.Solarpower.Derived.ConsumptionSum").val - getState("javascript.0.Solarpower.Derived.ConsumptionStart").val); testCreateState = 1; // do not check on createState any more } setInterval(function() // ------------------- // This is the main function triggering a read via modbus-tcp every 5000 ms (see end of SetInterval) // Processing of data is triggered as soon as one complete set of registers is copied // with 5 seconds, new values are displyed every 50 seconds { //console.debug("Triggering read of inverter " + currentinverter + " at address " + RegToRead[RegToReadPtr][0] + " with length " + RegToRead[RegToReadPtr][1]); readRegisterSpace(currentinverter, RegToRead[RegToReadPtr][0], RegToRead[RegToReadPtr][1]); // determine if all or only fast registers should be read var CurLength = RegFast; if ((RegReadCnt % RegFastMod) == 0) CurLength = RegToRead.length RegToReadPtr++; if (RegToReadPtr >= CurLength) { RegToReadPtr = 0; // go through all inverters, if there are several currentinverter++ if (currentinverter > ModBusIDs.length) { currentinverter = 1; ProcessData(); //if (CurLength == RegFast) log("Processing done (FAST)!", "info"); else log("Processing done (SLOW)!", "info"); RegReadCnt++; } } }, 5000); // one minute before midnight - perform housekeeping actions schedule("59 23 * * *", function () { // reset peak power for next day setState("javascript.0.Solarpower.Derived.PeakPanelPower", 0); // copy current export/import kWh - used to compute daily import/export in kWh setState("javascript.0.Solarpower.Derived.GridExportSum", getState("javascript.0.Solarpower.Huawei.Meter.PositiveActiveEnergy").val); setState("javascript.0.Solarpower.Derived.GridImportSum", getState("javascript.0.Solarpower.Huawei.Meter.ReverseActiveEnergy").val); // copy consumption Sum to Start for the next day setState("javascript.0.Solarpower.Derived.ConsumptionStart", getState("javascript.0.Solarpower.Derived.ConsumptionSum").val); // log important iformation to file SolarPowerLogging(); }); function SolarPowerLogging() //-------------------------- // write values of today in file { // get var log1 = getState("javascript.0.Solarpower.Derived.YieldToday").val; var log2 = getState("javascript.0.Solarpower.Derived.GridExportToday").val; var log3 = getState("javascript.0.Solarpower.Derived.GridImportToday").val; var log4 = getState("javascript.0.Solarpower.Derived.ConsumptionToday").val; // Zerlege Datum und Zeit in Variable var now = new Date(); var year = now.getFullYear(); var month = addZero(now.getMonth() + 1); var day = addZero(now.getDate()); var currDate = day + '.' + month + '.' + year; var string = " "; // create string that is appended to the file string = currDate + ";" + log1.toFixed(3) + ";" + log2.toFixed(3) + ";" + log3.toFixed(3) + ";" + log4.toFixed(3) + "\n"; fs.appendFileSync("/opt/iobroker/iobroker-data/SolarpowerLog.csv", string); // erzeuge Log-Eintrag log("Solerpower log:" + string, "info"); } function addZero(Num) //----------------- // if number <10 add zero values at the beginning of numbers { if (Num < 10) Num = "0" + Num; return Num; }
Wenn ich nun folgende, für mich unwichtige Teile, entferne
createState("javascript.0.Solarpower.Derived.BatteryOverview", "", {read: true, write: true, name: "Battery Overview SOC"}); createState("javascript.0.Solarpower.Derived.HouseConsumption", "", {read: true, write: true, name: "Consumption of House", unit: "W"}); createState("javascript.0.Solarpower.Derived.YieldToday", "", {read: true, write: true, name: "Yield Today", unit: "kW"}); createState("javascript.0.Solarpower.Derived.IsBatteryLoading", 0, {read: true, write: true, name: "Luna 2000 Battery is loading", type: "number"}); createState("javascript.0.Solarpower.Derived.IsGridExporting", 0, {read: true, write: true, name: "Exporting Power to Grid", type: "number"}); createState("javascript.0.Solarpower.Derived.PeakPanelPower", 0, {read: true, write: true, name: "Peak panel power today"}); createState("javascript.0.Solarpower.Derived.GridExportSum", 0, {read: true, write: true, name: "Total export to grid", unit: "kWh"}); createState("javascript.0.Solarpower.Derived.GridImportSum", 0, {read: true, write: true, name: "Total import from grid", unit: "kWh"}); createState("javascript.0.Solarpower.Derived.GridExportToday", 0, {read: true, write: true, name: "Export to grid today", unit: "kWh"}); createState("javascript.0.Solarpower.Derived.GridImportToday", 0, {read: true, write: true, name: "Import from grid today", unit: "kWh"}); createState("javascript.0.Solarpower.Derived.ConsumptionToday", 0, {read: true, write: true, name: "Consumption today", unit: "kWh"}); createState("javascript.0.Solarpower.Derived.ConsumptionSum", 0, {read: true, write: true, name: "Consumption total sum", unit: "kWh"}); createState("javascript.0.Solarpower.Derived.ConsumptionStart", 0, {read: true, write: true, name: "Consumption total sum at start of day", unit: "kWh"});
// one minute before midnight - perform housekeeping actions schedule("59 23 * * *", function () { // reset peak power for next day setState("javascript.0.Solarpower.Derived.PeakPanelPower", 0); // copy current export/import kWh - used to compute daily import/export in kWh setState("javascript.0.Solarpower.Derived.GridExportSum", getState("javascript.0.Solarpower.Huawei.Meter.PositiveActiveEnergy").val); setState("javascript.0.Solarpower.Derived.GridImportSum", getState("javascript.0.Solarpower.Huawei.Meter.ReverseActiveEnergy").val); // copy consumption Sum to Start for the next day setState("javascript.0.Solarpower.Derived.ConsumptionStart", getState("javascript.0.Solarpower.Derived.ConsumptionSum").val); // log important iformation to file SolarPowerLogging(); }); function SolarPowerLogging() //-------------------------- // write values of today in file { // get var log1 = getState("javascript.0.Solarpower.Derived.YieldToday").val; var log2 = getState("javascript.0.Solarpower.Derived.GridExportToday").val; var log3 = getState("javascript.0.Solarpower.Derived.GridImportToday").val; var log4 = getState("javascript.0.Solarpower.Derived.ConsumptionToday").val; // Zerlege Datum und Zeit in Variable var now = new Date(); var year = now.getFullYear(); var month = addZero(now.getMonth() + 1); var day = addZero(now.getDate()); var currDate = day + '.' + month + '.' + year; var string = " "; // create string that is appended to the file string = currDate + ";" + log1.toFixed(3) + ";" + log2.toFixed(3) + ";" + log3.toFixed(3) + ";" + log4.toFixed(3) + "\n"; fs.appendFileSync("/opt/iobroker/iobroker-data/SolarpowerLog.csv", string); // erzeuge Log-Eintrag log("Solerpower log:" + string, "info"); } function addZero(Num) //----------------- // if number <10 add zero values at the beginning of numbers { if (Num < 10) Num = "0" + Num; return Num; }
function ProcessData() //-------------------- { //console.debug("Processing new data..."); for ( var i = 1; i <= ModBusIDs.length; i++) { ProcessDeviceInfo(i); ProcessInverterStatus(i); ProcessBattery(i); //ProcessInverterPowerAdjustments(i); ProcessOptimizers(i); } ProcessPowerMeterStatus(); // get SOC of first battery stack and combine to one string var BatOverview = ""; for(var j = 1; j <= BatteryUnits[0][0]; j++) { if (j > 1) BatOverview += ", "; BatOverview += getState("javascript.0.Solarpower.Huawei.Inverter.1.Batterystack.1.Battery" + j + ".BatterySOC").val + "%"; } setState("javascript.0.Solarpower.Derived.BatteryOverview", BatOverview); // determine peak panel power var PanelPower = getState("javascript.0.Solarpower.Huawei.Inverter.1.InputPower").val; var PanelMax = getState("javascript.0.Solarpower.Derived.PeakPanelPower").val; if (PanelPower > PanelMax) setState("javascript.0.Solarpower.Derived.PeakPanelPower", PanelPower); // determine power used by house setState("javascript.0.Solarpower.Derived.HouseConsumption", getState("javascript.0.Solarpower.Huawei.Inverter.1.ActivePower").val * 1000 - getState("javascript.0.Solarpower.Huawei.Meter.ActivePower").val); // determine yield today setState("javascript.0.Solarpower.Derived.YieldToday", getState("javascript.0.Solarpower.Huawei.Inverter.1.DailyEnergyYield").val + getState("javascript.0.Solarpower.Huawei.Inverter.1.Batterystack.1.CurrentDayChargeCapacity").val - getState("javascript.0.Solarpower.Huawei.Inverter.1.Batterystack.1.CurrentDayDischargeCapacity").val) // determine if battery is loading setState("javascript.0.Solarpower.Derived.IsBatteryLoading", getState("javascript.0.Solarpower.Huawei.Inverter.1.Batterystack.1.ChargeAndDischargePower").val > 0 ? 0 : 1); // determine if power is imported or exported setState("javascript.0.Solarpower.Derived.IsGridExporting", getState("javascript.0.Solarpower.Huawei.Meter.ActivePower").val > 0 ? 1 : 0); // compute export and import today setState("javascript.0.Solarpower.Derived.GridExportToday", getState("javascript.0.Solarpower.Huawei.Meter.PositiveActiveEnergy").val - getState("javascript.0.Solarpower.Derived.GridExportSum").val); setState("javascript.0.Solarpower.Derived.GridImportToday", getState("javascript.0.Solarpower.Huawei.Meter.ReverseActiveEnergy").val - getState("javascript.0.Solarpower.Derived.GridImportSum").val); // compute consumption today setState("javascript.0.Solarpower.Derived.ConsumptionSum", getState("javascript.0.Solarpower.Huawei.Inverter.1.AccumulatedEnergyYield").val + getState("javascript.0.Solarpower.Huawei.Meter.ReverseActiveEnergy").val - getState("javascript.0.Solarpower.Huawei.Meter.PositiveActiveEnergy").val); setState("javascript.0.Solarpower.Derived.ConsumptionToday", getState("javascript.0.Solarpower.Derived.ConsumptionSum").val - getState("javascript.0.Solarpower.Derived.ConsumptionStart").val); testCreateState = 1; // do not check on createState any more }
Arbeitet das Skript nicht mehr. Ich bekomme aber kein Protokoll und auch keine Daten in den Objekten. Aber was genau fehlt mir, damit ich nun die Daten bekomme?
Viele Grüße
Martin -
@r4 said in Huawei Sun2000 & ioBroker via JS script funktioniert:
@leonundjulie
Für Versionsinfos auch hier schauen, man muss nur bisschen suchen...Beim SDongle sind V100R001C00SPC133 bzw. V200R022C10SPC107 derzeit aktuell.
Was soll ich sagen - es läuft. Warum? Zunächst habe ich mir die aktuellen Software Paketen für den WR und den Dongle aus dem Netz gezogen.
WR: alles aktuell
sDongle: um sich einloggen zu können -> SDongle heraus, nach 2 Minuten wieder rein, eingeloggt …. Software ist aktuell
Zurück zum IOBROKER, Skript gestartet …. , alle 5 Sekunden kommen Werte.
Jetzt hoffe ich nur, dass das auch so anhält.
Dank gebührt allen, die geholfen haben - Merci. Natürlich bleibe ich dabei, warte aufs nächste Update des Skriptes und teste gerne weiter mit
Nachtrag vom heutigen Sonntag: da ich erst heute Zeit finde, kann ich erst jetzt als Nachbrenner einbringen, das ich oben vergessen habe zu erwähnen, dass ich in meinem EnPAL-Konstrukt während des ganzen Testens die LAN-Verbindung zwischen dem Huawei S2000 und der EnPAL Box herausgezogen hatte. Kaum war der LAN-Stecker wieder in der Buchse, hat das Skript keine Werte mehr ausgeworfen. Dies führt zur Annahme, dass der SDongle - wenn WLAN und LAN gleichzeitig eingesteckt sind - (oder vielleicht der Wechselrichter selber) einer LAN-Verbindung Priorität gibt bzw. WLAN keine weiteren Zugriffe erlaubt.
Auch der in anderen Foren beschriebene Zugriff via WLAN funktioniert via dem WLAN des WR (Netz mit geringer Reichweite und nicht via WLAN des Dongles), wenn die LAN-Schnittstelle des SDongles verwendet wird.
Also werde ich jetzt mal versuchen meinen PI an das LAN der EnPAL-Box anzuschließen, ein Port ist noch frei :-), und mich wieder melden wenn ich das IP-Routing im Griff habe. Gemäß meiner obigen These müsste dann endlich gehen.
-
@hussi
?
Du entfernst Funktionen wie SolarPowerLogging() und vor allem ProcessData() und wunderst dich, dass es kein Loggingprotokoll mehr gibt und die SW nicht mehr tut?Bitte lass das Zeug drin, wenn du nicht weißt, was es tut.
So viel CPU Zeit benötigt das jetzt auch nicht...(ok,
schedule("59 23 * * *", function () {...}
kannst du rauslöschen, wenn du keine Logdatei willst.)
-
@r4 Nee ich wundere mich nicht. Ich weiß ja nicht was ich tue. Brauche aber die Berechnungen nicht und habe daher gedacht ich kann sie so rausnehmen.
Frei nach dem Gedanken: Je schmaler, je besser.
-
@hussi Ich würde echt nicht raten, solche Dinge rauszunehmen. Nicht weil es (teilweise) Dinge sind, die ichgeschrieben habe, aber einfach Dinge löschen bringt wenig, auch wenn Du gewisses nicht brauchst. Diese Berechnungen brauchen ja keine relevante Rechenleistung und dadurch wird das Skript nicht wirklich 'besser', in einer Form, die Du bemerken würdest... Gruss
-
@chris_b und @R. Guten Morgen Euch Beiden. Ich habe eine Verständnisfrage zum Konzept des Skripte. Die Frage kam auf im Rahmen der Analyse der bei mir Installierten EnPAL-Topologie und der Tatsache, dass man ganz am Anfang des Skriptes die ID des SmartMeters angibt, die dann beim Ablauf des Skriptes, also beim Abfragen der verschiedenen Werte, bei der Abfrage des SmartMeters verwendet wird.
Warum wird die Abfrage an das SmartMeter und nicht an den WR gerichtet? Die verwendeten Register-Adressen gehören doch zum Wechselrichter und nicht zum SmartMeter
-
@chris_b Hab ich verstanden. Dann lasse ich alles so. Wie gesagt: Dachte je schmaler, je besser.
Danke für Deine Tolle Arbeit!
Edit:
Wenn ich nur eine Batterie habe, mache ich das dann so:
const BatteryUnits = [[1, 0]];
?
-
@leonundjulie sagte in Huawei Sun2000 & ioBroker via JS script funktioniert:
Warum wird die Abfrage an das SmartMeter und nicht an den WR gerichtet? Die verwendeten Register-Adressen gehören doch zum Wechselrichter und nicht zum SmartMeter
Auch hier: ?
Das Script liest nur die ModBus-Daten des WR ein.
Der WR selbst stellt die Smartmeter-Daten bereit (liest die von dort selbst ein).
Und mitconst PowerMeterID = 0;
stellst du auch nicht die ID des PowerMeters ein (der hat gar keine), sondern
// On which Modbus-ID can we reach the power meter? (via Sun2000!)
hier also wird der erste Eintrag im Array
// Enter the Modbus-IDs of your Sun2000 inverters here (example for two inverters): const ModBusIDs = [16, 1]; const ModBusIDs = [1];
verwendet, was die Modbus-ID des WR ist, an dem der PowerMeter angeschlossen ist.
-
@r4 said in Huawei Sun2000 & ioBroker via JS script funktioniert:
@leonundjulie sagte in Huawei Sun2000 & ioBroker via JS script funktioniert:
Warum wird die Abfrage an das SmartMeter und nicht an den WR gerichtet? Die verwendeten Register-Adressen gehören doch zum Wechselrichter und nicht zum SmartMeter
Auch hier: ?
Das Script liest nur die ModBus-Daten des WR ein.
Der WR selbst stellt die Smartmeter-Daten bereit (liest die von dort selbst ein).
Und mitconst PowerMeterID = 0;
stellst du auch nicht die ID des PowerMeters ein (der hat gar keine), sondern
// On which Modbus-ID can we reach the power meter? (via Sun2000!)
hier also wird der erste Eintrag im Array
// Enter the Modbus-IDs of your Sun2000 inverters here (example for two inverters): const ModBusIDs = [16, 1]; const ModBusIDs = [1];
verwendet, was die Modbus-ID des WR ist, an dem der PowerMeter angeschlossen ist.
Ja, auch hier … da die Node-Red-Variante bei mir nicht laufen will - aber jetzt kann ich es ja vielleicht erklären (s.o.).
Danke für die Antwort. Auch den Anteil habe ich jetzt verstanden. Und ich dachte schon die Antwort dafür zu haben, warum in der Zeit - als ich die LAN-Strecke zwischen SUN2000 und EnPAL-Box unterbrochen hatte - im SUN2000 keine Meter-Werte mehr auftauchten. Irgendein Geheimnis steckten in dieser EnPAL-Topologie immer noch
-
@leonundjulie Der Antwort von @R4 habe ich nichts hinzuzufügen - genau so ist es Ich würde auch das im Skript nicht verändern, deckt den Fall von 2 WR ab. Ich weiss nicht, wie häufig das ist, aber es ist allgemeiner...