Skip to content
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Logo
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. Gelöst: Auslöser ermitteln

NEWS

  • Wartung am 15.11. – Forum ab 22:00 Uhr nicht erreichbar
    BluefoxB
    Bluefox
    12
    2
    237

  • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?
    apollon77A
    apollon77
    48
    3
    8.0k

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    13
    1
    1.7k

Gelöst: Auslöser ermitteln

Gelöst: Auslöser ermitteln

Scheduled Pinned Locked Moved Skripten / Logik
javascript
5 Posts 2 Posters 230 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michihorn
    wrote on last edited by michihorn
    #1

    Hallo mit folgenden kleine Script von Paul53 kann ich alle "true" gegen "false austauschen.
    Ich möchte gerne noch den Namen des Datensatz ermitteln der von true auf false gesetzt wurde

    const ids = $("iot.*.services.custom_Heimreise");
    
    function cntDel() {
        ids.each(function (id, i) {
            if (getState(id).val == 'true') 
            setState(id,"false")
        });
    };
    cntDel(); // Skriptstart
    ids.on(cntDel);
    

    Michael

    paul53P 1 Reply Last reply
    0
    • M michihorn

      Hallo mit folgenden kleine Script von Paul53 kann ich alle "true" gegen "false austauschen.
      Ich möchte gerne noch den Namen des Datensatz ermitteln der von true auf false gesetzt wurde

      const ids = $("iot.*.services.custom_Heimreise");
      
      function cntDel() {
          ids.each(function (id, i) {
              if (getState(id).val == 'true') 
              setState(id,"false")
          });
      };
      cntDel(); // Skriptstart
      ids.on(cntDel);
      

      Michael

      paul53P Offline
      paul53P Offline
      paul53
      wrote on last edited by paul53
      #2

      @michihorn sagte: alle "true" gegen "false austauschen

      Wirklich als String? Sonst:

      const ids = $("iot.*.services.custom_Heimreise");
       
      ids.each(function(id) { // Skriptstart
          if(getState(id).val) setState(id, false);
      });
      
      ids.on(function(dp) {
          if(dp.state.val) {
              setState(dp.id, false);
              log(dp.common.name);
          }
      });
      

      Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
      Produktiv: RPi 2 mit S.USV, HM-MOD-RPI und SLC-USB-Stick mit root fs

      M 1 Reply Last reply
      0
      • paul53P paul53

        @michihorn sagte: alle "true" gegen "false austauschen

        Wirklich als String? Sonst:

        const ids = $("iot.*.services.custom_Heimreise");
         
        ids.each(function(id) { // Skriptstart
            if(getState(id).val) setState(id, false);
        });
        
        ids.on(function(dp) {
            if(dp.state.val) {
                setState(dp.id, false);
                log(dp.common.name);
            }
        });
        
        M Offline
        M Offline
        michihorn
        wrote on last edited by
        #3

        @paul53 sagte in Auslöser ermitteln:

        @michihorn sagte: alle "true" gegen "false austauschen

        Wirklich als String? Sonst:

        const ids = $("iot.*.services.custom_Heimreise");
         
        ids.each(function(id) { // Skriptstart
            if(getState(id).val) setState(id, false);
        });
        
        ids.on(function(dp) {
            if(dp.state.val) {
                setState(dp.id, false);
                log(dp.common.name);
            }
        });
        

        Ja String, aber nur weil ich nicht weiß wie ich im IOT einen Boolschen Wert über geben kann.

        https://service.iobroker.in/v1/iotService?service=custom_Anreise&key=xxxxxxxxx&user=michi.xhxxrn%40gmail.com&data=<SOME_TEXT>
        
        paul53P 1 Reply Last reply
        0
        • M michihorn

          @paul53 sagte in Auslöser ermitteln:

          @michihorn sagte: alle "true" gegen "false austauschen

          Wirklich als String? Sonst:

          const ids = $("iot.*.services.custom_Heimreise");
           
          ids.each(function(id) { // Skriptstart
              if(getState(id).val) setState(id, false);
          });
          
          ids.on(function(dp) {
              if(dp.state.val) {
                  setState(dp.id, false);
                  log(dp.common.name);
              }
          });
          

          Ja String, aber nur weil ich nicht weiß wie ich im IOT einen Boolschen Wert über geben kann.

          https://service.iobroker.in/v1/iotService?service=custom_Anreise&key=xxxxxxxxx&user=michi.xhxxrn%40gmail.com&data=<SOME_TEXT>
          
          paul53P Offline
          paul53P Offline
          paul53
          wrote on last edited by
          #4

          @michihorn sagte: Ja String,

          Dann muss mit "true" verglichen und "false" gesetzt werden.

          Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
          Produktiv: RPi 2 mit S.USV, HM-MOD-RPI und SLC-USB-Stick mit root fs

          M 1 Reply Last reply
          0
          • paul53P paul53

            @michihorn sagte: Ja String,

            Dann muss mit "true" verglichen und "false" gesetzt werden.

            M Offline
            M Offline
            michihorn
            wrote on last edited by michihorn
            #5

            @paul53 sagte in Auslöser ermitteln:

            @michihorn sagte: Ja String,

            Dann muss mit "true" verglichen und "false" gesetzt werden.

            Ja das ist der Plan.
            Das Projekt soll eine Anwesenheitüberwachung für meine 3 Familienmitglieder im Geo Umkreis von 500 Meter machen, das klappt auch. Ich habe zwei weitere Dienste im IOT hinterlegt "Ankunft" triggert an der Grenze zu Holland und schaltet schon mal den Kühlschrank im Ferienhaus ein, stellt die Heizung/Klima auf 21Grad. 1h 20 min reichen aus.
            Ein weiter Dienst heisst Heimreise und der löst schon 30 km nach dem Verlassen des FH aus, Kühlschrank aus, Heizung auf 10 Grad. Der Hintergrund meiner Anfrage ist das Gegeseitige verriegeln von Anreise und Heimreise. Wenn ich z.B Heimreise soll falls meine Frau oder der Sohn noch vor Ort bleiben, nur mein Dienst "Anreise" auf false gesetzt werden.
            Das Script für Anreise sieht so aus:

            /*****GEOfancy ANREISE *****************************************
            **    Januar 2022
            **   IOT, EgiGeo
            **    (true), (false)
            **    erstellt: 24.01.22, 
            **    geändert: 14.06.23
            ***********************************************************************/
            var logging = true;
            const idFrigo = "tuya.0.bfce754681c6e2c8faowag.2"
            const idMedia = "tuya.0.bf292a4c8b62843697ntvv.1"
            const idTempIn = "tuya.0.73103057e868e768284a.3"
            const idHeizung = "tuya.0.73103057e868e768284a.2"
            const idAirCo = "daikin.0.control.power"
            const idAW = "0_userdata.0.Giethoorn.AW.AW"
            const ids = $('iot.*.services.custom_Anreise');
            const idCnt = "0_userdata.0.Giethoorn.AW.Anreise"
            var text
            
            function cntAnreise() {
                let cnt = 0;
                ids.each(function (id, i) {
                    if (getState(id).val == 'true') cnt++;
                });
                setState(idCnt, cnt, true);
                if (getState(idCnt).val >= 1) {
                    log("Anreise erkannt")
                    setState(idFrigo, true)
                    setState(idMedia, true)
                    setState(idHeizung, 22)
                    text = '\ud83d\ude98  Anreise von  🇩🇪  nach  🇳🇱  erkannt '
                    createEventlog("GTHRN", text)
                    if (logging) sendTo('whatsapp-cmb.0', 'send', { text, phone: '+491xxxxx' });
                    if ((getState(idTempIn).val >= 30)) {
                        setState(idAirCo, true)
                }
                }
            };
            cntAnreise(); // Skriptstart
            ids.on(cntAnreise);
            

            EDIT: Anbei der Objektbaum vom IOT
            Screenshot 2023-10-16 152935.png
            Als Lösung funktioniert nun folgendes Script:

            /*****GEOfancy ANREISE *****************************************
            **    Januar 2022
            **   IOT, EgiGeo
            **    (true), (false)
            **    erstellt: 24.01.22, 
            **    geändert: 14.06.23
            ***********************************************************************/
            var logging = true;
            const idFrigo = "tuya.0.bfce754681c6e2c8faowag.2"
            const idMedia = "tuya.0.bf292a4c8b62843697ntvv.1"
            const idTempIn = "tuya.0.73103057e868e768284a.3"
            const idHeizung = "tuya.0.73103057e868e768284a.2"
            const idAirCo = "daikin.0.control.power"
            const ids = $('iot.*.services.custom_Anreise');
            const idCnt = "0_userdata.0.Giethoorn.AW.Anreise"
            var text
            
            function cntAnreise() {
                let cnt = 0;
                ids.each(function (id, i) {
                    if (getState(id).val == 'true') cnt++;
                });
                setState(idCnt, cnt, true);
                if (getState(idCnt).val >= 1) {
                    log("Anreise erkannt")
                    setState(idFrigo, true)
                    setState(idMedia, true)
                    setState(idHeizung, 22)
                    text = '\ud83d\ude98  Anreise von  🇩🇪  nach  🇳🇱  erkannt '
                    createEventlog("GTHRN", text)
                    if (logging) sendTo('whatsapp-cmb.0', 'send', { text, phone: '+491xxxx149' });
                    if ((getState(idTempIn).val >= 30)) {
                        setState(idAirCo, true)
                    }
                }
            };
            cntAnreise(); // Skriptstart
            ids.on(cntAnreise);
            
            var newstring
            ids.each(function (id) { // Skriptstart
                if (getState(id).val)
                    setState(id, true);
            });
            
            ids.on(function (dp) {
                if (dp.state.val) {
                    log("INFO: " + dp.id);
                    var string = dp.id
                    newstring = string.replace("custom_Anreise", "custom_Heimreise");
                    log("Ergebnis: " + newstring)
                    setState(newstring, "false")
                }
            });
            

            Und für die Heimreise sieht das Script dann so aus.

            /*****GEOfancy HEIMREISE *****************************************
            **    Januar 2022
            **    IOT, EgiGeo
            **    (true), (false)
            **    erstellt: 24.01.22, 
            **    geändert: 14.6.23
            ***********************************************************************/
            
            var logging = true;
            const idFrigo = "tuya.0.bfce754681c6e2c8faowag.2"
            const idMedia = "tuya.0.bf292a4c8b62843697ntvv.1"
            const idTempIn = "tuya.0.73103057e868e768284a.3"
            const idHeizung = "tuya.0.73103057e868e768284a.2"
            const idAirCo = "daikin.0.control.power"
            const idAW = "0_userdata.0.Giethoorn.AW.AW"
            const ids = $("iot.*.services.custom_Heimreise");
            const idCnt = "0_userdata.0.Giethoorn.AW.Heimreise"
            var text
            
            function cntHeimreise() {
                let cnt = 0;
                ids.each(function (id, i) {
                    if (getState(id).val == 'true') cnt++;
                });
                setState(idCnt, cnt, true);
                if (getState(idCnt).val >= 1) {
                    log("Heimreise erkannt")
                    setState(idFrigo, false)
                    setState(idMedia, false)
                    setState(idHeizung, 10)
                    setState(idAirCo, false)
                    text = '\ud83d\ude98  Heimreise von  🇳🇱  nach  🇩🇪  erkannt '
                    createEventlog("GTHRN", text)
                    if (logging) sendTo('whatsapp-cmb.0', 'send', { text, phone: '+49xxxxx149' });
                }
            };
            cntHeimreise(); // Skriptstart
            ids.on(cntHeimreise);
            
            var newstring
            ids.each(function (id) { // Skriptstart
                if (getState(id).val)
                    setState(id, true);
            });
            
            ids.on(function (dp) {
                if (dp.state.val) {
                    log("INFO: " + dp.id);
                    var string = dp.id
                    newstring = string.replace("custom_Heimreise", "custom_Anreise");
                    log("Ergebnis: " + newstring)
                    setState(newstring, "false")
                }
            });
            
            
            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            Support us

            ioBroker
            Community Adapters
            Donate

            74

            Online

            32.4k

            Users

            81.3k

            Topics

            1.3m

            Posts
            Community
            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
            ioBroker Community 2014-2025
            logo
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Recent
            • Tags
            • Unread 0
            • Categories
            • Unreplied
            • Popular
            • GitHub
            • Docu
            • Hilfe