NEWS
Huawei Sun2000 & ioBroker via JS script funktioniert
-
@melonea Siehe soeben gepostet von mir.
Achtung: Connection Funktion eingebaut, aber nicht automatischer reconnect, da das bei mir nicht funktioniert hat.
Zum Einbinden wie oben beschrieben vorgehen.
Ich hoffe, das hilft. Gruss -
@chris_b sagte in Huawei Sun2000 & ioBroker via JS script funktioniert:
@melonea Siehe soeben gepostet von mir.
Achtung: Connection Funktion eingebaut, aber nicht automatischer reconnect, da das bei mir nicht funktioniert hat.
Zum Einbinden wie oben beschrieben vorgehen.
Ich hoffe, das hilft. GrussHmmm, da ich in der Materie ein kompletter neuling bin, wie bringe ich den automatischen reconnect dann zum laufen, oder verstehe ich da was falsch? Muss ich im Skript was umstellen, damit das automatisch geht?
Sorry für meine blöden Fargen.
Danke für deine Bemühungen, Gruß Jürgen. -
@juggi1962 sagte in Huawei Sun2000 & ioBroker via JS script funktioniert:
@chris_b sagte in Huawei Sun2000 & ioBroker via JS script funktioniert:
@melonea Siehe soeben gepostet von mir.
Achtung: Connection Funktion eingebaut, aber nicht automatischer reconnect, da das bei mir nicht funktioniert hat.
Zum Einbinden wie oben beschrieben vorgehen.
Ich hoffe, das hilft. GrussHmmm, da ich in der Materie ein kompletter neuling bin, wie bringe ich den automatischen reconnect dann zum laufen, oder verstehe ich da was falsch? Muss ich im Skript was umstellen, damit das automatisch geht?
Sorry für meine blöden Fargen.
Danke für deine Bemühungen, Gruß Jürgen.Hallo @Chris_b
Hab das Skript erfolgreich installiert aber leider sind folgende Fehler nach gut einer halben Stunde Laufzeit aufgetretenjavascript.0 2023-07-24 16:36:50.393 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37700 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:47.393 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37100 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:44.395 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37000 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:41.394 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 32000 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:38.394 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 38200 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:35.394 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37700 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:32.394 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37100 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:29.393 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37000 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:26.393 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 32000 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:23.393 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 38200 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:20.394 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37700 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:17.394 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37100 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:14.394 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37000 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:11.394 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 32000 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:08.393 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 38200 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:05.393 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37700 from id: 1 with error: undefined javascript.0 2023-07-24 16:36:02.393 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37100 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:59.393 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37000 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:56.394 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 32000 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:53.394 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 38200 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:50.393 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37700 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:47.394 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37100 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:44.394 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37000 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:41.393 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 32000 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:38.394 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 38200 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:35.392 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37700 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:32.392 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37100 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:29.391 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37000 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:26.391 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 32000 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:23.393 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 38200 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:20.392 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37700 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:17.390 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37100 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:14.390 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37000 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:11.391 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 32000 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:08.391 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 38200 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:05.390 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37700 from id: 1 with error: undefined javascript.0 2023-07-24 16:35:02.391 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37100 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:59.391 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37000 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:56.390 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 32000 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:53.390 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 38200 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:50.389 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37700 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:47.390 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37100 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:44.389 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37000 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:41.390 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 32000 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:38.389 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 38200 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:35.388 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37700 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:32.389 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37100 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:29.388 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 37000 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:26.387 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 32000 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:23.386 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 38400 from id: 1 with error: undefined javascript.0 2023-07-24 16:34:20.387 warn script.js.Neu.PV_Anlage.Modbus_Huawei_Sun2000: Error received reading address 38300 from id: 1 with error: undefined
Nach neustart ging es wieder. Das ist mein Problem das ich seit anfang an habe.
Mit dem einfacheren Skript wo aber die Batterie und alles was neu von dir ist fehlt ging es da sich das Skript immer wieder neu verbunden hat.// License: Beerware! Do what ever you like with this, but I'm not liable for anything that you do with it. // If you like this code, feel free to buy me a beer ... // Have fun with it! der Kachel // @ts-ignore var modbusRTU = require("modbus-serial"); var client = new modbusRTU(); 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)" ]; // Enter your inverter modbus IP and port here: const modbusHost = "192.168.1.7"; const modbusPort = 502; // Enter the Modbus-IDs of your Sun2000 inverters here: const modbusID = [1]; // On which Modbus-ID can we reach the power meter? (via Sun2000!) const powerMeterID = 0; // Connect to modbus client ConnectModbus(); // These register spaces need to be read: const registerSpacesToReadContinuously = [[37100, 114],[32000, 116]]; var registerSpacesToReadContinuouslyPtr = 0; var globalDataBuffer = new Array(1); globalDataBuffer[0] = new Array(50000); // not optimized.... // --------------------------------------------------------------- // Some helper functions: function ReadUnsignedInt16(array) { var value = array[0]; return value; } function ReadUnsignedInt32(array) { var value = array[0] * 256 * 256 + array[1]; return value; } 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) { var value = ReadUnsignedInt16(dataarray.slice(index, index+1)); return value; } function GetU32(dataarray, index) { var value = ReadUnsignedInt32(dataarray.slice(index, index+2)); return value; } function GetI16(dataarray, index) { var value = ReadSignedInt16(dataarray.slice(index, index+1)); return value; } function GetI32(dataarray, index) { var value = ReadSignedInt32(dataarray.slice(index, index+2)); return value; } 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; } // Funktion zum Herstellen einer Modbus-Verbindung function ConnectModbus() { console.log("Init connection to: " + modbusHost +":" + modbusPort); // set requests parameters client.setTimeout (10000); // try to connect client.connectTCP (modbusHost, { port: modbusPort }) .then(function() { console.log("Connected, wait for reading..."); }) .catch(function(e) { console.log(e); }); } // Funktion zum Anlegen und Beschreiben eines Datenpunkts function ForceSetState(objectname, value, options) { if(!existsState("javascript.0." + objectname)) createState(objectname, value, options); else setState(objectname, value); } // --------------------------------------------------------------- // Functions to map registers into ioBreaker objects: 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) / 100, {name: "", unit: "kWh"}); ForceSetState("Solarpower.Huawei.Meter.ReverseActiveEnergy", GetI32(globalDataBuffer[powerMeterID], 37121) / 100, {name: "", unit: "kWh"}); 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], 32002), {name: "", unit: ""}); ForceSetState("Solarpower.Huawei.Inverter." + id + ".State3", GetU32(globalDataBuffer[id-1], 32003), {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 + ".String.3_Voltage", GetI16(globalDataBuffer[id-1], 32020) / 10, {name: "", unit: "V"}); ForceSetState("Solarpower.Huawei.Inverter." + id + ".String.3_Current", GetI16(globalDataBuffer[id-1], 32021) / 100, {name: "", unit: "A"}); ForceSetState("Solarpower.Huawei.Inverter." + id + ".String.4_Voltage", GetI16(globalDataBuffer[id-1], 32022) / 10, {name: "", unit: "V"}); ForceSetState("Solarpower.Huawei.Inverter." + id + ".String.4_Current", GetI16(globalDataBuffer[id-1], 32023) / 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", String(new Date(GetU32(globalDataBuffer[id-1], 32091)*1000)), {name: "", unit: ""}); ForceSetState("Solarpower.Huawei.Inverter." + id + ".ShutdownTime", String(new Date(GetU32(globalDataBuffer[id-1], 32093)*1000)), {name: "", unit: ""}); ForceSetState("Solarpower.Huawei.Inverter." + id + ".AccomulatedEnergyYield", GetU32(globalDataBuffer[id-1], 32106) / 100, {name: "", unit: "kWh"}); ForceSetState("Solarpower.Huawei.Inverter." + id + ".DailyEnergyYield", GetU32(globalDataBuffer[id-1], 32114) / 100, {name: "", unit: "kWh"}); } function ReadRegisterSpace(id, address, length) { client.setID(modbusID[id-1]); client.readHoldingRegisters(address, length, function(err, data) { if (err) { if (err.modbusCode == null) { console.warn("Lost connection to client. Trying to reconnect..."); ConnectModbus(); } else console.warn("Error received reading address " + address + " from id: " + modbusID[id-1] + " with error: " + err.modbusCode); } else { console.debug("Read data from id/address " + modbusID[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.log("Processing new data..."); for(var i = 1; i <= modbusID.length; i++) { ProcessInverterStatus(i); } ProcessPowerMeterStatus(); //console.log("Processing done!"); } // ------------------------------------------------------------------- // This is the main function triggering a read via modbus-tcp every two seconds. // Processing of data is triggered as soon as one complete set of registers is copied. var triggerprocessing = 0; var currentinverter = 1; setInterval(function() { if(triggerprocessing == 1) { triggerprocessing = 0; ProcessData(); } //console.log("Triggering read of inverter " + currentinverter + " at address " + registerSpacesToReadContinuously[registerSpacesToReadContinuouslyPtr][0] + " with length " + registerSpacesToReadContinuously[registerSpacesToReadContinuouslyPtr][1]); ReadRegisterSpace(currentinverter, registerSpacesToReadContinuously[registerSpacesToReadContinuouslyPtr][0], registerSpacesToReadContinuously[registerSpacesToReadContinuouslyPtr][1]); registerSpacesToReadContinuouslyPtr++; if(registerSpacesToReadContinuouslyPtr >= registerSpacesToReadContinuously.length) { registerSpacesToReadContinuouslyPtr = 0; currentinverter++ if(currentinverter > modbusID.length){ currentinverter = 1; triggerprocessing = 1; } } }, 4000);
Kann man den Teil // Funktion zum Herstellen einer Modbus-Verbindung, von dem alten Skript irgend wie auch in das Neue bringen oder wäre der automatische reconnect das Selbe.
Bitte um Hilfe, Gruß Jürgen -
EDIT: Hat sich erledigt: Ich habe javascript.3 genutzt - daher kam der Fehler - stupid me
@chris_b Hi, ich habe auch soeben das Skript aktiviert und erhalte folgende Fehler:
18:45:06.075 warn javascript.3 (26162) at ProcessData (script.js.PV_auslesen.Huawei_WR_auslesen_V2:369:23) 18:45:06.075 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.075 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.075 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.075 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.075 warn javascript.3 (26162) at ProcessData (script.js.PV_auslesen.Huawei_WR_auslesen_V2:370:9) 18:45:06.075 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.076 warn javascript.3 (26162) at ProcessData (script.js.PV_auslesen.Huawei_WR_auslesen_V2:374:22) 18:45:06.076 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.077 warn javascript.3 (26162) at ProcessData (script.js.PV_auslesen.Huawei_WR_auslesen_V2:379:66) 18:45:06.077 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.077 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.077 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.077 warn javascript.3 (26162) at ProcessData (script.js.PV_auslesen.Huawei_WR_auslesen_V2:380:9) 18:45:06.077 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.079 warn javascript.3 (26162) at ProcessData (script.js.PV_auslesen.Huawei_WR_auslesen_V2:383:60) 18:45:06.079 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.084 warn javascript.3 (26162) at ProcessData (script.js.PV_auslesen.Huawei_WR_auslesen_V2:384:9) 18:45:06.084 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.084 warn javascript.3 (26162) at ProcessData (script.js.PV_auslesen.Huawei_WR_auslesen_V2:385:9) 18:45:06.085 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.085 warn javascript.3 (26162) at ProcessData (script.js.PV_auslesen.Huawei_WR_auslesen_V2:388:66) 18:45:06.085 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.086 warn javascript.3 (26162) at ProcessData (script.js.PV_auslesen.Huawei_WR_auslesen_V2:391:65) 18:45:06.086 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.087 warn javascript.3 (26162) at ProcessData (script.js.PV_auslesen.Huawei_WR_auslesen_V2:394:65) 18:45:06.087 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9) 18:45:06.087 warn javascript.3 (26162) at ProcessData (script.js.PV_auslesen.Huawei_WR_auslesen_V2:395:65) 18:45:06.087 warn javascript.3 (26162) at Object.<anonymous> (script.js.PV_auslesen.Huawei_WR_auslesen_V2:413:9)
Hast du eine Idee, woran das liegen könnte?
Die Datenpunkte werden noch erzeugt, danach passiert nichts mehr, außer diese Warnungen.
Danke schön. -
@Chris_B jetzt stehe ich etwas auf dem Schlauch: in welchem Objekt wird denn die aktuelle PV Produktion gespeichert?
Active Power ist es ja nicht - da wird auch eine etwaige Speicherentladung angezeigt.Danke für's Anknipsen des Lichts
-
@spooky82 Hallo. Ich glaube, wenn Du meinen Beitrag oben vom 25. Juni anschaust, dann wirst Du fündig. Dort sollte alles ausgeschlüsselt sein. Gruss
-
@spooky82 Ja, das wurde oben auch schon bemerkt. Das Skript enthält 'hard-coded' javascript.0 (also Instanz null). Das könnte (und sollte) man besser machen... Gruss
-
@juggi1962 Sorry Jürgen, das ist etwas länger zum Beschreiben. Versuche später einmal zu antworten...
-
@r4 Sorry, ich habe eine blöde Frage: Wo finde ich den Wert für das Minimum SoC. Dein Tip war ja, diesen Wert von 0% auf 5% oder 10% zu erhöhen. Gruss, Christian
-
@chris_b sagte in Huawei Sun2000 & ioBroker via JS script funktioniert:
@juggi1962 Sorry Jürgen, das ist etwas länger zum Beschreiben. Versuche später einmal zu antworten...
Hallo Christian.
Ja das wäre super, denn so wie du es jetzt hast funktionierts bei mir leider immer nur kurz und dann geht's erst wieder nach Neustart.
Vielleicht kannst du mir das in deinem Skript umschreiben, ich hab leider keine Ahnung von JS.
Danke und Gruß Jürgen -
@chris_b sagte in Huawei Sun2000 & ioBroker via JS script funktioniert:
@r4 Sorry, ich habe eine blöde Frage: Wo finde ich den Wert für das Minimum SoC. Dein Tip war ja, diesen Wert von 0% auf 5% oder 10% zu erhöhen. Gruss, Christian
Die Daten liest du noch nicht aus bei dir:
forcesetState("Solarpower.Huawei.Inverter.Battery.ChargingCutoffCapacity", getU16(GlobalDataBuffer, 47081) / 10, {name: "", unit: "%"}); forcesetState("Solarpower.Huawei.Inverter.Battery.DischargeCutoffCapacity", getU16(GlobalDataBuffer, 47082) / 10, {name: "", unit: "%"});
In FusionSolar wäre das dann:
-
@r4 sagte in Huawei Sun2000 & ioBroker via JS script funktioniert:
DischargeCutoffCapacity
OK, danke. Steht ja in der Huawei Modbus Beschreibung; hätte ich auch selbst finden können. Vielen Dank. Ist implementiert un läuft problemlos. Ist bei mir auf 15% und 100% gesetzt, also durchaus sinnvoll.
-
@kachel
Hallo, bin neue in der iobroker Welt. Habe eine Huawei Sun2000-8KTL-M1 mit 5 KWH Luna Batterie.
Habe das Skript laufen, es kommen jetzt auch keine Fehlermeldungen mehr, nur ein paar Warnungen.2023-07-28 14:27:23.369 - info: javascript.0 (11528) script.js.Huawei: Processing new data...
2023-07-28 14:27:23.373 - info: javascript.0 (11528) script.js.Huawei: Processing done!
2023-07-28 14:27:23.373 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 30000 with length 81
2023-07-28 14:27:25.378 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 37100 with length 114
2023-07-28 14:27:27.391 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 32000 with length 116
2023-07-28 14:27:29.402 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 37000 with length 68
2023-07-28 14:27:31.416 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 37700 with length 100
2023-07-28 14:27:33.422 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 37800 with length 100
2023-07-28 14:27:35.427 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 38200 with length 1002023-07-28 14:27:35.433 - warn: javascript.0 (11528) script.js.Huawei: Error received reading address 38200 from id: 1 with error: Slave device busy (retry request again later)
2023-07-28 14:27:37.440 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 38300 with length 100
2023-07-28 14:27:39.454 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 38400 with length 1002023-07-28 14:27:39.458 - warn: javascript.0 (11528) script.js.Huawei: Error received reading address 38400 from id: 1 with error: Slave device busy (retry request again later)
2023-07-28 14:27:41.464 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 35300 with length 40
2023-07-28 14:27:43.465 - info: javascript.0 (11528) script.js.Huawei: Processing new data...
2023-07-28 14:27:43.469 - info: javascript.0 (11528) script.js.Huawei: Processing done!
2023-07-28 14:27:43.469 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 30000 with length 81
2023-07-28 14:27:45.465 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 37100 with length 114
2023-07-28 14:27:47.474 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 32000 with length 116
2023-07-28 14:27:49.477 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 37000 with length 68
2023-07-28 14:27:51.485 - info: javascript.0 (11528) script.js.Huawei: Triggering read of inverter 1 at address 37700 with length 100hier meine Eingaben:
var ModbusRTU = require("modbus-serial");
var client = new ModbusRTU();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.178.64", { port: 502 });
// Enter the Modbus-IDs of your Sun2000 inverters here:
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], [0, 0]];Leider werden in den Objekten keine Werte angezeigt - alles Null.
Mit der BOPV.info Software habe ich jedoch einige Werte bekommen, ist jedoch nicht mein Ding.
Hat jemand einen Tipp?
-
@rainereglinsky Die meisten Meldungen sind ja nur Informationen, sind also OK. Die Warnungen kommen auch bei mir 'manchmal' (bei mir jeden Tag 'einige', bspw. 10, es können aber auch einmal mehr sein). Solange sich das in diesem Rahmen hält würde ich es ignorieren - für besseren Input bin ich aber offen.
Ich poste etwas später eine optimierte Version des KSripts. Bin gerade noch am Testen.
Gruss, Christian -
Neue Version meines Skripts mit einigen Optimierungen!
@R4 Ich habe endlich den Array etwas optimiert. Anstelle von 50'000 Elementen ist er nun 'nur' noch 18'000 Elemente gross. Also Faktor 3 besser. Könnte man nochmals verbessern, es werden ja nur kanpp 1'000 Elemente wirklich verwendet. Lass ich aber jetzt.
@juggi1962 Ich habe die reconnect Funkion für Dich nun eingebaut. Ist im Code aber 'auskommentiert'. Um ihn zu aktivieren in den Zeilen 392 bis 395 jeweils das // ganz vorne löschen. Dann wird ein reconnect über den Aufruf von ConnectModbus() durchgeführtVerbesserungen in dieser Version des Skripts:
- Array-Struktur optimiert (Faktor 3 kleiner).
- Es werden neu auch die "Battery Charging / Discharging Cutoff Capacities" gelesen (danke für den Tip @R4 ).
- Funktionsumbenennungen zur Verbesserung der Lesbarkeit (zumindest für mich).
- Reconnect Modbus Funktion 'auskommentiert' vorhanden, kann individuell aktiviert werden.
Hier ein Link zum Download des Skripts (Sun2000V2.js):
https://1drv.ms/u/s!AuJox5uVBmw-tE6KLGmyPFJhazS4?e=PBfTXhGruss, Christian
-
Warum externer Link.
Stell es doch gleich hier rein. -
@bahnuhr Der Grund dafür: Beim 'Code' Makro gibt es Probleme bei grossen Skripts, es werden '{1}' eingefügt. Erklärung siehe weiter oben in diesem thread. Bei einem externen Link passiert das nicht.
Ich möchte mein Skript nicht extra so abändern, dass das nicht passiert. Ich frage mich, wieso das Code Makro nicht korrigiert wird.
Falls Du eine Lösung weisst bin ich froh...
Gruss -
Danke für das neue Script. Habe es eingebaut, bekomme aber massive Fehlermeldungen.
2023-07-29 13:28:44.166 - info: admin.0 (3692) ==> Connected system.user.admin from ::1
2023-07-29 13:28:46.771 - info: admin.0 (3692) <== Disconnect system.user.admin from ::1 javascript
2023-07-29 13:29:00.017 - warn: javascript.0 (7268) State "javascript.0.variables.dayTime" has no existing object, this might lead to an error in future versions
2023-07-29 13:29:15.203 - error: javascript.0 (7268) script.js.Huawei: The "getState" method cannot be used synchronously, because the adapter setting "Do not subscribe to all states on start" is enabled.
2023-07-29 13:29:15.204 - error: javascript.0 (7268) script.js.Huawei: Please disable that setting or use "getState" with a callback, e.g.: getState("javascript.0.Solarpower.Huawei.Inverter.1.Batterystack.1.Battery1.BatterySOC", (err, state) => { ... });
2023-07-29 13:29:15.204 - error: javascript.0 (7268) Error in callback: TypeError: Cannot read properties of undefined (reading 'val')
2023-07-29 13:29:15.204 - error: javascript.0 (7268) at ProcessData (script.js.Huawei:425:120)
2023-07-29 13:29:15.204 - error: javascript.0 (7268) at Object. (script.js.Huawei:503:13)
2023-07-29 13:29:15.204 - error: javascript.0 (7268) at Timeout._onTimeout (C:\ioBroker\node_modules\iobroker.javascript\lib\sandbox.js:2723:34)
2023-07-29 13:29:15.204 - error: javascript.0 (7268) at listOnTimeout (node:internal/timers:569:17)
2023-07-29 13:29:15.204 - error: javascript.0 (7268) at processTimers (node:internal/timers:512:7)
2023-07-29 13:29:44.291 - info: admin.0 (3692) <== Disconnect system.user.admin from ::1 admin
2023-07-29 13:29:44.296 - info: admin.0 (3692) <== Disconnect system.user.admin from ::1 admin
2023-07-29 13:29:53.494 - info: admin.0 (3692) ==> Connected system.user.admin from ::1
2023-07-29 13:29:59.655 - info: admin.0 (3692) ==> Connected system.user.admin from ::1
2023-07-29 13:30:00.020 - warn: javascript.0 (7268) State "javascript.0.variables.dayTime" has no existing object, this might lead to an error in future versions
2023-07-29 13:30:02.417 - info: admin.0 (3692) <== Disconnect system.user.admin from ::1 javascript
2023-07-29 13:30:05.292 - error: javascript.0 (7268) script.js.Huawei: The "getState" method cannot be used synchronously, because the adapter setting "Do not subscribe to all states on start" is enabled.
2023-07-29 13:30:05.292 - error: javascript.0 (7268) script.js.Huawei: Please disable that setting or use "getState" with a callback, e.g.: getState("javascript.0.Solarpower.Huawei.Inverter.1.Batterystack.1.Battery1.BatterySOC", (err, state) => { ... });
2023-07-29 13:30:05.293 - error: javascript.0 (7268) Error in callback: TypeError: Cannot read properties of undefined (reading 'val')
2023-07-29 13:30:05.293 - error: javascript.0 (7268) at ProcessData (script.js.Huawei:425:120)
2023-07-29 13:30:05.293 - error: javascript.0 (7268) at Object. (script.js.Huawei:503:13)
2023-07-29 13:30:05.293 - error: javascript.0 (7268) at Timeout._onTimeout (C:\ioBroker\node_modules\iobroker.javascript\lib\sandbox.js:2723:34)
2023-07-29 13:30:05.293 - error: javascript.0 (7268) at listOnTimeout (node:internal/timers:569:17)
2023-07-29 13:30:05.293 - error: javascript.0 (7268) at processTimers (node:internal/timers:512:7)Muss die PowerMeterID in eckigen Klammern stehen (wie ModbusID) oder ohne Klammern wie im Script? Ist die ID "0" richtig?
Habe mit PowerMeterID =0 oder [0] die gleichen Ergebnisse in den Objekten
Alles "NULL" (erst grün, dann rot.Danke vorab für die Hilfe
-
- Bei PowerMeterID: Keine eckigen Klammern. Das ist kein Array, nur eine Zahl.
- Ich denke irgend etwas in Deinen Javascript Settings auf iobroker ist nicht in Ordnung; Du hast ganz komische Fehlermeldungen. Versuch einmal folgendes: Unter den Einstellungen des Javascript Adapters "Nicht alle Zustände beim Start abonnieren" NICHT auswählen (d.h. nicht selektiert).
Gruss
-
@juggi1962 Ich habe die reconnect Funkion für Dich nun eingebaut. Ist im Code aber 'auskommentiert'. Um ihn zu aktivieren in den Zeilen 392 bis 395 jeweils das // ganz vorne löschen. Dann wird ein reconnect über den Aufruf von ConnectModbus() durchgeführt
Hallo Christian vielen Dank, werde ich heute noch testen.
Gruß Jürgen