Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Script geht zeitweise auf Pause

    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

    Script geht zeitweise auf Pause

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

      @Negalein
      Dein letzter Fehler sieht so aus als wenn der Parser keine Daten geliefert hat und deshalb Zeile 18 gescheitert ist

      Versuche bitte mal folgendes: 2 Zeilen vertauschen und gasStation auf array/object prüfen.

      var gasStation = JSON.parse(obj.state.val);
      if (typeof gasStation != 'object' || gasStation.length === 0) return;
      gasStation = gasStation.filter(g => g.prices.length > 0);
      if (gasStation.length === 0) return;
      

      EDIT: ups

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

        @ticaki sagte in Script geht zeitweise auf Pause:

        Versuche bitte mal folgendes: 2 Zeilen vertauschen und gasStation auf array/object prüfen.

        Danke
        Habs eingefügt/vertauscht und werde es die nächsten Tage beobachten.

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

          @Negalein
          hab editiert bitte beachten

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

            @ticaki sagte in Script geht zeitweise auf Pause:

            hab editiert bitte beachten

            Also

                var gasStation = JSON.parse(obj.state.val);
                gasStation = gasStation.filter(g => g.prices.length > 0);
                if (gasStation.length === 0) return;
            

            gegen

            var gasStation = JSON.parse(obj.state.val);
            if (typeof gasStation != 'object' || gasStation.length === 0) return;
            gasStation = gasStation.filter(g => g.prices.length > 0);
            if (gasStation.length === 0) return;
            

            tauschen

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

              @Negalein
              Jup, habs nochmal verbessert. Mache zwar viel mit Arrays, mußte aber bis dato noch nicht prüfen, ob es auch eines ist 🙂

              var gasStation = JSON.parse(obj.state.val);
              if (!Array.isArray(gasStation) || gasStation.length === 0) return;
              gasStation = gasStation.filter(g => g.prices.length > 0);
              if (gasStation.length === 0) return;
              
              Negalein 1 Reply Last reply Reply Quote 0
              • Negalein
                Negalein Global Moderator @ticaki last edited by

                @ticaki sagte in Script geht zeitweise auf Pause:

                habs nochmal verbessert

                Thx

                sigi234 1 Reply Last reply Reply Quote 0
                • sigi234
                  sigi234 Forum Testing Most Active @Negalein last edited by sigi234

                  @Negalein sagte in Script geht zeitweise auf Pause:

                  @ticaki sagte in Script geht zeitweise auf Pause:

                  habs nochmal verbessert

                  Thx

                  Kann man das Skript jetzt oben benutzen? Ist das das aktuelle.

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

                    @sigi234 sagte in Script geht zeitweise auf Pause:

                    Kann man das Skript jetzt oben benutzen? Ist das das aktuelle.

                    Ja, diese 4 Zeilen

                    var gasStation = JSON.parse(obj.state.val);
                    if (!Array.isArray(gasStation) || gasStation.length === 0) return;
                    gasStation = gasStation.filter(g => g.prices.length > 0);
                    if (gasStation.length === 0) return;
                    

                    statt diesen nehmen

                    var gasStation = JSON.parse(obj.state.val);
                    gasStation = gasStation.filter(g => g.prices.length > 0);
                    if (gasStation.length === 0) return;
                    
                    1 Reply Last reply Reply Quote 0
                    • AlCalzone
                      AlCalzone Developer @Negalein last edited by

                      @Negalein Du hast zwar inzwischen die Lösung, aber generell sollte man lieber Fehler abfangen, als Skripte mit Fehlern einfach neu zu starten 😉

                      Z 1 Reply Last reply Reply Quote 1
                      • Z
                        zanabria @AlCalzone last edited by

                        @AlCalzone
                        hallo habe aktuell auch das Problem, dass viele Scripte auf Pause gehen. Woran kann das liegen? Habe alles gecheckt und keinen Fehler gefunden. Das Run Sript wurde kopiert aus dem Pause Script und nur angepasst. Es scheint das Bessere zu sein, siehe Bild.
                        543a46d4-1b5a-40ec-ad68-dc3d81648b81-grafik.png

                        Ich habe mal die beiden Scripte angehängt.
                        Pause-Script.txt
                        Run-Script.txt.
                        Kann man mir hier weiterhelfen.
                        LG Zanabria

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

                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        711
                        Online

                        31.8k
                        Users

                        80.0k
                        Topics

                        1.3m
                        Posts

                        javascript
                        7
                        32
                        1316
                        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