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

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    [Log Parser Adapter] Fragen zu Regex und Filterregeln

    This topic has been deleted. Only users with topic management privileges can see it.
    • 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
                                          • B
                                            BlackTigga last edited by

                                            Hallo, ich habe eine Frage zur globalen Blacklist.
                                            Ich habe verstanden, dass ich in den Blacklist Einstellungen "Ausdrücke" definieren kann, die dann nicht berücksichtigt werden. Kann man auch global einen kompletten Adapter bzw. seine Instanzen unberücksichtigt lassen?
                                            Nachfolgend ein Beispiel. Die Viessmann Instanz liefern am Tag diverse und verschiedenartige Meldungen die mich in Summe nicht interessieren. Kann ich Logparser so anpassen, dass sämtliche Meldungen aus der Instanz viessmannapi.0 nicht berücksichtigt werden?

                                            
                                            viessmannapi.0 2024-03-21 08:38:34.827	info	State value to set for "viessmannapi.0.396344.gateways01.devices02.id" has to be type "string" but received type "number"
                                            viessmannapi.0 2024-03-21 08:38:34.272	info	1 installations found.
                                            viessmannapi.0 2024-03-21 08:38:30.190	info	starting. Version 2.3.0 in /opt/iobroker/node_modules/iobroker.viessmannapi, node: v18.19.0, js-controller: 5.0.19
                                            viessmannapi.0 2024-03-21 08:38:25.224	info	terminating
                                            viessmannapi.0 2024-03-21 08:38:24.764	warn	Got terminate signal. Checking desired PID: xxx vs own PID xxx
                                            viessmannapi.0 2024-03-21 08:38:24.720	info	Terminated (ADAPTER_REQUESTED_TERMINATION): Without reason
                                            viessmannapi.0 2024-03-21 08:38:24.717	info	terminating
                                            viessmannapi.0 2024-03-21 08:38:24.712	warn	Got terminate signal. Checking desired PID: 0 vs own PID xxx
                                            viessmannapi.0 2024-03-21 08:38:04.183	info	State value to set for "viessmannapi.0.396344.gateways01.devices02.id" has to be type "string" but received type "number"
                                            viessmannapi.0 2024-03-21 08:38:03.684	info	1 installations found.
                                            viessmannapi.0 2024-03-21 08:37:58.225	info	starting. Version 2.3.0 in /opt/iobroker/node_modules/iobroker.viessmannapi, node: v18.19.0, js-controller: 5.0.19
                                            viessmannapi.0 2024-03-21 08:37:53.859	warn	Could not perform strict object check of state viessmannapi.0.396344.0.features.heating.compressors.0.feature: DB closed
                                            viessmannapi.0 2024-03-21 08:37:53.858	warn	Could not perform strict object check of state viessmannapi.0.396344.0.features.heating.compressors.1.statistics.uri: DB closed
                                            viessmannapi.0 2024-03-21 08:37:53.857	warn	Could not perform strict object check of state viessmannapi.0.396344.0.features.heating.compressors.1.statistics.apiVersion: DB closed
                                            viessmannapi.0 2024-03-21 08:37:53.856	warn	Could not perform strict object check of state viessmannapi.0.396344.0.features.heating.compressors.1.statistics.isReady: DB closed
                                            

                                            Besten Dank.

                                            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

                                            1.0k
                                            Online

                                            31.7k
                                            Users

                                            79.8k
                                            Topics

                                            1.3m
                                            Posts

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