Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JS / connection-status der linkeddevices anzeigen

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    JS / connection-status der linkeddevices anzeigen

    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      Roland Ambrosch last edited by Roland Ambrosch

      Hi,

      nachdem ich immer nur mitlese, mal was sinnvoll zu Teilendes:
      Falls jemand auch linkeddevices verwendet und gerne in VIS eine Übersicht hätte ob irgendwelche verlinkten Geräte aus zwave2, sonoff oder shelly Probleme machen, kann gerne mein Script verwenden.

      Der Output sieht dann so aus:
      a9f300f0-3123-4e3f-82ad-1b9f08c08de9-image.png

      var StatusHTMLzwave = 'javascript.0.zwave2NodeStatus';
      var StatusHTMLshelly = 'javascript.0.shellyNodeStatus';
      var StatusHTMLsonoff = 'javascript.0.sonoffNodeStatus';
      var StatusHTMLlinkeddevices = 'javascript.0.linkeddeviceNodeStatus';
      
      createState(StatusHTMLzwave, false, {
          read: true,
          write: true,
          type: 'string',
          name: 'Status aller IoT Sensoren/Aktoren als HTML',
          desc: 'Status aller IoT Sensoren/Aktoren als HTML'
      });
      
      
      createState(StatusHTMLshelly, false, {
          read: true,
          write: true,
          type: 'string',
          name: 'Status aller IoT Sensoren/Aktoren als HTML',
          desc: 'Status aller IoT Sensoren/Aktoren als HTML'
      });
      
      
      createState(StatusHTMLsonoff, false, {
          read: true,
          write: true,
          type: 'string',
          name: 'Status aller IoT Sensoren/Aktoren als HTML',
          desc: 'Status aller IoT Sensoren/Aktoren als HTML'
      });
      createState(StatusHTMLlinkeddevices, false, {
          read: true,
          write: true,
          type: 'string',
          name: 'Status aller IoT Sensoren/Aktoren als HTML',
          desc: 'Status aller IoT Sensoren/Aktoren als HTML'
      });
      function checkIoT(){
          /////////////////////ZWAVE
          // Get a list of all nodes under the Z-Wave2 root
          var nodes = $('zwave2.0.*.ready');
      
          // Initialize the HTML string
          let itemListHTML = '<h1>Z-Wave2 Node Status</h1>';
      
          nodes.each(function (id, i) {
              const nodeReady = getState(id);
              // Determine the circle color based on the "ready" state
              const circleClass = nodeReady.val ? 'green' : 'red';
      
              // Add the item to the HTML list
              itemListHTML += `
                  <div class="item">
                      <div class="circle ${circleClass}"></div>
                      <span>${id}: ${nodeReady.val ? 'Ready' : 'Not Ready'}</span>
                  </div>
              `;
          });
      
          // Create or update an HTML state in ioBroker to display the list
          setState(StatusHTMLzwave, itemListHTML, true);
          /////////////////////SONOFF
          // Get a list of all nodes under the Z-Wave2 root
          nodes = $('sonoff.0.*.alive');
      
          // Initialize the HTML string
          itemListHTML = '<h1>SONOFF Node Status</h1>';
      
          nodes.each(function (id, i) {
              const nodeReady = getState(id);
              // Determine the circle color based on the "ready" state
              const circleClass = nodeReady.val ? 'green' : 'red';
      
              // Add the item to the HTML list
              itemListHTML += `
                  <div class="item">
                      <div class="circle ${circleClass}"></div>
                      <span>${id}: ${nodeReady.val ? 'Ready' : 'Not Ready'}</span>
                  </div>
              `;
          });
      
          // Create or update an HTML state in ioBroker to display the list
          setState(StatusHTMLsonoff, itemListHTML, true);
          /////////////////////SHELLY
          // Get a list of all nodes under the Z-Wave2 root
          nodes = $('shelly.0.*.online');
      
          // Initialize the HTML string
          itemListHTML = '<h1>SHELLY Node Status</h1>';
      
          nodes.each(function (id, i) {
              const nodeReady = getState(id);
              // Determine the circle color based on the "ready" state
              const circleClass = nodeReady.val ? 'green' : 'red';
              // Add the item to the HTML list
              itemListHTML += `
                  <div class="item">
                      <div class="circle ${circleClass}"></div>
                      <span>${id}: ${nodeReady.val ? 'Ready' : 'Not Ready'}</span>
                  </div>
              `;
          });
          // Create or update an HTML state in ioBroker to display the list
          setState(StatusHTMLshelly, itemListHTML, true);
          /////////////////////LINKED DEVICES
          nodes = $('linkeddevices.0.*');
          // Initialize the HTML string
          itemListHTML = '';
      
          nodes.each(function (id, i) {
              var dPoint = getObject(id,"true");
              if (dPoint && dPoint.common) {
                  var settings = dPoint.common.custom;
                  //check if it is a linkeddevice
                  var dpCustom = false;
                  if(settings)
                      if(settings['linkeddevices.0'])
                          if(settings['linkeddevices.0'].enabled)
                              dpCustom = settings['linkeddevices.0'].enabled;
                 
                  if(dpCustom) {
                      //explode the parentid
                      var parentid = settings['linkeddevices.0'].parentId ? settings['linkeddevices.0'].parentId : "";
                      if(parentid == "")
                          return;
                      const parts = parentid.split('.');
                      if (parts.length >= 3) {
                          //extract the parentState
                          const parentState = parts.slice(0, 3).join('.');
                          if(parts[0] == 'zwave2')
                          {
                              const nodeReady = getState(parentState + '.ready');
                              // Determine the circle color based on the "ready" state
                              const circleClass = nodeReady.val ? 'green' : 'red';
                              // Add the item to the HTML list
                              itemListHTML += `
                                  <div class="item">
                                      <div class="circle ${circleClass}"></div>
                                      <span>${id}: ${nodeReady.val ? 'Ready' : 'Not Ready'}</span>
                                  </div>
                              `;
                          }
                      } 
                  }
              }
          });
          // Create or update an HTML state in ioBroker to display the list
          setState(StatusHTMLlinkeddevices, itemListHTML, true);
          
      }
      checkIoT();
      schedule('* * * * *',checkIoT);
      
      
      
      
      
      
      arteck 1 Reply Last reply Reply Quote 0
      • arteck
        arteck Developer Most Active @Roland Ambrosch last edited by

        @roland-ambrosch ich will dir keinen dämpfer verpassen aber.. es gibt einen adapter der das auch mach..

        device-watcher

        R 1 Reply Last reply Reply Quote 0
        • R
          Roland Ambrosch @arteck last edited by

          @arteck ah! Sehe ich mir an 😀

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

          Support us

          ioBroker
          Community Adapters
          Donate

          962
          Online

          31.7k
          Users

          79.6k
          Topics

          1.3m
          Posts

          2
          3
          115
          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