Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. ARTNET DMX Script "...has an invalid value (int)"

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    ARTNET DMX Script "...has an invalid value (int)"

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

      Hi Leute,

      ich hätte heute wieder mal versucht das ARTNET DMX Script in Betrieb zu nehmen:

      Hier das Script:

      //################## Hier IP Adresse des Artnet Gateways eintragen #################//
      var options = {
          host : '192.168.0.1',   // Hier die IP Adresse eintragen
          sendAll : true
      };
      var artnet;
      //################ Hier Artnet Universe und Updatefrequenz anpassen ################//
      
      var universe = 0;           // Default Universe ist 0!
      var updatesPerSecond = 25;  // Je nachdem sind hier Werte ab 15 halbwegs flimmerfrei!
      var updateValueSkip = 1;    // Hier können Werte übersprungen werden, default ist 0!
      
      // Standartmäßig wird mit jedem Update ein DMX Wert hoch/runter gezählt, mit updateValueSkip
      // kann ein Wert hinzuaddiert werden: Beispiel: updateValueSkip = 1 -> Es wird mit jedem Update
      // ein Wert + 1 (also 2 *g*) hoch/runter gezählt, somit wird schneller, aber ruppiger gefadet!
      
      //######################## Ab hier ist alles Programmcode! #########################//
      
      var dmx = [];
      var dmxNew = [];
      var dmxNewPending = [];
      
      var roundValue;
      var rounds;
      var isRunning = 0;
      var r;
      var pending;
      var stopExecution;
      
      function filterNull(noNull) {
          return noNull >= 0;
      }
      
      var initialize = function() {
      
          for (i = 0; i < '513'; i++) { 
              dmx[i] = 'null';
              dmxNew[i] = 'null';
              dmxNewPending[i] = 'null';
      
              try {
                  if (getIdByName("DMX_Channel_" + i) !== undefined) {
                      if (getState("artnet.universe" + universe + ".DMX_Channel_" + i).val > 0) {
                      dmx[i] = getState("artnet.universe" + universe + ".DMX_Channel_" + i).val;
                      }
                  } else if (i > 0) {
                      createState("artnet.universe" + universe + "." + "DMX_Channel_" + i , {
                          name: 'DMX_Channel_' + i,
                          type: 'int',
                          role: 'value',
                          def: 0,
                      });
                      if (i == 512) {
                          console.log("States wurden angelegt!");
                      }
                  }
              }   catch(e){}
          }   
      return idle();
      };
      
      function idle() {
      
          var DMXAddress;
          var DMXNewValue;
      
      on({id: /^javascript\.\d\.artnet.universe/, change: "ne"}, function (obj) {
      
          DMXAddress = obj.name.match(/\d+/);
          DMXNewValue = parseInt(obj.state.val);
          dmxNewPending[DMXAddress] = DMXNewValue;
          clearTimeout(pending);
          updateValues();
      });
      
      }
      
      var updateValues = function() {
      
          pending = setTimeout(function () {
                  if (dmxNew != dmxNewPending) {
                      if (isRunning) {
                          stopExecution = 1;
                          clearTimeout(pending);
                          return updateValues();
                      } if (!isRunning) {
                          stopExecution = 0;
                          dmxNew = dmxNewPending.slice();
                          for (i = 0; i < '513'; i++) { 
                              if (dmx[i] == 'null' && dmxNew[i] != 'null') {
                              dmx[i] = 0;
                              }
                          }
                          return executeArtnet();
                      }
                  }
              },500);
      };
      
      var executeArtnet = function() {
          isRunning = 1;
          artnet = require('artnet')(options);
      
          var dmxOldMinMax = [];
          var dmxNewMinMax = [];
      
          dmxOldMinMax = dmx.slice(1);
          dmxNewMinMax = dmxNew.slice(1);
      
          dmxNewMinValue = Math.min(...dmxNew.filter(filterNull));
          dmxNewMaxValue = Math.max(...dmxNew.filter(filterNull));
          dmxOldMinValue = Math.min(...dmx.filter(filterNull));
          dmxOldMaxValue =  Math.max(...dmx.filter(filterNull));
      
          dmxMaxValue = Math.max(dmxNewMaxValue, dmxOldMaxValue);
          dmxMinValue = Math.min(dmxNewMinValue, dmxOldMinValue);
      
          roundsCalc = Math.round((dmxMaxValue - dmxMinValue)/(updateValueSkip + 1));
          roundValue = 1 + updateValueSkip;
          rounds = Math.abs(roundsCalc);
          r = 0;
          return runArtnet();
      };
      
      var runArtnet = function() {
      
          setTimeout( function() {
              artnetStep();
              r++;
              if (stopExecution) {
                  return closeArtnet();
              } 
              if (r <= rounds + 1) {
                  return runArtnet();
              } if (r > rounds) {
                  return closeArtnet();
              }        
          },(1000/updatesPerSecond));
      };
      
      function artnetStep() {
          for (i = 0; i < '513'; i++) {
              if (i > 0 && dmxNew != 'null') {
                  if (dmx[i] < dmxNew[i]) {
                      if (dmx[i] + roundValue > 255) {
                          dmx[i] = 255;
                      } else if (dmx[i] == dmxNew[i]) {
                          dmx[i] = dmxNew[i];
                      //} else if (dmx[i] == 'null') {
                          //dmx[i] = 1 + roundValue;
                      } else {
                          dmx[i] = dmx[i] + roundValue;
                      }
                  }
                  if (dmx[i] > dmxNew[i]) {
                      if (dmx[i] - roundValue <= 0) {
                          dmx[i] = 0;
                      //} else if (dmx[i] == dmxNew[i] || dmx[i] == 'null') {
                      } else if (dmx[i] == dmxNew[i]) {
                          dmx[i] = dmxNew[i];
                      } else {
                          dmx[i] = dmx[i] - roundValue;
                      }
                  }
              }
          }
      return artnet.set(universe, 1 , dmx.slice(1));
      }
      
      var closeArtnet = function() {
          artnet.close();
          isRunning = 0;
          return;
      };
      
      initialize();
      
      
      

      aus folgendem Thread: https://forum.iobroker.net/topic/3575/art-net/114

      Leider erhalte ich diese Fehlermeldungen im LOG, sobald ich das Script starte:

      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) Object javascript.0.artnet.universe0.DMX_Channel_512 is invalid: obj.common.type has an invalid value (int) but has to be one of number, string, boolean, array, object, mixed, file, json
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) Object javascript.0.artnet.universe0.DMX_Channel_511 is invalid: obj.common.type has an invalid value (int) but has to be one of number, string, boolean, array, object, mixed, file, json
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) Object javascript.0.artnet.universe0.DMX_Channel_510 is invalid: obj.common.type has an invalid value (int) but has to be one of number, string, boolean, array, object, mixed, file, json
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) Object javascript.0.artnet.universe0.DMX_Channel_509 is invalid: obj.common.type has an invalid value (int) but has to be one of number, string, boolean, array, object, mixed, file, json
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) Object javascript.0.artnet.universe0.DMX_Channel_508 is invalid: obj.common.type has an invalid value (int) but has to be one of number, string, boolean, array, object, mixed, file, json
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) Object javascript.0.artnet.universe0.DMX_Channel_507 is invalid: obj.common.type has an invalid value (int) but has to be one of number, string, boolean, array, object, mixed, file, json
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) Object javascript.0.artnet.universe0.DMX_Channel_506 is invalid: obj.common.type has an invalid value (int) but has to be one of number, string, boolean, array, object, mixed, file, json
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) Object javascript.0.artnet.universe0.DMX_Channel_505 is invalid: obj.common.type has an invalid value (int) but has to be one of number, string, boolean, array, object, mixed, file, json
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) Object javascript.0.artnet.universe0.DMX_Channel_504 is invalid: obj.common.type has an invalid value (int) but has to be one of number, string, boolean, array, object, mixed, file, json
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) Object javascript.0.artnet.universe0.DMX_Channel_503 is invalid: obj.common.type has an invalid value (int) but has to be one of number, string, boolean, array, object, mixed, file, json
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) Object javascript.0.artnet.universe0.DMX_Channel_502 is invalid: obj.common.type has an invalid value (int) but has to be one of number, string, boolean, array, object, mixed, file, json
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) Object javascript.0.artnet.universe0.DMX_Channel_501 is invalid: obj.common.type has an invalid value (int) but has to be one of number, string, boolean, array, object, mixed, file, json
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) Object javascript.0.artnet.universe0.DMX_Channel_500 is invalid: obj.common.type has an invalid value (int) but has to be one of number, string, boolean, array, object, mixed, file, json
      javascript.0	2021-01-07 11:00:53.200	warn	(4588) This object will not be created in future versions. Please report this to the developer.
      

      Kann mir jemand sagen wo das Problem liegt bzw. helfen das Script zum Laufen zu bringen?

      Danke.

      Beste Grüße

      paul53 1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @Qlink last edited by

        @Qlink
        Ändere Zeilen 49, 50 in:

                            type: 'number',
                            role: 'level',
        
        Q 1 Reply Last reply Reply Quote 1
        • Q
          Qlink @paul53 last edited by

          @paul53

          Vielen Dank für die Hilfe. Jetzt läuft das Script wieder sauber ohne Fehlermeldung durch 🙂

          Beste Grüße

          1 Reply Last reply Reply Quote 0
          • Q
            Qlink last edited by Qlink

            @paul53

            Das Script funktioniert dank deiner Hilfe jetzt wie es soll und ich kann für jeden Farbkanal einen Wert von 0-255 vergeben.
            058fb632-3c3d-4868-9cad-f82432c59d11-image.png
            Was allerdings noch fehlt ist die Möglichkeit für z.B. die Kanäle 1-4, oder 5-8 (RGBW) einen Hex Wert angeben zu können, damit man Mischfarben darstellen kann bzw. mit Colorpicker Widgets, welche nahezu alle die Eingabe eines Hexwerts brauchen eine beliebige Farbe direkt anwählen zu können.

            Es müsste also folgende Möglichkeiten im Script geben:

            • Kanalgruppen angeben z.B. 1-4 oder 9-12 je nachdem ob RGBW oder RGB
            • für diese Kanalgruppen müsste dann ein zusätzlicher Datenpunkt angelegt werden, welcher dann die einzelnen RGB(W) Werte in einen Hexwert umrechnet und vice versa, also ein eingebauter Konverter wie z.B. hier https://ncalculators.com/digital-computation/rgb-to-hex-converter.htm

            Ähnlich wie beim artnet Adapter... der funktioniert allerdings leider nicht so gut, stabil und flüssig wie das Script
            8ad85db2-83b6-4bb0-adf0-f6ec29c5ff60-image.png

            Leider ist der Macher des Scripts seit mehreren Jahren im Forum nicht mehr aktiv.

            Lässt sich diese Funktionalität im Script entsprechend erweitern und falls ja, könntest du das eventuell machen ?

            Beste Grüße

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

            Support us

            ioBroker
            Community Adapters
            Donate

            539
            Online

            31.8k
            Users

            80.0k
            Topics

            1.3m
            Posts

            javascript
            2
            4
            222
            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