Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. [Log Parser Adapter] Fragen zu Regex und Filterregeln

    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

    [Log Parser Adapter] Fragen zu Regex und Filterregeln

    This topic has been deleted. Only users with topic management privileges can see it.
    • Mic
      Mic Developer @Negalein last edited by

      @Negalein
      Gibts ja nicht...
      Noch ein Versuch:
      Ersetze mal unter "Whitelist ODER" [Alexa-Log-Script], Alexa_Test_1 durch [Alexa-Log-Script], -+-

      Negalein 1 Reply Last reply Reply Quote 0
      • Negalein
        Negalein Global Moderator @Mic last edited by

        @Mic sagte in [Log Parser Adapter] Fragen zu Regex und Filterregeln:

        Noch ein Versuch:

        Fehlerbild bleibt

        Es wird nichts von [Alexa-Log-Script] und auch nichts von -+- angezeigt.

        Mic 1 Reply Last reply Reply Quote 0
        • Mic
          Mic Developer @Negalein last edited by Mic

          @Negalein
          Verstehe ich nicht.
          Ich setze z.B. folgenden Filter:
          f1.png

          Dann setze ich folgendes in einem beliebigen JavaScript ab:

          log('TEST A: [Alexa-Log-Script] Test');
          log('TEST B: -+- Test');
          

          Dann kommt alles schön an (Datenpunkt logparser.0.filters.Test.json)

          [
          	{
          		"date": "Heute 14:40",
          		"severity": "<span class='logInfo'>info</span>",
          		"from": "javascript.0",
          		"message": "script.js.Test_1: TEST B: -+- Test",
          		"ts": 1586781652664
          	},
          	{
          		"date": "Heute 14:40",
          		"severity": "<span class='logInfo'>info</span>",
          		"from": "javascript.0",
          		"message": "script.js.Test_1: TEST A: [Alexa-Log-Script] Test",
          		"ts": 1586781652664
          	}
          ]
          
          Negalein 1 Reply Last reply Reply Quote 0
          • Negalein
            Negalein Global Moderator @Mic last edited by Negalein

            @Mic sagte in [Log Parser Adapter] Fragen zu Regex und Filterregeln:

            Verstehe ich nicht.

            Ich hab jetzt mal komplett neu erstellt.
            instances - ioBroker (9).png
            Da funktioniert es. Nur der Regex in Bereinigen will nicht ganz.
            -+-, /script\.js\.[^:]*: [Alexa-Log-Script]/
            vis (21).png

            Mic 1 Reply Last reply Reply Quote 0
            • Mic
              Mic Developer @Negalein last edited by

              @Negalein sagte in [Log Parser Adapter] Fragen zu Regex und Filterregeln:

              Da funktioniert es.

              Ok, super.

              Nur der Regex in Bereinigen will nicht ganz.

              Trag da mal ein: /script\.js\.[^:]*: /, [Alexa-Log-Script], -+-

              Negalein 1 Reply Last reply Reply Quote 0
              • Negalein
                Negalein Global Moderator @Mic last edited by

                @Mic sagte in [Log Parser Adapter] Fragen zu Regex und Filterregeln:

                Ok, super.
                Trag da mal ein: /script.js.[^:]*: /, [Alexa-Log-Script], -+-

                Perfekt, es läuft!
                War eine schwere Geburt! 😉
                Hast du eine Kaffeekassa?

                vis (22).png

                Mic 1 Reply Last reply Reply Quote 0
                • Mic
                  Mic Developer @Negalein last edited by

                  @Negalein sagte in [Log Parser Adapter] Fragen zu Regex und Filterregeln:

                  Perfekt, es läuft!
                  War eine schwere Geburt! 😉
                  Hast du eine Kaffeekassa?

                  Das war's wirklich 🙂
                  Danke, noch nicht, sollte ich vielleicht mal bei Gelegenheit einrichten...
                  Aber ich helfe gerne und danke dir fürs Testen, will den Adapter möglichst bald ins Latest bekommen, und da brauche ich euer Feedback...

                  @Mic sagte in [Log Parser Adapter] Fragen zu Regex und Filterregeln:

                  /script\.js\.[^:]*: /

                  Das wäre evtl. auch was als globale Option im Adapter, also dass bei JavaScript-Logs grundsätzlich optional der ganze erste Teil script.js.Script-Pfad.Script-Name: rausgeschnitten wird.

                  Negalein Glasfaser 2 Replies Last reply Reply Quote 1
                  • Negalein
                    Negalein Global Moderator @Mic last edited by

                    @Mic sagte in [Log Parser Adapter] Fragen zu Regex und Filterregeln:

                    Danke, noch nicht, sollte ich vielleicht mal bei Gelegenheit einrichten...

                    schick mir per Chat mal deine Paypal 🙂

                    Aber ich helfe gerne und danke dir fürs Testen

                    Jetzt teste ich noch, dass ich die 2 derzeit deaktivierten "Alexa" und "Laura-Volume" im Adapter lösche, die beiden DP lösche und dann wieder im Adapter "Test" zu "Alexa" umbenenne.

                    1 Reply Last reply Reply Quote 0
                    • Glasfaser
                      Glasfaser @Mic last edited by Glasfaser

                      @Mic sagte in [Log Parser Adapter] Fragen zu Regex und Filterregeln:

                      Das wäre evtl. auch was als globale Option im Adapter,

                      Dann ist das Filterfeld ( Bereinigen ) auch nicht so vollgepackt 👍

                      ... bei dem Platzbedarf im Feld Bereinigen 😎

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

                        Hallo,
                        habe mal ne frage zu den Filterregeln Globale Blacklist verstehe das noch nicht so ganz.
                        Habe das in Globale Blacklist eingetragen :

                        /instance system\.adapter\.[^\s]*  Terminated (NO_ERROR): Without reason/
                        

                        Wird aber Trozdem unter Info angezeigt
                        log pareser.png
                        log pareser_1.png

                        Mic 1 Reply Last reply Reply Quote 0
                        • Mic
                          Mic Developer @Iccube last edited by

                          @Iccube
                          Gehe mal im ioBroker Admin links auf "Log", dann oben "LOG HERUNTERLADEN" und da dann die entsprechende Logzeile komplett kopieren und hier in Code-Tags einfügen.

                          Iccube BBTown 2 Replies Last reply Reply Quote 0
                          • Iccube
                            Iccube @Mic last edited by

                            @Mic

                            2020-04-27 19:20:00.021 - info: host.iobroker instance system.adapter.dwd.0 started with pid 4722
                            2020-04-27 19:20:00.623 - info: dwd.0 (4722) starting. Version 2.4.7 in /opt/iobroker/node_modules/iobroker.dwd, node: v12.16.2, js-controller: 3.0.19
                            2020-04-27 19:20:01.376 - info: dwd.0 (4722) Terminated (NO_ERROR): Without reason
                            2020-04-27 19:20:01.880 - info: host.iobroker instance system.adapter.dwd.0 terminated with code 0 (NO_ERROR)
                            
                            Mic 1 Reply Last reply Reply Quote 0
                            • BBTown
                              BBTown @Mic last edited by

                              @Mic

                              Hast Du eine Idee für mich weshalb die Angaben von alexa2.0.History.json nicht in logparser.0.filters.Alexa.json landen?
                              c64c8188-8eca-4d19-a3df-dff05fed42cb-grafik.png

                              ede76d40-bc16-424f-8ff9-274274561e38-grafik.png

                              /******************************************************************************************************
                              * JavaScript Adapter Script for Log-Parser-Adapter: https://github.com/Mic-M/ioBroker.logparser
                              * --------------------------------------------------------------
                              * Purpose: Get the history of all spoken Alexa commands into the log
                              *          Required: Alexa adapter - https://github.com/Apollon77/ioBroker.alexa2
                              * Source:  https://github.com/Mic-M/ioBroker.logparser
                              * Autor:   Mic-M (Github) | Mic (ioBroker)
                              * --------------------------------------------------------------------------------------
                              * Change Log:
                              *  1.0.0  Mic-M   * Adoption to Log Parser Adapter
                              *  0.1.0  Mic-M   * Initial release (for Log Script - https://github.com/Mic-M/iobroker.logfile-script).
                              ******************************************************************************************************/
                              
                              /******************************************************************************************************
                              * Script Settings
                              ******************************************************************************************************/
                              
                              // **Capitalize First Letters**
                              // The spoken command to Alexa is being returned in lowercase, like "turn on kitchen light". 
                              // With this option set to true, the output will be "Turn On Kitchen Light" (so capitalized first letter of each word)
                              const g_capFirstLetters = true;
                              
                              
                              /******************************************************************************************************
                              * End of Script Settings. Please do not change anything below here.
                              ******************************************************************************************************/
                              
                              main();
                              function main() {
                                 // All Alexa adapter instances, so alexa2.0.History.json, alexa2.1.History.json, alexa2.2.History.json, etc.
                                 on({id: /^alexa2\.\d\.History\.json$/, change:'any'}, function(obj) {
                              
                                     // obj.state.val: JSON string of object.
                                     // Like: {"name":"Alexa Flur","serialNumber":"xxxxxxxxxx","summary":"Wohnlicht an","creationTime":1582843794820, ... }
                                     let objHistory = JSON.parse(obj.state.val); 
                              
                                     // ignore alexa keywords or empty value.
                                     if(! (['', 'alexa','echo','computer'].includes(objHistory['summary']) )) {
                                         // ignore "sprich mir nach"
                                         if (!(objHistory['summary'].includes('sprich mir nach '))) {
                                             log('[Alexa-Log-Script] ##{"message":"' + formatAlexaSummary(objHistory['summary']) + '", "from":"' + objHistory['name'] + '"}##');
                                         }
                                     }
                                 });
                              }
                              
                              /**
                              * Formats the Alexa summary text accordingly.
                              * @param {string} summaryText   The summary text
                              * @return {string} the formatted summary
                              */
                              function formatAlexaSummary(summaryText) {
                                 if (g_capFirstLetters) summaryText = summaryText.replace(/(^|\s)\S/g, l => l.toUpperCase()); // Capitalize if set. https://stackoverflow.com/questions/2332811/
                                 return summaryText;
                              }
                              


                              8d5bc591-942f-4ecd-8d6f-613fa684b2db-grafik.png

                              Mic 1 Reply Last reply Reply Quote 0
                              • Mic
                                Mic Developer @Iccube last edited by

                                @Iccube
                                /instance system\.adapter\.[^\s]* Terminated (NO_ERROR): Without reason/ würde eine Logzeile wie diese hier erwarten:

                                host.ctioBroker instance system.adapter.dwd.0 Terminated (NO_ERROR): Without reason
                                

                                Bei dir ist die Logausgabe aber anders.
                                Mache einfach mal das hier in der Global Blacklist: Terminated (NO_ERROR): Without reason
                                Das brauchst du wohl bei anderen Adaptern auch nicht, daher generisch.

                                Iccube 1 Reply Last reply Reply Quote 0
                                • Mic
                                  Mic Developer @BBTown last edited by

                                  @BBTown sagte in [Log Parser Adapter] Fragen zu Regex und Filterregeln:

                                  @Mic

                                  Hast Du eine Idee für mich weshalb die Angaben von alexa2.0.History.json nicht in logparser.0.filters.Alexa.json landen?
                                  c64c8188-8eca-4d19-a3df-dff05fed42cb-grafik.png

                                  ede76d40-bc16-424f-8ff9-274274561e38-grafik.png

                                  /******************************************************************************************************
                                  * JavaScript Adapter Script for Log-Parser-Adapter: https://github.com/Mic-M/ioBroker.logparser
                                  * --------------------------------------------------------------
                                  * Purpose: Get the history of all spoken Alexa commands into the log
                                  *          Required: Alexa adapter - https://github.com/Apollon77/ioBroker.alexa2
                                  * Source:  https://github.com/Mic-M/ioBroker.logparser
                                  * Autor:   Mic-M (Github) | Mic (ioBroker)
                                  * --------------------------------------------------------------------------------------
                                  * Change Log:
                                  *  1.0.0  Mic-M   * Adoption to Log Parser Adapter
                                  *  0.1.0  Mic-M   * Initial release (for Log Script - https://github.com/Mic-M/iobroker.logfile-script).
                                  ******************************************************************************************************/
                                  
                                  /******************************************************************************************************
                                  * Script Settings
                                  ******************************************************************************************************/
                                  
                                  // **Capitalize First Letters**
                                  // The spoken command to Alexa is being returned in lowercase, like "turn on kitchen light". 
                                  // With this option set to true, the output will be "Turn On Kitchen Light" (so capitalized first letter of each word)
                                  const g_capFirstLetters = true;
                                  
                                  
                                  /******************************************************************************************************
                                  * End of Script Settings. Please do not change anything below here.
                                  ******************************************************************************************************/
                                  
                                  main();
                                  function main() {
                                     // All Alexa adapter instances, so alexa2.0.History.json, alexa2.1.History.json, alexa2.2.History.json, etc.
                                     on({id: /^alexa2\.\d\.History\.json$/, change:'any'}, function(obj) {
                                  
                                         // obj.state.val: JSON string of object.
                                         // Like: {"name":"Alexa Flur","serialNumber":"xxxxxxxxxx","summary":"Wohnlicht an","creationTime":1582843794820, ... }
                                         let objHistory = JSON.parse(obj.state.val); 
                                  
                                         // ignore alexa keywords or empty value.
                                         if(! (['', 'alexa','echo','computer'].includes(objHistory['summary']) )) {
                                             // ignore "sprich mir nach"
                                             if (!(objHistory['summary'].includes('sprich mir nach '))) {
                                                 log('[Alexa-Log-Script] ##{"message":"' + formatAlexaSummary(objHistory['summary']) + '", "from":"' + objHistory['name'] + '"}##');
                                             }
                                         }
                                     });
                                  }
                                  
                                  /**
                                  * Formats the Alexa summary text accordingly.
                                  * @param {string} summaryText   The summary text
                                  * @return {string} the formatted summary
                                  */
                                  function formatAlexaSummary(summaryText) {
                                     if (g_capFirstLetters) summaryText = summaryText.replace(/(^|\s)\S/g, l => l.toUpperCase()); // Capitalize if set. https://stackoverflow.com/questions/2332811/
                                     return summaryText;
                                  }
                                  


                                  8d5bc591-942f-4ecd-8d6f-613fa684b2db-grafik.png

                                  1. Ist das von dir gepostete Script identisch mit https://github.com/Mic-M/ioBroker.logparser/blob/master/accessories/alexa-history.js ?
                                  2. Sichergestellt, dass das Script läuft?
                                  3. Was steht genau in "Whitelist UND"? Nur das hier: [Alexa-Log-Script] - ohne Leerzeichen?
                                  4. Adapterversion ist frisch von Github installiert?
                                  5. Getestet mit neuem Alexa-Kommando, nachdem Script und Logparser-Adapter gestartet und ein paar Sekunden gewartet wurde?
                                  BBTown 1 Reply Last reply Reply Quote 0
                                  • BBTown
                                    BBTown @Mic last edited by BBTown

                                    @Mic

                                    Ist das von dir gepostete Script identisch mit https://github.com/Mic-M/ioBroker.logparser/blob/master/accessories/alexa-history.js ?
                                    Sichergestellt, dass das Script läuft?
                                    Was steht genau in "Whitelist UND"? Nur das hier: [Alexa-Log-Script] - ohne Leerzeichen?
                                    Adapterversion ist frisch von Github installiert?
                                    Getestet mit neuem Alexa-Kommando, nachdem Script und Logparser-Adapter gestartet und ein paar Sekunden gewartet wurde?

                                    Ich kann alles mit "Ja" beantworten, daher meine Verwunderung
                                    Es passieren ja nicht wirklich komplizierte Dinge.
                                    Das Script ist auch relativ simple und klar

                                    a257db2f-3a11-4a72-90f0-a4ac168eca77-grafik.png

                                    Mic 1 Reply Last reply Reply Quote 0
                                    • Iccube
                                      Iccube @Mic last edited by

                                      @Mic okay hat funktioniert danke dir
                                      wie kann ich den solche einträge entfernen :

                                      2020-04-27 20:10:00.667 - info: dwd.0 (2072) starting. Version 2.4.7 in /opt/iobroker/node_modules/iobroker.dwd, node: v12.16.2, js-controller: 3.0.19
                                      

                                      die kommen ja von mehreren Adaptern

                                      würde das so gehen wenn ich das nur eingebe:

                                      starting. Version
                                      
                                      Mic 1 Reply Last reply Reply Quote 0
                                      • Mic
                                        Mic Developer @BBTown last edited by

                                        @BBTown
                                        Prüfe mal, was im Logfile selbst ausgegeben wird, wenn du einen Befehl an Alexa absetzt. Da sollte dann vom JavaScript was kommen wie hier: https://github.com/Mic-M/ioBroker.logparser/blob/master/docs/de/logparser.md#beispiel

                                        BBTown 1 Reply Last reply Reply Quote 0
                                        • BBTown
                                          BBTown @Mic last edited by

                                          @Mic

                                          Dann kommt dies hier

                                          javascript.0	2020-04-27 20:20:43.248	info	(1370) script.js.common.logparserAlexa: [Alexa-Log-Script] ##{"message":"Licht An", "from":"echoDot (Büro)"}##
                                          
                                          1 Reply Last reply Reply Quote 0
                                          • Mic
                                            Mic Developer @Iccube last edited by

                                            @Iccube sagte in [Log Parser Adapter] Fragen zu Regex und Filterregeln:

                                            wie kann ich den solche einträge entfernen :

                                            2020-04-27 20:10:00.667 - info: dwd.0 (2072) starting. Version 2.4.7 in /opt/iobroker/node_modules/iobroker.dwd, node: v12.16.2, js-controller: 3.0.19
                                            

                                            die kommen ja von mehreren Adaptern
                                            würde das so gehen wenn ich das nur eingebe:

                                            starting. Version
                                            

                                            Du darfst gerne selbst testen 😉
                                            Das würde gehen, natürlich kannst du auch komplexer aber exakter abfragen, hier ist https://regex101.com/ hilfreich.
                                            Alternativ empfehle ich, bei Adaptern, die rund laufen, das Log-Level in der Adapter-Übersicht von info auf warn zu setzen, dann wird das erst gar nicht ausgegeben.

                                            BBTown Iccube 2 Replies 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

                                            799
                                            Online

                                            31.9k
                                            Users

                                            80.2k
                                            Topics

                                            1.3m
                                            Posts

                                            adapter filter logparser parser regex
                                            9
                                            40
                                            4649
                                            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