Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. Adapter "log Parser" - Komma bereinigen

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Adapter "log Parser" - Komma bereinigen

    This topic has been deleted. Only users with topic management privileges can see it.
    • bahnuhr
      bahnuhr Forum Testing Most Active last edited by

      Hallo,
      ich spiele gerade mit o.g. Adapter rum.

      In der Anleitung steht:
      70afb654-5614-4a57-bb3d-0018d6f039a2-image.png

      Was ist aber, wenn man einen String entfernen möchte der auch ein komma enthält.

      z.B.

      json = {"name": "Robo", "id": "081603", "status": {"status": 17, "distance": 0,.......
      

      Ich möchte nun den vorderen Teil:
      json = {"name": "Robo", "id": "081603", "status":
      entfernen.
      Da hier aber auch Komma enthalten sind, erkennt der Adpater dies nicht korrekt.

      Wie muss man dies nun eingeben, damit auch die Kommas im vorderen Teil entfernt werden?

      mfg
      Dieter

      M 1 Reply Last reply Reply Quote 0
      • M
        MCU @bahnuhr last edited by

        @bahnuhr
        Es handelt sich doch hier bei um json-DP. Dort kann man ja dann direkt auf die Werte zugreifen:

        json_distance =jsonataExpression((function () { try {return JSON.parse(DEIN_JSON);} catch(e) {return {};}})(),'status.distance');
        
        bahnuhr 1 Reply Last reply Reply Quote 0
        • bahnuhr
          bahnuhr Forum Testing Most Active @MCU last edited by

          @MCU sagte in Adapter "log Parser" - Komma bereinigen:

          Es handelt sich doch hier bei um json-DP. Dort kann man ja dann direkt auf die Werte zugreifen:

          Das will ich aber nicht. An die Werte komme ich schon per Script.

          Ich möchte mir die Meldungen im Zeitablauf in vis anschauen.
          Und dafür benötige ich eine Bereinigung

          M 1 Reply Last reply Reply Quote 0
          • M
            MCU @bahnuhr last edited by

            @bahnuhr Vielleicht muß man dann im log Parser, wenn man ein Komma weg haben will das in Hochkomma setzen /','/?

            bahnuhr 1 Reply Last reply Reply Quote 0
            • bahnuhr
              bahnuhr Forum Testing Most Active @MCU last edited by

              @MCU sagte in Adapter "log Parser" - Komma bereinigen:

              @bahnuhr Vielleicht muß man dann im log Parser, wenn man ein Komma weg haben will das in Hochkomma setzen /','/?

              Ich will ja nicht alle Komma weghaben, sondern nur den Text am Anfang; wie oben geschrieben.

              M 1 Reply Last reply Reply Quote 0
              • M
                MCU @bahnuhr last edited by

                @bahnuhr Muß das denn unbedingt der Parser machen. Oder substring? slice? Also Teilstring verwenden?

                bahnuhr 1 Reply Last reply Reply Quote 0
                • bahnuhr
                  bahnuhr Forum Testing Most Active @MCU last edited by

                  @MCU sagte in Adapter "log Parser" - Komma bereinigen:

                  @bahnuhr Muß das denn unbedingt der Parser machen. Oder substring? slice? Also Teilstring verwenden?

                  Per Script bekomm ich dies auch hin.

                  Aber muss ja irgendwie mit dem Parser auch gehen.
                  Momentan versuch ich es mit regex.
                  Teilweise klappt das schon.

                  1 Reply Last reply Reply Quote 0
                  • bahnuhr
                    bahnuhr Forum Testing Most Active last edited by bahnuhr

                    Folgenden Eintrag hab ich nun bei Bereinigen genommen:

                    json = ,/{"name"[^] "status": /,/ "clock"[^*]*true}/

                    Aus:
                    {"name": "Robo-Maeh", "id": "081603", "status": {"status": 17, "distance": 0, "stopped": false, "dooropen": false, "duration": 182300, "mode": 2, "battery": 100, "hours": 6}, "timer": {"status": 0}, "blades": {"quality": 97, "hours": 6, "days": 6}, "wlan": {"signal": -74}, "health": {"temperature": 23, "humidity": 25}, "clock": {"date": "2020-10-06", "time": "21:51:59", "unix": 1602021119}, "successful": true}

                    wird dann:
                    {"status": 17, "distance": 0, "stopped": false, "dooropen": false, "duration": 184100, "mode": 2, "battery": 100, "hours": 6}, "timer": {"status": 0}, "blades": {"quality": 97, "hours": 6, "days": 6}, "wlan": {"signal": -74}, "health": {"temperature": 23, "humidity": 25},

                    Nur das letzte Komma bekomme ich nicht weg.
                    In regex101 passt es.
                    Aber in iob will dies nicht so richtig.
                    Sobald das Komma vor clock steht, will iob nicht.

                    @Homoran
                    Du bist für mich der regex Spezialist.
                    Hast du eine Idee warum dies net tut.

                    mfg
                    Dieter

                    Homoran 1 Reply Last reply Reply Quote 0
                    • bahnuhr
                      bahnuhr Forum Testing Most Active last edited by

                      wie gesagt in regex101 tut es:
                      bf61235b-f913-4620-b28e-24af8518602a-image.png

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

                        @bahnuhr sagte in Adapter "log Parser" - Komma bereinigen:

                        Du bist für mich der regex Spezialist.

                        was macht denn hier das regex?

                        wenn ich den Thread verstanden habe willst du etwas mit Komma nicht separiert haben.
                        Hast du da schon mal versucht das Komma zu escapen \, oder in Hochkommata zu setzen 'bla,blubb'

                        Ich verstehe nicht wo hier was für ein Regex machen soll. Im Screenshot ist ein anderes als im Text

                        bahnuhr 1 Reply Last reply Reply Quote 0
                        • bahnuhr
                          bahnuhr Forum Testing Most Active @Homoran last edited by

                          @Homoran sagte in Adapter "log Parser" - Komma bereinigen:

                          was macht denn hier das regex?

                          Jetzt hatte ich alles schon geschrieben (inkl. Hardcopy)
                          Und dann war das Forum nicht erreichbar. Ärgerlich.

                          Fazit:
                          \ und ' klappt nicht.
                          Der Adapter mag keine Komma im String.
                          Funktioniert nicht.

                          mfg
                          Dieter

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

                            @bahnuhr sagte in Adapter "log Parser" - Komma bereinigen:

                            Jetzt hatte ich alles schon geschrieben (inkl. Hardcopy)

                            und ich verstehe immer noch nicht was du erreichen willst.

                            Ich kenne den Adapter nicht und weiß nicht wie er funktioniert.
                            Was soll das RegEx denn bewirken?
                            Was soll herauskommen?

                            Kannst du da mal ein Beispiel geben?
                            Vorher (Original) -> Nachher (Wunschzustand)

                            bahnuhr 1 Reply Last reply Reply Quote 0
                            • bahnuhr
                              bahnuhr Forum Testing Most Active @Homoran last edited by bahnuhr

                              @Homoran sagte in Adapter "log Parser" - Komma bereinigen:

                              Vorher (Original) -> Nachher (Wunschzustand)

                              Original:
                              json = {"name": "Robo-Maeh", "id": "081603", "status": {"status": 17, "distance": 0, "stopped": false, "dooropen": false,
                              "duration": 182300, "mode": 2, "battery": 100, "hours": 6}, "timer": {"status": 0}, "blades": {"quality": 97,
                              "hours": 6, "days": 6}, "wlan": {"signal": -74}, "health": {"temperature": 23, "humidity": 25}, "clock":
                              {"date": "2020-10-06", "time": "21:51:59", "unix": 1602021119}, "successful": true}

                              Wunsch:
                              {"status": 17, "distance": 0, "stopped": false, "dooropen": false,
                              "duration": 182300, "mode": 2, "battery": 100, "hours": 6}, "timer": {"status": 0}, "blades": {"quality": 97,
                              "hours": 6, "days": 6}, "wlan": {"signal": -74}, "health": {"temperature": 23, "humidity": 25}

                              also:
                              vorne bis status weg
                              und hinten ab clcok weg

                              erreicht habe ich dies bei Bereinigen mit:
                              json = ,/{"name"[^] "status": /,/ "clock"[^*]*true}/

                              es kommt dann:
                              {"status": 17, "distance": 0, "stopped": false, "dooropen": false, "duration": 184100, "mode": 2, "battery": 100, "hours": 6}, "timer": {"status": 0}, "blades": {"quality": 97, "hours": 6, "days": 6}, "wlan": {"signal": -74}, "health": {"temperature": 23, "humidity": 25},

                              -> Aber das letzte Komma geht nicht weg. Egal welcher regex ich benutze; (was aber in regex101 klappt)

                              Problem:
                              Adapter trennt die einzelnen Ausdrücke per Komma.

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

                                @bahnuhr

                                versuch es mal mit

                                tus": {"([[:ascii:]\s]+). "cl

                                regex101 hat mich gerade extrem verunsischert, üblicherweise steht ein Punkt für jedes beliebige Zeichen, anscheinend nicht in eckigen Klammern, also bei [.\s]+ gilt der Punkt angeblich tatsächlich nur als Punkt 😞

                                und du willst vorne hinter dem ersten "status" tatsächlich die führende geschweifte Klammer weg haben?

                                bahnuhr 1 Reply Last reply Reply Quote 0
                                • bahnuhr
                                  bahnuhr Forum Testing Most Active @Homoran last edited by

                                  @Homoran sagte in Adapter "log Parser" - Komma bereinigen:

                                  und du willst vorne hinter dem ersten "status" tatsächlich die führende geschweifte Klammer weg haben?

                                  Ne, ist aber im Wunsch doch noch drin.
                                  Wunsch:
                                  {"status": 17,...

                                  Habe es mal versucht mit regex101
                                  Es wird aber nichts gemacht.
                                  bdf2b930-1283-4f20-84d5-3f4bbf26dad3-image.png

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

                                    @bahnuhr sagte in Adapter "log Parser" - Komma bereinigen:

                                    Habe es mal versucht mit regex101

                                    wo meinst du, dass ich es her habe?
                                    Dieter_007.png

                                    Sorry, mein Fehler - melde mich gleich!

                                    1 Reply Last reply Reply Quote 0
                                    • bahnuhr
                                      bahnuhr Forum Testing Most Active last edited by

                                      dein oben geposteter sieht aber anders aus

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

                                        @bahnuhr sagte in Adapter "log Parser" - Komma bereinigen:

                                        dein oben geposteter sieht aber anders aus

                                        ja, hatte ihn anschließend noch was optimiert

                                        Aber jetzt: tus": {"(.+\s.+\s.+), "cl

                                        oder: tus": {"([\w\W]+), "cl

                                        1 Reply Last reply Reply Quote 0
                                        • bahnuhr
                                          bahnuhr Forum Testing Most Active last edited by

                                          @Homoran sagte in Adapter "log Parser" - Komma bereinigen:

                                          tus": {"(.+\s.+\s.+), "cl

                                          Rainer,
                                          ich brauchs aber genau andersrum.
                                          gemacht werden muss:
                                          json = {"name": "Robo-Maeh", "id": "081603", "status":
                                          und
                                          , "clock": {"date": "2020-10-06", "time": "21:51:59", "unix": 1602021119}, "successful": true}

                                          Also der erste und letzte Teil, weil dies wird ja bereinigt.
                                          Stehen bleiben soll dann:
                                          {"status": 17, "distance": 0, "stopped": false, "dooropen": false, "duration": 182300, "mode": 2, "battery": 100, "hours": 6}, "timer": {"status": 0}, "blades": {"quality": 97, "hours": 6, "days": 6}, "wlan": {"signal": -74}, "health": {"temperature": 23, "humidity": 25}

                                          Gerne auch in 2 matches.
                                          kann man ja dann mit Komma getrennt eintragen.

                                          Homoran 1 Reply Last reply Reply Quote 0
                                          • bahnuhr
                                            bahnuhr Forum Testing Most Active last edited by bahnuhr

                                            @bahnuhr sagte in Adapter "log Parser" - Komma bereinigen:

                                            json = {"name": "Robo-Maeh", "id": "081603", "status": {"status": 17, "distance": 0, "stopped": false, "dooropen": false,
                                            "duration": 182300, "mode": 2, "battery": 100, "hours": 6}, "timer": {"status": 0}, "blades": {"quality": 97,
                                            "hours": 6, "days": 6}, "wlan": {"signal": -74}, "health": {"temperature": 23, "humidity": 25}, "clock":
                                            {"date": "2020-10-06", "time": "21:51:59", "unix": 1602021119}, "successful": true}

                                            Der 1. Teil geht so:
                                            4cf2440b-72be-4de9-ab2b-9c80981296db-image.png

                                            Nur der 2. Teil geht nicht.

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate
                                            FAQ Cloud / IOT
                                            HowTo: Node.js-Update
                                            HowTo: Backup/Restore
                                            Downloads
                                            BLOG

                                            540
                                            Online

                                            31.6k
                                            Users

                                            79.6k
                                            Topics

                                            1.3m
                                            Posts

                                            komma log parser
                                            3
                                            37
                                            823
                                            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