Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Variable nach xx Minuten zurücksetzen

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Variable nach xx Minuten zurücksetzen

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

      Hallo zusammen

      ich habe ein Variable die bei einer bestimmten Aktion auf true gesetzt wird.

      Jetzt soll dies Variable nach 30 Minuten wieder false werden.

      Wie kann ich das realisieren?

      Gruß Norbert

      1 Reply Last reply Reply Quote 0
      • blauholsten
        blauholsten Developer last edited by

        var timer;
        
        function xxx()
        
        setState('yyy', true)
                if (!timer) {
                       timer = setTimeout(function () {
                   timer = null;
                   setState('yyy', false)
                }, 1800000);
        

        2858_view_tunein.txt

        1 Reply Last reply Reply Quote 0
        • N
          nobse last edited by

          Hallo blauholsten

          vielen Dank funktioniert super.

          Gruß Norbert

          1 Reply Last reply Reply Quote 0
          • P
            pix last edited by

            Hallo,

            oder so:

            on({ 
                id: idVariable, // Variable wird überwacht (idVariable muss natürlich im Skript oben deklariert werden)
                change: 'ne'
            }, function (obj) {
                if (obj.newState.val === true ) { // wenn Variable auf true gesetzt wird
                    setStateDelayed(idVariable, false, 30 * 60 * 1000); // nach 30min zurücksetzen
                }
            });
            
            

            oder noch kürzer müsste auch gehen (nicht probiert :roll: )

            on({"javascript.0.Variable",  // so gehts auch statt id
                val: true
            }, setStateDelayed("javascript.0.Variable", false, 30 * 60 * 1000); // nach 30min zurücksetzen
            );
            
            

            Gruß,

            Pix
            5373_img_4513.jpg

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

            Support us

            ioBroker
            Community Adapters
            Donate

            808
            Online

            31.7k
            Users

            79.7k
            Topics

            1.3m
            Posts

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