Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Telegram: Reihenfolge der empfangenen Nachrichten stimmt nicht

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Telegram: Reihenfolge der empfangenen Nachrichten stimmt nicht

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

      Hallo,

      folgendes Script:

      ! ````
      ! var anzahl = getState('javascript.0.Status.DWD_Anzahl').val;
      var vText = "";

      if (anzahl === 0) {
          sendTo('telegram', "Wetterwarnung Anzahl: 0");   
      } else if (anzahl >= 1) {
          sendTo('telegram', "Wetterwarnung Anzahl: " + anzahl);   
      

      ! if (anzahl === 1) {
      vText = "1: " + getState("dwd.0.warning.headline").val + "\n";
      vText = vText + getState("dwd.0.warning.description").val + "\n";
      vText = vText + "von " + getState("dwd.0.warning.begin").val + " Uhr \n";
      vText = vText + "bis " + getState("dwd.0.warning.end").val + " Uhr";
      sendTo('telegram', vText);
      }
      if (anzahl >= 2) {
      for (x=2; x <= anzahl; x++) {
      vText = x + ": " + getState("dwd.0.warning" + x-1 + ".headline").val + "\n";
      vText = vText + getState("dwd.0.warning" + x-1 + ".description").val + "\n";
      vText = vText + "von " + getState("dwd.0.warning" + x-1 + ".begin").val + " Uhr \n";
      vText = vText + "bis " + getState("dwd.0.warning" + x-1 + ".end").val + " Uhr";
      sendTo('telegram', vText);
      }
      }
      }
      ! ````

      Warum wird das Script nicht von oben nach unten abgearbeitet.

      Also zuerst die Nachricht "Wetterwarnung Anzahl …"

      Und dann die Meldung.

      Sondern es kommt:

      • erst die Meldung und dann die Anzahl

      Frage:

      Warum ist das so bzw. wie kann man das ändern.

      P.S.

      delay, Timeout oder das globale Script (wait -> aus dem Internet) klappt nicht.

      mfg

      Dieter

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

        Die nachfolgenden Befehle müssen in einer Callback-Funktion ausgeführt werden:

        ...
            } else {
                sendTo('telegram', "Wetterwarnung Anzahl: " + anzahl, function() {
                    if (anzahl === 1) {
                    ...
                });   
        
        
        1 Reply Last reply Reply Quote 0
        • bahnuhr
          bahnuhr Forum Testing Most Active last edited by

          habs geändert.

              var anzahl = getState('javascript.0.Status.DWD_Anzahl').val;
              var vText = "";
          
              if (anzahl === 0) {
                  sendTo('telegram', "Wetterwarnung Anzahl: 0");   
              } else {
                  log (anzahl);
                  sendTo('telegram', "Wetterwarnung Anzahl: " + anzahl, function () { 
          
                      if (anzahl === 1) {
                          vText = "1: " + getState("dwd.0.warning.headline").val + "\n";
                          vText = vText + getState("dwd.0.warning.description").val + "\n";
                          vText = vText + "von " + getState("dwd.0.warning.begin").val + " Uhr \n";
                          vText = vText + "bis " + getState("dwd.0.warning.end").val + " Uhr";
                          sendTo('telegram', vText);   
                      }
                  });
              }
          
          

          Jetzt kommt gar keine Nachricht mehr an.

          mfg

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

            Also, ich bekomms nicht hin.

            Könnte ihr doch nochmal mein Script im Beitrag 1 vorher anschauen.

            mfg

            Dieter

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

            Support us

            ioBroker
            Community Adapters
            Donate

            887
            Online

            31.7k
            Users

            79.8k
            Topics

            1.3m
            Posts

            2
            4
            589
            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