Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. [Vorlage] Busch Jäger Radio iNet 8216 U

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    [Vorlage] Busch Jäger Radio iNet 8216 U

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

      Moin Leute,

      ich habe mich die letzten Tage mal rangesetzt und ein Skript zum Steuern des Radios 8216U von Busch-Jäger erstellt.
      Vorraussetzung ist , der Energy Mode vom Radio muss auf Premium stehen damit das Radio jederzeit erreichbar ist.
      Änderungen (Befehle) werden sofort umgesetzt. Genauso werden Eingaben am Radio sofort erfasst da das Skript einen UDP Server erstellt welcher dauerhaft am Port lauscht.

      Im Skript einfach eure IP Adresse des Radios eintragen und es sollte funktionieren.

      Würde dies auch gerne in einen Adapter packen aber dafür benötige ich etwas Support. 😉

      Also viel Spass beim testen.
      Hoffe es funktioniert bei euch

      var pfad = 'Geraete.BuschJaeger.RadioINet.';
      var pfad2 = 'javascript.0.' + pfad
      
      var UDPListenPort = 4242; //nicht ändern 
      var UDPPort = 4244; //nicht ändern 
      var RadioIPadress = '192.168.100.73' // IP Adresse des Radios
      var HOST = '0.0.0.0'; //nicht ändern 
      
      var logging = false;
      
      
      // ab hier nichts mehr ändern 
      
      var dgram = require('dgram');
      var socket = dgram.createSocket('udp4');
      var server = dgram.createSocket('udp4');
      //var server2 = dgram.createSocket('udp4');
      
      createState(pfad + "Command", '', { type: 'string', name: 'Last command', write: false });
      createState(pfad + "WLAN_STRENGTH", '', { type: 'string', name: 'WLAN strength', write: false, unit: 'dBm' });
      createState(pfad + "NAME", '', { type: 'string', name: 'Name of radio', write: false });
      createState(pfad + "ID", '', { type: 'string', name: 'UDP ID', write: false });
      createState(pfad + "IPADDR", '', { type: 'string', name: 'IP adress', write: false });
      createState(pfad + "IPMASK", '', { type: 'string', name: 'IP Mask', write: false });
      createState(pfad + "IPMODE", '', { type: 'string', name: 'IP  Mode', write: false });
      createState(pfad + "GATEWAY", '', { type: 'string', name: 'Gateway', write: false });
      createState(pfad + "SSID", '', { type: 'string', name: 'SSID', write: false });
      createState(pfad + "MAC_ADRESS", '', { type: 'string', name: 'MAC adress', write: false });
      createState(pfad + "COUNTRY", '', { type: 'string', name: 'Country', write: false });
      createState(pfad + "SERIAL_NR", '', { type: 'string', name: 'Serial Nr', write: false });
      createState(pfad + "SW-VERSION", '', { type: 'string', name: 'Software version', write: false });
      createState(pfad + "WLAN-FW", '', { type: 'string', name: 'WLAN Firmware', write: false });
      
      
      
      createState(pfad + "POWER", '', { type: 'string', name: 'Current state of radio', write: false });
      createState(pfad + "ENERGY_MODE", '', { type: 'string', name: '', write: false });
      createState(pfad + "VOLUME", '', { type: 'number', name: 'VOLUME', write: false });
      createState(pfad + "PLAYING_MODE", '', { type: 'string', name: '', write: false });
      createState(pfad + "PLAYING", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATION_ID_PLAYING", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATION_URL_PLAYING", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATION_PLAYING", '', { type: 'string', name: '', write: false });
      createState(pfad + "TUNEIN_ID", '', { type: 'string', name: '', write: false });
      createState(pfad + "TUNEIN_SNR", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_1_NAME", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_1_URL", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_2_NAME", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_2_URL", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_3_NAME", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_3_URL", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_4_NAME", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_4_URL", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_5_NAME", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_5_URL", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_6_NAME", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_6_URL", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_7_NAME", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_7_URL", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_8_NAME", '', { type: 'string', name: '', write: false });
      createState(pfad + "STATIONS.STATION_8_URL", '', { type: 'string', name: '', write: false });
      
      createState(pfad + "COMMAND.VOLUME_INC", false, { type: 'boolean', name: '', read: false, write: true, role: 'button' });
      createState(pfad + "COMMAND.VOLUME_DEC", false, { type: 'boolean', name: '', read: false, write: true, role: 'button' });
      createState(pfad + "COMMAND.VOLUME_MUTE", false, { type: 'boolean', name: '', read: false, write: true, role: 'switch' });
      createState(pfad + "COMMAND.RADIO_ON", false, { type: 'boolean', name: '', read: false, write: true, role: 'switch' });
      createState(pfad + "COMMAND.PLAY_STATION", 1, { type: 'number', name: 'PLAYING STATION 1-8', read: false, write: true });
      createState(pfad + "COMMAND.VOLUME_SET", 1, { type: 'number', name: 'SET VOLUME 0-31', read: false, write: true });
      //createState(pfad+"COMMAND.VOLUME_DEC",      0,   {type: 'boolean', name: '', read: false, write: true, role:'button'});
      
      server.on('error', (err) => {
          log(`server error:\n${err.stack}`);
          server.close();
      });
      server.on('listening', function () {
          var address = server.address();
          log('UDP Server listening on ' + address.address + ":" + address.port);
      });
      server.bind(UDPListenPort, HOST);
      
      /* server2.on('listening', function () {
          server2.setBroadcast(true);
          server2.setMulticastLoopback(true);
          var address = server2.address();
         log('UDP Server 2 listening on ' + address.address + ":" + address.port);
      });
      server2.bind(PORT2, HOST); */
      
      // Antworten vom Radio auf Abfragen
      
      server.on('message', function (message, remote) {
          if (logging) log('Meldung vom RADIO: ' + message);
          var command = findstr("COMMAND:", message);
          if (command == "GET") {
              if (message.indexOf("INFO_BLOCK") >= 0) {
                  setState(pfad + "Command", findstr("COMMAND:", message));
                  setState(pfad + "WLAN_STRENGTH", findstr("WLAN STRENGTH:", message));
                  setState(pfad + "NAME", findstr("NAME:", message));
                  setState(pfad + "ID", findstr("ID:", message));
                  setState(pfad + "IPADDR", findstr("IPADDR:", message));
                  setState(pfad + "IPMASK", findstr("IPMASK:", message));
                  setState(pfad + "IPMODE", findstr("IPMODE:", message));
                  setState(pfad + "GATEWAY", findstr("GATEWAY:", message));
                  setState(pfad + "SSID", findstr("SSID:", message));
                  setState(pfad + "MAC_ADRESS", findstr("MAC:", message));
                  setState(pfad + "COUNTRY", findstr("COUNTRY:", message));
                  setState(pfad + "SERIAL_NR", findstr("SERNO:", message));
                  setState(pfad + "SW-VERSION", findstr("SW-VERSION:", message));
                  setState(pfad + "WLAN-FW", findstr("WLAN-FW:", message));
              } else if (message.indexOf("VOLUME") >= 0) {
                  setState(pfad + "Command", findstr("COMMAND:", message));
                  setState(pfad + "ID", findstr("ID:", message));
                  setState(pfad + "VOLUME", parseInt(findstr("VOLUME_SET:", message)));
                  if (parseInt(findstr("VOLUME_SET:", message)) >= 0 && parseInt(findstr("VOLUME_SET:", message)) <= 31 && message.indexOf("RESPONSE:ACK") >= 0) {
                      setState(pfad + "COMMAND.VOLUME_SET", parseInt(findstr("VOLUME_SET:", message)), true);
                  }
              } else if (message.indexOf("POWER_STATUS") >= 0) {
                  setState(pfad + "Command", findstr("COMMAND:", message));
                  setState(pfad + "ID", findstr("ID:", message));
                  setState(pfad + "POWER", findstr("POWER:", message));
                  if (findstr("POWER:", message) == "ON") {
                      setState(pfad + "COMMAND.RADIO_ON", true, true)
                  } else if (findstr("POWER:", message) == "OFF") {
                      setState(pfad + "COMMAND.RADIO_ON", false, true)
                  };
                  setState(pfad + "ENERGY_MODE", findstr("ENERGY_MODE:", message));
              } else if (message.indexOf("TUNEIN_PARTNER_ID") >= 0) {
                  setState(pfad + "Command", findstr("COMMAND:", message));
                  setState(pfad + "ID", findstr("ID:", message));
                  setState(pfad + "TUNEIN_ID", findstr("PARTNERID:", message));
                  setState(pfad + "TUNEIN_SNR", findstr("SERNO:", message));
              } else if (message.indexOf("ALL_STATION_INFO") >= 0) {
                  setState(pfad + "Command", findstr("COMMAND:", message));
                  setState(pfad + "ID", findstr("ID:", message));
                  setState(pfad + "STATIONS.STATION_1_NAME", findstr("1\r\nNAME:", message));
                  setState(pfad + "STATIONS.STATION_1_URL", findstr(findstr("1\r\nNAME:", message) + '\r\nURL:', message));
                  setState(pfad + "STATIONS.STATION_2_NAME", findstr("2\r\nNAME:", message));
                  setState(pfad + "STATIONS.STATION_2_URL", findstr(findstr("2\r\nNAME:", message) + '\r\nURL:', message));
                  setState(pfad + "STATIONS.STATION_3_NAME", findstr("3\r\nNAME:", message));
                  setState(pfad + "STATIONS.STATION_3_URL", findstr(findstr("3\r\nNAME:", message) + '\r\nURL:', message));
                  setState(pfad + "STATIONS.STATION_4_NAME", findstr("4\r\nNAME:", message));
                  setState(pfad + "STATIONS.STATION_4_URL", findstr(findstr("4\r\nNAME:", message) + '\r\nURL:', message));
                  setState(pfad + "STATIONS.STATION_5_NAME", findstr("5\r\nNAME:", message));
                  setState(pfad + "STATIONS.STATION_5_URL", findstr(findstr("5\r\nNAME:", message) + '\r\nURL:', message));
                  setState(pfad + "STATIONS.STATION_6_NAME", findstr("6\r\nNAME:", message));
                  setState(pfad + "STATIONS.STATION_6_URL", findstr(findstr("6\r\nNAME:", message) + '\r\nURL:', message));
                  setState(pfad + "STATIONS.STATION_7_NAME", findstr("7\r\nNAME:", message));
                  setState(pfad + "STATIONS.STATION_7_URL", findstr(findstr("7\r\nNAME:", message) + '\r\nURL:', message));
                  setState(pfad + "STATIONS.STATION_8_NAME", findstr("8\r\nNAME:", message));
                  setState(pfad + "STATIONS.STATION_8_URL", findstr(findstr("8\r\nNAME:", message) + '\r\nURL:', message));
              } else if (message.indexOf("PLAYING_MODE") >= 0) {
                  setState(pfad + "Command", findstr("COMMAND:", message));
                  setState(pfad + "ID", findstr("ID:", message));
                  setState(pfad + "PLAYING_MODE", findstr("MODE:", message));
                  setState(pfad + "PLAYING", findstr("PLAYING:", message));
                  setState(pfad + "STATION_ID_PLAYING", findstr("N\r\nID:", message));
                  setState(pfad + "STATION_URL_PLAYING", findstr("URL:", message));
                  setState(pfad + "STATION_PLAYING", findstr("NAME:", message));
              };
          } else if (command == "NOTIFICATION") {
              var event = findstr("EVENT:", message);
              setState(pfad + "Command", findstr("COMMAND:", message));
              setState(pfad + "IPADDR", findstr("IP:", message));
              setState(pfad + "NAME", findstr("NAME:", message));
              if (logging) log("Event = '" + event + "'");
              if (event == 'POWER_OFF' || event == 'POWER_ON') {
                  sendcmd('COMMAND:GET\r\nPOWER_STATUS\r\nID:ioBroker\r\n\r\n');
              };
              if (event == "VOLUME_CHANGED") {
                  sendcmd('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n');
              };
              if (event == 'STATION_CHANGED') {
              };
          } else if (command == "SET") {
              if (message.indexOf("VOLUME_ABSOLUTE") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                  setState(pfad + "VOLUME", parseInt(findstr("VOLUME_SET:", message)), true);
                  setState(pfad + "COMMAND.VOLUME_SET", parseInt(findstr("VOLUME_SET:", message)), true)
              }
              if (message.indexOf("VOLUME_DEC") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                  setState(pfad + "VOLUME", parseInt(findstr("VOLUME_SET:", message)), true);
                  setState(pfad + "COMMAND.VOLUME_SET", parseInt(findstr("VOLUME_SET:", message)), true)
              }
              if (message.indexOf("VOLUME_INC") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                  setState(pfad + "VOLUME", parseInt(findstr("VOLUME_SET:", message)), true);
                  setState(pfad + "COMMAND.VOLUME_SET", parseInt(findstr("VOLUME_SET:", message)), true)
              }
              if (message.indexOf("VOLUME_UNMUTE") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                  setState(pfad + "COMMAND.VOLUME_MUTE", false, true)
              }
              if (message.indexOf("VOLUME_MUTE") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                  setState(pfad + "COMMAND.VOLUME_MUTE", true, true)
              }
              if (message.indexOf("RADIO_OFF") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                  setState(pfad + "COMMAND.RADIO_ON", false, true);
                  setState(pfad + "POWER", "OFF");
              }
              if (message.indexOf("RADIO_ON") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                  setState(pfad + "COMMAND.RADIO_ON", true, true);
                  setState(pfad + "POWER", "ON");
              }
          } else if (command == "PLAY") {
              if (message.indexOf("STATION") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                  setState(pfad + "COMMAND.PLAY_STATION", parseInt(findstr("STATION:", message)), true);
                  setState(pfad + "STATION_ID_PLAYING", parseInt(findstr("STATION:", message)), true);
                  setState(pfad + "STATION_PLAYING", findstr("PLAYING:", message), true);
              }
          } else {
      
              if (logging) log('unexpected message: ' + message);
      
          }
      });
      
      // starten der Abfragen nach Empfang von Broadcasts
      /* var timer = null;
      
      server2.on('message', function (message, remote) {
          if (timer) clearTimeout(timer);
          if (logging) log('Broadcast vom Radio: ' + message);
          if (logging) log(JSON.stringify(message));
          //var obj = JSON.parse('{'+message+'}');
          sendcmd(buf2);
          timer = setTimeout(function () {
              sendcmd(buf3);
          }, 1000);
      }); */
      function findstr(name, str) {
          var suchstring = String(name);
          var teststring = String(str);
          var pos = parseInt(teststring.indexOf(suchstring) + suchstring.length);
          var zaehler = parseInt(pos) + 1;
          //log("String: " + suchstring + "befindet sich an " + pos + " Stelle")
          do {
              var Zeichen = String(teststring).charCodeAt(zaehler);
              //log ("Zeichen: " + Zeichen + " Zähler: " + (zaehler - pos));
              zaehler = zaehler + 1;
          } while (Zeichen != 13 && zaehler - pos <= 100);
      
      
          //log("Start: " + pos + "Ende: " + zaehler);
          var ergebnis = String(str).substring(pos, zaehler - 1);
          if (teststring.indexOf(suchstring) == -1) {
              ergebnis = ""
          };
      
          //log("Objekt: " + name + " Wert: '" + ergebnis + "'");
          return ergebnis
      }
      
      
      function sendcmd(cmd) {
          socket.send(cmd, 0, cmd.length, UDPPort, RadioIPadress, function (err, result) {
              if (err) log('Fehler Senden ' + cmd, 'error');
              else {
                  if (logging) log('Kommando gesendet: ' + cmd);
              }
          });
      }
      //einmalige Ausführung beim  Starten des Skriptes
      sendcmd('COMMAND:GET\r\nPOWER_STATUS\r\nID:ioBroker\r\n\r\n');
      sendcmd('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n');
      sendcmd('COMMAND:GET\r\nINFO_BLOCK\r\nID:ioBroker\r\n\r\n');
      sendcmd('COMMAND:GET\r\nPLAYING_MODE\r\nID:ioBroker\r\n\r\n');
      sendcmd('COMMAND:GET\r\nALL_STATION_INFO\r\nID:ioBroker\r\n\r\n');
      
      var timer1 = null;
      var timer2 = null;
      var timer3 = null;
      var timer4 = null;
      schedule('*/1 * * * *', function () {  // jede Minute die wichtigsten Infos aktualisieren
      
          if (timer1) clearTimeout(timer1);
          timer1 = setTimeout(function () {
              sendcmd('COMMAND:GET\r\nPOWER_STATUS\r\nID:ioBroker\r\n\r\n');
          }, 1000);
          if (timer2) clearTimeout(timer2);
          timer2 = setTimeout(function () {
              sendcmd('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n');
          }, 2000);
          if (timer3) clearTimeout(timer3);
          timer3 = setTimeout(function () {
              sendcmd('COMMAND:GET\r\nINFO_BLOCK\r\nID:ioBroker\r\n\r\n');
          }, 3000);
          if (timer4) clearTimeout(timer4);
          timer4 = setTimeout(function () {
              sendcmd('COMMAND:GET\r\nPLAYING_MODE\r\nID:ioBroker\r\n\r\n');
          }, 4000);
      });
      
      schedule('*/30 * * * *', function () {  // alle 30 Minuten die Stationsliste aktualisieren
          sendcmd('COMMAND:GET\r\nALL_STATION_INFO\r\nID:ioBroker\r\n\r\n');
      });
      // Reaktionen auf Befehle
      on({ id: pfad2 + "COMMAND.VOLUME_INC", val: true }, function (obj) {
          if (logging) log('COMMAND.VOLUME_INC');
          sendcmd('COMMAND:SET\r\nVOLUME_INC\r\nID:ioBroker\r\n\r\n');
          sendcmd('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n');
      });
      on({ id: pfad2 + "COMMAND.VOLUME_DEC", val: true }, function (obj) {
          if (logging) log('COMMAND.VOLUME_DEC');
          sendcmd('COMMAND:SET\r\nVOLUME_DEC\r\nID:ioBroker\r\n\r\n');
          sendcmd('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n');
      });
      on({ id: pfad2 + "COMMAND.VOLUME_MUTE", change: "ne" }, function (obj) {
          if (logging) log('COMMAND.VOLUME_MUTE');
          if (obj.state.val === true) {
              sendcmd('COMMAND:SET\r\nVOLUME_MUTE\r\nID:ioBroker\r\n\r\n');
          }
          if (obj.state.val === false) {
              sendcmd('COMMAND:SET\r\nVOLUME_UNMUTE\r\nID:ioBroker\r\n\r\n');
          }
          sendcmd('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n');
      });
      on({ id: pfad2 + "COMMAND.RADIO_ON", change: "ne", ack: false }, function (obj) {
          if (logging) log('COMMAND.RADIO_ON');
          if (obj.state.val === true) {
              sendcmd('COMMAND:SET\r\nRADIO_ON\r\nID:ioBroker\r\n\r\n');
          }
          if (obj.state.val === false) {
              sendcmd('COMMAND:SET\r\nRADIO_OFF\r\nID:ioBroker\r\n\r\n');
          }
          sendcmd('COMMAND:GET\r\nPOWER_STATUS\r\nID:ioBroker\r\n\r\n');
      });
      on({ id: pfad2 + "COMMAND.PLAY_STATION", change: "ne", ack: false }, function (obj) {
          if (logging) log('COMMAND.PLAY_STATION');
          if (obj.state.val <= 8 && obj.state.val > 0) {
              sendcmd('COMMAND:PLAY\r\nSTATION:' + obj.state.val + '\r\nID:ioBroker\r\n\r\n');
          }
      });
      on({ id: pfad2 + "COMMAND.VOLUME_SET", change: "ne", ack: false }, function (obj) {
          if (logging) log('COMMAND.PLAY_STATION');
          if (obj.state.val <= 31 && obj.state.val >= 0) {
              sendcmd('COMMAND:SET\r\nVOLUME_ABSOLUTE:' + obj.state.val + '\r\nID:ioBroker\r\n\r\n');
          }
      }); 
      
      crunchip E 2 Replies Last reply Reply Quote 0
      • crunchip
        crunchip Forum Testing Most Active @intruder7 last edited by

        @intruder7 coole Sache, das werd ich morgen dann gleich mal testen

        I 1 Reply Last reply Reply Quote 0
        • I
          intruder7 @crunchip last edited by

          @crunchip
          sehr gerne.
          es gibt dazu auch schon einen Adapter Request. Wenn mich dabei jemand unterstützen kann und der Bedarf da ist, könnte daraus auch ein Adapter werden

          crunchip 1 Reply Last reply Reply Quote 0
          • crunchip
            crunchip Forum Testing Most Active @intruder7 last edited by

            @intruder7 ich weiss nur das vor Ewigkeiten schon mal hier die Anfrage war wegen dem Busch und Jäger Radio, da auch einige daran interessiert waren.
            Unterstützen in hinsicht, testen...gerne...mit allem anderen, kenne ich mich so rein gar nicht aus.

            I 1 Reply Last reply Reply Quote 0
            • I
              intruder7 @crunchip last edited by

              @crunchip
              Kein Problem... Schritt für Schritt. Wenn Zeit ist werde ich mich da mal einlesen

              crunchip 1 Reply Last reply Reply Quote 0
              • crunchip
                crunchip Forum Testing Most Active @intruder7 last edited by

                @intruder7 habs heute mal installiert. Daten kommen fast alle an, sofern überall was drin stehen sollte.
                9b63c27d-010e-46d5-bcbc-d6b0a2d2fdaf-image.png

                I 1 Reply Last reply Reply Quote 0
                • I
                  intruder7 @crunchip last edited by

                  @crunchip sehr schön. Ich habe bis jetzt nur die Steuerung und Nutzung der speixherbaren 8 Fav eingebaut. Die ganze TuneIn Geschichte noch nicht.

                  1 Reply Last reply Reply Quote 0
                  • crunchip
                    crunchip Forum Testing Most Active last edited by

                    @intruder7 gibt es hier schon was neues zu berichten?

                    I 1 Reply Last reply Reply Quote 0
                    • I
                      intruder7 @crunchip last edited by

                      @crunchip Nicht wirklich. Das Skript liefert mir alles was ich benötige. Über einen Adapter hatte ich nachgedacht und versucht auch etwas reinzulesen. Aber ohne Unterstützung bzw einer genauen Step by Step Anleitung werde ich das nicht schaffen. Auch fehlt mir dafür gerade die Zeit.

                      Sollten natürlich noch Fehler sein, werde ich diese auch beseitigen.

                      Grüße

                      crunchip 1 Reply Last reply Reply Quote 0
                      • crunchip
                        crunchip Forum Testing Most Active @intruder7 last edited by

                        @intruder7 ok, ich hatte selbst bisher auch kaum Zeit, das überhaupt umzusetzen bzw zu integrieren.
                        Muss erst mal schaun wie das funktioniert.

                        1 Reply Last reply Reply Quote 0
                        • E
                          Eaterhnk @intruder7 last edited by

                          @intruder7

                          Hey das Skript läuft einwandfrei für ein Radio, habe allerdings 2 davon und möchte gerne beide bedienen. Wenn ich allerdings in der erste Zeile den Pfad ändere und auch die IP ändere, das ganze in ein weiteres Skript kopiere, bekomme ich garkeine Daten. Bin leider in Java nicht so zuhause... was mache ich falsch bzw. muss ich noch ändern um 2 Radios steuern zu können?

                          VG

                          I 1 Reply Last reply Reply Quote 0
                          • I
                            intruder7 @Eaterhnk last edited by

                            @Eaterhnk mein erster Gedanke wäre auch gewesen das Skript zu kopieren und für das zweite Radio einen eigenen Pfad anzulegen und die IP zu ändern. wobei die IP nur zum senden von Befehlen nötig ist. die Antworten kommen von beiden Radios über UDP rein. Ich kann es leider nicht testen weil ich keine zwei Radios habe

                            E 1 Reply Last reply Reply Quote 0
                            • E
                              Eaterhnk @intruder7 last edited by

                              @intruder7
                              ok. schade, hast du denn vielleicht noch einen anderen Ansatz für mich was ich vielleicht mal testen könnte?

                              I 1 Reply Last reply Reply Quote 0
                              • I
                                intruder7 @Eaterhnk last edited by

                                @Eaterhnk einen Ansatz kann ich dir leider nicht liefern. Ich würde versuchen auf dem try and error Weg eine Lösung zu erreichen. Mir die ganzen UDP Messages anschauen u.s.w. Ich denke schwer ist es nicht aber ohne zweites Radio nicht möglich. Sorry

                                1 Reply Last reply Reply Quote 0
                                • N
                                  Nahasapee last edited by

                                  Hi,
                                  ich steck zwar nicht wirklich drin,
                                  da ich nicht so nen Radio habe bzw. udp Geschichte nicht in nodejs programmiert habe.

                                  Allerdings glaube ich, wenn ihr das script einfach nur in ne neue Datei kopiert und die IpAdresse des Clients ändert würden zwei Server versuchen auf den gleichen Port zu lauschen und das geht glaube ich nicht,
                                  ich steck da allerdings nicht drin, wenns einer genauer weiß berichtigt mich bitte.
                                  Ich glaube eher, dass ihr das Scrpt in Zeile 93 bzw 217 erweitern müsst
                                  auf die unterschiedlichen Clients.
                                  entweder steht in der message || remote welches Radio gerade sendet.
                                  gebt doch mal das log von der message bzw remote variable aus und postet es.
                                  Viele Grüße

                                  E 1 Reply Last reply Reply Quote 0
                                  • E
                                    Eaterhnk @Nahasapee last edited by

                                    @Nahasapee
                                    Guten Abend,
                                    das ist ein Auszug aus dem LOG von gestern: hier wurde das Skript kopiert und nur der Pfad und die IP geändert. Mit den Änderungen in den von dir benannten Zeilen komm ich nicht weiter:

                                    2019-12-09 19:52:00.068 - warn: javascript.0 (29194) Wrong type of javascript.0.Geraete.BuschJaeger.RadioINet.STATION_ID_PLAYING: "number". Please fix, while deprecated and will not work in next versions.
                                    2019-12-09 19:52:00.069 - warn: javascript.0 (29194) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1258:20)
                                    2019-12-09 19:52:00.069 - warn: javascript.0 (29194) at Socket. (script.js.Skrypte_in_Betrieb.Radio_EG:204:13)
                                    2019-12-09 19:52:00.070 - warn: javascript.0 (29194) at Socket.emit (events.js:198:13)
                                    2019-12-09 19:52:00.070 - warn: javascript.0 (29194) at UDP.onMessage (dgram.js:628:8)

                                    1 Reply Last reply Reply Quote 0
                                    • N
                                      Nahasapee last edited by

                                      Sorry,
                                      du hast mich jetzt falsch verstanden, du solltest einfach mal die zwei
                                      Variablen ausgeben mit
                                      füge am besten in einer der benannten Zeilen mal folgendes log ein

                                      console.log(JSON.stringify(message));
                                      console.log(JSON.stringify(remote));
                                      

                                      ich vermute ja, dass in der Variable remote die Adresse steht welches Radio gerade gesendet hat
                                      dann müsste man entsprechend in den jeweiligen Pfad speichern.
                                      Wie oben schon gesagt, denke ich das du keine zwei skripte anlegen darfst, sondern dieses an den besagten stellen erweitern musst
                                      dass es mit zwei oder mehr Radios umgehen kann.

                                      E 1 Reply Last reply Reply Quote 0
                                      • N
                                        Nahasapee last edited by

                                        Hi,
                                        ich hab das Skript mal angepasst, so wie ich glaube
                                        das es funktionieren könnte.

                                        das einzige was ich nicht angepasst habe ist ganz unten im Abschnitt "reaktion auf Befehle"
                                        da müssen die Pfade noch angepasst werden aber ich bin jetzt müde 😉
                                        habs erst mal auskommentiert.

                                        ich hab jetzt quasi die ganzen createstate geraffel in ne Funktion gebastelt und und am Anfang ne Liste mit Radios hinterlegt
                                        die müsstest du dann füllen mit korrekten IP Adressen.
                                        bei mir sah das im Objektbaum dann so aus:

                                        cd783475-1b2b-4da9-b89a-5d496354f547-image.png

                                        zum Schluss hab ich den server angepasst damit er auf unterschiedliche IP reagieren kann und entsprechend mappt
                                        die sendcmd hab ich auch modifiziert damit die ganzen scheduler unten Funktionieren

                                        für den "Abschnitt Reaktion auf Befehle" bräuchte man wahrscheinlich noch mal ne explizite sendcmd die an eine spezielle ipadresse sendet
                                        für die gesamten on befehle die danach kommen.
                                        hier das modifizierte skript konnte ich natürlich nur bedingt testen
                                        Grüße und guten Nacht!

                                        var pfad = 'Geraete.BuschJaeger.RadioINet.';
                                        var pfad2 = 'javascript.0.' + pfad
                                         
                                        var UDPListenPort = 4242; //nicht ändern 
                                        var UDPPort = 4244; //nicht ändern 
                                        var RadioIPadress = '192.168.100.73' // IP Adresse des Radios
                                        var HOST = '0.0.0.0'; //nicht ändern 
                                         
                                        var logging = false;
                                         
                                        const radios =  [
                                             {
                                                     IP: '192.168.100.73',
                                                     pfad: 'Bad'
                                                    },
                                            {
                                                     IP: '192.168.100.74',
                                                     pfad: 'Keller'
                                                    }        
                                        ];
                                        
                                         
                                        // ab hier nichts mehr ändern 
                                         
                                        var dgram = require('dgram');
                                        var socket = dgram.createSocket('udp4');
                                        var server = dgram.createSocket('udp4');
                                        //var server2 = dgram.createSocket('udp4');
                                        
                                        const getRadioForIP= (IP)=>{
                                            return radios.find(radio=>radio.IP == IP )
                                        }
                                        
                                        const createAllStates = ()=>{
                                            console.log("createALL");
                                            radios.forEach((radio)=>{createRadioState(radio);});    
                                        };
                                        
                                        const createRadioState = (radio)=>{
                                        createState(pfad+ radio.pfad +"."+ "Command", '', { type: 'string', name: 'Last command', write: false });
                                        createState(pfad+ radio.pfad +"."+ "WLAN_STRENGTH", '', { type: 'string', name: 'WLAN strength', write: false, unit: 'dBm' });
                                        createState(pfad+ radio.pfad +"."+ "NAME", '', { type: 'string', name: 'Name of radio', write: false });
                                        createState(pfad+ radio.pfad +"."+ "ID", '', { type: 'string', name: 'UDP ID', write: false });
                                        createState(pfad+ radio.pfad +"."+ "IPADDR", '', { type: 'string', name: 'IP adress', write: false });
                                        createState(pfad+ radio.pfad +"."+ "IPMASK", '', { type: 'string', name: 'IP Mask', write: false });
                                        createState(pfad+ radio.pfad +"."+ "IPMODE", '', { type: 'string', name: 'IP  Mode', write: false });
                                        createState(pfad+ radio.pfad +"."+ "GATEWAY", '', { type: 'string', name: 'Gateway', write: false });
                                        createState(pfad+ radio.pfad +"."+ "SSID", '', { type: 'string', name: 'SSID', write: false });
                                        createState(pfad+ radio.pfad +"."+ "MAC_ADRESS", '', { type: 'string', name: 'MAC adress', write: false });
                                        createState(pfad+ radio.pfad +"."+ "COUNTRY", '', { type: 'string', name: 'Country', write: false });
                                        createState(pfad+ radio.pfad +"."+ "SERIAL_NR", '', { type: 'string', name: 'Serial Nr', write: false });
                                        createState(pfad+ radio.pfad +"."+ "SW-VERSION", '', { type: 'string', name: 'Software version', write: false });
                                        createState(pfad+ radio.pfad +"."+ "WLAN-FW", '', { type: 'string', name: 'WLAN Firmware', write: false });
                                        
                                         
                                        createState(pfad +radio.pfad+ "." + "POWER", '', { type: 'string', name: 'Current state of radio', write: false });
                                        createState(pfad +radio.pfad+ "." + "ENERGY_MODE", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "VOLUME", '', { type: 'number', name: 'VOLUME', write: false });
                                        createState(pfad +radio.pfad+ "." + "PLAYING_MODE", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "PLAYING", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATION_ID_PLAYING", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATION_URL_PLAYING", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATION_PLAYING", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "TUNEIN_ID", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "TUNEIN_SNR", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_1_NAME", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_1_URL", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_2_NAME", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_2_URL", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_3_NAME", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_3_URL", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_4_NAME", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_4_URL", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_5_NAME", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_5_URL", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_6_NAME", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_6_URL", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_7_NAME", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_7_URL", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_8_NAME", '', { type: 'string', name: '', write: false });
                                        createState(pfad +radio.pfad+ "." + "STATIONS.STATION_8_URL", '', { type: 'string', name: '', write: false });
                                         
                                        createState(pfad + radio.pfad +"." + "COMMAND.VOLUME_INC", false, { type: 'boolean', name: '', read: false, write: true, role: 'button' });
                                        createState(pfad + radio.pfad +"." + "COMMAND.VOLUME_DEC", false, { type: 'boolean', name: '', read: false, write: true, role: 'button' });
                                        createState(pfad + radio.pfad +"." + "COMMAND.VOLUME_MUTE", false, { type: 'boolean', name: '', read: false, write: true, role: 'switch' });
                                        createState(pfad + radio.pfad +"." + "COMMAND.RADIO_ON", false, { type: 'boolean', name: '', read: false, write: true, role: 'switch' });
                                        createState(pfad + radio.pfad +"." + "COMMAND.PLAY_STATION", 1, { type: 'number', name: 'PLAYING STATION 1-8', read: false, write: true });
                                        createState(pfad + radio.pfad +"." + "COMMAND.VOLUME_SET", 1, { type: 'number', name: 'SET VOLUME 0-31', read: false, write: true });
                                        //createState(pfad+"COMMAND.VOLUME_DEC",      0,   {type: 'boolean', name: '', read: false, write: true, role:'button'});
                                        };
                                        createAllStates();
                                        
                                        
                                         server.on('error', (err) => {
                                            log(`server error:\n${err.stack}`);
                                            server.close();
                                        });
                                        server.on('listening', function () {
                                            var address = server.address();
                                            log('UDP Server listening on ' + address.address + ":" + address.port);
                                        });
                                        server.bind(UDPListenPort, HOST);
                                         
                                        /* server2.on('listening', function () {
                                            server2.setBroadcast(true);
                                            server2.setMulticastLoopback(true);
                                            var address = server2.address();
                                           log('UDP Server 2 listening on ' + address.address + ":" + address.port);
                                        });
                                        server2.bind(PORT2, HOST); */
                                         
                                        // Antworten vom Radio auf Abfragen
                                         
                                        server.on('message', function (message, remote) {
                                            if (logging) log('Meldung vom RADIO: ' + message);
                                            const radio = getRadioForIP(remote.address);
                                            
                                            var command = findstr("COMMAND:", message);
                                        if (command == "GET") {
                                            if (message.indexOf("INFO_BLOCK") >= 0) {
                                                setState(pfad + radio.pfad + "." + "Command", findstr("COMMAND:", message));
                                                setState(pfad + radio.pfad + "." + "WLAN_STRENGTH", findstr("WLAN STRENGTH:", message));
                                                setState(pfad + radio.pfad + "." + "NAME", findstr("NAME:", message));
                                                setState(pfad + radio.pfad + "." + "ID", findstr("ID:", message));
                                                setState(pfad + radio.pfad + "." + "IPADDR", findstr("IPADDR:", message));
                                                setState(pfad + radio.pfad + "." + "IPMASK", findstr("IPMASK:", message));
                                                setState(pfad + radio.pfad + "." + "IPMODE", findstr("IPMODE:", message));
                                                setState(pfad + radio.pfad + "." + "GATEWAY", findstr("GATEWAY:", message));
                                                setState(pfad + radio.pfad + "." + "SSID", findstr("SSID:", message));
                                                setState(pfad + radio.pfad + "." + "MAC_ADRESS", findstr("MAC:", message));
                                                setState(pfad + radio.pfad + "." + "COUNTRY", findstr("COUNTRY:", message));
                                                setState(pfad + radio.pfad + "." + "SERIAL_NR", findstr("SERNO:", message));
                                                setState(pfad + radio.pfad + "." + "SW-VERSION", findstr("SW-VERSION:", message));
                                                setState(pfad + radio.pfad + "." + "WLAN-FW", findstr("WLAN-FW:", message));
                                            } else if (message.indexOf("VOLUME") >= 0) {
                                                setState(pfad + radio.pfad + "." + "Command", findstr("COMMAND:", message));
                                                setState(pfad + radio.pfad + "." + "ID", findstr("ID:", message));
                                                setState(pfad + radio.pfad + "." + "VOLUME", parseInt(findstr("VOLUME_SET:", message)));
                                                if (parseInt(findstr("VOLUME_SET:", message)) >= 0 && parseInt(findstr("VOLUME_SET:", message)) <= 31 && message.indexOf("RESPONSE:ACK") >= 0) {
                                                    setState(pfad + radio.pfad + "." + "COMMAND.VOLUME_SET", parseInt(findstr("VOLUME_SET:", message)), true);
                                                }
                                            } else if (message.indexOf("POWER_STATUS") >= 0) {
                                                setState(pfad + radio.pfad + "." + "Command", findstr("COMMAND:", message));
                                                setState(pfad + radio.pfad + "." + "ID", findstr("ID:", message));
                                                setState(pfad + radio.pfad + "." + "POWER", findstr("POWER:", message));
                                                if (findstr("POWER:", message) == "ON") {
                                                    setState(pfad + radio.pfad + "." + "COMMAND.RADIO_ON", true, true)
                                                } else if (findstr("POWER:", message) == "OFF") {
                                                    setState(pfad + radio.pfad + "." + "COMMAND.RADIO_ON", false, true)
                                                };
                                                setState(pfad + radio.pfad + "." + "ENERGY_MODE", findstr("ENERGY_MODE:", message));
                                            } else if (message.indexOf("TUNEIN_PARTNER_ID") >= 0) {
                                                setState(pfad + radio.pfad + "." + "Command", findstr("COMMAND:", message));
                                                setState(pfad + radio.pfad + "." + "ID", findstr("ID:", message));
                                                setState(pfad + radio.pfad + "." + "TUNEIN_ID", findstr("PARTNERID:", message));
                                                setState(pfad + radio.pfad + "." + "TUNEIN_SNR", findstr("SERNO:", message));
                                            } else if (message.indexOf("ALL_STATION_INFO") >= 0) {
                                                setState(pfad + radio.pfad + "." + "Command", findstr("COMMAND:", message));
                                                setState(pfad + radio.pfad + "." + "ID", findstr("ID:", message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_1_NAME", findstr("1\r\nNAME:", message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_1_URL", findstr(findstr("1\r\nNAME:", message) + '\r\nURL:', message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_2_NAME", findstr("2\r\nNAME:", message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_2_URL", findstr(findstr("2\r\nNAME:", message) + '\r\nURL:', message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_3_NAME", findstr("3\r\nNAME:", message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_3_URL", findstr(findstr("3\r\nNAME:", message) + '\r\nURL:', message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_4_NAME", findstr("4\r\nNAME:", message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_4_URL", findstr(findstr("4\r\nNAME:", message) + '\r\nURL:', message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_5_NAME", findstr("5\r\nNAME:", message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_5_URL", findstr(findstr("5\r\nNAME:", message) + '\r\nURL:', message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_6_NAME", findstr("6\r\nNAME:", message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_6_URL", findstr(findstr("6\r\nNAME:", message) + '\r\nURL:', message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_7_NAME", findstr("7\r\nNAME:", message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_7_URL", findstr(findstr("7\r\nNAME:", message) + '\r\nURL:', message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_8_NAME", findstr("8\r\nNAME:", message));
                                                setState(pfad + radio.pfad + "." + "STATIONS.STATION_8_URL", findstr(findstr("8\r\nNAME:", message) + '\r\nURL:', message));
                                            } else if (message.indexOf("PLAYING_MODE") >= 0) {
                                                setState(pfad + radio.pfad + "." + "Command", findstr("COMMAND:", message));
                                                setState(pfad + radio.pfad + "." + "ID", findstr("ID:", message));
                                                setState(pfad + radio.pfad + "." + "PLAYING_MODE", findstr("MODE:", message));
                                                setState(pfad + radio.pfad + "." + "PLAYING", findstr("PLAYING:", message));
                                                setState(pfad + radio.pfad + "." + "STATION_ID_PLAYING", findstr("N\r\nID:", message));
                                                setState(pfad + radio.pfad + "." + "STATION_URL_PLAYING", findstr("URL:", message));
                                                setState(pfad + radio.pfad + "." + "STATION_PLAYING", findstr("NAME:", message));
                                            };
                                        } else if (command == "NOTIFICATION") {
                                            var event = findstr("EVENT:", message);
                                            setState(pfad + radio.pfad + "." + "Command", findstr("COMMAND:", message));
                                            setState(pfad + radio.pfad + "." + "IPADDR", findstr("IP:", message));
                                            setState(pfad + radio.pfad + "." + "NAME", findstr("NAME:", message));
                                            if (logging) log("Event = '" + event + "'");
                                            if (event == 'POWER_OFF' || event == 'POWER_ON') {
                                                sendcmd('COMMAND:GET\r\nPOWER_STATUS\r\nID:ioBroker\r\n\r\n');
                                            };
                                            if (event == "VOLUME_CHANGED") {
                                                sendcmd('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n');
                                            };
                                            if (event == 'STATION_CHANGED') {
                                            };
                                        } else if (command == "SET") {
                                            if (message.indexOf("VOLUME_ABSOLUTE") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                                                setState(pfad + radio.pfad + "." + "VOLUME", parseInt(findstr("VOLUME_SET:", message)), true);
                                                setState(pfad + radio.pfad + "." + "COMMAND.VOLUME_SET", parseInt(findstr("VOLUME_SET:", message)), true)
                                            }
                                            if (message.indexOf("VOLUME_DEC") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                                                setState(pfad + radio.pfad + "." + "VOLUME", parseInt(findstr("VOLUME_SET:", message)), true);
                                                setState(pfad + radio.pfad + "." + "COMMAND.VOLUME_SET", parseInt(findstr("VOLUME_SET:", message)), true)
                                            }
                                            if (message.indexOf("VOLUME_INC") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                                                setState(pfad + radio.pfad + "." + "VOLUME", parseInt(findstr("VOLUME_SET:", message)), true);
                                                setState(pfad + radio.pfad + "." + "COMMAND.VOLUME_SET", parseInt(findstr("VOLUME_SET:", message)), true)
                                            }
                                            if (message.indexOf("VOLUME_UNMUTE") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                                                setState(pfad + radio.pfad + "." + "COMMAND.VOLUME_MUTE", false, true)
                                            }
                                            if (message.indexOf("VOLUME_MUTE") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                                                setState(pfad + radio.pfad + "." + "COMMAND.VOLUME_MUTE", true, true)
                                            }
                                            if (message.indexOf("RADIO_OFF") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                                                setState(pfad + radio.pfad + "." + "COMMAND.RADIO_ON", false, true);
                                                setState(pfad + radio.pfad + "." + "POWER", "OFF");
                                            }
                                            if (message.indexOf("RADIO_ON") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                                                setState(pfad + radio.pfad + "." + "COMMAND.RADIO_ON", true, true);
                                                setState(pfad + radio.pfad + "." + "POWER", "ON");
                                            }
                                        } else if (command == "PLAY") {
                                            if (message.indexOf("STATION") >= 0 && message.indexOf("RESPONSE:ACK") >= 0) {
                                                setState(pfad + radio.pfad + "." + "COMMAND.PLAY_STATION", parseInt(findstr("STATION:", message)), true);
                                                setState(pfad + radio.pfad + "." + "STATION_ID_PLAYING", parseInt(findstr("STATION:", message)), true);
                                                setState(pfad + radio.pfad + "." + "STATION_PLAYING", findstr("PLAYING:", message), true);
                                            }
                                        } else {
                                        
                                            if (logging) log('unexpected message: ' + message);
                                        
                                        }
                                        });
                                         
                                        // starten der Abfragen nach Empfang von Broadcasts
                                        /* var timer = null;
                                         
                                        server2.on('message', function (message, remote) {
                                            if (timer) clearTimeout(timer);
                                            if (logging) log('Broadcast vom Radio: ' + message);
                                            if (logging) log(JSON.stringify(message));
                                            //var obj = JSON.parse('{'+message+'}');
                                            sendcmd(buf2);
                                            timer = setTimeout(function () {
                                                sendcmd(buf3);
                                            }, 1000);
                                        }); */
                                        function findstr(name, str) {
                                            var suchstring = String(name);
                                            var teststring = String(str);
                                            var pos = parseInt(teststring.indexOf(suchstring) + suchstring.length);
                                            var zaehler = parseInt(pos) + 1;
                                            //log("String: " + suchstring + "befindet sich an " + pos + " Stelle")
                                            do {
                                                var Zeichen = String(teststring).charCodeAt(zaehler);
                                                //log ("Zeichen: " + Zeichen + " Zähler: " + (zaehler - pos));
                                                zaehler = zaehler + 1;
                                            } while (Zeichen != 13 && zaehler - pos <= 100);
                                         
                                         
                                            //log("Start: " + pos + "Ende: " + zaehler);
                                            var ergebnis = String(str).substring(pos, zaehler - 1);
                                            if (teststring.indexOf(suchstring) == -1) {
                                                ergebnis = ""
                                            };
                                         
                                            //log("Objekt: " + name + " Wert: '" + ergebnis + "'");
                                            return ergebnis
                                        }
                                         
                                         
                                        function sendcmd(cmd) {
                                            radios.forEach(radio=>{
                                            socket.send(cmd, 0, cmd.length, UDPPort, radio.IP, function (err, result) {
                                                if (err) log('Fehler Senden ' + cmd, 'error');
                                                else {
                                                    if (logging) log('Kommando gesendet: ' + cmd);
                                                }
                                            });
                                        
                                            })
                                            
                                        }
                                        //einmalige Ausführung beim  Starten des Skriptes
                                        
                                        
                                        sendcmd('COMMAND:GET\r\nPOWER_STATUS\r\nID:ioBroker\r\n\r\n');
                                        sendcmd('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n');
                                        sendcmd('COMMAND:GET\r\nINFO_BLOCK\r\nID:ioBroker\r\n\r\n');
                                        sendcmd('COMMAND:GET\r\nPLAYING_MODE\r\nID:ioBroker\r\n\r\n');
                                        sendcmd('COMMAND:GET\r\nALL_STATION_INFO\r\nID:ioBroker\r\n\r\n');
                                        
                                         
                                        var timer1 = null;
                                        var timer2 = null;
                                        var timer3 = null;
                                        var timer4 = null;
                                        schedule('*/1 * * * *', function () {  // jede Minute die wichtigsten Infos aktualisieren
                                         
                                            if (timer1) clearTimeout(timer1);
                                            timer1 = setTimeout(function () {
                                                sendcmd('COMMAND:GET\r\nPOWER_STATUS\r\nID:ioBroker\r\n\r\n');
                                            }, 1000);
                                            if (timer2) clearTimeout(timer2);
                                            timer2 = setTimeout(function () {
                                                sendcmd('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n');
                                            }, 2000);
                                            if (timer3) clearTimeout(timer3);
                                            timer3 = setTimeout(function () {
                                                sendcmd('COMMAND:GET\r\nINFO_BLOCK\r\nID:ioBroker\r\n\r\n');
                                            }, 3000);
                                            if (timer4) clearTimeout(timer4);
                                            timer4 = setTimeout(function () {
                                                sendcmd('COMMAND:GET\r\nPLAYING_MODE\r\nID:ioBroker\r\n\r\n');
                                            }, 4000);
                                        });
                                         
                                        schedule('*/30 * * * *', function () {  // alle 30 Minuten die Stationsliste aktualisieren
                                            sendcmd('COMMAND:GET\r\nALL_STATION_INFO\r\nID:ioBroker\r\n\r\n');
                                        });
                                        
                                        // Reaktionen auf Befehle
                                        // on({ id: pfad2 + "COMMAND.VOLUME_INC", val: true }, function (obj) {
                                        //     if (logging) log('COMMAND.VOLUME_INC');
                                        //     sendcmd('COMMAND:SET\r\nVOLUME_INC\r\nID:ioBroker\r\n\r\n');
                                        //     sendcmd('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n');
                                        // });
                                        // on({ id: pfad2 + "COMMAND.VOLUME_DEC", val: true }, function (obj) {
                                        //     if (logging) log('COMMAND.VOLUME_DEC');
                                        //     sendcmd('COMMAND:SET\r\nVOLUME_DEC\r\nID:ioBroker\r\n\r\n');
                                        //     sendcmd('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n');
                                        // });
                                        // on({ id: pfad2 + "COMMAND.VOLUME_MUTE", change: "ne" }, function (obj) {
                                        //     if (logging) log('COMMAND.VOLUME_MUTE');
                                        //     if (obj.state.val === true) {
                                        //         sendcmd('COMMAND:SET\r\nVOLUME_MUTE\r\nID:ioBroker\r\n\r\n');
                                        //     }
                                        //     if (obj.state.val === false) {
                                        //         sendcmd('COMMAND:SET\r\nVOLUME_UNMUTE\r\nID:ioBroker\r\n\r\n');
                                        //     }
                                        //     sendcmd('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n');
                                        // });
                                        // on({ id: pfad2 + "COMMAND.RADIO_ON", change: "ne", ack: false }, function (obj) {
                                        //     if (logging) log('COMMAND.RADIO_ON');
                                        //     if (obj.state.val === true) {
                                        //         sendcmd('COMMAND:SET\r\nRADIO_ON\r\nID:ioBroker\r\n\r\n');
                                        //     }
                                        //     if (obj.state.val === false) {
                                        //         sendcmd('COMMAND:SET\r\nRADIO_OFF\r\nID:ioBroker\r\n\r\n');
                                        //     }
                                        //     sendcmd('COMMAND:GET\r\nPOWER_STATUS\r\nID:ioBroker\r\n\r\n');
                                        // });
                                        // on({ id: pfad2 + "COMMAND.PLAY_STATION", change: "ne", ack: false }, function (obj) {
                                        //     if (logging) log('COMMAND.PLAY_STATION');
                                        //     if (obj.state.val <= 8 && obj.state.val > 0) {
                                        //         sendcmd('COMMAND:PLAY\r\nSTATION:' + obj.state.val + '\r\nID:ioBroker\r\n\r\n');
                                        //     }
                                        // });
                                        // on({ id: pfad2 + "COMMAND.VOLUME_SET", change: "ne", ack: false }, function (obj) {
                                        //     if (logging) log('COMMAND.PLAY_STATION');
                                        //     if (obj.state.val <= 31 && obj.state.val >= 0) {
                                        //         sendcmd('COMMAND:SET\r\nVOLUME_ABSOLUTE:' + obj.state.val + '\r\nID:ioBroker\r\n\r\n');
                                        //     }
                                        // }); 
                                        
                                        1 Reply Last reply Reply Quote 0
                                        • E
                                          Eaterhnk @Nahasapee last edited by Eaterhnk

                                          @Nahasapee
                                          vielen Dank für deine Hilfe, habe das geänderte Skript kopiert und die IPs bzw den Pfad angepasst. Leider funktioniert es nicht. Habe aber in dem vorherigen Skript in Zeile 97 die von dir genannten Befehle eingefügt und im LOG wird folgendes ausgegeben:

                                          javascript.0 2019-12-11 20:38:26.941 info at process._tickCallback (internal/process/next_tick.js:63:19)
                                          javascript.0 2019-12-11 20:38:26.941 info at state.handle.lookup (dgram.js:242:18)
                                          javascript.0 2019-12-11 20:38:26.941 info Error: bind EADDRINUSE 0.0.0.0:4242
                                          javascript.0 2019-12-11 20:38:26.941 info (29194) script.js.Skrypte_in_Betrieb.Radio_Kueche: server error:
                                          javascript.0 2019-12-11 20:38:26.940 info (29194) script.js.Skrypte_in_Betrieb.Radio_Kueche: registered 6 subscriptions and 2 schedules
                                          javascript.0 2019-12-11 20:38:26.927 info (29194) Start javascript script.js.Skrypte_in_Betrieb.Radio_Kueche

                                          1 Reply Last reply Reply Quote 0
                                          • N
                                            Nahasapee last edited by

                                            @Eaterhnk sagte in [Vorlage] Busch Jäger Radio iNet 8216 U:

                                            javascript.0 2019-12-11 20:38:26.941 info Error: bind EADDRINUSE 0.0.0.0:4242

                                            du musst deine java script Instanz stoppen und wieder starten , das Skript scheint die ports nicht wieder freizugeben
                                            und
                                            @Eaterhnk sagte in [Vorlage] Busch Jäger Radio iNet 8216 U:

                                            . Leider funktioniert es nicht.

                                            die info ist bisschen wenig um dir zu helfen 😉

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            1.1k
                                            Online

                                            31.7k
                                            Users

                                            79.7k
                                            Topics

                                            1.3m
                                            Posts

                                            8
                                            38
                                            3964
                                            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