Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. *gelöst*Hilfe bei Javascript Bool setzen

    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

    *gelöst*Hilfe bei Javascript Bool setzen

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

      Ich habe ein Problem bei einem Script das ich verändern möchte.
      Aber dabei erhalte ich immer eine Fehlermeldung:

      alexa2.0	2020-09-27 10:02:35.219	error	(28199) Datatype for Echo-Devices.G2A0P30774060LLE.Routines.11242dac-bf4b-4ab1-9521-37fdf5dae51d differs from expected, ignore state change! Please write correct datatype (boolean)
      javascript.0	2020-09-27 10:02:35.185	warn	(425) at processImmediate (internal/timers.js:456:21)
      javascript.0	2020-09-27 10:02:35.185	warn	(425) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5384:37)
      javascript.0	2020-09-27 10:02:35.185	warn	(425) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:472:25)
      javascript.0	2020-09-27 10:02:35.184	warn	(425) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1055:38)
      javascript.0	2020-09-27 10:02:35.184	warn	(425) at Object.<anonymous> (script.js.Klingel.Klingel3:9:5)
      javascript.0	2020-09-27 10:02:35.183	warn	(425) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1358:20)
      javascript.0	2020-09-27 10:02:35.148	warn	(425) You are assigning a string to the state "alexa2.0.Echo-Devices.G2A0P30774060LLE.Routines.11242dac-bf4b-4ab1-9521-37fdf5dae51d" which expects a boolean. Please fix your code to use a boolean or
      

      Das ist das betroffene Script (zumindest der zu ändernde Teil:

      var sperre = false;  //verhindert das doppeltes Drücken das Script stoppt
      var timeout1, timeout2, timeout3, timeout4, timeout5, timeout6, timeout7, timeout8, timeout9, timeout10, timeout11;
      var fs = require('fs');
      
      
      
      on({id: 'sonoff.0.Eingang.POWER2', val: true}, function (obj) {
        if(!sperre) {
          sperre = true;
          setState("alexa2.0.Echo-Devices.G2A0P30774060LLE.Routines.11242dac-bf4b-4ab1-9521-37fdf5dae51d", 'true'); //Klingelt 15 Sekunden auf dem Telefon
           // Speichert das erste Bild bei Klingeln
      
      

      Ich kenne mich mit Javascript nur sehr schlecht aus und stelle hier sicher eine lächerliche Frage, aber wie kann ich den Datenpunkt auf Boolean ändern?
      Ich habe schon mit val experimentiert, aber das scheint für mich erfolglos zu laufen.
      Kann mir jemand bitte weiterhelfen.

      paul53 Chaot coyote 3 Replies Last reply Reply Quote 0
      • paul53
        paul53 @Chaot last edited by

        @Chaot
        Ändere bei setState() 'true' in true.

        Chaot 1 Reply Last reply Reply Quote 1
        • Chaot
          Chaot @Chaot last edited by

          Problem gelöst.
          Manchmal baut man sich die Probleme eben selbst ein.
          Ich habe zwar eine Variable definiert, sie aber dann beim Abruf in Anführungszeichen gesetzt 😲

          1 Reply Last reply Reply Quote 0
          • coyote
            coyote Most Active @Chaot last edited by coyote

            @Chaot

            setState("alexa2.0.Echo-Devices.G2A0P30774060LLE.Routines.11242dac-bf4b-4ab1-9521-37fdf5dae51d", 'true'); //Klingelt 15 Sekunden auf dem Telefon
             // Speichert das erste Bild bei Klingeln
            

            Mach mal aus 'true' -> true ohne Hochkomma

            setState("alexa2.0.Echo-Devices.G2A0P30774060LLE.Routines.11242dac-bf4b-4ab1-9521-37fdf5dae51d", true); //Klingelt 15 Sekunden auf dem Telefon
             // Speichert das erste Bild bei Klingeln
            

            EDIT: zu spät 😊

            1 Reply Last reply Reply Quote 1
            • Chaot
              Chaot @paul53 last edited by

              @paul53 Danke dir - die Version klappt auch
              Ich wusste doch das mit den Spezialisten hier das schnell geht.👏 👍

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

              Support us

              ioBroker
              Community Adapters
              Donate

              824
              Online

              31.8k
              Users

              80.0k
              Topics

              1.3m
              Posts

              javascript
              3
              5
              244
              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