Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. [gelöst]Skript soll nur EINMAL auslösen: wie?

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    [gelöst]Skript soll nur EINMAL auslösen: wie?

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

      Ich habe mir einen Pushover Alarm angelegt, wen mein Staubsauger "hängt". Hier das Skript:

      // ##################################
      // Deklarationen
      // ##################################
      
      var IDxiaomiFehler ="mihome-vacuum.1.info.error"/*Error*/;
      
      // ##################################
      // Programm
      // ##################################
      
      on({id: IDxiaomiFehler}, function (data) {
      
      var fehlerWert = getState("mihome-vacuum.1.info.error").val;
      
          if (fehlerWert !== 0) {
      
          sendTo("pushover.0", {
              message:  'FEHLER', // mandatory - your text message
              title:    'Xiaomi UNTEN', // optional  - your message's title, otherwise your app's name is used
              sound:    'spacealarm',     // optional  - the name of one of the sounds supported by device clients to override the user's default sound choice
                                        //    pushover, bike, bugle, cashregister, classical, cosmic, falling,
                                        //    gamelan, incoming, intermission, magic, mechanical, pianobar, siren,
                                        //    spacealarm, tugboat, alien, climb, persistent, echo, updown, none
              priority: 1,          // optional
                                        //    -1 to always send as a quiet notification,
                                        //    1 to display as high-priority and bypass the user's quiet hours, or
                                        //    2 to also require confirmation from the user
          });        
      }                          
      });
      

      Soweit, so gut.

      Allerdings löst es jetzt bei jeder Aktualisierung des Objekts "mihome-vacuum.1.info.error" aus, also quasi alle 30 sec. Das soll so aber nicht sein. EINE pushover Information reicht mir.

      Meine Frage: wie löse ich das im Skript, daß ich also nur EINMAL beim ersten Auftritt des Fehlers eine Nachricht erhalte und dann nicht mehr.

      Danke für die Hilfe!

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

        Hallo Skorpil,

        Schnell aus der Kaffeepause vom Usertreffen:

        Lass mal var fehlerWert weg und ändere die if Abfrage in

        if (data.state.val !==0 && data.oldState.val ===0) {
        

        Also neuer Wert ist Fehler und alter Wert ist kein Fehler.

        Gruß

        Pix

        1 Reply Last reply Reply Quote 0
        • Dutchman
          Dutchman Developer Most Active Administrators last edited by

          due loest wohl aus bei any, mach mal:

          on({id: IDxiaomiFehler, , change: "ne"}, function (data)

          dan sollte er es nur bei aenderung machen

          Edit: Pix war schneller 🙂 Nu ausloesen script sollte auch nur bei aenderung variable ?

          1 Reply Last reply Reply Quote 0
          • S
            skorpil last edited by

            Pix, schneller als der Schall! Vielen Dank! Und, Gruß an alle Beim Usertreffen[emoji23]

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

              Dutchman hat natürlich Recht, aber meine Lösung ließ sich besser in tapatalk tippeln…

              Wenn du in der on()-Funktion das "id:" weglässt, dann ist die Auslösung auf change ne gestellt.

              Also:

              on(IDxiaomiFehler, function(data) {
              ````ist das gleiche wie
              

              on({id:IDxiaomiFehler, change: 'ne'}, function(data) {

              
              Pix
              1 Reply Last reply Reply Quote 0
              • S
                skorpil last edited by

                Daaanke an alle. Läuft!

                1 Reply Last reply Reply Quote 0
                • Dutchman
                  Dutchman Developer Most Active Administrators last edited by

                  @skorpil:

                  Daaanke an alle. Läuft! `

                  Super, schreibe bitte gelöst in den thread Title

                  @Pix,

                  Danke kannte ich noch nicht wieder was gelernt

                  Sent from my iPhone using Tapatalk

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

                  Support us

                  ioBroker
                  Community Adapters
                  Donate

                  800
                  Online

                  31.7k
                  Users

                  79.8k
                  Topics

                  1.3m
                  Posts

                  3
                  7
                  788
                  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