Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. on trigger

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    on trigger

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

      @tminimax sagte in on trigger:

      wie müßte - sofern das geht - die korrekte ON "Funktion" aussehen:

      Ist schon etwas her, bastel es dir hieraus bitte zusammen 🙂

      var mainStatePath = '0_userdata.0.wetterwarnung.';
      
      on(new RegExp(getRegEx(mainStatePath +'config.basiskonfiguration.warnzelle.', '^')+'.*'), function(obj) {
      
      function getRegEx(value, firstChar) {
          let path = value.split('.');
          if (value[value.length-1] == '.') path.splice(path.length-1,1);
          let r = '';
          if (firstChar !== undefined) r+=firstChar;
          for (let a=0;a<path.length;a++) {
              if (path[a]) r+=path[a]+'\.';
          }
          return r;
      }
      

      https://github.com/ticaki/DWD-UWZ-NINA-Pushwarnungen-iobroker/blob/cdc0cdbf1979537d0d5d5d9b6f8bd2adbf008a78/dwd_uwz_nina_script.js#L1009

      In dem Skript werden eine ganze Menge RegExp trigger benutzt.

      Edit: und das richtige Suchpattern wäre sowas hier:

      /0_userdata\.0\.sonstige_Variablen\.Raffstore\.Beschattungsautomatik\.Fassade[0-9]{1,2}\..+/
      
      1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @Codierknecht last edited by

        @codierknecht sagte: Das kannst Du mit den "wildcards" erreichen.

        Nur mittels Selektor oder RegExp.

        Codierknecht 1 Reply Last reply Reply Quote 0
        • Codierknecht
          Codierknecht Developer Most Active @paul53 last edited by

          @paul53 sagte in on trigger:

          Nur mittels Selektor oder RegExp.

          <kopfauftischplatte>

          Natürlich

          on ({id : $('0_userdata.0.sonstige_Variablen.Raffstore.Beschattungsautomatik.*.Beschattung_jetzt_aktiv').toArray(), change : 'ne'}, function (obj) {
             //code here
          });
          
          T 1 Reply Last reply Reply Quote 0
          • T
            tminimax @Codierknecht last edited by tminimax

            @codierknecht & @paul53: super danke - jetzt funktioniert es

            1 Reply Last reply Reply Quote 0
            • T
              ticaki Developer last edited by

              Vorteil von RegExp ist das es nicht statisch ist, es werden auch neu erstelle States gefunden im laufenden Betrieb.
              Vorteil von Selektor ist, das er nicht kryptisch ist 🙂

              T 1 Reply Last reply Reply Quote 0
              • T
                tminimax @ticaki last edited by

                @ticaki danke, dann werde ich versuchen, das mit RegExp nachzubauen um es noch weiter zu optimieren - danke (ich hoffe ich kann das von deinem Muster auf meine Anforderung umbauen)

                T paul53 2 Replies Last reply Reply Quote 0
                • T
                  ticaki Developer @tminimax last edited by

                  @tminimax

                  im meinem Suchpattern fehlt noch am Anfang das ^ für: hiermit beginnt der string

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

                    @tminimax sagte: mit RegExp

                    on(/^0_userdata\.0\.sonstige_Variablen\.Raffstore\.Beschattungsautomatik\.Fassade.+\.Beschattung_jetzt_aktiv$/, function (obj) {
                       //code here
                    });
                    
                    T T 2 Replies Last reply Reply Quote 0
                    • T
                      ticaki Developer @paul53 last edited by ticaki

                      @paul53 sagte in on trigger:

                      @tminimax sagte: mit RegExp

                      on(/^0_userdata\.0\.sonstige_Variablen\.Raffstore\.Beschattungsautomatik\.Fassade\d+\.Beschattung_jetzt_aktiv$/, function (obj) {
                         //code here
                      });
                      

                      🙂

                      T 1 Reply Last reply Reply Quote 0
                      • T
                        tminimax @paul53 last edited by

                        @paul53 danke perfekt - super!

                        1 Reply Last reply Reply Quote 0
                        • T
                          tminimax @ticaki last edited by

                          @ticaki danke perfekt - super!

                          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

                          609
                          Online

                          31.6k
                          Users

                          79.6k
                          Topics

                          1.3m
                          Posts

                          5
                          18
                          386
                          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