Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. [gelöst] Erstes Script

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    [gelöst] Erstes Script

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

      Hi.

      Ich versuche mein erstes Script zum Laufen zu bekommen, aber irgendwie komme ich auf keinen grünen Zweig…

      Zwei Werte sollen gelesen werden ein boolscher und eine Zahl, wenn der boolsche wert true ist ind die Zhal <100 dann soll eine Grafik angezeigt werden, sonst nicht.

      Javacript adapter läuft, Das script ist under global abgelegt

      createState('EntfeuchterVoll', false);
      
      on('hm-rpc.0.MEQ1478175:1.STATE', function(obj) 
      {
          if (obj.state.val === false)
          {
              setState('EntfeuchterVoll', false);
              log("EntfeuchterVoll: false");
          }
      });
      
      on('hm-rpc.0.MEQ1478175.2.CURRENT', function(obj) 
      {
          var schalter = getState('hm-rpc.0.MEQ1478175:1.STATE');
          if (obj.state.val  > 100)
          {
              setState('EntfeuchterVoll', false);
              log("EntfeuchterVoll: false");
          }
          else
          {
              if (schalter === true)
              {
                setState('EntfeuchterVoll', true);
                log("EntfeuchterVoll: true");
              }
              else
              {
                setState('EntfeuchterVoll', false);
                log("EntfeuchterVoll: flase");
      
              }
          }
      });
      
      

      Das icon wird mit dem basic image wgiget hergezeicht und über die sichtbarkeit gesteuert:

      die Obkejt ID ist:````
      javascript.0.scriptEnabled.global.Entfeuchter

      
      Ich bekomme im log noch nicht mal die Ausgaben aus dem script.
      
      Was mach ich falsch?
      1 Reply Last reply Reply Quote 0
      • htrecksler
        htrecksler Forum Testing last edited by

        @murphy:

        Das script ist under global abgelegt `

        Ich hab mir das Script noch nicht angesehen, aber das das Script unter Global liegt ist auf jeden Fall falsch.

        Scripte die dort liegen werden vor jedes Script vorangestellt.

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

          @murphy:

          Das script ist under global abgelegt `
          Das Skript kann überall erstellt werden, nur nicht unter global !
          @murphy:

          wenn der boolsche wert true ist ind die Zhal <100 dann soll eine Grafik angezeigt werden, sonst nicht. `
          Vorschlag:

          createState('EntfeuchterVoll', false, {type: 'boolean'});
          
          var schalter = getState('hm-rpc.0.MEQ1478175:1.STATE').val;
          var strom = getState('hm-rpc.0.MEQ1478175.2.CURRENT').val;
          
          function voll() {
             if(schalter && strom < 100) {
                setState('EntfeuchterVoll', true, true);
                log("EntfeuchterVoll: true");
             } else {
                setState('EntfeuchterVoll', false, true);
                log("EntfeuchterVoll: false");
             }
          }
          
          voll();  // Skriptstart
          
          on('hm-rpc.0.MEQ1478175:1.STATE', function(obj) {
             schalter = obj.state.val;
             voll();
          });
          
          on('hm-rpc.0.MEQ1478175.2.CURRENT', function(obj) {
             strom = obj.state.val;
             voll();
          });      
          
          
          1 Reply Last reply Reply Quote 0
          • M
            murphy last edited by

            Cool, vielen Dank 😄

            Kaum macht man es richtig, klappt es auch schon.

            Musste nur noch naheliegenderweise die Objekt ID auf````
            avascript.0.EntfeuchterVoll

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

            Support us

            ioBroker
            Community Adapters
            Donate

            674
            Online

            31.7k
            Users

            79.8k
            Topics

            1.3m
            Posts

            3
            4
            573
            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