Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Gelöst: Fehler im Script

    NEWS

    • 15. 05. Wartungsarbeiten am ioBroker Forum

    • Monatsrückblick - April 2025

    • Minor js-controller 7.0.7 Update in latest repo

    Gelöst: Fehler im Script

    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      michihorn last edited by michihorn

      Hallo, ich suche mir gerade einen "heissen"
      Mein Script siht wie folgt aus:

      const idLichtsensor = 'hm-rpc.2.00185BE98B3FCA.1.ILLUMINATION' //Wetterstation
      const idWind = 'hm-rpc.2.00185BE98B3FCA.1.WIND_SPEED';  //Wetterstation
      const idRegen = 'hm-rpc.2.00185BE98B3FCA.1.RAINING'  //Wetterstation
      const idLux = '0_userdata.0.Garten.Tahoma.Markise.SWLux'; // Auslösewert Lux
      const idSWWind = '0_userdata.0.Garten.Tahoma.Markise.SWWind'; // Auslösewert Wind
      const id_RolloL = 'tahoma.0.devices.Markisse_Links.states.core:DeploymentState'
      const id_RolloR = 'tahoma.0.devices.Markisse_Rechts.states.core:DeploymentState'
      const id_Auto = "0_userdata.0.Garten.Tahoma.Markise.Auto"
      const id_Hand = "0_userdata.0.Garten.Tahoma.Markise.Hand"
      
      var timer = null;
      var text
      //EINFAHREN Bewölkung
      subscribe(idLichtsensor, function (dp) {
          if (dp.state.val < getState(idLux).val) {
              if (!timer) {
                    timer = setTimeout(function () {
                      timer = null;
                      log('\u2601\ufe0f  Lux ' + getState(idLichtsensor).val + " " + formatDate(dp.state.lc, 'hh:mm:ss' + " - " + "L " + getState(id_RolloL).val + " - R " + getState(id_RolloR).val));
                      if ((getState(id_RolloL).val == 100) && (getState(id_RolloR).val == 100) && (getState(id_Auto).val == true)) {
                          setState(id_RolloL, 0);
                         setTimeout(function() {setState(id_RolloR, 0);}, 20000);
                          log("Markisse eingefahren")
                          text = '\u2600\ufe0f  *Bewölkung*\n Markise EINGEFAHREN'
                          //createEventlog("Markise", text);
                          WhatsAppBot([0], text);
                      }
                  }, 10000);
              }
          } else {
              // Sonnig. Falls timer läuft = stopp
              if (timer) {
                  clearTimeout(timer);
                  timer = null;
              }
          }
      });
      

      Ich bekomme im LOG folgenden Fehler:

      16:42:39.664	info	javascript.0 (3954) script.js.HAUS.Markiese.EINFAHREN_Bewölkung: ☁️ Lux 5282 16:42:29 - L 100 - R 100
      16:42:39.664	info	javascript.0 (3954) script.js.HAUS.Markiese.EINFAHREN_Bewölkung: Markisse eingefahren
      16:42:39.666	info	javascript.0 (3954) script.js.HAUS.Markiese.EINFAHREN_Bewölkung: exec is not available. Please enable "Enable Exec" option in instance settings
      16:42:39.672	error	javascript.0 (3954) script.js.HAUS.Markiese.EINFAHREN_Bewölkung: TypeError: Cannot read properties of undefined (reading 'includes')
      16:42:39.673	error	javascript.0 (3954) at Immediate.<anonymous> (script.js.HAUS.Markiese.EINFAHREN_Bewölkung:67:28)
      16:42:39.888	error	host.iobroker-pi Caught by controller[0]: at Immediate.<anonymous> (script.js.HAUS.Markiese.EINFAHREN_Bewölkung:67:28)
      

      Die Verzögerung habe ich eingebaut, weil Tahoma offenbar zwischen zwei Befehlen etwas Zeit braucht.

      setTimeout(function() {setState(id_RolloR, 0);}, 20000);
      

      In der Java Instance ist Excec "enable"

      Brauche mal einen Tip
      Michael

      paul53 C 2 Replies Last reply Reply Quote 0
      • paul53
        paul53 @michihorn last edited by

        @michihorn
        Was passiert in Zeile 26?

        M 1 Reply Last reply Reply Quote 0
        • C
          Chrunchy @michihorn last edited by Chrunchy

          @michihorn in Zeile 23 und 24 fehlt ein Semikolon am Ende, oder?

          OK, da fehlen wohl noch ein paar mehr als nur in den zwei Zeilen.

          OliverIO 1 Reply Last reply Reply Quote 0
          • OliverIO
            OliverIO @Chrunchy last edited by

            @chrunchy sagte in Fehler im Script:

            in Zeile 23 und 24 fehlt ein Semikolon am Ende, oder?

            ist zwar empfohlen, aber bei javascript kein muss
            nur bei ein paar bestimmten befehlen wird es benötigt
            https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#automatic_semicolon_insertion
            also hier nicht wirklich ein fehler

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

              @paul53 Dort wird ein Script von "https://www.kreyenborg.koeln/whatsapp-nachrichten-mit-iobroker-versenden/" verarbeitet, dass mehrere Whatsapp Adressaten anschreiben kann und auch seit langen funktioniert.

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

                @michihorn
                Die Fehlermeldungen werden durch dieses globale Skript verursacht, denn nur das enthält "exec" und "includes".

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

                  @paul53 Okay Danke, ich werde das mal "rausnehmen"
                  Edit: Ja das war es. Danke!

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

                  Support us

                  ioBroker
                  Community Adapters
                  Donate

                  928
                  Online

                  31.6k
                  Users

                  79.4k
                  Topics

                  1.3m
                  Posts

                  javascript
                  4
                  7
                  180
                  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