Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Weissnicht

    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

    W
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 20
    • Best 3
    • Groups 1

    Weissnicht

    @Weissnicht

    Starter

    3
    Reputation
    11
    Profile views
    20
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Weissnicht Follow
    Starter

    Best posts made by Weissnicht

    • RE: [gelöst] MQTT - Problem mit Publish

      @mickym

      Und Dein letzter Satz stimmt einfach nicht - bei mir geht das ohne Probleme.

      Tja, nach meiner heutigen Erfahrung hat Du mit der letzten Aussage wohl recht - es geht.

      Ich habe jetzt nochmal probiert - auf einmal ging es obwohl ich mir mehr wie sicher bin, es bereits am Wochenende probiert zu haben. Keine Ahnung, was zwischen evtl. Tippfehlern und nicht gemachten Neustarts des Adapters nicht korrekt war.

      Also, der Trick ist: Man muss in dem Objekt, welches den Topic repräsentieren soll, unter dem Reiter NATIV einen Paramter topic anlegen, welcher als Inhalt genau den Topic hat , den man senden möchte. In meinem Beispiel also:
      Objekt.PNG

      Dieser Topic wird dann vom MQTT Adapter genauso veröffentlicht. Puh, ich könnte schwören, das hatte ich das am Wochenende genauso getestet hatte.

      Der MQTT Adapter muss dann nur diesen (oder auch noch andere) Objektbaum abonnieren, wie hier:
      Abo.PNG
      Dann veröffentlicht er das bei jeder Änderung im Objekt ohne irgendwelche Zusätze.
      Und da ich den Objekt-Baum des Adapers selbst nicht abonniere, ist es auch egal, was sich dort ändert.

      Nebenbei, ich konnte jetzt keine negativen Effekte erkennen, im Adapter Publish bei Änderungen und Bekanntgabe eigene States beim Verbinden anzukreuzen.
      Und diese beiden Funktionen benötige ich ja auch. Oder?

      Das Einzige, was mich jetzt noch stört, hat scheinbar was mit Mosquitto zu tun oder ist ein Thema des MQTT Protokolls:
      Da der MQTT Adapter alles abonniert, was mit instar anfängt, sendet der Mosquitto Broker auch immer die Veröffentlichung des MQTT Adapters wieder zurück an diesen. Warum, verstehe ich noch nicht ganz. Liegt aber einfach nur daran, dass der Adapter eben alles zu diesem Präfix-Topic abonniert hat. Auch die eigenen Meldungen 🙂

      Bin jetzt sehr zufrieden, habe einen MQTT Broker der unabhängig vom ioBroker funktioniert, was später evtl. eine Spielwiese für andere Projekte öffnet 😊

      posted in ioBroker Allgemein
      W
      Weissnicht
    • RE: Kostal Smartmeter per modbus auslesen

      @uli977
      Gut, dann war es doch die fehlende "1"

      Hier als Startpunkt mal meine Registereinstellungen. Hatte lange gebraucht zu kapieren, wie es funktioniert.
      7475cfbd-2472-431a-8cc0-e71b042b0f6e-grafik.png

      posted in ioBroker Allgemein
      W
      Weissnicht
    • RE: Adapter: ebus

      Da ich auch gerade (mal wieder) mit dem ebus kämpfe noch ein Tipp von mir, um zumindest immer gleiche Ergebnisse zu erhalten, falls noch jemand das Problem hat:

      Da der ebus Service bei mir beim Starten sehr unzuverlässig die csv Dateien den gescannten Geräten zugeordnet hat (mal garnicht, mal eine ander Datei genommen) wurden danach andere Objekte in ioBroker aktualisiert bzw. halt nicht mehr aktualisiert. Im dümmsten Fall wurde auf git die csv aktualisiert und etwas umbenannt, dann war es nach Neustart des ebus Service ein anderes Objekt. Dadurch hat meine VIS oft nicht mehr gestimmt.
      Ich habe jetzt die csv lokal abgelegt (durch ein lokales git repository clonen, sehr einfach; händisch kopieren hat nur zu Fehlermeldungen geführt) und seitdem ist nach jedem ebus Neustart auf dem Raspi die Zurodnung der csv identisch 👍

      Wenn man nun wie im vorherigen Post einen Status hat, der immer wieder ungwewollt auftaucht, kann man diese Zeile in der lokalen csv einfach löschen. Dann erscheint er nach Neustart des ebus daemons sicher nicht mehr.

      ABER: klar, Aktualisierungen werden online dann nicht mehr gezogen. Da sich eine Heizungssystem aber nicht sooo oft ändert, ist das akzeptabel, denke ich.

      Was ich noch nicht herausgefunden habe: wie kann ich manuell eine csv einem in ebus gefundenem Gerät zuordnen, z.B. nach einem Scan? Aber das ist keine ioBroker Frage, sondern ebus ☺

      posted in ioBroker Allgemein
      W
      Weissnicht

    Latest posts made by Weissnicht

    • RE: eBus Adapter Vaillant

      @drurob
      Hast du mal verglichen, welche csv vorher angezogen wurde und welche jetzt?
      Meine Erfahrung mit werten d/nicht da ist, dass (aus mir unbekannten Gründen) andere csv angezogen werden.
      Um das zukünftig zu umgehen habe ich nun auf lokale csv umgestellt.

      posted in ioBroker Allgemein
      W
      Weissnicht
    • RE: Adapter: ebus

      Da ich auch gerade (mal wieder) mit dem ebus kämpfe noch ein Tipp von mir, um zumindest immer gleiche Ergebnisse zu erhalten, falls noch jemand das Problem hat:

      Da der ebus Service bei mir beim Starten sehr unzuverlässig die csv Dateien den gescannten Geräten zugeordnet hat (mal garnicht, mal eine ander Datei genommen) wurden danach andere Objekte in ioBroker aktualisiert bzw. halt nicht mehr aktualisiert. Im dümmsten Fall wurde auf git die csv aktualisiert und etwas umbenannt, dann war es nach Neustart des ebus Service ein anderes Objekt. Dadurch hat meine VIS oft nicht mehr gestimmt.
      Ich habe jetzt die csv lokal abgelegt (durch ein lokales git repository clonen, sehr einfach; händisch kopieren hat nur zu Fehlermeldungen geführt) und seitdem ist nach jedem ebus Neustart auf dem Raspi die Zurodnung der csv identisch 👍

      Wenn man nun wie im vorherigen Post einen Status hat, der immer wieder ungwewollt auftaucht, kann man diese Zeile in der lokalen csv einfach löschen. Dann erscheint er nach Neustart des ebus daemons sicher nicht mehr.

      ABER: klar, Aktualisierungen werden online dann nicht mehr gezogen. Da sich eine Heizungssystem aber nicht sooo oft ändert, ist das akzeptabel, denke ich.

      Was ich noch nicht herausgefunden habe: wie kann ich manuell eine csv einem in ebus gefundenem Gerät zuordnen, z.B. nach einem Scan? Aber das ist keine ioBroker Frage, sondern ebus ☺

      posted in ioBroker Allgemein
      W
      Weissnicht
    • RE: Kostal Smartmeter per modbus auslesen

      @hank-0
      Bist Du dir sicher, dass der Wert im SM überhaupt zur Verfügung steht?

      Ich berechne ihn innerhalb von ioBroker, da der Wert nicht zur Verfüguing steht.

      Marc

      posted in ioBroker Allgemein
      W
      Weissnicht
    • Backitup und SSL Zertifikat von Grafana

      Hallo zusammen,

      ich setze gerade meinen Raspi neu auf und komme da an ein paar Dingen vorbei.

      Mir ist aufgefallen, dass Grafana von Backitup garnie gesichert wurde (keine Ahnung, war mir keiner Meldung bewusst).
      Aber egal, es liegt daran, dass ich ein eignes Zertifikat nutze. Dafür wurde ab 2.5.x ja die Option zum Zulassen selbst signierter Zertifikate hinzugefügt. Wenn ich diese nutze, funktioniert das Backup 👍

      Aber: Ich habe ein selbst signiertes Zertifikat, habe aber mein CA überall wo mir bekannt hinterlegt (also Raspis, PCs, Smartphnes etc.)

      Trotzdem wird Grafana nur gesichert, wenn ich die Prüfung deaktiviere.
      Daher meine Frage: Wo prüft der Backitup Adapter, ob das Zertifikat signiert ist? D.h. welche CA Liste nutzt er?

      Danke 🙂

      Marc

      posted in ioBroker Allgemein
      W
      Weissnicht
    • RE: Test Adapter KNX v2.x

      @chefkoch009
      Habe diesen Verzögerungseffekt zB auch beim Senden von Datum / Uhrzeit aus ioBroker an KNX. In Version 2.0.13 passiert das nicht.

      posted in Tester
      W
      Weissnicht
    • RE: [Vorlage] Busch Jäger Radio iNet 8216 U

      @e-s
      Ah, danke!
      Interessant, hätte ich nie gefunden 👶

      Sieht auf den ersten Blick noch rudimentär aus aber werde ich bei Gelegenheit mal testen.
      Mit dem Skript läuft es ganz gut. Lediglich der Erfolg, die Lautstärke automatisch anzupassen, wenn das Radio (z.B. spät Abends) eingeschaltet wird, ist vom Zeitpunkt des Befehls abhängig, ob es klappt.
      Naja, gut zu wissen.

      posted in JavaScript
      W
      Weissnicht
    • RE: Kostal Smartmeter per modbus auslesen

      @martybr
      Gerne:
      6efeb00b-ae42-4c14-a08e-60130a2d3a84-grafik.png

      posted in ioBroker Allgemein
      W
      Weissnicht
    • RE: Kostal Smartmeter per modbus auslesen

      @uli977
      Gut, dann war es doch die fehlende "1"

      Hier als Startpunkt mal meine Registereinstellungen. Hatte lange gebraucht zu kapieren, wie es funktioniert.
      7475cfbd-2472-431a-8cc0-e71b042b0f6e-grafik.png

      posted in ioBroker Allgemein
      W
      Weissnicht
    • RE: Kostal Smartmeter per modbus auslesen

      @uli977
      Falls es hilft: Nutze die gleichen Einstellungen in Verbindung mit dem KSEM und einem PIKO 12.
      Das einzige, was mir auffällt, ist das Abfrageintervall (habe 2000ms), denke aber das ist nicht das Problem.
      Z.Info, am Piko habe ich die Modbus Adresse 1 eingestellt.
      Erinnere mich, habe lange mit den Registereinstellungen herumgemacht, bis es funktioniert hat.

      posted in ioBroker Allgemein
      W
      Weissnicht
    • RE: [Vorlage] Busch Jäger Radio iNet 8216 U

      @crunchip @CKO

      ja, so ist es (wohl). Habe diese Korrektur bei mir bereits vorgenommen, daher hier gerne zum C&P.

      Und wirklich, funktioniert prima als Skript! 👍 Aber ein Adapter wäre auch etwas schönes 🙂

      Off topic: Seit iOS15 ist die Busch Jäger App nicht mal mehr aufrufbar am Telefon

      /* Change history:
      v1.2
      - added ack: true to setstates() command when states are updated by the radio
      
      v1.1
      - comment of line var RadioIpaddress as no longer used due to multi radio support
      - found bug: if IP address not correct, the jscript adapter crashes; has to be fixed. How?
      - added function onClose to relese the socket binding when script ist stopped / restarted
        otherwise restart throws an error due to binding to port not possible as still blocked
      
      v1.0 script copy of ioBroker forum from user intruder7
      */
      
      var pfad = 'Geraete.BuschJaeger.RadioINet.';
      var pfad2 = 'javascript.0.' + pfad
       // vollständiger id Pfad wird: pfad2 + radio.pfad
      
      var UDPListenPort = 4242; //nicht ändern 
      var UDPPort = 4244; //nicht ändern 
      // var RadioIPadress = '192.168.2.67' // IP Adresse des Radios
      var HOST = '0.0.0.0'; //nicht ändern 
      
      var logging = false;
       
      /* ToDo: 
      - wenn IP nicht korrekt, stürzt der komplette jscript Adapter ab!
        Grund: Das sende-Kommando kann nicht gebaut werden: radio.path ist undefined für die IP
      - Prüfen, ob sendcmd und sendcmdToIP vereinheitlicht werden kann
        sendcmd: sendet an alle Radios
        sendcmdToIP: sendet nur an ein bestimmtes Radio
      */
      
      const radios =  [
           {
                   IP: '192.168.2.67',
                   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 = ()=>{    
          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 });
      };
      
      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);
      });
      
      try{
      server.bind(UDPListenPort);
      }
      
      catch(error){console.log(error);}
       
      
      /* 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('(148) 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),true);
      
              setState(pfad + radio.pfad + "." + "WLAN_STRENGTH", findstr("WLAN STRENGTH:", message),true);
      
              setState(pfad + radio.pfad + "." + "NAME", findstr("NAME:", message),true);
      
              setState(pfad + radio.pfad + "." + "ID", findstr("ID:", message),true);
      
              setState(pfad + radio.pfad + "." + "IPADDR", findstr("IPADDR:", message),true);
      
              setState(pfad + radio.pfad + "." + "IPMASK", findstr("IPMASK:", message),true);
      
              setState(pfad + radio.pfad + "." + "IPMODE", findstr("IPMODE:", message),true);
      
              setState(pfad + radio.pfad + "." + "GATEWAY", findstr("GATEWAY:", message),true);
      
              setState(pfad + radio.pfad + "." + "SSID", findstr("SSID:", message),true);
      
              setState(pfad + radio.pfad + "." + "MAC_ADRESS", findstr("MAC:", message),true);
      
              setState(pfad + radio.pfad + "." + "COUNTRY", findstr("COUNTRY:", message),true);
      
              setState(pfad + radio.pfad + "." + "SERIAL_NR", findstr("SERNO:", message),true);
      
              setState(pfad + radio.pfad + "." + "SW-VERSION", findstr("SW-VERSION:", message),true);
      
              setState(pfad + radio.pfad + "." + "WLAN-FW", findstr("WLAN-FW:", message),true);
      
          } else if (message.indexOf("VOLUME") >= 0) {
      
              setState(pfad + radio.pfad + "." + "Command", findstr("COMMAND:", message),true);
      
              setState(pfad + radio.pfad + "." + "ID", findstr("ID:", message),true);
      
              setState(pfad + radio.pfad + "." + "VOLUME", parseInt(findstr("VOLUME_SET:", message)),true);
      
              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),true);
      
              setState(pfad + radio.pfad + "." + "ID", findstr("ID:", message),true);
      
              setState(pfad + radio.pfad + "." + "POWER", findstr("POWER:", message),true);
      
              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),true);
      
          } else if (message.indexOf("TUNEIN_PARTNER_ID") >= 0) {
      
              setState(pfad + radio.pfad + "." + "Command", findstr("COMMAND:", message),true);
      
              setState(pfad + radio.pfad + "." + "ID", findstr("ID:", message),true);
      
              setState(pfad + radio.pfad + "." + "TUNEIN_ID", findstr("PARTNERID:", message),true);
      
              setState(pfad + radio.pfad + "." + "TUNEIN_SNR", findstr("SERNO:", message),true);
      
          } else if (message.indexOf("ALL_STATION_INFO") >= 0) {
      
              setState(pfad + radio.pfad + "." + "Command", findstr("COMMAND:", message),true);
      
              setState(pfad + radio.pfad + "." + "ID", findstr("ID:", message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_1_NAME", findstr("1\r\nNAME:", message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_1_URL", findstr(findstr("1\r\nNAME:", message) + '\r\nURL:', message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_2_NAME", findstr("2\r\nNAME:", message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_2_URL", findstr(findstr("2\r\nNAME:", message) + '\r\nURL:', message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_3_NAME", findstr("3\r\nNAME:", message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_3_URL", findstr(findstr("3\r\nNAME:", message) + '\r\nURL:', message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_4_NAME", findstr("4\r\nNAME:", message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_4_URL", findstr(findstr("4\r\nNAME:", message) + '\r\nURL:', message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_5_NAME", findstr("5\r\nNAME:", message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_5_URL", findstr(findstr("5\r\nNAME:", message) + '\r\nURL:', message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_6_NAME", findstr("6\r\nNAME:", message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_6_URL", findstr(findstr("6\r\nNAME:", message) + '\r\nURL:', message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_7_NAME", findstr("7\r\nNAME:", message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_7_URL", findstr(findstr("7\r\nNAME:", message) + '\r\nURL:', message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_8_NAME", findstr("8\r\nNAME:", message),true);
      
              setState(pfad + radio.pfad + "." + "STATIONS.STATION_8_URL", findstr(findstr("8\r\nNAME:", message) + '\r\nURL:', message),true);
      
          } else if (message.indexOf("PLAYING_MODE") >= 0) {
      
              setState(pfad + radio.pfad + "." + "Command", findstr("COMMAND:", message),true);
      
              setState(pfad + radio.pfad + "." + "ID", findstr("ID:", message),true);
      
              setState(pfad + radio.pfad + "." + "PLAYING_MODE", findstr("MODE:", message),true);
      
              setState(pfad + radio.pfad + "." + "PLAYING", findstr("PLAYING:", message),true);
      
              setState(pfad + radio.pfad + "." + "STATION_ID_PLAYING", findstr("N\r\nID:", message),true);
      
              setState(pfad + radio.pfad + "." + "STATION_URL_PLAYING", findstr("URL:", message),true);
      
              setState(pfad + radio.pfad + "." + "STATION_PLAYING", findstr("NAME:", message),true);
      
          };
      
      } else if (command == "NOTIFICATION") {
      
          var event = findstr("EVENT:", message);
      
          setState(pfad + radio.pfad + "." + "Command", findstr("COMMAND:", message),true);
      
          setState(pfad + radio.pfad + "." + "IPADDR", findstr("IP:", message),true);
      
          setState(pfad + radio.pfad + "." + "NAME", findstr("NAME:", message),true);
      
          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",true);
      
          }
      
          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",true);
      
          }
      
      } 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 = (teststring.indexOf(suchstring) + suchstring.length);
      
          var zaehler = (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('(477) Kommando gesendet: ' + cmd);
      
              }
      
          });})   
      
      }
      
       
      
      function sendcmdToIp(cmd,IP) {    
      
          socket.send(cmd, 0, cmd.length, UDPPort, IP, function (err, result) {
      
              if (err) log('Fehler Senden ' + cmd, 'error');
      
              else {
      
                  if (logging) log('(495) 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');
      
      });
      
       
      
      const initOnForAllRadios =()=>{
      
          radios.forEach(radio=>
      
          {
      
            on({ id: pfad2 + radio.pfad + ".COMMAND.VOLUME_INC", val: true }, function (obj) {                        
      
                  
      
                       sendcmdToIp('COMMAND:SET\r\nVOLUME_INC\r\nID:ioBroker\r\n\r\n',radio.IP);
      
                       sendcmdToIp('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n',radio.IP);
      
                   });                                                                         
      
       
      
             on({ id: pfad2 + radio.pfad + ".COMMAND.VOLUME_DEC", val: true }, function (obj) {        
      
               sendcmdToIp('COMMAND:SET\r\nVOLUME_DEC\r\nID:ioBroker\r\n\r\n',radio.IP);
      
               sendcmdToIp('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n',radio.IP);});
      
             on({ id: pfad2  + radio.pfad + ".COMMAND.VOLUME_MUTE", change: "ne" }, function (obj) {            
      
                  if (obj.state.val === true) {
      
                      sendcmdToIp('COMMAND:SET\r\nVOLUME_MUTE\r\nID:ioBroker\r\n\r\n',radio.IP);}
      
                  if (obj.state.val === false) {
      
                    sendcmdToIp('COMMAND:SET\r\nVOLUME_UNMUTE\r\nID:ioBroker\r\n\r\n',radio.IP);
      
                  }
      
               sendcmdToIp('COMMAND:GET\r\nVOLUME\r\nID:ioBroker\r\n\r\n',radio.IP);
      
               });
      
             on({ id: pfad2 +radio.pfad+ ".COMMAND.RADIO_ON", change: "ne", ack: false }, function (obj) {    
      
                      if (obj.state.val === true) 
      
                          sendcmdToIp('COMMAND:SET\r\nRADIO_ON\r\nID:ioBroker\r\n\r\n',radio.IP);                
      
                      if (obj.state.val === false) 
      
                          sendcmdToIp('COMMAND:SET\r\nRADIO_OFF\r\nID:ioBroker\r\n\r\n',radio.IP);    
      
                      sendcmdToIp('COMMAND:GET\r\nPOWER_STATUS\r\nID:ioBroker\r\n\r\n',radio.IP);});
      
            on({ id: pfad2 +radio.pfad+ ".COMMAND.PLAY_STATION", change: "ne", ack: false }, function (obj) {    
      
              if (obj.state.val <= 8 && obj.state.val > 0) {
      
                  sendcmdToIp('COMMAND:PLAY\r\nSTATION:' + obj.state.val + '\r\nID:ioBroker\r\n\r\n',radio.IP);}}); 
      
            on({ id: pfad2+radio.pfad + ".COMMAND.VOLUME_SET", change: "ne", ack: false }, function (obj) {    
      
              if (obj.state.val <= 31 && obj.state.val >= 0) {
      
                  sendcmdToIp('COMMAND:SET\r\nVOLUME_ABSOLUTE:' + obj.state.val + '\r\nID:ioBroker\r\n\r\n',radio.IP);}});         
      
          });
      
      };
      
      initOnForAllRadios();
      
      onStop(() => { 
      
          socket.close();
          server.close();
      
      });
      
      posted in JavaScript
      W
      Weissnicht
    Community
    Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
    The ioBroker Community 2014-2023
    logo