Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. ecoflow-connector-Script zur dynamischen Leistungsanpassung

    NEWS

    • Monatsrückblick - April 2025

    • Minor js-controller 7.0.7 Update in latest repo

    • Save The Date: ioBroker@Smart Living Forum Solingen, 14.06.

    ecoflow-connector-Script zur dynamischen Leistungsanpassung

    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      Waly_de @mattenausohz last edited by

      @mattenausohz Ja genau... Halte ich aus auch für das Beste. Die Umwelt dankt es uns 🙂

      1 Reply Last reply Reply Quote 0
      • U
        udomuc @Waly_de last edited by

        @waly_de
        Klasse Sache, danke! Hatte dir auf FB aus der EF-Community geschrieben, vielleicht findest ja Zeit!

        1 Reply Last reply Reply Quote 0
        • F
          foxthefox Developer last edited by

          @waly_de
          Ich habe mich an der Verbesserung der Dekodierung der ankommenden Telegramme gemacht.
          Dazu habe ich mir in node-red die MQTT Telegramme in base64 kodiert loggen lassen.
          Dieser output verträgt sich auch mit der https://protobuf-decoder.netlify.app um die Struktur anzuschauen.

          Aus den unterschiedlich langen Telegrammen habe ich dann ein Message-Objekt erstellt. key=Länge, value=Array aus den Telegrammen.

          Die Proto-Definition hat ihre Basis aus
          link

          Nunmehr kann man auf "HeaderMessage", "InverterMessage", "PowerMessage" und "EnergyMessage" den übergebenen Puffer prüfen.
          Die Energiewerte sind derzeitig noch unklar und deswegen als bytes definiert.

          const protobuf = require('protobufjs');
          
          const protoSource = `
          syntax = "proto3";
          
          message inverter_heartbeat {
              optional uint32 invErrCode = 1;
              optional uint32 invWarnCode = 3;
              optional uint32 pv1ErrCode = 2;
              optional uint32 pv1WarnCode = 4;
              optional uint32 pv2ErrCode = 5;
              optional uint32 pv2WarningCode = 6;
              optional uint32 batErrCode = 7;
              optional uint32 batWarningCode = 8;
              optional uint32 llcErrCode = 9;
              optional uint32 llcWarningCode = 10;
              optional uint32 pv1Status = 11;
              optional uint32 pv2Status = 12;
              optional uint32 batStatus = 13;
              optional uint32 llcStatus = 14;
              optional uint32 invStatus = 15;
              optional int32 pv1InputVolt = 16;
              optional int32 pv1OpVolt = 17;
              optional int32 pv1InputCur = 18;
              optional int32 pv1InputWatts = 19;
              optional int32 pv1Temp = 20;
              optional int32 pv2InputVolt = 21;
              optional int32 pv2OpVolt = 22;
              optional int32 pv2InputCur = 23;
              optional int32 pv2InputWatts = 24;
              optional int32 pv2Temp = 25;
              optional int32 batInputVolt = 26;
              optional int32 batOpVolt = 27;
              optional int32 batInputCur = 28;
              optional int32 batInputWatts = 29;
              optional int32 batTemp = 30;
              optional uint32 batSoc = 31;
              optional int32 llcInputVolt = 32;
              optional int32 llcOpVolt = 33;
              optional int32 llcTemp = 34;
              optional int32 invInputVolt = 35;
              optional int32 invOpVolt = 36;
              optional int32 invOutputCur = 37;
              optional int32 invOutputWatts = 38;
              optional int32 invTemp = 39;
              optional int32 invFreq = 40;
              optional int32 invDcCur = 41;
              optional int32 bpType = 42;
              optional int32 invRelayStatus = 43;
              optional int32 pv1RelayStatus = 44;
              optional int32 pv2RelayStatus = 45;
              optional uint32 installCountry = 46;
              optional uint32 installTown = 47;
              optional uint32 permanentWatts = 48;
              optional uint32 dynamicWatts = 49;
              optional uint32 supplyPriority = 50;
              optional uint32 lowerLimit = 51;
              optional uint32 upperLimit = 52;
              optional uint32 invOnOff = 53;
              optional uint32 wirelessErrCode = 54;
              optional uint32 wirelessWarnCode = 55;
              optional uint32 invBrightness = 56;
              optional uint32 heartbeatFrequency = 57;
              optional uint32 ratedPower = 58;
          }
          
          message permanent_watts_pack
          {
              optional uint32 permanent_watts = 1;
          }
          
          message supply_priority_pack
          {
              optional uint32 supply_priority = 1;
          }
          
          message bat_lower_pack
          {
              optional int32 lower_limit = 1;
          }
          
          message bat_upper_pack
          {
              optional int32 upper_limit = 1;
          }
          
          message brightness_pack
          {
              optional int32 brightness = 1;
          }
          
          message PowerItem
          {
              optional uint32 timestamp = 1;
              optional sint32 timezone = 2;
              optional uint32 inv_to_grid_power = 3;
              optional uint32 inv_to_plug_power = 4;
              optional int32 battery_power = 5;
              optional uint32 pv1_output_power = 6;
              optional uint32 pv2_output_power = 7;
          }
          
          message PowerPack
          {
              optional uint32 sys_seq = 1;
              repeated PowerItem sys_power_stream = 2;
          }
          
          //war ein Versuch
          message EnergyValue
          { 
              optional sint32 test1 = 1;
              optional uint32 test2 = 2;
              optional fixed64 test3 = 3;
              //optional sint32 test4 = 4;
              //optional uint32 test5 = 5;
          }
          
          message EnergyItem
          {
          	optional uint32 timestamp = 1;
              optional int32 item = 2;
              optional bytes watt = 3; // passt noch nicht
          }
          
          message EnergyPack
          {
              optional uint32 sys_seq = 1;
              repeated EnergyItem sys_energy_stream = 2;
          }
          
          message PowerAckPack
          {
              optional uint32 sys_seq = 1;
          }
          
          message node_massage
          {
              optional string sn = 1;
              optional bytes mac = 2;
          }
          
          message mesh_child_node_info
          {
              optional uint32 topology_type = 1;
              optional uint32 mesh_protocol = 2;
              optional uint32 max_sub_device_num = 3;
              optional bytes parent_mac_id = 4;
              optional bytes mesh_id = 5;
              repeated node_massage sub_device_list = 6;
          }
          
          message Header
          {
              optional int32 src = 2;
              optional int32 dest = 3;
              optional int32 d_src= 4;
              optional int32 d_dest = 5;
              optional int32 enc_type = 6;
              optional int32 check_type = 7;
              optional int32 cmd_func = 8;
              optional int32 cmd_id = 9;
              optional int32 data_len = 10;
              optional int32 need_ack = 11;
              optional int32 is_ack = 12;
              optional int32 seq = 14;
              optional int32 product_id = 15;
              optional int32 version = 16;
              optional int32 payload_ver = 17;
              optional int32 time_snap = 18;
              optional int32 is_rw_cmd = 19;
              optional int32 is_queue = 20;
              optional int32 ack_type= 21;
              optional string code = 22;
              optional string from = 23;
              optional string module_sn = 24;
              optional string device_sn = 25;
          }
          
          message HeaderMessage {
          	optional Header header = 1;
          }
          
          message InverterMessage {
          	optional inverter_heartbeat inverter = 1;
              optional Header header = 2;
          }
          
          message PowerMessageProto {
          	optional PowerPack powerpack  = 1;
              optional int32 src = 2;
              optional int32 dest = 3;
              optional int32 d_src= 4;
              optional int32 d_dest = 5;
              optional int32 enc_type = 6;
              optional int32 check_type = 7;
              optional int32 cmd_func = 8;
              optional int32 cmd_id = 9;
              optional int32 data_len = 10;
              optional int32 need_ack = 11;
              optional int32 is_ack = 12;
              optional int32 seq = 14;
              optional int32 product_id = 15;
              optional int32 version = 16;
              optional int32 payload_ver = 17;
              optional int32 time_snap = 18;
              optional int32 is_rw_cmd = 19;
              optional int32 is_queue = 20;
              optional int32 ack_type= 21;
              optional string code = 22;
              optional string from = 23;
              optional string module_sn = 24;
              optional string device_sn = 25;
          }
          
          message PowerMessage {
              PowerMessageProto item = 1;
          }
          
          message EnergyMessageProto {
          	optional EnergyPack energypack  = 1;
              optional int32 src = 2;
              optional int32 dest = 3;
              optional int32 d_src= 4;
              optional int32 d_dest = 5;
              optional int32 enc_type = 6;
              optional int32 check_type = 7;
              optional int32 cmd_func = 8;
              optional int32 cmd_id = 9;
              optional int32 data_len = 10;
              optional int32 need_ack = 11;
              optional int32 is_ack = 12;
              optional int32 seq = 14;
              optional int32 product_id = 15;
              optional int32 version = 16;
              optional int32 payload_ver = 17;
              optional int32 time_snap = 18;
              optional int32 is_rw_cmd = 19;
              optional int32 is_queue = 20;
              optional int32 ack_type= 21;
              optional string code = 22;
              optional string from = 23;
              optional string module_sn = 24;
              optional string device_sn = 25;
          }
          
          message EnergyMessage{
          	optional EnergyMessageProto item = 1;
          }
          
          message Send_Header_Msg
          {
              optional Header msg = 1;
          }
          
          message SendMsgHart
          {
              optional int32 link_id = 1;
              optional int32 src = 2;
              optional int32 dest = 3;
              optional int32 d_src = 4;
              optional int32 d_dest = 5;
              optional int32 enc_type = 6;
              optional int32 check_type = 7;
              optional int32 cmd_func = 8;
              optional int32 cmd_id = 9;
              optional int32 data_len = 10;
              optional int32 need_ack = 11;
              optional int32 is_ack = 12;
              optional int32 ack_type = 13;
              optional int32 seq = 14;
              optional int32 time_snap = 15;
              optional int32 is_rw_cmd = 16;
              optional int32 is_queue = 17;
              optional int32 product_id = 18;
              optional int32 version = 19;
          }
          `;
          
          messages = {
          	'252': ['deine Message mit 252er Länge']
          };
          
          function decodeMsg(hexString, msgtype) {
          	const root = protobuf.parse(protoSource).root;
          	const PowerMessage = root.lookupType(msgtype);
          	const message = PowerMessage.decode(Buffer.from(hexString, 'hex'));
          	const object = PowerMessage.toObject(message, { defaults: false });
          	return object;
          }
          
          function parsemsg(message) {
          	Object.entries(message).forEach(([ key, value ]) => {
          		console.log('msg length: ', key);
          		var len = value.length;
          		for (var i = 0; i < len; i++) {
          			var buf = new Buffer.from(value[i], 'base64'); //wandelt die Texte aus dem Messagearray in buffer um
          			try {
          				let msgobj = decodeMsg(buf, 'HeaderMessage');
          				let packetType = msgobj.header.cmdId;
          				console.log('packetType: ', packetType);
          				if (packetType == 136) {
          					try {
          						let msgobj136 = decodeMsg(buf, 'PowerMessage');
          						console.log(JSON.stringify(msgobj136));
          					} catch (error) {
          						console.log('id 136 error at: ', error);
          					}
          				} else if (packetType == 32) {
          					try {
          						let msgobj32 = decodeMsg(buf, 'EnergyMessage');
          						console.log(JSON.stringify(msgobj32));
          					} catch (error) {
          						console.log('id 32 error at: ', error);
          					}
          				} else if (packetType == 1) {
          					try {
          						let msgobj1 = decodeMsg(buf, 'InverterMessage');
          						console.log(JSON.stringify(msgobj1));
          					} catch (error) {
          						console.log('id 1 error at: ', error);
          					}
          				} else {
          					console.log('unknown packetType', packetType);
          				}
          			} catch (error) {
          				console.log('error at: ', i, error);
          			}
          		}
          	});
          }
          
          parsemsg(messages);
          

          Ich denke das kann für eine weitere Auswertung der Daten ganz hilfreich sein.

          Gruß
          Klaus

          F W 2 Replies Last reply Reply Quote 2
          • F
            foxthefox Developer @foxthefox last edited by

            Hatte heute folgende Meldung, nachdem ich den Powerstream angeschlossen habe.
            error Script script.js.powerstream is calling setState more than 1000 times per minute! Stopping Script now! Please check your script!

            Ich nutze das script ohne einen Sensor für die Einspeiseleistung.

            1 Reply Last reply Reply Quote 0
            • W
              Waly_de @foxthefox last edited by

              @foxthefox das ist großartig! Da werde ich mich nächste Woche mal mit befassen. Ich bin leider gerade im Urlaub und kann nichts machen. Wobei ich mich frage, woher die Felddefinitionen kommen…

              Zu deinem Fehler: ich fürchte, es werden einfach so viele Updates von EcoFlow gesendet. Ich hatte das gleiche Problem, darum habe ich in der Definition die Möglichkeit eingebaut, bestimmte Geräte nicht zu abonnieren. Ich verzichte zum Beispiel auf die Daten des Delta Max. Gerade die PowerPack senden unglaublich viele Daten die man nicht braucht.
              Du kannst aber das Limit in den Einstellungen Dennis Java Skript Adapter so setzen.
              Viele Grüße, Markus

              F 1 Reply Last reply Reply Quote 0
              • F
                foxthefox Developer @Waly_de last edited by

                @waly_de
                Wie schon oben beschrieben, Basis war die proto von hier: https://github.com/tolwi/hassio-ecoflow-cloud/issues/54
                und die sind wohl aus der App herausgeholt.
                Ich denke man kann davon ausgehen, daß die Positionen sicher sind.

                und die ...Messages hab ich dann nach Analyse zusammengeschachtelt.

                Beschäftige mich derzeitig mit den Multiplikationsfaktoren für die einzelnen Analogwerte.
                Gruß
                Klaus

                sporttiger1000 created this issue in tolwi/hassio-ecoflow-cloud

                open PowerStream Support? #54

                Homoran W 2 Replies Last reply Reply Quote 0
                • Homoran
                  Homoran Global Moderator Administrators @foxthefox last edited by Homoran

                  @foxthefox
                  @Waly_de

                  ist das wirklich ein Thema für das Einsteigerforum?

                  W 1 Reply Last reply Reply Quote 0
                  • W
                    Waly_de @foxthefox last edited by

                    @foxthefox sagte in ecoflow-connector-Script zur dynamischen Leistungsanpassung:

                    Beschäftige mich derzeitig mit den Multiplikationsfaktoren für die einzelnen Analogwerte.

                    Wäre toll wenn du was findest. Hab schon gut 2 Tage da rein gesteckt, ohne Ergebnis. Ich weiss nur, dass es kein linearer Factor ist, und keiner der Werte die ich auslesen kann weder addiert noch multipliziert irgendwie zu dem richtigen Ergebnis führen.

                    1 Reply Last reply Reply Quote 0
                    • W
                      Waly_de @Homoran last edited by

                      @homoran sagte in ecoflow-connector-Script zur dynamischen Leistungsanpassung:

                      @foxthefox
                      @Waly_de

                      ist das wirklich ein Thema für das Einsteigerforum?

                      Sorry… hab ich garnicht bemerkt… hatte den Einstiegsbeitrag gefunden und in die gleiche Kategorie gepostet. Kann ich meinen Beitrag hier selbst irgendwie verschieben? ( bin wie gesagt im Urlaub und kann nicht so viel machen. Ich habe auch nur mein Smartphone hier.)

                      Homoran 1 Reply Last reply Reply Quote 0
                      • Homoran
                        Homoran Global Moderator Administrators @Waly_de last edited by

                        @waly_de sagte in ecoflow-connector-Script zur dynamischen Leistungsanpassung:

                        Kann ich meinen Beitrag hier selbst irgendwie verschieben

                        nö!

                        wo soll's denn hin?

                        • Showcase?
                        • javascript?
                        W 1 Reply Last reply Reply Quote 0
                        • W
                          Waly_de @Homoran last edited by

                          @homoran JavaScript passt glaub ich am besten 👍

                          Homoran 1 Reply Last reply Reply Quote 0
                          • Homoran
                            Homoran Global Moderator Administrators @Waly_de last edited by

                            @waly_de sagte in ecoflow-connector-Script zur dynamischen Leistungsanpassung:

                            @homoran JavaScript passt glaub ich am besten 👍

                            erledigt!

                            man kann auch zweimal verschieben 😉

                            schönen Urlaub!

                            1 Reply Last reply Reply Quote 0
                            • planetkeane
                              planetkeane last edited by

                              Sorry bin noch nicht so erfahren. Habe mir den Powerstream und die Delta Max 2 bestellt. Die Panele und der Akku sind schon da, warte noch auf den Powerstream.
                              Habe schon mal das Skript eingefügt (noch nicht gestartet), sehe aber schon Fehlermeldungen wie diese hier.

                              "Cannot find module 'mqtt' or its corresponding type declarations.(2307)"
                              
                              'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module.(1375)
                              Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.(1378)
                              

                              Sorry wenn ich blöd frage... Muss ich noch einen Adapter installieren? Aber kann ich es nachher überhaupt ausführen? Den Stromverbrauch ermittel ich über zwischensteckdosen im Haus.

                              F 1 Reply Last reply Reply Quote 0
                              • F
                                foxthefox Developer @planetkeane last edited by

                                @planetkeane
                                Ich denke du must in Javascripr Adapter noch die Module mqtt und protobufjs im Admin der Instant angeben.

                                planetkeane 1 Reply Last reply Reply Quote 1
                                • planetkeane
                                  planetkeane @foxthefox last edited by

                                  @foxthefox Tut mir leid, ich habe die Möglichkeit leider nicht gefunden. Kann mir jemand erklären, wo ich diese Eintragung durchführen kann? Bei Instanzeinstellung finde ich leider nichts, genauso wie im Objektbaum

                                  W 1 Reply Last reply Reply Quote 0
                                  • W
                                    Waly_de @planetkeane last edited by

                                    @planetkeane sagte in ecoflow-connector-Script zur dynamischen Leistungsanpassung:

                                    @foxthefox Tut mir leid, ich habe die Möglichkeit leider nicht gefunden. Kann mir jemand erklären, wo ich diese Eintragung durchführen kann? Bei Instanzeinstellung finde ich leider nichts, genauso wie im Objektbaum

                                    Bildschirmfoto 2023-07-17 um 10.56.49.jpg

                                    1 Reply Last reply Reply Quote 0
                                    • planetkeane
                                      planetkeane last edited by

                                      @waly_de Danke, es wird aber wohl nicht reichen, wenn ich einfach "mqtt" in zusätzliche NMP Module eintrage, richtig?

                                      W 1 Reply Last reply Reply Quote 0
                                      • W
                                        Waly_de @planetkeane last edited by

                                        @planetkeane sagte in ecoflow-connector-Script zur dynamischen Leistungsanpassung:

                                        @waly_de Danke, es wird aber wohl nicht reichen, wenn ich einfach "mqtt" in zusätzliche NMP Module eintrage, richtig?

                                        Doch 😉

                                        planetkeane 1 Reply Last reply Reply Quote 0
                                        • planetkeane
                                          planetkeane @Waly_de last edited by

                                          @waly_de Irgendwas mache ich falsch...

                                          b71c0318-4a0e-421a-9db9-8589793316dd-grafik.png

                                          Wird aber trotzdem als Fehler angezeigt (Cannot find module 'mqtt' or its corresponding type declarations.(2307)):
                                          38241b3f-6ddf-4c52-862a-3723f89b785f-grafik.png

                                          W 1 Reply Last reply Reply Quote 0
                                          • W
                                            Waly_de @planetkeane last edited by

                                            @planetkeane startet denn das script jetzt? Die Anzeige im Editor ist nicht ausschlaggebend.

                                            planetkeane 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            1.0k
                                            Online

                                            31.6k
                                            Users

                                            79.4k
                                            Topics

                                            1.3m
                                            Posts

                                            126
                                            1630
                                            500182
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo