Skip to content
  • Home
  • 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
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. Weiterverarbeiten der Stati des Ping Adapters

NEWS

  • Monatsrückblick Januar/Februar 2026 ist online!
    BluefoxB
    Bluefox
    18
    1
    656

  • Jahresrückblick 2025 – unser neuer Blogbeitrag ist online! ✨
    BluefoxB
    Bluefox
    18
    1
    5.7k

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    13
    1
    1.5k

Weiterverarbeiten der Stati des Ping Adapters

Scheduled Pinned Locked Moved Skripten / Logik
5 Posts 2 Posters 1.5k Views
  • 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.
  • PeoplesP Offline
    PeoplesP Offline
    Peoples
    wrote on last edited by
    #1

    Hi,

    ich möchte verschiedene Ip-Adressen bzw. deren Stati via Script auswerten und in Abhängigkeit des Status eine Variable setzen. Das ganze wollte ich mit folgendem Script machen, doch unabhängig vom hinterlegten Status (true/false) des Ping-Adapters im Objekte Baum wird die Variable immer auf false gesetzt.

    Vielleicht kann mir einer sagen wo mein Fehler ist.

    Danke Peoples

    createState('Netzwerk.GesamtStatus', false, {
        type: 'boolean',
        name: 'Netzwerkstatus',
        desc: 'Gesamtstatus Netzwerk'
    });
    var idState = 'javascript.0.Netzwerk.GesamtStatus'; // auf richtige Instanz achten
    
    schedule("* * * * *", function () {
    
        if(("ping.0.ioBroker-RasPi.192_168_1_1" === true) &&
           ("ping.0.ioBroker-RasPi.192_168_1_2" === true) &&
            ("ping.0.ioBroker-RasPi.192_168_1_3" === true)
        ){
            setState(idState, true);
            log ("a");
        }
        else{
            setState(idState, false);
            log ("b");
        }
    });
    
    

    Ich beantworte keine Fragen zu Themen via PN

    1 Reply Last reply
    0
    • paul53P Offline
      paul53P Offline
      paul53
      wrote on last edited by
      #2
          if(("ping.0.ioBroker-RasPi.192_168_1_1" === true) &&
             ("ping.0.ioBroker-RasPi.192_168_1_2" === true) &&
              ("ping.0.ioBroker-RasPi.192_168_1_3" === true)
              ) {
      

      –>

          if(getState("ping.0.ioBroker-RasPi.192_168_1_1").val === true && getState("ping.0.ioBroker-RasPi.192_168_1_2").val === true && getState("ping.0.ioBroker-RasPi.192_168_1_3").val === true) {
      
      

      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

      1 Reply Last reply
      0
      • paul53P Offline
        paul53P Offline
        paul53
        wrote on last edited by
        #3

        Da der Ping-Adapter ohnehin zyklisch arbeitet, sollte man nicht mit einem weiteren Zyklus (schedule) abfragen, sondern besser auf Änderung triggern:

        var idState = 'javascript.0.Netzwerk.GesamtStatus'; // auf richtige Instanz achten
        
        var ping1 = getState("ping.0.ioBroker-RasPi.192_168_1_1").val;
        var ping2 = getState("ping.0.ioBroker-RasPi.192_168_1_2").val;
        var ping3 = getState("ping.0.ioBroker-RasPi.192_168_1_3").val;
        
        function check() {
            if(ping1 && ping2 && ping3) {
                setState(idState, true);
                log ("a");
            } else { 
                setState(idState, false);
                log ("b");
            }
        }
        
        check();  // script start
        
        on("ping.0.ioBroker-RasPi.192_168_1_1", function(dp) {
            ping1 = dp.state.val;
            check();
        });
        
        on("ping.0.ioBroker-RasPi.192_168_1_2", function(dp) {
            ping2 = dp.state.val;
            check();
        });
        
        on("ping.0.ioBroker-RasPi.192_168_1_3", function(dp) {
            ping3 = dp.state.val;
            check();
        });
        
        

        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

        1 Reply Last reply
        0
        • PeoplesP Offline
          PeoplesP Offline
          Peoples
          wrote on last edited by
          #4

          Perfekt! Danke!

          Eine weitere Frage habe ich jedoch dazu noch:

          Kann man auch die "Inhalte / Unterpunkte" eines "Channels" sprich die einzelnen Einträge von "ping.0.ioBroker-RasPi" auslesen?

          So könnte ich das dann in einer foreach - Schleife automatisieren und bräuchte nicht bei jedem neuen Eintrag im Ping-Adapter das Script anpassen.

          Ich beantworte keine Fragen zu Themen via PN

          1 Reply Last reply
          0
          • paul53P Offline
            paul53P Offline
            paul53
            wrote on last edited by
            #5

            Das müsste mit einem Selektor gehen:

            var idState = 'javascript.0.Netzwerk.GesamtStatus'; // auf richtige Instanz achten
            
            schedule("* * * * *", function () {
                var allpings = true;
                $('channel[id=ping.0.ioBroker-RasPi*]').each(function(id, i) {
                    if(!getState(id).val) allpings = false;
                    log(id + ': ' + allpings);
                });
                setState(idState, allpings);
            });
            

            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

            1 Reply Last reply
            0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            Support us

            ioBroker
            Community Adapters
            Donate

            533

            Online

            32.7k

            Users

            82.6k

            Topics

            1.3m

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

            • Don't have an account? Register

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