Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Datenpunkt berechnen

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Datenpunkt berechnen

    This topic has been deleted. Only users with topic management privileges can see it.
    • Homoran
      Homoran Global Moderator Administrators last edited by

      Hallo Paul,

      ich hätte nur gerne einen Schubs in die Richtung, in die ich gehen muss.

      Wenn ich an einem realen Beispiel mit einem gewissen "Leidensdruck" arbeite, denke ich kann ich besser lernen, als wenn man nur etwas abtippt.

      @paul53:

      Modbus. `
      nein, höchstens S0

      Piko 5.5

      @paul53:

      Wie bekommst Du die Werte in die CCU ? `
      Damals auch mit cut and paste (Das muss ein Ende haben 😉 )

      als shell-script auf dem Pi/Cubie…

      #!/bin/bash
      # http://homematic-forum.de/forum/viewtopic.php?p=131956#p131956
      #
      #   define common parameters for wget
      #
      COMMONWGETARGS="-q -O - --timeout=10"
      
      wget $COMMONWGETARGS --http-user=USERNAME --http-password=MySecurePassword "http://192.168.138.54/index.fhtml" | sed -e "s/nbsp/nbsp;/g" | sed -e "s/nbsp;;/nbsp;/g" | sed -e "s/\ //g" | html2text | tr -s " \t\r\n" | sed -e "s/^ //" | sed -e "s/x x x/0/g" >/tmp/power-inverter1.values
      PHOTOVOLTAICS_DC1U=$( cat /tmp/power-inverter1.values | grep Spannung | head -1 | cut -f2 -d" " )
      PHOTOVOLTAICS_DC2U=$( cat /tmp/power-inverter1.values | grep Spannung | head -2 | tail -1 | cut -f2 -d" " )
      PHOTOVOLTAICS_DC1I=$( cat /tmp/power-inverter1.values | grep Strom | head -1 | cut -f2 -d" " | awk '{printf "%d\n",$1*1000}' )
      PHOTOVOLTAICS_DC2I=$( cat /tmp/power-inverter1.values | grep Strom | head -2 | tail -1 | cut -f2 -d" " | awk '{printf "%d\n",$1*1000}' )
      PHOTOVOLTAICS_DC1P=$(( $PHOTOVOLTAICS_DC1U * $PHOTOVOLTAICS_DC1I / 1000 ))
      PHOTOVOLTAICS_DC2P=$(( $PHOTOVOLTAICS_DC2U * $PHOTOVOLTAICS_DC2I / 1000 ))
      
      PHOTOVOLTAICS_ACCURP=$( cat /tmp/power-inverter1.values | grep aktuell | cut -f2 -d" " )
      PHOTOVOLTAICS_ACTOTP=$( cat /tmp/power-inverter1.values | grep Gesamtenergie | cut -f5 -d" " )
      PHOTOVOLTAICS_DAILYP=$( cat /tmp/power-inverter1.values | grep Tagesenergie | cut -f2 -d" " )
      
      #
      #   update the system variables in the HomeMatic
      #
      wget $COMMONWGETARGS "http://192.168.138.52/addons/db/state.cgi?item=PV.DC1&value=$PHOTOVOLTAICS_DC1P"
      wget $COMMONWGETARGS "http://192.168.138.52/addons/db/state.cgi?item=PV.DC2&value=$PHOTOVOLTAICS_DC2P"
      wget $COMMONWGETARGS "http://192.168.138.52/addons/db/state.cgi?item=PV.AC&value=$PHOTOVOLTAICS_ACCURP"
      wget $COMMONWGETARGS "http://192.168.138.52/addons/db/state.cgi?item=PV.DAILYP&value=$PHOTOVOLTAICS_DAILYP"
      wget $COMMONWGETARGS "http://192.168.138.52/addons/db/state.cgi?item=PV.TOTP&value=$PHOTOVOLTAICS_ACTOTP"
      

      Davon verstehe ich auch nichts.

      Inzwischen habe ich es mit node-red hinbekommen die Website mit den Credentials aufzurufen und den Quelltext herunterzuladen,

      auch ein split nachbrachte schon mal einige brauchbare Blöcke.

      Hier fehlt mir im Moment die Weiterverarbeitung von Arrays.

      Danke für deine Hilfe

      Rainer

      1 Reply Last reply Reply Quote 0
      • E
        ein-bayer last edited by

        solardaten in iobroker => 2. ir sensor von volkszähler, und iobroker 2. instanz von smartmeter
        1342_bildschirmfoto_2017-02-19_um_17.59.54.png

        1 Reply Last reply Reply Quote 0
        • Y
          ykuendig last edited by

          @Homoran; Hab zwar nicht den ganzen Artikel gelesen. aber hat nicht Paul schon hier: http://forum.iobroker.net/viewtopic.php … 5.5#p48206 das Script in JS übersetzt?

          Geht das nicht?

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

            @ykuendig:

            aber hat nicht Paul schon hier: viewtopic.php?f=21&t=4888&p=48710&hilit=Piko+5.5#p48206 das Script in JS übersetzt? `
            Das ist die Nach-Nachfolger Firmware. Dagegen sieht meine aus wie DOS im Vergleich zu Win10

            Gruß

            Rainer

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

              An dem shell script sehe ich, dass offenbar die Daten aus der Datei "/tmp/power-inverter1.values" geholt werden und mit grep gesucht wird.

              Zur Anregung: In Javacsript kann man https://github.com/ioBroker/ioBroker.javascript#readfile und falls es eine Textdatei ist, mit https://wiki.selfhtml.org/wiki/JavaScript/Objekte/String/indexOf im Text suchen und mit https://wiki.selfhtml.org/wiki/JavaScript/Objekte/String/substr Teilzeichenketten ermitteln.

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

                Hallo Paul,

                @paul53:

                dass offenbar die Daten aus der Datei "/tmp/power-inverter1.values" geholt werden und mit grep gesucht wird. `
                da werden sie in Zeile 8 erst einmal hingeschrieben 😞

                @paul53:

                falls es eine Textdatei ist, `
                leider nein, ist eine HTML-Datei.

                ! ````
                ! <title>PV Webserver</title>
                ! <form method="post" action="">
                ! | |
                ! | |

                PIKO 5.5

                ! Helios (255)
                |
                |
                ! |

                ! * * *
                ! |
                ! | |
                ! |

                AC-Leistung |
                  |

                Energie |

                ! | |
                ! |

                aktuell |

                x x x  |
                  W |

                Gesamtenergie |

                23117 |
                  kWh |
                  |

                ! | |
                ! |

                |

                |
                  |

                Tagesenergie |

                7.47 |
                  kWh |
                  |

                ! | |
                ! |

                Status |

                Aus |
                  |

                ! | |
                ! |
                ! |

                ! * * *
                ! |
                ! | |
                ! |
                ! |

                PV-Generator |
                  |

                Ausgangsleistung |
                  |
                  |

                ! | |
                ! |

                <u>String 1</u> |
                  |
                  |

                <u>L1</u> |
                  |
                  |
                  |

                ! |

                Spannung |

                x x x  |
                  V |

                Spannung |

                x x x  |
                  V |
                  |

                ! | |
                !   |

                Strom |

                x x x  |
                  A |

                Leistung |

                x x x  |
                  W |
                  |

                ! | |
                ! |

                <u>String 2</u> |
                  |
                  |

                <u>L2</u> |
                  |
                  |
                  |

                ! |

                Spannung |

                x x x  |
                  V |

                Spannung |

                x x x  |
                  V |
                  |

                ! | |
                !   |

                Strom |

                x x x  |
                  A |

                Leistung |

                x x x  |
                  W |
                  |

                ! | |
                ! |

                <u>String 3</u> |
                  |
                  |

                <u>L3</u> |
                  |
                  |
                  |

                ! |

                Spannung |

                x x x  |

                V |

                Spannung |

                x x x  |
                  V |
                  |

                ! | |
                !   |

                Strom |

                x x x  |

                A |

                Leistung |

                x x x  |
                  W |
                  |

                ! | |
                ! |
                ! | |

                ! * * *
                ! |
                ! | |
                ! |
                ! | |
                RS485 Kommunikation |
                ! | |
                ! | |
                Wechselrichter |
                | |
                ! * * *
                ! | |
                ! | |

                Historie

                Infoseite |

                Einstellungen

                ! </form>
                ! ````

                im shellscript wird die anscheinend mit dem Paket html2text in Text umgewandelt (?)

                Das nach dem o.a. Split herausgegebene zweite Elemet des Arrays, enthält die aktuelle Stromproduktion:

                msg.payload : string[116]
                "↵ aktuell↵↵ x x x ↵  W↵"
                

                Jetzt nur noch x x x, da ich meine Lunarmodule noch nicht montiert habe 😉

                Gruß

                Rainer

                1 Reply Last reply Reply Quote 0
                • M
                  moebius last edited by

                  @homoran: wenn du es mit node-red machen möchtest, lade die html Datei hoch, die du parsen willst.

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

                    Siehe im letzten post im Spoiler

                    Gruß

                    Rainer

                    1 Reply Last reply Reply Quote 0
                    • Y
                      ykuendig last edited by

                      Das wär ja die Paradeaufgabe für den Parser Adapter. Blöd sprech ich kein RegEx..

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

                        @ykuendig:

                        Das wär ja die Paradeaufgabe für den Parser Adapter. Blöd sprech ich kein RegEx.. `

                        Damit habe ich es auch nicht hinbekommen 😞

                        Gruß

                        Rainer

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

                          @Homoran:

                          da werden sie in Zeile 8 erst einmal hingeschrieben `
                          Oh, das habe ich übersehen :shock: Dann sollte man sich den Umweg über die Datei sparen und die HTML-Seite direkt einlesen (https://www.npmjs.com/package/request).

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

                            @paul53:

                            Oh, das habe ich übersehen Dann sollte man sich den Umweg über die Datei sparen und die HTML-Seite direkt einlesen (request). `
                            und mit dem request-Block in Blockly habe ich es auch nicht hinbekommen, da kam nichts zurück 😢 😢 😢

                            Dann muss ich es auf die Harte Tour mit dem "echten" js versuchen.

                            Danke erstmal für alles

                            Rainer

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

                              Um die Auswertung zu vereinfachen, sollte HTML in Text gewandelt werden, wozu das NPM-Modul "https://www.npmjs.com/package/html2plaintext" dienen kann, das in die Konfiguration der JS-Adapter-Instanz eingetragen werden muss.

                              1 Reply Last reply Reply Quote 0
                              • M
                                moebius last edited by

                                Der flow liefert ein Array mit allen Werten.

                                ! [
                                ! {
                                ! "id": "1f5df07c.81145",
                                ! "type": "tab",
                                ! "label": "Flow 5"
                                ! },
                                ! {
                                ! "id": "12035f81.de82c",
                                ! "type": "html",
                                ! "z": "1f5df07c.81145",
                                ! "name": "",
                                ! "tag": "[bgcolor="#FFFFFF"]",
                                ! "ret": "text",
                                ! "as": "single",
                                ! "x": 592,
                                ! "y": 334,
                                ! "wires": [
                                ! [
                                ! "dd0ca08d.c45bd"
                                ! ]
                                ! ]
                                ! },
                                ! {
                                ! "id": "d487fa3f.daea58",
                                ! "type": "inject",
                                ! "z": "1f5df07c.81145",
                                ! "name": "",
                                ! "topic": "",
                                ! "payload": " <title>PV Webserver</title>
                                ! <form method="&quot;post&quot;" action="&quot;&quot;">
                                ! | |
                                | | PIKO 5.5
                                Helios (255) | |
                                ! | |
                                ! * * *

                                !
                                !
                                AC-Leistung Energie
                                aktuell x x x W Gesamtenergie 23117 kWh
                                Tagesenergie 7.47 kWh
                                Status Aus
                                !

                                ! * * *

                                !
                                !
                                PV-Generator Ausgangsleistung
                                <u>String 1</u> <u>L1</u>
                                Spannung x x x V Spannung x x x V
                                Strom x x x A Leistung x x x W
                                <u>String 2</u> <u>L2</u>
                                Spannung x x x V Spannung x x x V
                                Strom x x x A Leistung x x x W
                                <u>String 3</u> <u>L3</u>
                                Spannung x x x V Spannung x x x V
                                Strom x x x A Leistung x x x W
                                !

                                ! * * *
                                ! |
                                | |
                                ! |
                                ! | | RS485 Kommunikation |
                                | |
                                | | Wechselrichter |
                                | |
                                ! * * *
                                ! | |
                                | | Historie       Infoseite | Einstellungen | |
                                ! </form>
                                ! ",
                                ! "payloadType": "str",
                                ! "repeat": "",
                                ! "crontab": "",
                                ! "once": false,
                                ! "x": 376,
                                ! "y": 331,
                                ! "wires": [
                                ! [
                                ! "12035f81.de82c"
                                ! ]
                                ! ]
                                ! },
                                ! {
                                ! "id": "dd0ca08d.c45bd",
                                ! "type": "debug",
                                ! "z": "1f5df07c.81145",
                                ! "name": "",
                                ! "active": true,
                                ! "console": "false",
                                ! "complete": "true",
                                ! "x": 833,
                                ! "y": 334,
                                ! "wires": []
                                ! }
                                ! ]
                                1803_clipboard03.jpg

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

                                  STOP!!

                                  Danke!!

                                  das sind genug Ansätze. 😮 😮

                                  @moebius:

                                  Der flow liefert ein Array mit allen Werten. `
                                  Nur wie kann ich ein Array mit allen Werten bei node-js weiterverarbeiten.

                                  Da war ich ja schon mit dem split node und kam nicht weiter.

                                  Habe jetzt genug zu tüfteln

                                  Danke erstmal an alle Helfer.

                                  Gruß

                                  Rainer

                                  1 Reply Last reply Reply Quote 0
                                  • Y
                                    ykuendig last edited by

                                    Rainer, nur damit wir mit-tüfteln können.

                                    Kannst Du ein Beispiel machen, was genau anstelle x x x

                                    dort steht. Sind das drei Werte für zB 3 Phasen oder was genau?

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

                                      Habe erst einmal mit dem node angefangen.

                                      Das ist doch nicht dein Ernst. :lol: :lol:

                                      Warum kannte ich diesen node nicht:
                                      ` > Extracts elements from an html document held in msg.payload using a selector.

                                      If left blank the selector may be set dynamically by passing in msg.select along with the msg.payload.

                                      The selector uses Cheerio which uses the CSS selector syntax.

                                      The result can be either a single message with a payload containing an array of the matched elements, or multiple messages that each contain a matched element. `

                                      kein Split, kein Regex, kein match 😮

                                      Sieht gut aus! aber was nun.

                                      Wie kann ich (in node-red) mit einem Array weiterarbeiten.

                                      Gruß

                                      Rainer

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

                                        @ykuendig:

                                        Rainer, nur damit wir mit-tüfteln können.

                                        Kannst Du ein Beispiel machen, was genau anstelle x x x

                                        dort steht. Sind das drei Werte für zB 3 Phasen oder was genau? `

                                        Da stehen die entsprechenden Werte:
                                        144_kostal.jpg

                                        Gruß

                                        Rainer

                                        1 Reply Last reply Reply Quote 0
                                        • M
                                          moebius last edited by

                                          weiterverarbeiten kann aber vieles sein…

                                          zB machst du einfach einen function node dran und mit "msg.payload[2]" holst du dir den 3 Wert im Array = 7.47

                                          Bin ziemlich sicher das es mit allen anderen Lösungen (bash, js, usw) wesentlich aufwendiger ist.

                                          Wenn es eine einfachere Lösung gibt - also unter 18 Zeichen - würde ich die jedenfalls gerne sehen 🙂

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

                                            @moebius:

                                            zB machst du einfach einen function node dran und mit "msg.payload[2]" holst du dir den 3 Wert im Array = 7.47 `
                                            so etwas hatte ich nach split auch versucht, hatte aber nicht geklappt, wahrscheinlich weil ich einen Multi-Output node nutzen wollte. Jedenfalls kam immer eine Fehlermeldung, dass keine msg_ID (????) dem Wert zugefügt werden könnte, die ich früher mit einem "msg.payload = " wegbekommen hatte.

                                            Werde jetzt nochmal mit kleinen Schritten arbeiten, bis ich es verstanden habe.

                                            Danke

                                            Rainer

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            536
                                            Online

                                            31.9k
                                            Users

                                            80.1k
                                            Topics

                                            1.3m
                                            Posts

                                            7
                                            70
                                            12640
                                            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