NEWS
Huawei Sun2000 & ioBroker via JS script funktioniert
-
@badsnoopy667 Klappt super den Wert zu ändern, hast du evtl eine Idee wie ich den Akku laden lassen kann? habe es mit 47100 (1) probiert aber es funktioniert nicht......
-
@majawe
Nein, das habe ich noch nicht probiert, da ich keinen variablen Stromtarif habe... aber darüber nachgedacht, ob es geht, habe ich auch schon. Falls Du also etwas rausbekommen solltest, sag gerne Bescheid! -
@majawe
Kurzes Update: Über Modbus habe ich es noch nicht geschafft den Akku laden zu lassen. Ich vermute übrigens, Du hast nicht die letzte Version (V3) Der "modbus-interface-definitions"
Link: solar-inverter-modbus-interface-definitions-v3.0.pdf .
Das Register was Du da zeigst gibt es da nicht mehr. Es gibt aber ein Register [Energy storage unit] Time-of-use electricity price periods - 47200. Da kann man wohl die Lade- und Entladezeiten eintragen für den Akku. Da das Ding aber 41 Zeichen lang ist, habe ich keinen Plan, wie das korrekte Format aussehen muss. Ich habe mal den Huawei Support angeschrieben.
Aber: Was ich gerade mal getestet habe: Mit der SUN2000 App (Nicht FusionSolar, geht aber vll auch, k.a.) habe ich mich auf den Wechselrichter als Installateur verbunden (über das SDongle WLan im Keller) und habe die Betriebsweise das Akkus auf "TOU" gestellt. Also zeitgesteuertes Laden. Wenn man da dann eine Ladezeit einträgt, fängt das Ding auch an aus dem Netz zu laden.
Daher meine fixe Idee als Workaround: In der App eine Ladezeit einstelle (z.B. von 23:00 - 6:00 Uhr Nachts, in der Annahme das Nachts die günstigesten Preise vorliegen). Und dann das Register [Energy storage unit] Maximum charging power - 47075 entsprechend auf 0 setzen, zu Zeiten wenn man nicht laden will und auf 5000 (für 5000W, bei mind. 10kWh Akku, sonst weniger), wenn man laden möchte in dieser Zeit. Morgens natürlich dann wieder hochsetzen. Habe ich aber noch nicht ausprobiert. Könnte mir aber vorstellen, dass es klappt. Bin mir nur nicht sicher, ob er dann noch entlädt (in der Zeit wo die Ladeleistung 0 ist, aber die Ladezeit gesetzt ist). -
@badsnoopy667 said in Huawei Sun2000 & ioBroker via JS script funktioniert:
[Energy storage unit] Maximum charging power - 47075
Die Idee hatte ich auch schon, leider bekomme ich es nicht hin das er die 0 annimmt bzw überträgt
-
@majawe
Das sollte ja das kleinste Problem sein. Der Wert wird genauso geschrieben wie das Register 47077 (Max. Entladeleistung). Hab's gerade probiert. Wenn ich im Flow die Adresse von 47077 auf 47075 ändere (und sonst alles gleich lasse), kann ich die Ladeleistung einstellen. "0" habe ich nicht probiert, aber 4999 und 5000W hat geklappt. -
@badsnoopy667 könntest du mir den flow mal exportieren oder ein scrennshot der karte bitte machen?
-
@majawe
Hier der Flow für beide Zustände (Charge und Discharge)
flows_read_write_charge_discharge.json
Sobald du eines der beiden Objekte "_SET" änderst (vorher anlegen!), wird das entsprechende Register geschrieben.
Und wie immer bei meinem Flow: Achte auf die Unit-ID. Bei mir ist die 2, bei dir vermutlich nicht! Mein WR war mal defekt.Hast Du darauf geachtet beim Ändern nicht nur den Namen, sondern wirklich die Adresse zu ändern? Das hab ich schon ein paar mal durcheinander gebracht. Der Name allein hilft nicht, der ist sowieso völlig beliebig.
-
@badsnoopy667 Funktioniert heute auf Anhieb komischer weise ich denke es lag am Dongle update
Tou kannst du auch online umstellen unter, https://region02eu5.fusionsolar.huawei.com, Dongle, EMS Control oder direkt am Handy unter Dongel, Parametereinstellung, Arbeitsmodus Tou.
Also brauchst dich nicht direkt am Wechselrichter einloggen
-
@badsnoopy667 Super so wird es gemacht
Danke -
@majawe
Schön, dass es klappt! Aber ENT-laden im Ladezeitraum tut er nicht, oder? Das ist nämlich vermutlich noch der Haken. Den Zeitraum würde ich ja immer (in der Nacht) stehen lassen und über die Ladeleistung dann quasi aktivieren und deaktivieren.
Wobei man streiten kann, ob das ein Problem ist, im Winter ist der Akku Nachts sowieso fast immer leer. Dann spielt es keine Rolle. Und im Sommer brauche ich ihn ihn nicht extern laden.Zu der FusionSolar Seite: Wo geht das denn? Bei mir kann ich da gar nix einstellen. Welche Dongle Firmware ist das? Oder hast Du da Installateur Zugriff auf FusionSolar?
-
@badsnoopy667 Ich denke bei sonnenuntergang setze ich den auf 0watt, und dann wenn kleiner als 5cent = 5000Watt. Den Rest erledigt Tou zwischen 0 - 5 Uhr.
-
@badsnoopy667 Ich habe den Installateur zugang, da ist der Punkt sichtbar. Der Dongle hat die FW PC133 am ende aber gesehen habe ich den Punkt bereits mit der PC130
-
Erst mal vielen Dank für das Script, hat fast sofort funtioniert.
Ich musste nur die IDs raten, bei meiner nagelneuen Anlage mit 2 KTLs und dem Powermeter und ohne Batterien bin ich hier gelandet:const ModBusIDs = [1, 2]; const PowerMeterID = 0;
Powermeter läuft wunderbar.
Das Problem, daß die Werte nur einmal geschrieben wurden habe ich mit einem Workaround hier gelöst:function forcesetState(objectname, value, options) { if(!existsState(objectname)) { createState(objectname, value, options); console.log("createstate " + objectname + " to value " + value); } //Workaround setState(objectname, value); }
also das setstate aus der else-clause genommen, denn das !existsState scheint nicht sauber zu funktionieren.
Ach so, noch eine gute Nachricht:
Der Installateur kann den Modbus (inwischen?) remote aktivieren, da muss keiner vor Ort sein.
Hat mich eine Mail an meinen Solateur gekostet und zwei Stunden später war alles aktiv. -
@zoid1988 Hallo zusammen, gibt es hier Neuigkeiten. Hab heute mein WR angeschlossen. Datenpunkte wurden generiert aber erhalte den selben Fehler. Gibt es Lösungen? Danke an alle für die Hilfe!
Ich habe auch den Workaround eingesetzt, erhalte immer aber die gleiche Warnung:
21:02:25.393 info javascript.0 (23379) script.js.Test.PV-Test: Triggering read of inverter 1 at address 30000 with length 81
21:02:25.394 warn javascript.0 (23379) script.js.Test.PV-Test: Error received reading address 30000 from id: 1 with error: undefined
21:02:27.393 info javascript.0 (23379) script.js.Test.PV-Test: Triggering read of inverter 1 at address 37100 with length 114
21:02:27.394 warn javascript.0 (23379) script.js.Test.PV-Test: Error received reading address 37100 from id: 1 with error: undefined
21:02:29.394 info javascript.0 (23379) script.js.Test.PV-Test: Triggering read of inverter 1 at address 32000 with length 116
21:02:29.394 warn javascript.0 (23379) script.js.Test.PV-Test: Error received reading address 32000 from id: 1 with error: undefined
21:02:31.394 info javascript.0 (23379) script.js.Test.PV-Test: Triggering read of inverter 1 at address 37000 with length 68
21:02:31.395 warn javascript.0 (23379) script.js.Test.PV-Test: Error received reading address 37000 from id: 1 with error: undefined
21:02:33.395 info javascript.0 (23379) script.js.Test.PV-Test: Triggering read of inverter 1 at address 37700 with length 100
21:02:33.396 warn javascript.0 (23379) script.js.Test.PV-Test: Error received reading address 37700 from id: 1 with error: undefined
21:02:35.395 info javascript.0 (23379) script.js.Test.PV-Test: Triggering read of inverter 1 at address 37800 with length 100
21:02:35.396 warn javascript.0 (23379) script.js.Test.PV-Test: Error received reading address 37800 from id: 1 with error: undefined
21:02:37.395 info javascript.0 (23379) script.js.Test.PV-Test: Triggering read of inverter 1 at address 38200 with length 100
21:02:37.396 warn javascript.0 (23379) script.js.Test.PV-Test: Error received reading address 38200 from id: 1 with error: undefined
21:02:39.406 info javascript.0 (23379) script.js.Test.PV-Test: Triggering read of inverter 1 at address 38300 with length 100
21:02:39.406 warn javascript.0 (23379) script.js.Test.PV-Test: Error received reading address 38300 from id: 1 with error: undefined
21:02:41.406 info javascript.0 (23379) script.js.Test.PV-Test: Triggering read of inverter 1 at address 38400 with length 100
21:02:41.407 warn javascript.0 (23379) script.js.Test.PV-Test: Error received reading address 38400 from id: 1 with error: undefined
21:02:43.407 info javascript.0 (23379) script.js.Test.PV-Test: Triggering read of inverter 1 at address 35300 with length 40
21:02:43.408 warn javascript.0 (23379) script.js.Test.PV-Test: Error received reading address 35300 from id: 1 with error: undefined -
Dear all, any support on my issue (see above).
Thanks for your support
-
@oswibz
Als Newbie: Da stimmen Deine IDs nicht. So, wie ich das Script verstehe, gibt es die ID, aber es ist nicht der Gerätetyp, der abgefragt wird. -
@thomas42
wo finde ich den korrekten ID? -
@oswibz Keine Ahnung, ich habe geraten.
Das Smartmeter scheint immer die Null zu sein, der erste WR war bei die 1, der zweite die 2. -
Hallo zusammen, versuche auch meinen SUN2000 ausgelesen zu bekommen, leider funktioniert es nicht. Es werde auch irgendwie keine Werte geschrieben. Habe 1 String, 1 Batteriespeicher LUNA2000 10kw. Was fehlt hier ggf noch?
// 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
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.10.101", { port: 502 });
// Enter the Modbus-IDs of your Sun2000 inverters here:
const ModBusIDs = [16, 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 = [[3, 2], [3, 0]];// These register spaces need to be read:
const RegisterSpacesToReadContinuously = [[30000, 81], [37100, 114], [32000, 116], [37000, 68], [37700, 100], [37800, 100], [38200, 100], [38300, 100], [38400, 100], [35300, 40]];
var RegisterSpacesToReadContinuouslyPtr = 0;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) {
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;
}function forcesetState(objectname, value, options) {
if(!existsState(objectname)) {
createState(objectname, value, options);
}
else {
setState(objectname, value);
}
}
// ---------------------------------------------------------------
// Functions to map registers into ioBreaker objects:
function processOptimizers(id) {
forcesetState("Solarpower.Huawei.Inverter." + id + ".OptimizerTotalNumber", getU16(GlobalDataBuffer[id-1], 35200), {name: "", unit: ""});
forcesetState("Solarpower.Huawei.Inverter." + id + ".OptimizerOnlineNumber", getU16(GlobalDataBuffer[id-1], 35201), {name: "", unit: ""});
forcesetState("Solarpower.Huawei.Inverter." + id + ".OptimizerFeatureData", getU16(GlobalDataBuffer[id-1], 35202), {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) / 100, {name: "", unit: "kWh"});
forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.CurrentDayDischargeCapacity", getU32(GlobalDataBuffer[id-1], 37017) / 100, {name: "", unit: "kWh"});
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) / 100, {name: "", unit: "kWh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.1.TotalDischarge", getU32(GlobalDataBuffer[id-1], 37068) / 100, {name: "", unit: "kWh"}); } // 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) / 100, {name: "", unit: "kWh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack.2.TotalDischarge", getU32(GlobalDataBuffer[id-1], 37755) / 100, {name: "", unit: "kWh"}); } // 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) / 100, {name: "", unit: "kWh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.TotalDischarge", getU32(GlobalDataBuffer[id-1], 37782) / 100, {name: "", unit: "kWh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.CurrentDayChargeCapacity", getU32(GlobalDataBuffer[id-1], 37784) / 100, {name: "", unit: "kWh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Battery.CurrentDayDischargeCapacity", getU32(GlobalDataBuffer[id-1], 37786) / 100, {name: "Current DayDiscarge ", unit: "kWh"}); // 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) / 100, {name: "", unit: "kWh"}); forcesetState("Solarpower.Huawei.Inverter." + id + ".Batterystack." + i + ".Battery" + j + ".TotalDischarge", getU32(GlobalDataBuffer[id-1], 38240+(i-1)*126+(j-1)*42) / 100, {name: "", unit: "kWh"}); // [[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) / 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], 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 + ".AccomulatedEnergyYield", getU16(GlobalDataBuffer[id-1], 32106), {name: "", unit: "kWh"});
forcesetState("Solarpower.Huawei.Inverter." + id + ".DailyEnergyYield", getU16(GlobalDataBuffer[id-1], 32114), {name: "", unit: "kWh"});
}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.log("Processing new data...");
for(var i = 1; i <= ModBusIDs.length; i++) {
ProcessDeviceInfo(i);
processInverterStatus(i);
processBattery(i);
processInverterPowerAdjustments(i);
processOptimizers(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 > ModBusIDs.length){ currentinverter = 1; triggerprocessing = 1; } }
}, 2000);
Wäre schön wenn mir da jemand helfen könnte.
-
@wilher Hi,
wäre eventuell hifreich, wenn Du Dein Log posten würdest und nicht das Script