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.
    • 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
                      • BBTown
                        BBTown @Mic last edited by BBTown

                        @Mic
                        Du darfst mich gerne schlagen 😎
                        Aufgrund ddeiner Frage habe ich das Script erneut heruntergeladen und per copy`n paste eingefügt und nun macht es was er soll .... frage mich nicht was bei der ersten Kopie unterwegs verloren gegangen sein kann/soll.

                        Es läuft nun alles wie gewünscht, sorry !

                        .... mal wieder Fehler 40?!?!

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

                          @Mic okay werde ich mal testen danke dir nochmal

                          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:

                            Es läuft nun alles wie gewünscht, sorry !

                            Kein Thema, Hauptsache es läuft und ist kein Fehler im Adapter ☺

                            1 Reply Last reply Reply Quote 1
                            • M
                              Manu.Oe last edited by

                              Hallo zusammen,

                              gibt es ne Möglichkeit einen Filter zu erstellen der nur Logs vom Javascript Adapter anzeigt?
                              Ich schreibe in meinen ganzen Blocklys Statusmeldungen raus und suche eine Möglichekit, nur diese angezeigt zu bekommen.
                              Danke und Grüße

                              liv-in-sky Mic 2 Replies Last reply Reply Quote 0
                              • liv-in-sky
                                liv-in-sky @Manu.Oe last edited by liv-in-sky

                                @Manu-Oe

                                hier stand blödsinn

                                Negalein 1 Reply Last reply Reply Quote 0
                                • Negalein
                                  Negalein Global Moderator @liv-in-sky last edited by

                                  @liv-in-sky sagte in [Log Parser Adapter] Fragen zu Regex und Filterregeln:

                                  da git es einen anderen adapter dafür

                                  Frage von @Manu-Oe passt hier gut rein.
                                  Hier im Thread geht es eh um Regex und Filterregeln zu @Mic seinem Log Parser Adapter. 😊

                                  liv-in-sky 1 Reply Last reply Reply Quote 0
                                  • liv-in-sky
                                    liv-in-sky @Negalein last edited by

                                    @Negalein oh sorry- danke für den hinweis

                                    Negalein 1 Reply Last reply Reply Quote 0
                                    • Negalein
                                      Negalein Global Moderator @liv-in-sky last edited by

                                      @liv-in-sky sagte in [Log Parser Adapter] Fragen zu Regex und Filterregeln:

                                      oh sorry

                                      kein Problem 🙂

                                      1 Reply Last reply Reply Quote 0
                                      • Mic
                                        Mic Developer @Manu.Oe last edited by

                                        @Manu-Oe sagte in [Log Parser Adapter] Fragen zu Regex und Filterregeln:

                                        gibt es ne Möglichkeit einen Filter zu erstellen der nur Logs vom Javascript Adapter anzeigt?
                                        Ich schreibe in meinen ganzen Blocklys Statusmeldungen raus und suche eine Möglichekit, nur diese angezeigt zu bekommen.
                                        Danke und Grüße

                                        Z.B. so:
                                        1dadb56d-b41d-441f-a171-a40501f3f447-image.png

                                        Whitelist UND: /javascript\.[0-9]/

                                        1 Reply Last reply Reply Quote 0
                                        • M
                                          Manu.Oe last edited by

                                          Super Danke, werd ich gleich ausprobieren 👍

                                          kann man des mit allen Adaptern so machen "/Adaptername.[0-9]/" ?
                                          Das 0-9 steht dann vermutlich für die Instanzen

                                          Mic 1 Reply Last reply Reply Quote 0
                                          • Mic
                                            Mic Developer @Manu.Oe last edited by

                                            @Manu-Oe

                                            Genau, kannst hier gut testen:
                                            https://regex101.com/r/h7r6jN/1

                                            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

                                            903
                                            Online

                                            31.9k
                                            Users

                                            80.1k
                                            Topics

                                            1.3m
                                            Posts

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