Skip to content
  • Home
  • Aktuell
  • Tags
  • 0 Ungelesen 0
  • Kategorien
  • Unreplied
  • Beliebt
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Standard: (Kein Skin)
  • Kein Skin
Einklappen
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. JavaScript
  5. Internet Filter in der Fritzbox mit JavaScript setzen

NEWS

  • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?
    apollon77A
    apollon77
    48
    3
    8.5k

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    13
    1
    2.1k

  • Neues Video "KI im Smart Home" - ioBroker plus n8n
    BluefoxB
    Bluefox
    16
    1
    2.7k

Internet Filter in der Fritzbox mit JavaScript setzen

Geplant Angeheftet Gesperrt Verschoben JavaScript
fritzboxkindersicherungfilter
145 Beiträge 24 Kommentatoren 25.7k Aufrufe 36 Watching
  • Älteste zuerst
  • Neuste zuerst
  • Meiste Stimmen
Antworten
  • In einem neuen Thema antworten
Anmelden zum Antworten
Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
  • J jack99n

    Jetzt kommen wenigstens schon mal fehler.

    javascript.0	2020-09-14 12:40:02.130	error	(4020) at processTicksAndRejections (internal/process/task_queues.js:97:5)
    javascript.0	2020-09-14 12:40:02.130	error	(4020) at runMicrotasks (<anonymous>)
    javascript.0	2020-09-14 12:40:02.130	error	(4020) at /opt/iobroker/node_modules/standard-as-callback/built/index.js:19:49
    javascript.0	2020-09-14 12:40:02.130	error	(4020) at tryCatcher (/opt/iobroker/node_modules/standard-as-callback/built/utils.js:11:23)
    javascript.0	2020-09-14 12:40:02.130	error	(4020) at /opt/iobroker/node_modules/iobroker.js-controller/lib/states/statesInRedis.js:608:33
    javascript.0	2020-09-14 12:40:02.130	error	(4020) at /opt/iobroker/node_modules/iobroker.javascript/main.js:1112:17
    javascript.0	2020-09-14 12:40:02.129	error	(4020) at /opt/iobroker/node_modules/iobroker.javascript/main.js:1521:17
    javascript.0	2020-09-14 12:40:02.129	error	(4020) at prepareScript (/opt/iobroker/node_modules/iobroker.javascript/main.js:1468:37)
    javascript.0	2020-09-14 12:40:02.129	error	(4020) at compile (/opt/iobroker/node_modules/iobroker.javascript/main.js:1245:28)
    javascript.0	2020-09-14 12:40:02.129	error	(4020) at Object.createScript (vm.js:261:10)
    javascript.0	2020-09-14 12:40:02.129	error	(4020) at new Script (vm.js:88:7)
    javascript.0	2020-09-14 12:40:02.129	error	(4020) SyntaxError: Unexpected token '*'
    javascript.0	2020-09-14 12:40:02.129	error	(4020) ^
    javascript.0	2020-09-14 12:40:02.128	error	(4020) */
    javascript.0	2020-09-14 12:40:02.127	error	at script.js.Programme.FritzBox_.Test:107
    javascript.0	2020-09-14 12:40:02.127	error	(4020) script.js.Programme.FritzBox_.Test compile failed:
    
    moelskiM Offline
    moelskiM Offline
    moelski
    schrieb am zuletzt editiert von
    #104

    @jack99n
    Es reicht wenn du dein Script bis Zeile 114 (function getFbChallenge(){) zeigst.
    An dem Rest wird eh nichts geändert.

    Grüße Dominik

    J 1 Antwort Letzte Antwort
    0
    • moelskiM moelski

      @jack99n
      Es reicht wenn du dein Script bis Zeile 114 (function getFbChallenge(){) zeigst.
      An dem Rest wird eh nichts geändert.

      J Offline
      J Offline
      jack99n
      schrieb am zuletzt editiert von
      #105

      @moelski

      /*******************************************************
      * Basis: 
      * https://community.openhab.org/t/disable-internet-connection-of-specific-echo-device-on-fritz-box-via-script/91374
      * https://forum.fhem.de/index.php?topic=109689.0
      * https://www.kuketz-blog.de/fritzbox-wlan-toggle-per-skript/
      *******************************************************/ 
       
      /*******************************************************
      * Script SetDeviceFilter
      * 
      * 13.09.20 V1.09    Regex mit Escape beim . und Fix für Liste
      * 12.09.20 V1.08    Regex um . erweitert
      * 12.09.20 V1.07    Erweritertes Logging aktivierbar für Fehlersuche
      * 08.09.20 V1.06    Anpassungen an FirtzOS 7.20 (Regex Auswertung für Listenerstellung)
      * 05.09.20 V1.05    Ausgabe einer Device / Filter Liste möglich als JSON 
      *                   Logging reduziert wenn FbListOnly = false
      * 04.09.20 V1.04    Fix für doppelte Einträge in Listen
      * 02.09.20 V1.03    Erweiterung zum automatischen Start mittels ioB Datenpunkt
      * 02.09.20 V1.02    Script Abbruch wenn der Login nicht geklappt hat
      * 02.09.20 V1.01    Regex Erweiterung, Login auch mit User/Passwort
      * 01.09.20 V1.00    erste öffentliches Release
      *******************************************************/ 
      const Version = "1.09";
       
      // TODO
      // * Liste erzeugen mit Devices und aktuellem Filter
      //   > als JSON in einen DP speichern -> für Tabellenauswertung
       
      // https://forum.iobroker.net/topic/16184/http-request-in-javascript/5
      var request = require('request');
      var headers = { 
          'Content-Type': 'application/x-www-form-urlencoded', 
          'User-Agent': 'curl/7.64.0', 
          'Accept': '*/*'
      }; 
       
      /*******************************************************
      * E I N S T E L L U N G E N 
      *******************************************************/
       
      // Die IP Der Fritzbox
      const FbIp          = "192.168.10.1";              
      // Der User der Fritzbox 
      // HINWEIS : Den Benutzer leer lassen wenn die Anmeldung an der FB nur mit Passwort erfolgt !
      const FbUser        = "********"; 
      // Das Password der Fritzbox                  
      const FbPassword    = "***";   
      // welcher Rechner soll "bearbeitet" werden                
      var   FbDevice      = "Comp-L-Pi";   
      // Das neue Profil für den Rechner              
      var   FbProfile     = "filtprof4";  
      // erweitertes Logging aktivieren für Fehlersuche
      const FbDebugging   = false;
      // Keine Änderung an der Fritzbox (true) -> Listet dann nur alle Profile und Rechner               
      const FbListOnly    = true; 
      // Device / Filter Liste erzeugen Ja (true), Nein (false)
      const FbCreateList  = false; 
      // Datenpunkt (string) für einen automatischen Script Start (muss angelegt werden!)
      // Der Datenpunkt wir mit Device;Profil beschrieben. Bsp: Comp-L-Pi;filtprof1
      const FbIobObject   = "0_userdata.0.Fritzbox.ChangeDeviceFilter"  
      // Datenpunkt in den die Device / Filter Liste als JSON geschrieben wird                    
      const FbIobJsonList = "0_userdata.0.Fritzbox.DeviceFilterListJson" 
       
      var secChallenge;
      var secMd5;
      var secLogin;
      var secSid;
      var secProfileNames = [];
      var secProfileIds   = [];
      var secDeviceNames  = [];
      var secDeviceIds    = [];
      var JsonList        = "";
       
      /*******************************************************
      * Object Trigger Version
      * Wenn auf einen Datenpunkt getriggert werden soll, dann muss der folgende Block auskommentiert werden. 
      * FbIobObject muss mit einem string Datenpunkt versehen werden.
      * Den Static Teil dann auskommentieren !
      * Diese Variante erlaubt es das Script dynamisch für alle Devices / Profile der FB zu verwenden. 
      *******************************************************/
      
      on({id: FbIobObject, change: "ne"}, function (obj) {
      /*
          console.log("Profile Changer started ... (Version : " + Version + ")");
          */
          var data = obj.state.val.split(";");
          if (data.length != 2) {
              console.log("Wrong parameter : " + obj.state.val);
              return;
          }
       
          if (FbDebugging){
              console.log(" > Datapoint : " + data);
          }
       
          console.log("Computer : " + data[0]);
          console.log("Filter   : " + data[1]);
          FbDevice  = data[0];
          FbProfile = data[1];
       /*
          getFbChallenge();
          
          console.log("Profile Changer done");
      */
      });
      
      */
      /*******************************************************
      * Static Version
      * Die folgenden 3 Zeilen lassen das Script  sofort laufen. 
      * Dabei sollte der Object Trigger Block auskommentiert werden. 
      *******************************************************/
      // console.log("Profile Changer started ... (Version : " + Version + ")");
      // getFbChallenge();
      
      moelskiM 1 Antwort Letzte Antwort
      0
      • J jack99n

        @moelski

        /*******************************************************
        * Basis: 
        * https://community.openhab.org/t/disable-internet-connection-of-specific-echo-device-on-fritz-box-via-script/91374
        * https://forum.fhem.de/index.php?topic=109689.0
        * https://www.kuketz-blog.de/fritzbox-wlan-toggle-per-skript/
        *******************************************************/ 
         
        /*******************************************************
        * Script SetDeviceFilter
        * 
        * 13.09.20 V1.09    Regex mit Escape beim . und Fix für Liste
        * 12.09.20 V1.08    Regex um . erweitert
        * 12.09.20 V1.07    Erweritertes Logging aktivierbar für Fehlersuche
        * 08.09.20 V1.06    Anpassungen an FirtzOS 7.20 (Regex Auswertung für Listenerstellung)
        * 05.09.20 V1.05    Ausgabe einer Device / Filter Liste möglich als JSON 
        *                   Logging reduziert wenn FbListOnly = false
        * 04.09.20 V1.04    Fix für doppelte Einträge in Listen
        * 02.09.20 V1.03    Erweiterung zum automatischen Start mittels ioB Datenpunkt
        * 02.09.20 V1.02    Script Abbruch wenn der Login nicht geklappt hat
        * 02.09.20 V1.01    Regex Erweiterung, Login auch mit User/Passwort
        * 01.09.20 V1.00    erste öffentliches Release
        *******************************************************/ 
        const Version = "1.09";
         
        // TODO
        // * Liste erzeugen mit Devices und aktuellem Filter
        //   > als JSON in einen DP speichern -> für Tabellenauswertung
         
        // https://forum.iobroker.net/topic/16184/http-request-in-javascript/5
        var request = require('request');
        var headers = { 
            'Content-Type': 'application/x-www-form-urlencoded', 
            'User-Agent': 'curl/7.64.0', 
            'Accept': '*/*'
        }; 
         
        /*******************************************************
        * E I N S T E L L U N G E N 
        *******************************************************/
         
        // Die IP Der Fritzbox
        const FbIp          = "192.168.10.1";              
        // Der User der Fritzbox 
        // HINWEIS : Den Benutzer leer lassen wenn die Anmeldung an der FB nur mit Passwort erfolgt !
        const FbUser        = "********"; 
        // Das Password der Fritzbox                  
        const FbPassword    = "***";   
        // welcher Rechner soll "bearbeitet" werden                
        var   FbDevice      = "Comp-L-Pi";   
        // Das neue Profil für den Rechner              
        var   FbProfile     = "filtprof4";  
        // erweitertes Logging aktivieren für Fehlersuche
        const FbDebugging   = false;
        // Keine Änderung an der Fritzbox (true) -> Listet dann nur alle Profile und Rechner               
        const FbListOnly    = true; 
        // Device / Filter Liste erzeugen Ja (true), Nein (false)
        const FbCreateList  = false; 
        // Datenpunkt (string) für einen automatischen Script Start (muss angelegt werden!)
        // Der Datenpunkt wir mit Device;Profil beschrieben. Bsp: Comp-L-Pi;filtprof1
        const FbIobObject   = "0_userdata.0.Fritzbox.ChangeDeviceFilter"  
        // Datenpunkt in den die Device / Filter Liste als JSON geschrieben wird                    
        const FbIobJsonList = "0_userdata.0.Fritzbox.DeviceFilterListJson" 
         
        var secChallenge;
        var secMd5;
        var secLogin;
        var secSid;
        var secProfileNames = [];
        var secProfileIds   = [];
        var secDeviceNames  = [];
        var secDeviceIds    = [];
        var JsonList        = "";
         
        /*******************************************************
        * Object Trigger Version
        * Wenn auf einen Datenpunkt getriggert werden soll, dann muss der folgende Block auskommentiert werden. 
        * FbIobObject muss mit einem string Datenpunkt versehen werden.
        * Den Static Teil dann auskommentieren !
        * Diese Variante erlaubt es das Script dynamisch für alle Devices / Profile der FB zu verwenden. 
        *******************************************************/
        
        on({id: FbIobObject, change: "ne"}, function (obj) {
        /*
            console.log("Profile Changer started ... (Version : " + Version + ")");
            */
            var data = obj.state.val.split(";");
            if (data.length != 2) {
                console.log("Wrong parameter : " + obj.state.val);
                return;
            }
         
            if (FbDebugging){
                console.log(" > Datapoint : " + data);
            }
         
            console.log("Computer : " + data[0]);
            console.log("Filter   : " + data[1]);
            FbDevice  = data[0];
            FbProfile = data[1];
         /*
            getFbChallenge();
            
            console.log("Profile Changer done");
        */
        });
        
        */
        /*******************************************************
        * Static Version
        * Die folgenden 3 Zeilen lassen das Script  sofort laufen. 
        * Dabei sollte der Object Trigger Block auskommentiert werden. 
        *******************************************************/
        // console.log("Profile Changer started ... (Version : " + Version + ")");
        // getFbChallenge();
        
        moelskiM Offline
        moelskiM Offline
        moelski
        schrieb am zuletzt editiert von moelski
        #106

        @jack99n
        Wo hakt es denn nun genau?
        Ich vermute du hast ein bissel viel auskommentiert ... Es sieht so aus, als wenn du ein */ zu viel im Code hast ...

        In Zeile 107

        Grüße Dominik

        J 1 Antwort Letzte Antwort
        0
        • moelskiM moelski

          @jack99n
          Wo hakt es denn nun genau?
          Ich vermute du hast ein bissel viel auskommentiert ... Es sieht so aus, als wenn du ein */ zu viel im Code hast ...

          In Zeile 107

          J Offline
          J Offline
          jack99n
          schrieb am zuletzt editiert von
          #107

          @moelski Ich glaube ich gebe es auf bin zu Blöd dafür. Jetzt kommt wieder kein Fehler mehr aber eine Liste wird mir nicht angezeigt.

          /*******************************************************
          * Basis: 
          * https://community.openhab.org/t/disable-internet-connection-of-specific-echo-device-on-fritz-box-via-script/91374
          * https://forum.fhem.de/index.php?topic=109689.0
          * https://www.kuketz-blog.de/fritzbox-wlan-toggle-per-skript/
          *******************************************************/ 
           
          /*******************************************************
          * Script SetDeviceFilter
          * 
          * 13.09.20 V1.09    Regex mit Escape beim . und Fix für Liste
          * 12.09.20 V1.08    Regex um . erweitert
          * 12.09.20 V1.07    Erweritertes Logging aktivierbar für Fehlersuche
          * 08.09.20 V1.06    Anpassungen an FirtzOS 7.20 (Regex Auswertung für Listenerstellung)
          * 05.09.20 V1.05    Ausgabe einer Device / Filter Liste möglich als JSON 
          *                   Logging reduziert wenn FbListOnly = false
          * 04.09.20 V1.04    Fix für doppelte Einträge in Listen
          * 02.09.20 V1.03    Erweiterung zum automatischen Start mittels ioB Datenpunkt
          * 02.09.20 V1.02    Script Abbruch wenn der Login nicht geklappt hat
          * 02.09.20 V1.01    Regex Erweiterung, Login auch mit User/Passwort
          * 01.09.20 V1.00    erste öffentliches Release
          *******************************************************/ 
          const Version = "1.09";
           
          // TODO
          // * Liste erzeugen mit Devices und aktuellem Filter
          //   > als JSON in einen DP speichern -> für Tabellenauswertung
           
          // https://forum.iobroker.net/topic/16184/http-request-in-javascript/5
          var request = require('request');
          var headers = { 
              'Content-Type': 'application/x-www-form-urlencoded', 
              'User-Agent': 'curl/7.64.0', 
              'Accept': '*/*'
          }; 
           
          /*******************************************************
          * E I N S T E L L U N G E N 
          *******************************************************/
           
          // Die IP Der Fritzbox
          const FbIp          = "192.168.10.1";              
          // Der User der Fritzbox 
          // HINWEIS : Den Benutzer leer lassen wenn die Anmeldung an der FB nur mit Passwort erfolgt !
          const FbUser        = ""; 
          // Das Password der Fritzbox                  
          const FbPassword    = "*******";   
          // welcher Rechner soll "bearbeitet" werden                
          var   FbDevice      = "Comp-L-Pi";   
          // Das neue Profil für den Rechner              
          var   FbProfile     = "filtprof4";  
          // erweitertes Logging aktivieren für Fehlersuche
          const FbDebugging   = false;
          // Keine Änderung an der Fritzbox (true) -> Listet dann nur alle Profile und Rechner               
          const FbListOnly    = true; 
          // Device / Filter Liste erzeugen Ja (true), Nein (false)
          const FbCreateList  = false; 
          // Datenpunkt (string) für einen automatischen Script Start (muss angelegt werden!)
          // Der Datenpunkt wir mit Device;Profil beschrieben. Bsp: Comp-L-Pi;filtprof1
          const FbIobObject   = "0_userdata.0.Fritzbox.ChangeDeviceFilter"  
          // Datenpunkt in den die Device / Filter Liste als JSON geschrieben wird                    
          const FbIobJsonList = "0_userdata.0.Fritzbox.DeviceFilterListJson" 
           
          var secChallenge;
          var secMd5;
          var secLogin;
          var secSid;
          var secProfileNames = [];
          var secProfileIds   = [];
          var secDeviceNames  = [];
          var secDeviceIds    = [];
          var JsonList        = "";
           
          /*******************************************************
          * Object Trigger Version
          * Wenn auf einen Datenpunkt getriggert werden soll, dann muss der folgende Block auskommentiert werden. 
          * FbIobObject muss mit einem string Datenpunkt versehen werden.
          * Den Static Teil dann auskommentieren !
          * Diese Variante erlaubt es das Script dynamisch für alle Devices / Profile der FB zu verwenden. 
          *******************************************************/
          on({id: FbIobObject, change: "ne"}, function (obj) {
              console.log("Profile Changer started ... (Version : " + Version + ")");
              var data = obj.state.val.split(";");
              if (data.length != 2) {
                  console.log("Wrong parameter : " + obj.state.val);
                  return;
              }
           
              if (FbDebugging){
                  console.log(" > Datapoint : " + data);
              }
           
              console.log("Computer : " + data[0]);
              console.log("Filter   : " + data[1]);
              FbDevice  = data[0];
              FbProfile = data[1];
           
              getFbChallenge();
              
              console.log("Profile Changer done");
          });
           
          /*******************************************************
          * Static Version
          * Die folgenden 3 Zeilen lassen das Script  sofort laufen. 
          * Dabei sollte der Object Trigger Block auskommentiert werden. 
          *******************************************************/
          /*
          // console.log("Profile Changer started ... (Version : " + Version + ")");
          // getFbChallenge();
          // console.log("Profile Changer done");
          */ 
          // Get the Challenge String from the FritzBox
          // Compute the md5 Hash
          
          moelskiM 1 Antwort Letzte Antwort
          0
          • J jack99n

            @moelski Ich glaube ich gebe es auf bin zu Blöd dafür. Jetzt kommt wieder kein Fehler mehr aber eine Liste wird mir nicht angezeigt.

            /*******************************************************
            * Basis: 
            * https://community.openhab.org/t/disable-internet-connection-of-specific-echo-device-on-fritz-box-via-script/91374
            * https://forum.fhem.de/index.php?topic=109689.0
            * https://www.kuketz-blog.de/fritzbox-wlan-toggle-per-skript/
            *******************************************************/ 
             
            /*******************************************************
            * Script SetDeviceFilter
            * 
            * 13.09.20 V1.09    Regex mit Escape beim . und Fix für Liste
            * 12.09.20 V1.08    Regex um . erweitert
            * 12.09.20 V1.07    Erweritertes Logging aktivierbar für Fehlersuche
            * 08.09.20 V1.06    Anpassungen an FirtzOS 7.20 (Regex Auswertung für Listenerstellung)
            * 05.09.20 V1.05    Ausgabe einer Device / Filter Liste möglich als JSON 
            *                   Logging reduziert wenn FbListOnly = false
            * 04.09.20 V1.04    Fix für doppelte Einträge in Listen
            * 02.09.20 V1.03    Erweiterung zum automatischen Start mittels ioB Datenpunkt
            * 02.09.20 V1.02    Script Abbruch wenn der Login nicht geklappt hat
            * 02.09.20 V1.01    Regex Erweiterung, Login auch mit User/Passwort
            * 01.09.20 V1.00    erste öffentliches Release
            *******************************************************/ 
            const Version = "1.09";
             
            // TODO
            // * Liste erzeugen mit Devices und aktuellem Filter
            //   > als JSON in einen DP speichern -> für Tabellenauswertung
             
            // https://forum.iobroker.net/topic/16184/http-request-in-javascript/5
            var request = require('request');
            var headers = { 
                'Content-Type': 'application/x-www-form-urlencoded', 
                'User-Agent': 'curl/7.64.0', 
                'Accept': '*/*'
            }; 
             
            /*******************************************************
            * E I N S T E L L U N G E N 
            *******************************************************/
             
            // Die IP Der Fritzbox
            const FbIp          = "192.168.10.1";              
            // Der User der Fritzbox 
            // HINWEIS : Den Benutzer leer lassen wenn die Anmeldung an der FB nur mit Passwort erfolgt !
            const FbUser        = ""; 
            // Das Password der Fritzbox                  
            const FbPassword    = "*******";   
            // welcher Rechner soll "bearbeitet" werden                
            var   FbDevice      = "Comp-L-Pi";   
            // Das neue Profil für den Rechner              
            var   FbProfile     = "filtprof4";  
            // erweitertes Logging aktivieren für Fehlersuche
            const FbDebugging   = false;
            // Keine Änderung an der Fritzbox (true) -> Listet dann nur alle Profile und Rechner               
            const FbListOnly    = true; 
            // Device / Filter Liste erzeugen Ja (true), Nein (false)
            const FbCreateList  = false; 
            // Datenpunkt (string) für einen automatischen Script Start (muss angelegt werden!)
            // Der Datenpunkt wir mit Device;Profil beschrieben. Bsp: Comp-L-Pi;filtprof1
            const FbIobObject   = "0_userdata.0.Fritzbox.ChangeDeviceFilter"  
            // Datenpunkt in den die Device / Filter Liste als JSON geschrieben wird                    
            const FbIobJsonList = "0_userdata.0.Fritzbox.DeviceFilterListJson" 
             
            var secChallenge;
            var secMd5;
            var secLogin;
            var secSid;
            var secProfileNames = [];
            var secProfileIds   = [];
            var secDeviceNames  = [];
            var secDeviceIds    = [];
            var JsonList        = "";
             
            /*******************************************************
            * Object Trigger Version
            * Wenn auf einen Datenpunkt getriggert werden soll, dann muss der folgende Block auskommentiert werden. 
            * FbIobObject muss mit einem string Datenpunkt versehen werden.
            * Den Static Teil dann auskommentieren !
            * Diese Variante erlaubt es das Script dynamisch für alle Devices / Profile der FB zu verwenden. 
            *******************************************************/
            on({id: FbIobObject, change: "ne"}, function (obj) {
                console.log("Profile Changer started ... (Version : " + Version + ")");
                var data = obj.state.val.split(";");
                if (data.length != 2) {
                    console.log("Wrong parameter : " + obj.state.val);
                    return;
                }
             
                if (FbDebugging){
                    console.log(" > Datapoint : " + data);
                }
             
                console.log("Computer : " + data[0]);
                console.log("Filter   : " + data[1]);
                FbDevice  = data[0];
                FbProfile = data[1];
             
                getFbChallenge();
                
                console.log("Profile Changer done");
            });
             
            /*******************************************************
            * Static Version
            * Die folgenden 3 Zeilen lassen das Script  sofort laufen. 
            * Dabei sollte der Object Trigger Block auskommentiert werden. 
            *******************************************************/
            /*
            // console.log("Profile Changer started ... (Version : " + Version + ")");
            // getFbChallenge();
            // console.log("Profile Changer done");
            */ 
            // Get the Challenge String from the FritzBox
            // Compute the md5 Hash
            
            moelskiM Offline
            moelskiM Offline
            moelski
            schrieb am zuletzt editiert von
            #108

            @jack99n
            Ach so schwer ist das nicht. Im Zweifel das Script neu kopieren und nochmal anfangen ... Oder mein Angebot aus dem Chat in Anspruch nehmen

            Grüße Dominik

            moelskiM 1 Antwort Letzte Antwort
            0
            • moelskiM moelski

              @jack99n
              Ach so schwer ist das nicht. Im Zweifel das Script neu kopieren und nochmal anfangen ... Oder mein Angebot aus dem Chat in Anspruch nehmen

              moelskiM Offline
              moelskiM Offline
              moelski
              schrieb am zuletzt editiert von moelski
              #109

              Ok hat sich ja noch dies und das im Script geändert. Und @jack99n hat ja auch noch Stress. Also eine kurze Anleitung wie man mit dem aktuellen Script am schnellsten voran kommt :-)

              • Das Script in den JavaScript Adapter bringen und zwar als JavaScript - nicht Blockly oder sonstwas
              • FbIp anpassen mit der IP deiner Fritzbox
              • FbUser anpassen - das wäre der User den du beim Fritzbox Login brauchst. Wenn du nur passwort verwendest dann hier = "" verwenden
              • FbPassword Das Passwort von deinem Fritzbox Login kommt hier hin
              • FbDebugging auf false
              • FbListOnly auf true
              • FbIobObject hier den Datenpunkt eintragen den du erzeugt hast (Typ String) wo Änderungen eingefügt werden
              • FbIobJsonList Hier kommt der Datenpunkt hin wo die JSON Liste erzeugt wird. Die musst du ebenfalls anlegen als String

              Soweit die Vorbereitung .... Alles andere im Script so lassen wie es ist :-)

              Jetzt gehst du in die Objekte und änderst den Datenpunkt den du bei FbIobObject eingetragen hast. Dort einfach mal Test;test eintragen. Da wird nur die Listen haben wollen mit den Devices und Filtern ist es egal was hier rein kommt. Wichtig ist nur ... 2 Wörter mit Semikolon getrennt.

              Jetzt findest du im Logging Einträge mit Filter named ... und Device named

              Such dir das Device raus was du umbiegen willst. Davon brauchst du den Namen. Also das was im Log in den '' steht.
              Bei den Filtern brauchst du die ID. Das ist das was rechts neben dem : steht.
              Raus kommt dann sowas wie Laptop_Junior;filtprof4

              Das merken wir uns gerade ... Im Script jetzt FbListOnly auf false setzen.
              Jetzt werden Änderungen auch in der Fritzbox übernommen.

              So jetzt den Schnipsel von eben nehmen Laptop_Junior;filtprof4 (als Beispiel) und in deinen Datenpunkt eintragen der bei FbIobObject hinterlegt ist.
              Nun sollte das Gerät den neuen Filter zugewiesen kriegen.

              Grüße Dominik

              J J 2 Antworten Letzte Antwort
              2
              • moelskiM moelski

                Ok hat sich ja noch dies und das im Script geändert. Und @jack99n hat ja auch noch Stress. Also eine kurze Anleitung wie man mit dem aktuellen Script am schnellsten voran kommt :-)

                • Das Script in den JavaScript Adapter bringen und zwar als JavaScript - nicht Blockly oder sonstwas
                • FbIp anpassen mit der IP deiner Fritzbox
                • FbUser anpassen - das wäre der User den du beim Fritzbox Login brauchst. Wenn du nur passwort verwendest dann hier = "" verwenden
                • FbPassword Das Passwort von deinem Fritzbox Login kommt hier hin
                • FbDebugging auf false
                • FbListOnly auf true
                • FbIobObject hier den Datenpunkt eintragen den du erzeugt hast (Typ String) wo Änderungen eingefügt werden
                • FbIobJsonList Hier kommt der Datenpunkt hin wo die JSON Liste erzeugt wird. Die musst du ebenfalls anlegen als String

                Soweit die Vorbereitung .... Alles andere im Script so lassen wie es ist :-)

                Jetzt gehst du in die Objekte und änderst den Datenpunkt den du bei FbIobObject eingetragen hast. Dort einfach mal Test;test eintragen. Da wird nur die Listen haben wollen mit den Devices und Filtern ist es egal was hier rein kommt. Wichtig ist nur ... 2 Wörter mit Semikolon getrennt.

                Jetzt findest du im Logging Einträge mit Filter named ... und Device named

                Such dir das Device raus was du umbiegen willst. Davon brauchst du den Namen. Also das was im Log in den '' steht.
                Bei den Filtern brauchst du die ID. Das ist das was rechts neben dem : steht.
                Raus kommt dann sowas wie Laptop_Junior;filtprof4

                Das merken wir uns gerade ... Im Script jetzt FbListOnly auf false setzen.
                Jetzt werden Änderungen auch in der Fritzbox übernommen.

                So jetzt den Schnipsel von eben nehmen Laptop_Junior;filtprof4 (als Beispiel) und in deinen Datenpunkt eintragen der bei FbIobObject hinterlegt ist.
                Nun sollte das Gerät den neuen Filter zugewiesen kriegen.

                J Offline
                J Offline
                jack99n
                schrieb am zuletzt editiert von
                #110

                @moelski

                Vielen Dank jetzt läuft das Skript bei mir auch 1A! Wie ist das eigentlich wenn man mehrere Geräte mit einmal ändern möchte, muss ich dann für jedes Gerät ein eigenes Skript anlegen?

                moelskiM 1 Antwort Letzte Antwort
                0
                • J jack99n

                  @moelski

                  Vielen Dank jetzt läuft das Skript bei mir auch 1A! Wie ist das eigentlich wenn man mehrere Geräte mit einmal ändern möchte, muss ich dann für jedes Gerät ein eigenes Skript anlegen?

                  moelskiM Offline
                  moelskiM Offline
                  moelski
                  schrieb am zuletzt editiert von
                  #111

                  @jack99n said in Internet Filter in der Fritzbox mit JavaScript setzen:

                  Wie ist das eigentlich wenn man mehrere Geräte mit einmal ändern möchte, muss ich dann für jedes Gerät ein eigenes Skript anlegen?

                  Also die Idee ist / war das man Button in der VIS anlegt um damit eben bestimmte Geräte bearbeiten zu können.
                  Jedes Gerät eben einen oder zwei Button für Sperren / entsperren.
                  Ganze Gruppen auf einen Schlag ... Hmm, das ginge sicherlich auch. Geht aber mit dem Script so out of the box derzeit nicht.

                  Grüße Dominik

                  F 1 Antwort Letzte Antwort
                  0
                  • moelskiM moelski

                    @jack99n said in Internet Filter in der Fritzbox mit JavaScript setzen:

                    Wie ist das eigentlich wenn man mehrere Geräte mit einmal ändern möchte, muss ich dann für jedes Gerät ein eigenes Skript anlegen?

                    Also die Idee ist / war das man Button in der VIS anlegt um damit eben bestimmte Geräte bearbeiten zu können.
                    Jedes Gerät eben einen oder zwei Button für Sperren / entsperren.
                    Ganze Gruppen auf einen Schlag ... Hmm, das ginge sicherlich auch. Geht aber mit dem Script so out of the box derzeit nicht.

                    F Offline
                    F Offline
                    firehero
                    schrieb am zuletzt editiert von
                    #112

                    Bei mir läuft das Skript auch perfekt.

                    Ich habe das bei uns so gelöst, dass ich einen Button für Internet erlaubt und Internet gesperrt in der Vis eingebaut habe.

                    Man könnte via Skript auch mehre Geräte damit nacheinander schalten. Müsste aber eine Pause einbauen.

                    Ich vergleiche den Timestamp vom Datenpunkt ChangeDeviceFilter und DeviceFilterListJson. Sobald die Tabelle Json neuer ist als ChangeDeviceFilter kann ich das nächste Gerät umschalten, solange belieben die Knöpfe ausgeblendet.

                    Super Sache, das Skript. Leider ist unsere Fitzbox 7590 etwas mit den vielen Geräte überlastet, sodass die Umstellung gerne mal mehr als 1 Minute dauert.

                    Wollte damit das Internet in der Firma für gewisse Zeitpunkte voll freischalten und während der Arbeitszeit mit einer Whiteliste eingrenzen. Nur leider funktioniert das mit der FirtzBox und Whiteliste nicht so recht, ohne einen Neustart des Rechners. Weiter kann man nur 500 Url´s in die White und Blackliste eintragen. Somit muss ich mich leider mit dem Thema andere Firewall umschauen.

                    VG

                    moelskiM 1 Antwort Letzte Antwort
                    0
                    • F firehero

                      Bei mir läuft das Skript auch perfekt.

                      Ich habe das bei uns so gelöst, dass ich einen Button für Internet erlaubt und Internet gesperrt in der Vis eingebaut habe.

                      Man könnte via Skript auch mehre Geräte damit nacheinander schalten. Müsste aber eine Pause einbauen.

                      Ich vergleiche den Timestamp vom Datenpunkt ChangeDeviceFilter und DeviceFilterListJson. Sobald die Tabelle Json neuer ist als ChangeDeviceFilter kann ich das nächste Gerät umschalten, solange belieben die Knöpfe ausgeblendet.

                      Super Sache, das Skript. Leider ist unsere Fitzbox 7590 etwas mit den vielen Geräte überlastet, sodass die Umstellung gerne mal mehr als 1 Minute dauert.

                      Wollte damit das Internet in der Firma für gewisse Zeitpunkte voll freischalten und während der Arbeitszeit mit einer Whiteliste eingrenzen. Nur leider funktioniert das mit der FirtzBox und Whiteliste nicht so recht, ohne einen Neustart des Rechners. Weiter kann man nur 500 Url´s in die White und Blackliste eintragen. Somit muss ich mich leider mit dem Thema andere Firewall umschauen.

                      VG

                      moelskiM Offline
                      moelskiM Offline
                      moelski
                      schrieb am zuletzt editiert von
                      #113

                      @firehero
                      Hmm wenns um Black / Whitelist geht würde ich mir mal PiHole ansehen.
                      Das ann man in der 5er Version super damit erschlagen ...

                      @firehero said in Internet Filter in der Fritzbox mit JavaScript setzen:

                      Bei mir läuft das Skript auch perfekt.

                      :the_horns:

                      Grüße Dominik

                      J 1 Antwort Letzte Antwort
                      0
                      • moelskiM moelski

                        @firehero
                        Hmm wenns um Black / Whitelist geht würde ich mir mal PiHole ansehen.
                        Das ann man in der 5er Version super damit erschlagen ...

                        @firehero said in Internet Filter in der Fritzbox mit JavaScript setzen:

                        Bei mir läuft das Skript auch perfekt.

                        :the_horns:

                        J Offline
                        J Offline
                        jack99n
                        schrieb am zuletzt editiert von
                        #114

                        @moelski Habe mal noch ne Frage. Kann man die Geräte Namen zusätzlich in einen Datenpunkt vom Typ Werteliste schreiben lassen?

                        moelskiM 1 Antwort Letzte Antwort
                        0
                        • J jack99n

                          @moelski Habe mal noch ne Frage. Kann man die Geräte Namen zusätzlich in einen Datenpunkt vom Typ Werteliste schreiben lassen?

                          moelskiM Offline
                          moelskiM Offline
                          moelski
                          schrieb am zuletzt editiert von
                          #115

                          @jack99n
                          Das ist die Idee für 1.10 :-)
                          Genauso wie die Filter ...

                          Grüße Dominik

                          J M 2 Antworten Letzte Antwort
                          0
                          • moelskiM moelski

                            @jack99n
                            Das ist die Idee für 1.10 :-)
                            Genauso wie die Filter ...

                            J Offline
                            J Offline
                            jack99n
                            schrieb am zuletzt editiert von
                            #116

                            @moelski 👍 vielen Dank für deine Arbeit.

                            O 1 Antwort Letzte Antwort
                            0
                            • J jack99n

                              @moelski 👍 vielen Dank für deine Arbeit.

                              O Offline
                              O Offline
                              ottokar
                              schrieb am zuletzt editiert von ottokar
                              #117

                              Ok,

                              ich hatte mal ein bisschen Lust und Laune weiterzubauen,
                              Geplant war ein über die JSON Tabelle selektiertes GEerät sperren zu können.
                              ich hab das jetzt folgendermaßen gelöst.

                              Ich hab es jetzt mit der Basic Table soweit gebaut das man aus der Liste ein Gerät selektieren kann und mit Sperren/Entsperren Knopf entsprechend ein Profil zuweisen kann(man könnte auch mehrer Knöpfe mit mehr Filtern nehmen oder vielleicht ein Dropdown um den Filter auszuwählen)

                              Die Basic Table kann die Auswahl als JSON in einen Datenpunkt und in eine Detailview schreiben..
                              (hierzu kann man ein Basic HTML Widget in der Vis nutzen. In den Eigenschaften de Tabelle dann bei Detailed widget: die Widget Nummer des HTML-Widgets eintragen)

                              So kann man am Smartphone auch schön auswählen (beim wischen wird automatisch selektiert, das ist doof)
                              Die Auswahl wird also in einen Datenpunkt geschrieben, dies triggert ein Script welches den Gerätenamen (aus dem Auswahl JSON-String) in einen weiteren Datenpunkt schreibt.
                              eaf89af1-0419-4edd-a403-fe2fe7aa125e-image.png

                              in den Knöpfen ist jeweils der Wert für das Filterprofil hinterleg also filterprof1 für frei und filtprof2913 für sperren bei mir
                              Wir der Knopf gedrückt wid der wert in einem Datenpunkt aktualisiert und ein Script getriggert welches dann den Datenpunkt Devicename und filterprof im richtigen Format in den Fritzbox Sperre Datenpunkt schreibt der in moelskis Script hier hinterlegt ist.
                              e476fd05-8045-4166-81da-3b59d06653c6-image.png

                              Datenpunkte:
                              f3704591-6a3b-4238-af4d-c175c43ed922-image.png

                              9176a9d5-0eaf-4916-9709-75668e5b5543-image.png
                              Die Überschrift wird aus dem Datenpunkt aktualisiert, so sieht man welches Gerät als lettes ausgewählt wurde bevor man sperrt oder entsperrt.
                              Bei den Knöpfen hab ich ein BasicHTML state Widget drübergelegt, war irgendwie einfacher, der Knopf hat irgendwie nicht geschalten.. ;-/

                              Vielleicht braucht jemand ja so eine Lösung...

                              Grüssle Oli

                              O M 2 Antworten Letzte Antwort
                              0
                              • O ottokar

                                Ok,

                                ich hatte mal ein bisschen Lust und Laune weiterzubauen,
                                Geplant war ein über die JSON Tabelle selektiertes GEerät sperren zu können.
                                ich hab das jetzt folgendermaßen gelöst.

                                Ich hab es jetzt mit der Basic Table soweit gebaut das man aus der Liste ein Gerät selektieren kann und mit Sperren/Entsperren Knopf entsprechend ein Profil zuweisen kann(man könnte auch mehrer Knöpfe mit mehr Filtern nehmen oder vielleicht ein Dropdown um den Filter auszuwählen)

                                Die Basic Table kann die Auswahl als JSON in einen Datenpunkt und in eine Detailview schreiben..
                                (hierzu kann man ein Basic HTML Widget in der Vis nutzen. In den Eigenschaften de Tabelle dann bei Detailed widget: die Widget Nummer des HTML-Widgets eintragen)

                                So kann man am Smartphone auch schön auswählen (beim wischen wird automatisch selektiert, das ist doof)
                                Die Auswahl wird also in einen Datenpunkt geschrieben, dies triggert ein Script welches den Gerätenamen (aus dem Auswahl JSON-String) in einen weiteren Datenpunkt schreibt.
                                eaf89af1-0419-4edd-a403-fe2fe7aa125e-image.png

                                in den Knöpfen ist jeweils der Wert für das Filterprofil hinterleg also filterprof1 für frei und filtprof2913 für sperren bei mir
                                Wir der Knopf gedrückt wid der wert in einem Datenpunkt aktualisiert und ein Script getriggert welches dann den Datenpunkt Devicename und filterprof im richtigen Format in den Fritzbox Sperre Datenpunkt schreibt der in moelskis Script hier hinterlegt ist.
                                e476fd05-8045-4166-81da-3b59d06653c6-image.png

                                Datenpunkte:
                                f3704591-6a3b-4238-af4d-c175c43ed922-image.png

                                9176a9d5-0eaf-4916-9709-75668e5b5543-image.png
                                Die Überschrift wird aus dem Datenpunkt aktualisiert, so sieht man welches Gerät als lettes ausgewählt wurde bevor man sperrt oder entsperrt.
                                Bei den Knöpfen hab ich ein BasicHTML state Widget drübergelegt, war irgendwie einfacher, der Knopf hat irgendwie nicht geschalten.. ;-/

                                Vielleicht braucht jemand ja so eine Lösung...

                                Grüssle Oli

                                O Offline
                                O Offline
                                ottokar
                                schrieb am zuletzt editiert von ottokar
                                #118

                                Automatisches refreshen der Tabelle(der Vis) nach dem setzen des Filterwertes,
                                je nachdem wie schnell die Fritzbox ist reichen ein paar Sekunden.
                                hier das erweiterte Blockly:
                                1b3577c9-4035-4d04-9ff8-82ac50de6afa-image.png

                                Zusätzliche Quelle: https://forum.iobroker.net/topic/6956/script-für-automatischen-refresh-von-vis

                                M 1 Antwort Letzte Antwort
                                0
                                • moelskiM moelski

                                  Moin !

                                  Gestern Abend doch glatt am TV verschlummert :face_with_rolling_eyes: Aber nun ...

                                  Hier aber nun das Script:

                                  /*******************************************************
                                  * Basis: 
                                  * https://community.openhab.org/t/disable-internet-connection-of-specific-echo-device-on-fritz-box-via-script/91374
                                  * https://forum.fhem.de/index.php?topic=109689.0
                                  * https://www.kuketz-blog.de/fritzbox-wlan-toggle-per-skript/
                                  *******************************************************/ 
                                  
                                  /*******************************************************
                                  * Script SetDeviceFilter
                                  * 
                                  * 13.09.20 V1.09    Regex mit Escape beim . und Fix für Liste
                                  * 12.09.20 V1.08    Regex um . erweitert
                                  * 12.09.20 V1.07    Erweritertes Logging aktivierbar für Fehlersuche
                                  * 08.09.20 V1.06    Anpassungen an FirtzOS 7.20 (Regex Auswertung für Listenerstellung)
                                  * 05.09.20 V1.05    Ausgabe einer Device / Filter Liste möglich als JSON 
                                  *                   Logging reduziert wenn FbListOnly = false
                                  * 04.09.20 V1.04    Fix für doppelte Einträge in Listen
                                  * 02.09.20 V1.03    Erweiterung zum automatischen Start mittels ioB Datenpunkt
                                  * 02.09.20 V1.02    Script Abbruch wenn der Login nicht geklappt hat
                                  * 02.09.20 V1.01    Regex Erweiterung, Login auch mit User/Passwort
                                  * 01.09.20 V1.00    erste öffentliches Release
                                  *******************************************************/ 
                                  const Version = "1.09";
                                  
                                  // TODO
                                  // * Liste erzeugen mit Devices und aktuellem Filter
                                  //   > als JSON in einen DP speichern -> für Tabellenauswertung
                                  
                                  // https://forum.iobroker.net/topic/16184/http-request-in-javascript/5
                                  var request = require('request');
                                  var headers = { 
                                      'Content-Type': 'application/x-www-form-urlencoded', 
                                      'User-Agent': 'curl/7.64.0', 
                                      'Accept': '*/*'
                                  }; 
                                  
                                  /*******************************************************
                                  * E I N S T E L L U N G E N 
                                  *******************************************************/
                                  
                                  // Die IP Der Fritzbox
                                  const FbIp          = "192.168.30.1";              
                                  // Der User der Fritzbox 
                                  // HINWEIS : Den Benutzer leer lassen wenn die Anmeldung an der FB nur mit Passwort erfolgt !
                                  const FbUser        = ""; 
                                  // Das Password der Fritzbox                  
                                  const FbPassword    = "";   
                                  // welcher Rechner soll "bearbeitet" werden                
                                  var   FbDevice      = "Comp-L-Pi";   
                                  // Das neue Profil für den Rechner              
                                  var   FbProfile     = "filtprof4";  
                                  // erweitertes Logging aktivieren für Fehlersuche
                                  const FbDebugging   = false;
                                  // Keine Änderung an der Fritzbox (true) -> Listet dann nur alle Profile und Rechner               
                                  const FbListOnly    = false; 
                                  // Device / Filter Liste erzeugen Ja (true), Nein (false)
                                  const FbCreateList  = true; 
                                  // Datenpunkt (string) für einen automatischen Script Start (muss angelegt werden!)
                                  // Der Datenpunkt wir mit Device;Profil beschrieben. Bsp: Comp-L-Pi;filtprof1
                                  const FbIobObject   = "Global.0.Fritzbox.ChangeDeviceFilter"  
                                  // Datenpunkt in den die Device / Filter Liste als JSON geschrieben wird                    
                                  const FbIobJsonList = "Global.0.Fritzbox.DeviceFilterListJson" 
                                  
                                  var secChallenge;
                                  var secMd5;
                                  var secLogin;
                                  var secSid;
                                  var secProfileNames = [];
                                  var secProfileIds   = [];
                                  var secDeviceNames  = [];
                                  var secDeviceIds    = [];
                                  var JsonList        = "";
                                  
                                  /*******************************************************
                                  * Object Trigger Version
                                  * Wenn auf einen Datenpunkt getriggert werden soll, dann muss der folgende Block auskommentiert werden. 
                                  * FbIobObject muss mit einem string Datenpunkt versehen werden.
                                  * Den Static Teil dann auskommentieren !
                                  * Diese Variante erlaubt es das Script dynamisch für alle Devices / Profile der FB zu verwenden. 
                                  *******************************************************/
                                  on({id: FbIobObject, change: "ne"}, function (obj) {
                                      console.log("Profile Changer started ... (Version : " + Version + ")");
                                      var data = obj.state.val.split(";");
                                      if (data.length != 2) {
                                          console.log("Wrong parameter : " + obj.state.val);
                                          return;
                                      }
                                  
                                      if (FbDebugging){
                                          console.log(" > Datapoint : " + data);
                                      }
                                  
                                      console.log("Computer : " + data[0]);
                                      console.log("Filter   : " + data[1]);
                                      FbDevice  = data[0];
                                      FbProfile = data[1];
                                  
                                      getFbChallenge();
                                      
                                      console.log("Profile Changer done");
                                  });
                                  
                                  /*******************************************************
                                  * Static Version
                                  * Die folgenden 3 Zeilen lassen das Script  sofort laufen. 
                                  * Dabei sollte der Object Trigger Block auskommentiert werden. 
                                  *******************************************************/
                                  // console.log("Profile Changer started ... (Version : " + Version + ")");
                                  // getFbChallenge();
                                  // console.log("Profile Changer done");
                                  
                                  // Get the Challenge String from the FritzBox
                                  // Compute the md5 Hash
                                  function getFbChallenge(){
                                      console.log("function getFbChallenge");
                                      request.get({
                                          url:        'http://' + FbIp + '/login_sid.lua?username=' + FbUser,
                                          headers:    headers
                                      }, function(error, response, body) {
                                          if (error) log(error, 'error');
                                          //console.log(response);
                                          // https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/RegExp
                                          // <?xml version="1.0" encoding="utf-8"?><SessionInfo><SID>0000000000000000</SID><Challenge>d36de231</Challenge><BlockTime>0</BlockTime><Rights></Rights></SessionI
                                          secChallenge = body.match(/Challenge>(.*)<\/Challenge/)[1];
                                          console.log(" > Challenge : " + secChallenge);
                                  
                                          var uft16le = str2rstr_utf16le(secChallenge + "-" +FbPassword );
                                          var md5     = rstr_md5(uft16le);
                                          secMd5      = rstr2hex(md5);
                                                  
                                          console.log(" > MD5       : " + secMd5);   
                                  
                                          // response="${challenge}-${md5}"
                                          // sid=$(curl -i -s -k -d "response=${response}&username=" "http://$1" | grep -Po -m 1 '(?<=sid=)[a-f\d]+' | tail -1)
                                          secLogin = "response=" + secChallenge + "-" + secMd5 + "&username=" + FbUser;
                                  
                                          console.log(" > Login     : " + secLogin);
                                  
                                          getFbSid();
                                      });
                                  }
                                  
                                  // Get the SID from the Fritzbox
                                  function getFbSid() {
                                      console.log("function getFbSid");
                                  
                                      request.post({
                                          url:        'http://' + FbIp,
                                          headers:    headers, 
                                          form:       secLogin
                                      }, function(error, response, body) {
                                          if (error) log(error, 'error');
                                          // SID filtern 
                                          // "sid":"c503b24dae458086"
                                          try {
                                              secSid = response.body.match(/\"sid\":\"(.*)\"/)[1];
                                          }
                                          catch (e) {
                                              if (secSid == undefined) {
                                                  console.log("Your login was not successful. End Script", Error)
                                                  return;
                                              }
                                          }
                                  
                                          console.log(" > SID       : " + secSid);
                                  
                                          //getFbDeviceInfos();
                                          getFbProfiles();
                                      });
                                  } 
                                  
                                  // TBD: 
                                  // Netzwerkinfos mit allen Devices lesen: 
                                  // var req = "xhr=1&sid=" + secSid + "&lang=de&page=netDev&xhrId=cleanup&useajax=1&no_sidrenew=" 
                                  function getFbDeviceInfos(){
                                      console.log("function getFbDeviceInfos");
                                      var req = "xhr=1&sid=" + secSid + "&lang=de&page=netDev&xhrId=cleanup&useajax=1&no_sidrenew=" 
                                  
                                      request.post({
                                          url:        'http://' + FbIp + '/data.lua',
                                          headers:    headers, 
                                          form:       req
                                      }, function(error, response, body) {
                                          if (error) log(error, 'error');
                                          console.log(response.body);
                                      });    
                                  }
                                  
                                  // Get all Profiles from the Fritzbox
                                  function getFbProfiles() {
                                      console.log("function getFbProfiles");
                                      // #curl -d "xhr=1&sid=${sid}&lang=de&no_sidrenew=&page=kidPro" "http://$1/data.lua"
                                      var req = "xhr=1&sid=" + secSid + "&lang=de&no_sidrenew=&page=kidPro";
                                  
                                      request.post({
                                          url:        'http://' + FbIp + '/data.lua',
                                          headers:    headers, 
                                          form:       req
                                      }, function(error, response, body) {
                                          if (error) log(error, 'error');
                                          
                                          if (FbDebugging){
                                              console.log(" > response.body : \n" + response.body);
                                          }
                                  
                                          secProfileIds   = [];
                                          secProfileNames = [];
                                  
                                          console.log(" > Decode Names")
                                          var rx = new RegExp( /class=\"name\"\stitle=\"([a-zA-Z0-9 äöüÄÖÜ\-\_\.]*)\"\sdatalabel/g );
                                          while( (match = rx.exec( body )) != null ) {
                                              secProfileNames.push(match[1]);
                                          }
                                          if (FbDebugging){
                                              console.log(" > secProfileNames : \n" + secProfileNames);
                                          }
                                  
                                          console.log(" > Decode Filters")
                                          // submit" name="edit" value="
                                          rx = new RegExp( /submit\"\sname=\"edit\"\svalue=\"([a-zA-Z0-9 äöüÄÖÜ\-\_\.]*)\"\sclass=\"icon/g );
                                          while( (match = rx.exec( body )) != null ) {
                                              secProfileIds.push(match[1]);
                                          }
                                          if (FbDebugging){
                                              console.log(" > secProfileIds : \n" + secProfileIds);
                                          }
                                  
                                          if (FbListOnly) {
                                              console.log("Filter Count : " + secProfileIds.length);
                                              for (var i = 0; i < secProfileIds.length; i++) {
                                                  console.log("Filter named '"+ secProfileNames[i] + "' has ID : " + secProfileIds[i]);
                                              }
                                          }
                                  
                                          getFbDevices();
                                      });
                                  }
                                  
                                  // IMPORTANT: 
                                  // The DeviceId changes when you switch the profile. 
                                  // If you use default profiles it is something like "landevice308962"
                                  // If you use your own profiles it is something like "user7749"
                                  function getFbDevices() {
                                      console.log("function getFbDevices");
                                      // xhr=1&sid=5f5ba302815594d8&lang=de&no_sidrenew=&page=kidLis
                                      var req = "xhr=1&sid=" + secSid + "&lang=de&no_sidrenew=&page=kidLis";
                                  
                                      request.post({
                                          url:        'http://' + FbIp + '/data.lua',
                                          headers:    headers, 
                                          form:       req
                                      }, function(error, response, body) {
                                          if (error) log(error, 'error');
                                          if (FbDebugging){
                                              console.log(" > response.body : \n" + response.body);
                                          }
                                  
                                          // TESTING
                                          //body = getState("Global.0.Testing.StringValue").val;
                                  
                                          secDeviceNames = [];
                                          secDeviceIds   = [];
                                  
                                          console.log(" > Decode Device Names")
                                          var rx = new RegExp( /class=\"name"\stitle=\"([a-zA-Z0-9 äöüÄÖÜ\-\_\.]*)\"\sdatalabel/g );
                                          while( (match = rx.exec( body )) != null ) {
                                              secDeviceNames.push(match[1]);
                                          }
                                          if (FbDebugging){
                                              console.log(" > secDeviceNames : \n" + secDeviceNames);
                                          }
                                  
                                          console.log(" > Decode Device Ids")
                                          rx = new RegExp( /name=\"profile:([a-zA-Z0-9 äöüÄÖÜ\-\_\.]*)\"><option/g );
                                          while( (match = rx.exec( body )) != null ) {
                                              secDeviceIds.push(match[1]);
                                          }
                                          if (FbDebugging){
                                              console.log(" > secDeviceIds : \n" + secDeviceIds);
                                          }
                                          
                                          if (FbListOnly) {
                                              console.log("Device Count : " + secDeviceIds.length);
                                              for (var i = 0; i < secDeviceNames.length; i++) {
                                                  console.log(i + " - Device named '"+ secDeviceNames[i] + "' has ID : " + secDeviceIds[i]);
                                              }
                                          }
                                  
                                          if (!FbListOnly) { 
                                              setFbSperre(); 
                                          } else { 
                                              console.log("DONE : Listmode - No Device blocking ..."); 
                                          }
                                      });
                                  }
                                  
                                  //curl -d "sid=${sid}&edit=$3&time=$4&budget=unlimited&apply=&page=kids_profileedit" "http://$1/data.lua" >/dev/null 2>&1
                                  function setFbSperre() {
                                      console.log("function setFbSperre");
                                      
                                      // Device suchen ... 
                                      var devId = -1;
                                      for (var i = 0; i < secDeviceNames.length; i++) {
                                          if (secDeviceNames[i] == FbDevice) {
                                              devId = i;
                                          }
                                      }
                                      
                                      console.log(" > Device Nr   : " + devId); 
                                      console.log(" > Device ID   : " + secDeviceIds[devId]); 
                                      console.log(" > Device Name : " + secDeviceNames[devId]);
                                      //var profile = "filtprof4";
                                      //var profile = "filtprof3079";
                                  
                                      // xhr=1&sid=b46f3d48b3b0fcc2&lang=de&no_sidrenew=&profile%3Alandevice308962=filtprof4&apply=&oldpage=%2Finternet%2Fkids_userlist.lua
                                      var req2 = "xhr=1&sid=" + secSid + "&lang=de&no_sidrenew=&profile%3A" + secDeviceIds[devId] + "=" + FbProfile + "&apply=&oldpage=%2Finternet%2Fkids_userlist.lua";
                                      console.log(" > req : " + req2);
                                      //var req2 = "xhr=1&sid=" + sid + "&lang=de&no_sidrenew=&profile%3Alandevice308962=filtprof3079&profile%3Auser7725=filtprof4&profile%3Alandevice2671=filtprof1&profile%3Alandevice2444=filtprof1&profile%3Alandevice2330=filtprof1&profile%3Alandevice2195=filtprof1&profile%3Alandevice229903=filtprof1&profile%3Alandevice8486=filtprof1&profile%3Alandevice1908=filtprof1&profile%3Alandevice1865=filtprof1&profile%3Alandevice516865=filtprof1&profile%3Alandevice518551=filtprof1&profile%3Alandevice169594=filtprof1&profile%3Alandevice171398=filtprof1&profile%3Alandevice175510=filtprof1&profile%3Alandevice177635=filtprof1&profile%3Alandevice178875=filtprof1&profile%3Alandevice179702=filtprof1&profile%3Alandevice180995=filtprof1&profile%3Alandevice182196=filtprof1&profile%3Alandevice183607=filtprof1&profile%3Alandevice184405=filtprof1&profile%3Alandevice638220=filtprof1&profile%3Alandevice634583=filtprof1&profile%3Alandevice7650=filtprof1&profile%3Alandevice353720=filtprof1&profile%3Auser7731=filtprof4&profile%3Alandevice170191=filtprof1&profile%3Alandevice941076=filtprof1&profile%3Alandevice358722=filtprof1&profile%3Alandevice2859=filtprof1&profile%3Auser7739=filtprof4&profile%3Alandevice8035=filtprof1&profile%3Auser7733=filtprof4&profile%3Auser7740=filtprof4&profile%3Alandevice1333=filtprof1&profile%3Alandevice6211=filtprof1&profile%3Alandevice35977=filtprof1&profile%3Alandevice8101=filtprof1&profile%3Alandevice8174=filtprof1&profile%3Auser7729=filtprof4&profile%3Alandevice1125=filtprof1&profile%3Alandevice1124=filtprof1&profile%3Alandevice7715=filtprof1&profile%3Alandevice52361=filtprof1&profile%3Alandevice30084=filtprof1&profile%3Alandevice26151=filtprof1&profile%3Alandevice26138=filtprof1&profile%3Alandevice6162=filtprof1&profile%3Alandevice5204=filtprof1&profile%3Alandevice1129367=filtprof1&profile%3Alandevice9399=filtprof1&profile%3Alandevice232149=filtprof1&profile%3Alandevice6935=filtprof1&profile%3Alandevice941333=filtprof1&profile%3Alandevice941569=filtprof1&apply=&oldpage=%2Finternet%2Fkids_userlist.lua";
                                      //var req2 = "xhr=1&sid=" + sid + "&lang=de&no_sidrenew=&profile:landevice308962=filtprof4&apply=&oldpage=/internet/kids_userlist.lua";
                                  
                                      request.post({
                                          url:        'http://' + FbIp + '/data.lua',
                                          headers:    headers, 
                                          form:       req2
                                      }, function(error, response, body) {
                                          if (error) log(error, 'error');
                                          if (FbDebugging){
                                              console.log(" > response : \n" + response);
                                          }
                                  
                                          console.log("Change done. Check your FB / Device if it worked :-)");
                                  
                                          if (FbCreateList) {
                                              getFbDeviceFilterList();
                                          }
                                      });    
                                  }
                                  
                                  function getFbDeviceFilterList() {
                                      console.log("function getFbDeviceFilterList");
                                      
                                      // xhr=1&sid=e2d99419592fb780&lang=de&no_sidrenew=&page=kidLis
                                      var req = "xhr=1&sid=" + secSid + "&lang=de&no_sidrenew=&page=kidLis";
                                  
                                      request.post({
                                          url:        'http://' + FbIp + '/data.lua',
                                          headers:    headers, 
                                          form:       req
                                      }, function(error, response, body) {
                                          //if (error) log(error, 'error');
                                          //console.log(response.body);
                                  
                                          JsonList = "";
                                          var tmpDevices      = [];
                                          var tmpUsage        = [];
                                          var tmpProfilesId   = [];
                                          var tmpProfilesName = [];
                                          var tmpTimes        = [];
                                  
                                          // TESTING
                                          //body = getState("Global.0.Testing.StringValue").val;
                                          
                                          console.log(" > Decode Device Names")
                                          var rx = new RegExp(/class=\"name"\stitle=\"([a-zA-Z0-9 äöüÄÖÜ\-\_\.]*)\"\sdatalabel/g);
                                          while ((match = rx.exec(body)) != null) {
                                              tmpDevices.push(match[1]);
                                          }
                                          //console.log(" > " + tmpDevices);
                                  
                                          console.log(" > Decode Device Profile ID");
                                          //rx = new RegExp(/button\s.*?value=\"([a-zA-Z0-9 äöüÄÖÜ]*?)\"/g);
                                          rx = new RegExp(/option\svalue=\"([a-zA-Z0-9 äöüÄÖÜ\-]*?)\"\sselected/g);
                                          while ((match = rx.exec(body)) != null) {
                                              tmpProfilesId.push(match[1]);
                                          }
                                          //console.log(" > " + tmpProfilesId);
                                  
                                          console.log(" > Decode Device Profile Names");
                                          for (var i = 0; i < tmpProfilesId.length; i++) {
                                              for (var j = 0; j < secProfileIds.length; j++) { 
                                                  //console.log(tmpProfilesId[i] + " > " + secProfileIds[j]);
                                                  if (tmpProfilesId[i] == secProfileIds[j]){
                                                      tmpProfilesName.push(secProfileNames[j]);
                                                  }
                                              }
                                          }
                                          //console.log(" > " + tmpProfilesName);
                                  
                                          console.log(" > Decode Internetnutzung")
                                          rx = new RegExp(/td\sdatalabel=\"[a-zA-Z0-9 äöüÄÖÜ\-]+\"\sclass=\"usage\">(.*?)<\/td>/g);
                                          while ((match = rx.exec(body)) != null) { 
                                              var tmp = match[1];
                                              tmp = tmp.replace("<span>", "").replace("<\/span>", "");
                                              tmpUsage.push(tmp);
                                          }
                                          //console.log(" > " + tmpUsage);
                                  
                                          console.log(" > Decode Times")
                                          rx = new RegExp(/td\sdatalabel=\"[a-zA-Z0-9 äöüÄÖÜ\-]+\"\sclass=\"bar\stime\">(.*?)<\/td>/g);
                                          while ((match = rx.exec(body)) != null) {
                                              var tmp = match[1];
                                              if (tmp.includes("\"")) {
                                                  tmp = tmp.replace("<span title=\"", "");
                                                  tmp = tmp.slice(0, tmp.indexOf("\""));
                                                  tmpTimes.push(tmp);
                                              } else {
                                                  tmpTimes.push(tmp);
                                              }
                                          }
                                          //console.log(" > " + tmpTimes);
                                  
                                          // console.log("Device Count : " + secDeviceIds.length);
                                          JsonList = "[";
                                          for (var i = 0; i < tmpDevices.length; i++) {
                                              JsonList += "{";
                                              JsonList += "\"Device\": \"" + tmpDevices[i] + "\"," 
                                              JsonList += "\"Profile ID\": \"" + tmpProfilesId[i] + "\","
                                              JsonList += "\"Profile Name\": \"" + tmpProfilesName[i] + "\","
                                              JsonList += "\"Usage\": \"" + tmpUsage[i] + "\","
                                              JsonList += "\"Time\": \"" + tmpTimes[i] + "\""
                                              if (i != tmpDevices.length - 1) { JsonList += "},"; } else { JsonList += "}"; }
                                          }
                                          JsonList += "]";
                                  
                                          //console.log(JsonList);
                                          setState(FbIobJsonList,  JsonList, true);
                                  
                                          console.log("DONE : List generated ...");
                                      });   
                                  }
                                  
                                  
                                  // https://gist.githubusercontent.com/josedaniel/951664/raw/33c7a6b44d6cc53dc75cb5230fb551bc4ba7a46a/md5.js
                                  // http://pajhome.org.uk/crypt/md5/instructions.html
                                  
                                  /*
                                   * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
                                   * Digest Algorithm, as defined in RFC 1321.
                                   * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
                                   * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
                                   * Distributed under the BSD License
                                   * See http://pajhome.org.uk/crypt/md5 for more info.
                                   */
                                  
                                  /*
                                   * Configurable variables. You may need to tweak these to be compatible with
                                   * the server-side, but the defaults work in most cases.
                                   */
                                  var hexcase = 0;   /* hex output format. 0 - lowercase; 1 - uppercase        */
                                  var b64pad  = "";  /* base-64 pad character. "=" for strict RFC compliance   */
                                  
                                  /*
                                   * These are the functions you'll usually want to call
                                   * They take string arguments and return either hex or base-64 encoded strings
                                   */
                                  function hex_md5(s)    { return rstr2hex(rstr_md5(str2rstr_utf8(s))); }
                                  function b64_md5(s)    { return rstr2b64(rstr_md5(str2rstr_utf8(s))); }
                                  function any_md5(s, e) { return rstr2any(rstr_md5(str2rstr_utf8(s)), e); }
                                  function hex_hmac_md5(k, d)
                                    { return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); }
                                  function b64_hmac_md5(k, d)
                                    { return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); }
                                  function any_hmac_md5(k, d, e)
                                    { return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e); }
                                  
                                  /*
                                   * Perform a simple self-test to see if the VM is working
                                   */
                                  function md5_vm_test()
                                  {
                                    return hex_md5("abc").toLowerCase() == "900150983cd24fb0d6963f7d28e17f72";
                                  }
                                  
                                  /*
                                   * Calculate the MD5 of a raw string
                                   */
                                  function rstr_md5(s)
                                  {
                                    return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
                                  }
                                  
                                  /*
                                   * Calculate the HMAC-MD5, of a key and some data (raw strings)
                                   */
                                  function rstr_hmac_md5(key, data)
                                  {
                                    var bkey = rstr2binl(key);
                                    if(bkey.length > 16) bkey = binl_md5(bkey, key.length * 8);
                                  
                                    var ipad = Array(16), opad = Array(16);
                                    for(var i = 0; i < 16; i++)
                                    {
                                      ipad[i] = bkey[i] ^ 0x36363636;
                                      opad[i] = bkey[i] ^ 0x5C5C5C5C;
                                    }
                                  
                                    var hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
                                    return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
                                  }
                                  
                                  /*
                                   * Convert a raw string to a hex string
                                   */
                                  function rstr2hex(input)
                                  {
                                    try { hexcase } catch(e) { hexcase=0; }
                                    var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
                                    var output = "";
                                    var x;
                                    for(var i = 0; i < input.length; i++)
                                    {
                                      x = input.charCodeAt(i);
                                      output += hex_tab.charAt((x >>> 4) & 0x0F)
                                             +  hex_tab.charAt( x        & 0x0F);
                                    }
                                    return output;
                                  }
                                  
                                  /*
                                   * Convert a raw string to a base-64 string
                                   */
                                  function rstr2b64(input)
                                  {
                                    try { b64pad } catch(e) { b64pad=''; }
                                    var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
                                    var output = "";
                                    var len = input.length;
                                    for(var i = 0; i < len; i += 3)
                                    {
                                      var triplet = (input.charCodeAt(i) << 16)
                                                  | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
                                                  | (i + 2 < len ? input.charCodeAt(i+2)      : 0);
                                      for(var j = 0; j < 4; j++)
                                      {
                                        if(i * 8 + j * 6 > input.length * 8) output += b64pad;
                                        else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
                                      }
                                    }
                                    return output;
                                  }
                                  
                                  /*
                                   * Convert a raw string to an arbitrary string encoding
                                   */
                                  function rstr2any(input, encoding)
                                  {
                                    var divisor = encoding.length;
                                    var i, j, q, x, quotient;
                                  
                                    /* Convert to an array of 16-bit big-endian values, forming the dividend */
                                    var dividend = Array(Math.ceil(input.length / 2));
                                    for(i = 0; i < dividend.length; i++)
                                    {
                                      dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
                                    }
                                  
                                    /*
                                     * Repeatedly perform a long division. The binary array forms the dividend,
                                     * the length of the encoding is the divisor. Once computed, the quotient
                                     * forms the dividend for the next step. All remainders are stored for later
                                     * use.
                                     */
                                    var full_length = Math.ceil(input.length * 8 /
                                                                      (Math.log(encoding.length) / Math.log(2)));
                                    var remainders = Array(full_length);
                                    for(j = 0; j < full_length; j++)
                                    {
                                      quotient = Array();
                                      x = 0;
                                      for(i = 0; i < dividend.length; i++)
                                      {
                                        x = (x << 16) + dividend[i];
                                        q = Math.floor(x / divisor);
                                        x -= q * divisor;
                                        if(quotient.length > 0 || q > 0)
                                          quotient[quotient.length] = q;
                                      }
                                      remainders[j] = x;
                                      dividend = quotient;
                                    }
                                  
                                    /* Convert the remainders to the output string */
                                    var output = "";
                                    for(i = remainders.length - 1; i >= 0; i--)
                                      output += encoding.charAt(remainders[i]);
                                  
                                    return output;
                                  }
                                  
                                  /*
                                   * Encode a string as utf-8.
                                   * For efficiency, this assumes the input is valid utf-16.
                                   */
                                  function str2rstr_utf8(input)
                                  {
                                    var output = "";
                                    var i = -1;
                                    var x, y;
                                  
                                    while(++i < input.length)
                                    {
                                      /* Decode utf-16 surrogate pairs */
                                      x = input.charCodeAt(i);
                                      y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
                                      if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF)
                                      {
                                        x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
                                        i++;
                                      }
                                  
                                      /* Encode output as utf-8 */
                                      if(x <= 0x7F)
                                        output += String.fromCharCode(x);
                                      else if(x <= 0x7FF)
                                        output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
                                                                      0x80 | ( x         & 0x3F));
                                      else if(x <= 0xFFFF)
                                        output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
                                                                      0x80 | ((x >>> 6 ) & 0x3F),
                                                                      0x80 | ( x         & 0x3F));
                                      else if(x <= 0x1FFFFF)
                                        output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
                                                                      0x80 | ((x >>> 12) & 0x3F),
                                                                      0x80 | ((x >>> 6 ) & 0x3F),
                                                                      0x80 | ( x         & 0x3F));
                                    }
                                    return output;
                                  }
                                  
                                  /*
                                   * Encode a string as utf-16
                                   */
                                  function str2rstr_utf16le(input)
                                  {
                                    var output = "";
                                    for(var i = 0; i < input.length; i++)
                                      output += String.fromCharCode( input.charCodeAt(i)        & 0xFF,
                                                                    (input.charCodeAt(i) >>> 8) & 0xFF);
                                    return output;
                                  }
                                  
                                  function str2rstr_utf16be(input)
                                  {
                                    var output = "";
                                    for(var i = 0; i < input.length; i++)
                                      output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
                                                                     input.charCodeAt(i)        & 0xFF);
                                    return output;
                                  }
                                  
                                  /*
                                   * Convert a raw string to an array of little-endian words
                                   * Characters >255 have their high-byte silently ignored.
                                   */
                                  function rstr2binl(input)
                                  {
                                    var output = Array(input.length >> 2);
                                    for(var i = 0; i < output.length; i++)
                                      output[i] = 0;
                                    for(var i = 0; i < input.length * 8; i += 8)
                                      output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32);
                                    return output;
                                  }
                                  
                                  /*
                                   * Convert an array of little-endian words to a string
                                   */
                                  function binl2rstr(input)
                                  {
                                    var output = "";
                                    for(var i = 0; i < input.length * 32; i += 8)
                                      output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF);
                                    return output;
                                  }
                                  
                                  /*
                                   * Calculate the MD5 of an array of little-endian words, and a bit length.
                                   */
                                  function binl_md5(x, len)
                                  {
                                    /* append padding */
                                    x[len >> 5] |= 0x80 << ((len) % 32);
                                    x[(((len + 64) >>> 9) << 4) + 14] = len;
                                  
                                    var a =  1732584193;
                                    var b = -271733879;
                                    var c = -1732584194;
                                    var d =  271733878;
                                  
                                    for(var i = 0; i < x.length; i += 16)
                                    {
                                      var olda = a;
                                      var oldb = b;
                                      var oldc = c;
                                      var oldd = d;
                                  
                                      a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
                                      d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
                                      c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
                                      b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
                                      a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
                                      d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
                                      c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
                                      b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
                                      a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
                                      d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
                                      c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
                                      b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
                                      a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
                                      d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
                                      c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
                                      b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);
                                  
                                      a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
                                      d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
                                      c = md5_gg(c, d, a, b, x[i+11], 14,  643717713);
                                      b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
                                      a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
                                      d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
                                      c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
                                      b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
                                      a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
                                      d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
                                      c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
                                      b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
                                      a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
                                      d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
                                      c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
                                      b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
                                  
                                      a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
                                      d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
                                      c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562);
                                      b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
                                      a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
                                      d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
                                      c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
                                      b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
                                      a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
                                      d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
                                      c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
                                      b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
                                      a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
                                      d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
                                      c = md5_hh(c, d, a, b, x[i+15], 16,  530742520);
                                      b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
                                  
                                      a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
                                      d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
                                      c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
                                      b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
                                      a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
                                      d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
                                      c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
                                      b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
                                      a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
                                      d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
                                      c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
                                      b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649);
                                      a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
                                      d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
                                      c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
                                      b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
                                  
                                      a = safe_add(a, olda);
                                      b = safe_add(b, oldb);
                                      c = safe_add(c, oldc);
                                      d = safe_add(d, oldd);
                                    }
                                    return Array(a, b, c, d);
                                  }
                                  
                                  /*
                                   * These functions implement the four basic operations the algorithm uses.
                                   */
                                  function md5_cmn(q, a, b, x, s, t)
                                  {
                                    return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
                                  }
                                  function md5_ff(a, b, c, d, x, s, t)
                                  {
                                    return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
                                  }
                                  function md5_gg(a, b, c, d, x, s, t)
                                  {
                                    return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
                                  }
                                  function md5_hh(a, b, c, d, x, s, t)
                                  {
                                    return md5_cmn(b ^ c ^ d, a, b, x, s, t);
                                  }
                                  function md5_ii(a, b, c, d, x, s, t)
                                  {
                                    return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
                                  }
                                  
                                  /*
                                   * Add integers, wrapping at 2^32. This uses 16-bit operations internally
                                   * to work around bugs in some JS interpreters.
                                   */
                                  function safe_add(x, y)
                                  {
                                    var lsw = (x & 0xFFFF) + (y & 0xFFFF);
                                    var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
                                    return (msw << 16) | (lsw & 0xFFFF);
                                  }
                                  
                                  /*
                                   * Bitwise rotate a 32-bit number to the left.
                                   */
                                  function bit_rol(num, cnt)
                                  {
                                    return (num << cnt) | (num >>> (32 - cnt));
                                  }
                                  

                                  Ursprung
                                  Das Script basiert auf einem Post den ich mal gefunden habe und zwar hier:
                                  https://community.openhab.org/t/disable-internet-connection-of-specific-echo-device-on-fritz-box-via-script/91374
                                  Das ist nur ein 5 Zeilen Shell Script und ich habe mir gedacht dass das auch in JavaScript gehen müsste - tut es auch :-)

                                  Funktionsweise
                                  Das Script läuft in mehreren Stufen ab ... Erst muss eine "Challange" von der FB abgeholt werden. Damit wird dann zusammen mit dem Passwort ein MD5 Hash gebildet.
                                  Das nutzt man dann wiederum um die SID von der Fritzbox zu bekommen. Jetzt kann man mit der SID diverse Anfragen an die FB stellen.
                                  Ich lese dann z.B. alle verfügbaren Filter Profile aus und die bekannten Geräte in der Fritzbox nebst ihren IDs.
                                  Dieser Part ist in dem ursprünglichen Script etwas rudimentär. Da geht es dann mit F12 und Developer Tools ans eingemachte. Aber das lasse ich hier erstmal weg.
                                  Am Ende ruft das Script dann eine Seite der FB auf und setzt damit dann den neuen Filter für das Device.

                                  Ich sage es mal gleich vorweg ... Die ist keine FB API ! Im Grunde ist es ein Hack der den Login und die Datenbewegung der FB Webseite nutzt - nur eben ohne die Webseite.
                                  Und ja ... Man kann mit diesem "Toolset" noch mehr anstellen. Ich kann z.B. alle Geräte der FB lesen mit ihren IPs. Im Grunde muss man über die Developer Tools nur mal schauen was die Webseite so an Daten schiebt wenn man etwas einstellt.
                                  Daraus kann man dann interessante Rückschlüsse ziehen. Aber das ist out of Scope hier ...

                                  Einrichtung und Nutzung
                                  Tja ihr müsst das Script kopieren und im JavaScript Adapter ein neues JavaScript erstellen. Da dann den Inhalt rein kopieren. 90% erledigt :-)
                                  Jetzt etwas "Schnüffeln" und Settings setzen.

                                  • Zum Testen solltet ihr erstmal die "Static Version" nutzen. Damit läuft das Script nur 1x durch. Wie man das aktiviert steht im Script. Wenn das Script dann sauber läuft kann man auf die "Object Trigger Version" umschwenken und alles über einen Datenpunkt in ioB steuern. Infos dazu stehen im Script.
                                  • Erstmal müsst ihr natürlich bei FbIp und FbPassword die entsprechenden Werte eintragen. Also einmal die FB IP und das FB Passwort.
                                  • Wenn der Login auf eure FritzBox mittels User und Passwort erfolgt, dann muss in FbUser der User noch eingetragen werden. Ansonsten dieses Feld einfach leer lassen.
                                  • FbListOnly jetzt auf true setzen. Denn wir wollen erstmal nur sehen ob es a) klappt und b) die Filter und Devices listen.
                                  • Wenn alles eingetragen ist (FbDevice & FbProfile sind an dieser Stelle noch unwichtig) dann mal das Script abspulen lassen ...
                                  • Ihr bekommt jetzt im Logging diverse Ausgaben (hoffentlich keine Fehler). Einmal folgendes:
                                  06:29:58.055	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: > Decode Filters
                                  06:29:58.056	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Filter named 'Standard' has ID : filtprof1
                                  06:29:58.057	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Filter named 'Gast' has ID : filtprof2
                                  06:29:58.057	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Filter named 'Unbeschränkt' has ID : filtprof3
                                  06:29:58.057	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Filter named 'Gesperrt' has ID : filtprof4
                                  

                                  Und dann noch sowas:

                                  06:30:01.191	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Device named 'Comp-L-Acer-L' has ID : user2482
                                  06:30:01.191	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Device named 'Comp-L-Pi' has ID : landevice37174
                                  06:30:01.192	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Device named 'Comp-M-Tablet-W' has ID : landevice2671
                                  

                                  Wenn das gelistet wird dann funktioniert def. schon mal der Zugriff auf die FB. Wenn nicht ... Nun dann müssen wir mal guggn :-)

                                  • Was wir jetzt brauchen ist erstmal das Gerät was wir einstellen wollen. Ihr nehmt also aus der Device Liste die ID.
                                    Beispiel:
                                    Device named 'Comp-L-Acer-L' has ID : user2482
                                    Wir brauchen den Namen und NICHT die ID!! Also kopieren wir uns Comp-L-Acer-L als Beispiel.
                                    Diesen Namen kopieren wir im Script hinter FbDevice.
                                  • Jetzt brauchen wir noch den Filter. Auch die wurden ja im ersten Lauf gelistet.
                                    Beispiel:
                                    Filter named 'Gesperrt' has ID : filtprof4
                                    Wir brauchen die ID und NICHT den Namen. Wir kopieren uns also filtprof4 als Beispiel.
                                    Diese ID tragen wir dann bei FbProfile ein.
                                    Anmerkung ... Ok das könnte man noch auf den Namen umstellen merke ich gerade :-)
                                  • FbListOnly jetzt auf false setzen.
                                  • Jetzt kommt der Teil wo die Kuh ins Gras beisst :-) Wir lassen das Script laufen.
                                    Und wenn nicht alles daneben geht, dann ändert sich wie von Zauberhand der Filter für den entsprechenden Rechner.
                                    Und in meinem Fall gingen 2 Jahre Lösungssuche für dieses Problem zu Ende ....

                                  Hinweise
                                  Mir ist bewusst das man an dem Script noch einiges verbessern könnte. Und ich würde es demnächst auch in github einstellen inkl. Anleitung.
                                  Man könnte es auch in einen Adapter überführen. Aber erstmal wäre gut zu wissen ob es bei anderen auch klappt ...
                                  Wenn man das Script mit der VIS verheiraten will, dann muss man da noch etwas dran umbauen. Da braucht es dann 2-3 Datenpunkte.
                                  Aber ein riesen Drama sollte das nicht sein ...

                                  Ok jetzt bin ich gespannt auf das Feedback :-)

                                  Bis dahin ...

                                  M Offline
                                  M Offline
                                  marcel-k
                                  schrieb am zuletzt editiert von
                                  #119

                                  @moelski vielen vielen Dank für dein Skript !! Du hast mir mit meinen 3 Jungs das Leben erleichert ;-)

                                  Geile Community ! ich muss mich ständig wiederholen = Das macht einen riesen Spass mit Euch hier

                                  Grüße, Marcel

                                  1 Antwort Letzte Antwort
                                  0
                                  • O ottokar

                                    Ok,

                                    ich hatte mal ein bisschen Lust und Laune weiterzubauen,
                                    Geplant war ein über die JSON Tabelle selektiertes GEerät sperren zu können.
                                    ich hab das jetzt folgendermaßen gelöst.

                                    Ich hab es jetzt mit der Basic Table soweit gebaut das man aus der Liste ein Gerät selektieren kann und mit Sperren/Entsperren Knopf entsprechend ein Profil zuweisen kann(man könnte auch mehrer Knöpfe mit mehr Filtern nehmen oder vielleicht ein Dropdown um den Filter auszuwählen)

                                    Die Basic Table kann die Auswahl als JSON in einen Datenpunkt und in eine Detailview schreiben..
                                    (hierzu kann man ein Basic HTML Widget in der Vis nutzen. In den Eigenschaften de Tabelle dann bei Detailed widget: die Widget Nummer des HTML-Widgets eintragen)

                                    So kann man am Smartphone auch schön auswählen (beim wischen wird automatisch selektiert, das ist doof)
                                    Die Auswahl wird also in einen Datenpunkt geschrieben, dies triggert ein Script welches den Gerätenamen (aus dem Auswahl JSON-String) in einen weiteren Datenpunkt schreibt.
                                    eaf89af1-0419-4edd-a403-fe2fe7aa125e-image.png

                                    in den Knöpfen ist jeweils der Wert für das Filterprofil hinterleg also filterprof1 für frei und filtprof2913 für sperren bei mir
                                    Wir der Knopf gedrückt wid der wert in einem Datenpunkt aktualisiert und ein Script getriggert welches dann den Datenpunkt Devicename und filterprof im richtigen Format in den Fritzbox Sperre Datenpunkt schreibt der in moelskis Script hier hinterlegt ist.
                                    e476fd05-8045-4166-81da-3b59d06653c6-image.png

                                    Datenpunkte:
                                    f3704591-6a3b-4238-af4d-c175c43ed922-image.png

                                    9176a9d5-0eaf-4916-9709-75668e5b5543-image.png
                                    Die Überschrift wird aus dem Datenpunkt aktualisiert, so sieht man welches Gerät als lettes ausgewählt wurde bevor man sperrt oder entsperrt.
                                    Bei den Knöpfen hab ich ein BasicHTML state Widget drübergelegt, war irgendwie einfacher, der Knopf hat irgendwie nicht geschalten.. ;-/

                                    Vielleicht braucht jemand ja so eine Lösung...

                                    Grüssle Oli

                                    M Offline
                                    M Offline
                                    marcel-k
                                    schrieb am zuletzt editiert von marcel-k
                                    #120

                                    @ottokar Servus, macht es Dir was aus uns evtl. deine VIS View zur Verfügung zu stellen? bzw. die einzelnen Widgets? ... ich bekomm das mit deiner Anleitung leider nicht nachgebaut :-(

                                    Blockly ist nicht das Problem ...

                                    Für mich ist mit deiner Lösung für die VIS dieses klasse Script erst richtig rund ...

                                    Grüße

                                    1 Antwort Letzte Antwort
                                    0
                                    • O ottokar

                                      Automatisches refreshen der Tabelle(der Vis) nach dem setzen des Filterwertes,
                                      je nachdem wie schnell die Fritzbox ist reichen ein paar Sekunden.
                                      hier das erweiterte Blockly:
                                      1b3577c9-4035-4d04-9ff8-82ac50de6afa-image.png

                                      Zusätzliche Quelle: https://forum.iobroker.net/topic/6956/script-für-automatischen-refresh-von-vis

                                      M Offline
                                      M Offline
                                      marcel-k
                                      schrieb am zuletzt editiert von marcel-k
                                      #121

                                      @ottokar Hallo lieber ottokar und moelski ... heute habe ich mich nochmal rangesetzt und es funktioniert nun auch auf der VIS ... ich kann nicht oft genug Danke sagen ... weshalb diese Script, gerade zu Corona Zeiten anhand von Post´s und Nachfragen nicht durch die Decke geht?

                                      Mit meinen 3 Jungs (11, 10 und 5 Jahre alt) ist das Thema Internet und zocken JEDEN TAG !! Thema und Diskussion ... okay, meine Frau und ich sind da etwas strenger vermutlich ... was aber bei 3 Jungs die sich gegenseitig hochpushen auch einfach sein muss ...

                                      Leider sah das bisher so aus, das ich am Tag (unter der Woche auf Arbeit) durchschnittlich 5 Anrufe von den Kids bekommen habe: "Papa, dürfen wir zocken ... machst du uns das Internet an?" + 3 Anrufe von meiner Frau: "Mach bitte das Internet aus ..."

                                      Über VPN auf die Fritze 7490 jedesmal so ca. 5 min beschätigt ... es lädt wegen der vielen Geräte wirklich extrem langsam :-( ... bis ich auf der Filterseite bin , vergehen ca. 3 minuten :-(

                                      Dadurch das jetzt im Wohnzimmer auf dem Tablet dieses geile Script zur Verfügung steht = kann nun auch meine Frau schalten und walten !

                                      Mir ist das gerade sehr wichtig euch aus dem Leben gegriffen dies mitzuteilen ... Jeder der Kinder hat weiß selbst am besten wie wichtig es ist, seinen Kindern Grenzen zu ziehen, klare Regeln aufzustellen und Familienritualen zu beherzigen ... Seinen eigenen Kindern tagsüber eine angemessen Zeit vor digitalen Geräten zu erlauben, zu Coronazeiten noch schwieriger :-( das ist leider einfach so ...

                                      Mir ist klar, das die Internetbeschränkung einige von Euch einfach über Android oder Apple lösen ... bei uns ist es aber so, dass bei 3 Jungs der eine ein Apple Gerät haben möchte ... für den anderen ist evtl. nur ein älteres Android Gerät finanziell möglich (worauf Family Link nicht funktioniert) ... und und und .. die Situationen sind sehr verschieden ... + der Vater liebt aus unterschiedlichsten Gründen die Fritz Box (hierüber läuft u.a. die Doorbird-Türsteuerung hervorragend) - jedoch die Profil bzw. Kindersicherung ist eine absolute Krücke ...

                                      Von daher ... nochmals vielen Dank ... und macht bitte weiter so ... ohne Euch würde das Ganze nicht leben ...

                                      Beste Grüße, Marcel

                                      1 Antwort Letzte Antwort
                                      0
                                      • moelskiM moelski

                                        @jack99n
                                        Das ist die Idee für 1.10 :-)
                                        Genauso wie die Filter ...

                                        M Offline
                                        M Offline
                                        marcel-k
                                        schrieb am zuletzt editiert von
                                        #122

                                        @moelski Hallo ... mir ist vollkommen bewusst das ich seit den letzten Post´s ein monolog führe :-)

                                        Dein Script habe habe ich seit kurzem erfolgreich am laufen ... siehe Bild ... die Anleitung ist für meine Frau + Schwiegermutter (ohne dieser müsste ich alles 20x erklären)

                                        Folgende Wünsche (jammern auf höchstem Niveau! ;-) )

                                        • kann das Script nicht doch als Adapter veröffentlicht werden?

                                        • die Funktion nur bestimmte Geräte in der Liste zu haben ... bei mir wären es nur ca. 7 Geräte von den Kids ... die restlichen 50 sind völlig uninteressant

                                        • die Funktion mehrere Geräte aufeinmal einstellen zu können... ich habe hier gelesen das es schon thematisiert wurde, aber a. bringt es die Fritzbox auf der Filterseite von sich aus mit (unwissend einfach mal in den Raum geworfen) b. dieser Wunsch einfach nur in Bezug auf den Wunsch eines Adapters ...

                                        Das war´s ... nochmals vielen Dank für dieses Script! In den letzten 2 Tagen hast du mir dadurch ca. 20 min. Lebenszeit geschenkt :-)

                                        Grüße, Marcel

                                        1.JPG

                                        ? L 2 Antworten Letzte Antwort
                                        0
                                        • moelskiM moelski

                                          Moin !

                                          Gestern Abend doch glatt am TV verschlummert :face_with_rolling_eyes: Aber nun ...

                                          Hier aber nun das Script:

                                          /*******************************************************
                                          * Basis: 
                                          * https://community.openhab.org/t/disable-internet-connection-of-specific-echo-device-on-fritz-box-via-script/91374
                                          * https://forum.fhem.de/index.php?topic=109689.0
                                          * https://www.kuketz-blog.de/fritzbox-wlan-toggle-per-skript/
                                          *******************************************************/ 
                                          
                                          /*******************************************************
                                          * Script SetDeviceFilter
                                          * 
                                          * 13.09.20 V1.09    Regex mit Escape beim . und Fix für Liste
                                          * 12.09.20 V1.08    Regex um . erweitert
                                          * 12.09.20 V1.07    Erweritertes Logging aktivierbar für Fehlersuche
                                          * 08.09.20 V1.06    Anpassungen an FirtzOS 7.20 (Regex Auswertung für Listenerstellung)
                                          * 05.09.20 V1.05    Ausgabe einer Device / Filter Liste möglich als JSON 
                                          *                   Logging reduziert wenn FbListOnly = false
                                          * 04.09.20 V1.04    Fix für doppelte Einträge in Listen
                                          * 02.09.20 V1.03    Erweiterung zum automatischen Start mittels ioB Datenpunkt
                                          * 02.09.20 V1.02    Script Abbruch wenn der Login nicht geklappt hat
                                          * 02.09.20 V1.01    Regex Erweiterung, Login auch mit User/Passwort
                                          * 01.09.20 V1.00    erste öffentliches Release
                                          *******************************************************/ 
                                          const Version = "1.09";
                                          
                                          // TODO
                                          // * Liste erzeugen mit Devices und aktuellem Filter
                                          //   > als JSON in einen DP speichern -> für Tabellenauswertung
                                          
                                          // https://forum.iobroker.net/topic/16184/http-request-in-javascript/5
                                          var request = require('request');
                                          var headers = { 
                                              'Content-Type': 'application/x-www-form-urlencoded', 
                                              'User-Agent': 'curl/7.64.0', 
                                              'Accept': '*/*'
                                          }; 
                                          
                                          /*******************************************************
                                          * E I N S T E L L U N G E N 
                                          *******************************************************/
                                          
                                          // Die IP Der Fritzbox
                                          const FbIp          = "192.168.30.1";              
                                          // Der User der Fritzbox 
                                          // HINWEIS : Den Benutzer leer lassen wenn die Anmeldung an der FB nur mit Passwort erfolgt !
                                          const FbUser        = ""; 
                                          // Das Password der Fritzbox                  
                                          const FbPassword    = "";   
                                          // welcher Rechner soll "bearbeitet" werden                
                                          var   FbDevice      = "Comp-L-Pi";   
                                          // Das neue Profil für den Rechner              
                                          var   FbProfile     = "filtprof4";  
                                          // erweitertes Logging aktivieren für Fehlersuche
                                          const FbDebugging   = false;
                                          // Keine Änderung an der Fritzbox (true) -> Listet dann nur alle Profile und Rechner               
                                          const FbListOnly    = false; 
                                          // Device / Filter Liste erzeugen Ja (true), Nein (false)
                                          const FbCreateList  = true; 
                                          // Datenpunkt (string) für einen automatischen Script Start (muss angelegt werden!)
                                          // Der Datenpunkt wir mit Device;Profil beschrieben. Bsp: Comp-L-Pi;filtprof1
                                          const FbIobObject   = "Global.0.Fritzbox.ChangeDeviceFilter"  
                                          // Datenpunkt in den die Device / Filter Liste als JSON geschrieben wird                    
                                          const FbIobJsonList = "Global.0.Fritzbox.DeviceFilterListJson" 
                                          
                                          var secChallenge;
                                          var secMd5;
                                          var secLogin;
                                          var secSid;
                                          var secProfileNames = [];
                                          var secProfileIds   = [];
                                          var secDeviceNames  = [];
                                          var secDeviceIds    = [];
                                          var JsonList        = "";
                                          
                                          /*******************************************************
                                          * Object Trigger Version
                                          * Wenn auf einen Datenpunkt getriggert werden soll, dann muss der folgende Block auskommentiert werden. 
                                          * FbIobObject muss mit einem string Datenpunkt versehen werden.
                                          * Den Static Teil dann auskommentieren !
                                          * Diese Variante erlaubt es das Script dynamisch für alle Devices / Profile der FB zu verwenden. 
                                          *******************************************************/
                                          on({id: FbIobObject, change: "ne"}, function (obj) {
                                              console.log("Profile Changer started ... (Version : " + Version + ")");
                                              var data = obj.state.val.split(";");
                                              if (data.length != 2) {
                                                  console.log("Wrong parameter : " + obj.state.val);
                                                  return;
                                              }
                                          
                                              if (FbDebugging){
                                                  console.log(" > Datapoint : " + data);
                                              }
                                          
                                              console.log("Computer : " + data[0]);
                                              console.log("Filter   : " + data[1]);
                                              FbDevice  = data[0];
                                              FbProfile = data[1];
                                          
                                              getFbChallenge();
                                              
                                              console.log("Profile Changer done");
                                          });
                                          
                                          /*******************************************************
                                          * Static Version
                                          * Die folgenden 3 Zeilen lassen das Script  sofort laufen. 
                                          * Dabei sollte der Object Trigger Block auskommentiert werden. 
                                          *******************************************************/
                                          // console.log("Profile Changer started ... (Version : " + Version + ")");
                                          // getFbChallenge();
                                          // console.log("Profile Changer done");
                                          
                                          // Get the Challenge String from the FritzBox
                                          // Compute the md5 Hash
                                          function getFbChallenge(){
                                              console.log("function getFbChallenge");
                                              request.get({
                                                  url:        'http://' + FbIp + '/login_sid.lua?username=' + FbUser,
                                                  headers:    headers
                                              }, function(error, response, body) {
                                                  if (error) log(error, 'error');
                                                  //console.log(response);
                                                  // https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/RegExp
                                                  // <?xml version="1.0" encoding="utf-8"?><SessionInfo><SID>0000000000000000</SID><Challenge>d36de231</Challenge><BlockTime>0</BlockTime><Rights></Rights></SessionI
                                                  secChallenge = body.match(/Challenge>(.*)<\/Challenge/)[1];
                                                  console.log(" > Challenge : " + secChallenge);
                                          
                                                  var uft16le = str2rstr_utf16le(secChallenge + "-" +FbPassword );
                                                  var md5     = rstr_md5(uft16le);
                                                  secMd5      = rstr2hex(md5);
                                                          
                                                  console.log(" > MD5       : " + secMd5);   
                                          
                                                  // response="${challenge}-${md5}"
                                                  // sid=$(curl -i -s -k -d "response=${response}&username=" "http://$1" | grep -Po -m 1 '(?<=sid=)[a-f\d]+' | tail -1)
                                                  secLogin = "response=" + secChallenge + "-" + secMd5 + "&username=" + FbUser;
                                          
                                                  console.log(" > Login     : " + secLogin);
                                          
                                                  getFbSid();
                                              });
                                          }
                                          
                                          // Get the SID from the Fritzbox
                                          function getFbSid() {
                                              console.log("function getFbSid");
                                          
                                              request.post({
                                                  url:        'http://' + FbIp,
                                                  headers:    headers, 
                                                  form:       secLogin
                                              }, function(error, response, body) {
                                                  if (error) log(error, 'error');
                                                  // SID filtern 
                                                  // "sid":"c503b24dae458086"
                                                  try {
                                                      secSid = response.body.match(/\"sid\":\"(.*)\"/)[1];
                                                  }
                                                  catch (e) {
                                                      if (secSid == undefined) {
                                                          console.log("Your login was not successful. End Script", Error)
                                                          return;
                                                      }
                                                  }
                                          
                                                  console.log(" > SID       : " + secSid);
                                          
                                                  //getFbDeviceInfos();
                                                  getFbProfiles();
                                              });
                                          } 
                                          
                                          // TBD: 
                                          // Netzwerkinfos mit allen Devices lesen: 
                                          // var req = "xhr=1&sid=" + secSid + "&lang=de&page=netDev&xhrId=cleanup&useajax=1&no_sidrenew=" 
                                          function getFbDeviceInfos(){
                                              console.log("function getFbDeviceInfos");
                                              var req = "xhr=1&sid=" + secSid + "&lang=de&page=netDev&xhrId=cleanup&useajax=1&no_sidrenew=" 
                                          
                                              request.post({
                                                  url:        'http://' + FbIp + '/data.lua',
                                                  headers:    headers, 
                                                  form:       req
                                              }, function(error, response, body) {
                                                  if (error) log(error, 'error');
                                                  console.log(response.body);
                                              });    
                                          }
                                          
                                          // Get all Profiles from the Fritzbox
                                          function getFbProfiles() {
                                              console.log("function getFbProfiles");
                                              // #curl -d "xhr=1&sid=${sid}&lang=de&no_sidrenew=&page=kidPro" "http://$1/data.lua"
                                              var req = "xhr=1&sid=" + secSid + "&lang=de&no_sidrenew=&page=kidPro";
                                          
                                              request.post({
                                                  url:        'http://' + FbIp + '/data.lua',
                                                  headers:    headers, 
                                                  form:       req
                                              }, function(error, response, body) {
                                                  if (error) log(error, 'error');
                                                  
                                                  if (FbDebugging){
                                                      console.log(" > response.body : \n" + response.body);
                                                  }
                                          
                                                  secProfileIds   = [];
                                                  secProfileNames = [];
                                          
                                                  console.log(" > Decode Names")
                                                  var rx = new RegExp( /class=\"name\"\stitle=\"([a-zA-Z0-9 äöüÄÖÜ\-\_\.]*)\"\sdatalabel/g );
                                                  while( (match = rx.exec( body )) != null ) {
                                                      secProfileNames.push(match[1]);
                                                  }
                                                  if (FbDebugging){
                                                      console.log(" > secProfileNames : \n" + secProfileNames);
                                                  }
                                          
                                                  console.log(" > Decode Filters")
                                                  // submit" name="edit" value="
                                                  rx = new RegExp( /submit\"\sname=\"edit\"\svalue=\"([a-zA-Z0-9 äöüÄÖÜ\-\_\.]*)\"\sclass=\"icon/g );
                                                  while( (match = rx.exec( body )) != null ) {
                                                      secProfileIds.push(match[1]);
                                                  }
                                                  if (FbDebugging){
                                                      console.log(" > secProfileIds : \n" + secProfileIds);
                                                  }
                                          
                                                  if (FbListOnly) {
                                                      console.log("Filter Count : " + secProfileIds.length);
                                                      for (var i = 0; i < secProfileIds.length; i++) {
                                                          console.log("Filter named '"+ secProfileNames[i] + "' has ID : " + secProfileIds[i]);
                                                      }
                                                  }
                                          
                                                  getFbDevices();
                                              });
                                          }
                                          
                                          // IMPORTANT: 
                                          // The DeviceId changes when you switch the profile. 
                                          // If you use default profiles it is something like "landevice308962"
                                          // If you use your own profiles it is something like "user7749"
                                          function getFbDevices() {
                                              console.log("function getFbDevices");
                                              // xhr=1&sid=5f5ba302815594d8&lang=de&no_sidrenew=&page=kidLis
                                              var req = "xhr=1&sid=" + secSid + "&lang=de&no_sidrenew=&page=kidLis";
                                          
                                              request.post({
                                                  url:        'http://' + FbIp + '/data.lua',
                                                  headers:    headers, 
                                                  form:       req
                                              }, function(error, response, body) {
                                                  if (error) log(error, 'error');
                                                  if (FbDebugging){
                                                      console.log(" > response.body : \n" + response.body);
                                                  }
                                          
                                                  // TESTING
                                                  //body = getState("Global.0.Testing.StringValue").val;
                                          
                                                  secDeviceNames = [];
                                                  secDeviceIds   = [];
                                          
                                                  console.log(" > Decode Device Names")
                                                  var rx = new RegExp( /class=\"name"\stitle=\"([a-zA-Z0-9 äöüÄÖÜ\-\_\.]*)\"\sdatalabel/g );
                                                  while( (match = rx.exec( body )) != null ) {
                                                      secDeviceNames.push(match[1]);
                                                  }
                                                  if (FbDebugging){
                                                      console.log(" > secDeviceNames : \n" + secDeviceNames);
                                                  }
                                          
                                                  console.log(" > Decode Device Ids")
                                                  rx = new RegExp( /name=\"profile:([a-zA-Z0-9 äöüÄÖÜ\-\_\.]*)\"><option/g );
                                                  while( (match = rx.exec( body )) != null ) {
                                                      secDeviceIds.push(match[1]);
                                                  }
                                                  if (FbDebugging){
                                                      console.log(" > secDeviceIds : \n" + secDeviceIds);
                                                  }
                                                  
                                                  if (FbListOnly) {
                                                      console.log("Device Count : " + secDeviceIds.length);
                                                      for (var i = 0; i < secDeviceNames.length; i++) {
                                                          console.log(i + " - Device named '"+ secDeviceNames[i] + "' has ID : " + secDeviceIds[i]);
                                                      }
                                                  }
                                          
                                                  if (!FbListOnly) { 
                                                      setFbSperre(); 
                                                  } else { 
                                                      console.log("DONE : Listmode - No Device blocking ..."); 
                                                  }
                                              });
                                          }
                                          
                                          //curl -d "sid=${sid}&edit=$3&time=$4&budget=unlimited&apply=&page=kids_profileedit" "http://$1/data.lua" >/dev/null 2>&1
                                          function setFbSperre() {
                                              console.log("function setFbSperre");
                                              
                                              // Device suchen ... 
                                              var devId = -1;
                                              for (var i = 0; i < secDeviceNames.length; i++) {
                                                  if (secDeviceNames[i] == FbDevice) {
                                                      devId = i;
                                                  }
                                              }
                                              
                                              console.log(" > Device Nr   : " + devId); 
                                              console.log(" > Device ID   : " + secDeviceIds[devId]); 
                                              console.log(" > Device Name : " + secDeviceNames[devId]);
                                              //var profile = "filtprof4";
                                              //var profile = "filtprof3079";
                                          
                                              // xhr=1&sid=b46f3d48b3b0fcc2&lang=de&no_sidrenew=&profile%3Alandevice308962=filtprof4&apply=&oldpage=%2Finternet%2Fkids_userlist.lua
                                              var req2 = "xhr=1&sid=" + secSid + "&lang=de&no_sidrenew=&profile%3A" + secDeviceIds[devId] + "=" + FbProfile + "&apply=&oldpage=%2Finternet%2Fkids_userlist.lua";
                                              console.log(" > req : " + req2);
                                              //var req2 = "xhr=1&sid=" + sid + "&lang=de&no_sidrenew=&profile%3Alandevice308962=filtprof3079&profile%3Auser7725=filtprof4&profile%3Alandevice2671=filtprof1&profile%3Alandevice2444=filtprof1&profile%3Alandevice2330=filtprof1&profile%3Alandevice2195=filtprof1&profile%3Alandevice229903=filtprof1&profile%3Alandevice8486=filtprof1&profile%3Alandevice1908=filtprof1&profile%3Alandevice1865=filtprof1&profile%3Alandevice516865=filtprof1&profile%3Alandevice518551=filtprof1&profile%3Alandevice169594=filtprof1&profile%3Alandevice171398=filtprof1&profile%3Alandevice175510=filtprof1&profile%3Alandevice177635=filtprof1&profile%3Alandevice178875=filtprof1&profile%3Alandevice179702=filtprof1&profile%3Alandevice180995=filtprof1&profile%3Alandevice182196=filtprof1&profile%3Alandevice183607=filtprof1&profile%3Alandevice184405=filtprof1&profile%3Alandevice638220=filtprof1&profile%3Alandevice634583=filtprof1&profile%3Alandevice7650=filtprof1&profile%3Alandevice353720=filtprof1&profile%3Auser7731=filtprof4&profile%3Alandevice170191=filtprof1&profile%3Alandevice941076=filtprof1&profile%3Alandevice358722=filtprof1&profile%3Alandevice2859=filtprof1&profile%3Auser7739=filtprof4&profile%3Alandevice8035=filtprof1&profile%3Auser7733=filtprof4&profile%3Auser7740=filtprof4&profile%3Alandevice1333=filtprof1&profile%3Alandevice6211=filtprof1&profile%3Alandevice35977=filtprof1&profile%3Alandevice8101=filtprof1&profile%3Alandevice8174=filtprof1&profile%3Auser7729=filtprof4&profile%3Alandevice1125=filtprof1&profile%3Alandevice1124=filtprof1&profile%3Alandevice7715=filtprof1&profile%3Alandevice52361=filtprof1&profile%3Alandevice30084=filtprof1&profile%3Alandevice26151=filtprof1&profile%3Alandevice26138=filtprof1&profile%3Alandevice6162=filtprof1&profile%3Alandevice5204=filtprof1&profile%3Alandevice1129367=filtprof1&profile%3Alandevice9399=filtprof1&profile%3Alandevice232149=filtprof1&profile%3Alandevice6935=filtprof1&profile%3Alandevice941333=filtprof1&profile%3Alandevice941569=filtprof1&apply=&oldpage=%2Finternet%2Fkids_userlist.lua";
                                              //var req2 = "xhr=1&sid=" + sid + "&lang=de&no_sidrenew=&profile:landevice308962=filtprof4&apply=&oldpage=/internet/kids_userlist.lua";
                                          
                                              request.post({
                                                  url:        'http://' + FbIp + '/data.lua',
                                                  headers:    headers, 
                                                  form:       req2
                                              }, function(error, response, body) {
                                                  if (error) log(error, 'error');
                                                  if (FbDebugging){
                                                      console.log(" > response : \n" + response);
                                                  }
                                          
                                                  console.log("Change done. Check your FB / Device if it worked :-)");
                                          
                                                  if (FbCreateList) {
                                                      getFbDeviceFilterList();
                                                  }
                                              });    
                                          }
                                          
                                          function getFbDeviceFilterList() {
                                              console.log("function getFbDeviceFilterList");
                                              
                                              // xhr=1&sid=e2d99419592fb780&lang=de&no_sidrenew=&page=kidLis
                                              var req = "xhr=1&sid=" + secSid + "&lang=de&no_sidrenew=&page=kidLis";
                                          
                                              request.post({
                                                  url:        'http://' + FbIp + '/data.lua',
                                                  headers:    headers, 
                                                  form:       req
                                              }, function(error, response, body) {
                                                  //if (error) log(error, 'error');
                                                  //console.log(response.body);
                                          
                                                  JsonList = "";
                                                  var tmpDevices      = [];
                                                  var tmpUsage        = [];
                                                  var tmpProfilesId   = [];
                                                  var tmpProfilesName = [];
                                                  var tmpTimes        = [];
                                          
                                                  // TESTING
                                                  //body = getState("Global.0.Testing.StringValue").val;
                                                  
                                                  console.log(" > Decode Device Names")
                                                  var rx = new RegExp(/class=\"name"\stitle=\"([a-zA-Z0-9 äöüÄÖÜ\-\_\.]*)\"\sdatalabel/g);
                                                  while ((match = rx.exec(body)) != null) {
                                                      tmpDevices.push(match[1]);
                                                  }
                                                  //console.log(" > " + tmpDevices);
                                          
                                                  console.log(" > Decode Device Profile ID");
                                                  //rx = new RegExp(/button\s.*?value=\"([a-zA-Z0-9 äöüÄÖÜ]*?)\"/g);
                                                  rx = new RegExp(/option\svalue=\"([a-zA-Z0-9 äöüÄÖÜ\-]*?)\"\sselected/g);
                                                  while ((match = rx.exec(body)) != null) {
                                                      tmpProfilesId.push(match[1]);
                                                  }
                                                  //console.log(" > " + tmpProfilesId);
                                          
                                                  console.log(" > Decode Device Profile Names");
                                                  for (var i = 0; i < tmpProfilesId.length; i++) {
                                                      for (var j = 0; j < secProfileIds.length; j++) { 
                                                          //console.log(tmpProfilesId[i] + " > " + secProfileIds[j]);
                                                          if (tmpProfilesId[i] == secProfileIds[j]){
                                                              tmpProfilesName.push(secProfileNames[j]);
                                                          }
                                                      }
                                                  }
                                                  //console.log(" > " + tmpProfilesName);
                                          
                                                  console.log(" > Decode Internetnutzung")
                                                  rx = new RegExp(/td\sdatalabel=\"[a-zA-Z0-9 äöüÄÖÜ\-]+\"\sclass=\"usage\">(.*?)<\/td>/g);
                                                  while ((match = rx.exec(body)) != null) { 
                                                      var tmp = match[1];
                                                      tmp = tmp.replace("<span>", "").replace("<\/span>", "");
                                                      tmpUsage.push(tmp);
                                                  }
                                                  //console.log(" > " + tmpUsage);
                                          
                                                  console.log(" > Decode Times")
                                                  rx = new RegExp(/td\sdatalabel=\"[a-zA-Z0-9 äöüÄÖÜ\-]+\"\sclass=\"bar\stime\">(.*?)<\/td>/g);
                                                  while ((match = rx.exec(body)) != null) {
                                                      var tmp = match[1];
                                                      if (tmp.includes("\"")) {
                                                          tmp = tmp.replace("<span title=\"", "");
                                                          tmp = tmp.slice(0, tmp.indexOf("\""));
                                                          tmpTimes.push(tmp);
                                                      } else {
                                                          tmpTimes.push(tmp);
                                                      }
                                                  }
                                                  //console.log(" > " + tmpTimes);
                                          
                                                  // console.log("Device Count : " + secDeviceIds.length);
                                                  JsonList = "[";
                                                  for (var i = 0; i < tmpDevices.length; i++) {
                                                      JsonList += "{";
                                                      JsonList += "\"Device\": \"" + tmpDevices[i] + "\"," 
                                                      JsonList += "\"Profile ID\": \"" + tmpProfilesId[i] + "\","
                                                      JsonList += "\"Profile Name\": \"" + tmpProfilesName[i] + "\","
                                                      JsonList += "\"Usage\": \"" + tmpUsage[i] + "\","
                                                      JsonList += "\"Time\": \"" + tmpTimes[i] + "\""
                                                      if (i != tmpDevices.length - 1) { JsonList += "},"; } else { JsonList += "}"; }
                                                  }
                                                  JsonList += "]";
                                          
                                                  //console.log(JsonList);
                                                  setState(FbIobJsonList,  JsonList, true);
                                          
                                                  console.log("DONE : List generated ...");
                                              });   
                                          }
                                          
                                          
                                          // https://gist.githubusercontent.com/josedaniel/951664/raw/33c7a6b44d6cc53dc75cb5230fb551bc4ba7a46a/md5.js
                                          // http://pajhome.org.uk/crypt/md5/instructions.html
                                          
                                          /*
                                           * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
                                           * Digest Algorithm, as defined in RFC 1321.
                                           * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
                                           * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
                                           * Distributed under the BSD License
                                           * See http://pajhome.org.uk/crypt/md5 for more info.
                                           */
                                          
                                          /*
                                           * Configurable variables. You may need to tweak these to be compatible with
                                           * the server-side, but the defaults work in most cases.
                                           */
                                          var hexcase = 0;   /* hex output format. 0 - lowercase; 1 - uppercase        */
                                          var b64pad  = "";  /* base-64 pad character. "=" for strict RFC compliance   */
                                          
                                          /*
                                           * These are the functions you'll usually want to call
                                           * They take string arguments and return either hex or base-64 encoded strings
                                           */
                                          function hex_md5(s)    { return rstr2hex(rstr_md5(str2rstr_utf8(s))); }
                                          function b64_md5(s)    { return rstr2b64(rstr_md5(str2rstr_utf8(s))); }
                                          function any_md5(s, e) { return rstr2any(rstr_md5(str2rstr_utf8(s)), e); }
                                          function hex_hmac_md5(k, d)
                                            { return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); }
                                          function b64_hmac_md5(k, d)
                                            { return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); }
                                          function any_hmac_md5(k, d, e)
                                            { return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e); }
                                          
                                          /*
                                           * Perform a simple self-test to see if the VM is working
                                           */
                                          function md5_vm_test()
                                          {
                                            return hex_md5("abc").toLowerCase() == "900150983cd24fb0d6963f7d28e17f72";
                                          }
                                          
                                          /*
                                           * Calculate the MD5 of a raw string
                                           */
                                          function rstr_md5(s)
                                          {
                                            return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
                                          }
                                          
                                          /*
                                           * Calculate the HMAC-MD5, of a key and some data (raw strings)
                                           */
                                          function rstr_hmac_md5(key, data)
                                          {
                                            var bkey = rstr2binl(key);
                                            if(bkey.length > 16) bkey = binl_md5(bkey, key.length * 8);
                                          
                                            var ipad = Array(16), opad = Array(16);
                                            for(var i = 0; i < 16; i++)
                                            {
                                              ipad[i] = bkey[i] ^ 0x36363636;
                                              opad[i] = bkey[i] ^ 0x5C5C5C5C;
                                            }
                                          
                                            var hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
                                            return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
                                          }
                                          
                                          /*
                                           * Convert a raw string to a hex string
                                           */
                                          function rstr2hex(input)
                                          {
                                            try { hexcase } catch(e) { hexcase=0; }
                                            var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
                                            var output = "";
                                            var x;
                                            for(var i = 0; i < input.length; i++)
                                            {
                                              x = input.charCodeAt(i);
                                              output += hex_tab.charAt((x >>> 4) & 0x0F)
                                                     +  hex_tab.charAt( x        & 0x0F);
                                            }
                                            return output;
                                          }
                                          
                                          /*
                                           * Convert a raw string to a base-64 string
                                           */
                                          function rstr2b64(input)
                                          {
                                            try { b64pad } catch(e) { b64pad=''; }
                                            var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
                                            var output = "";
                                            var len = input.length;
                                            for(var i = 0; i < len; i += 3)
                                            {
                                              var triplet = (input.charCodeAt(i) << 16)
                                                          | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
                                                          | (i + 2 < len ? input.charCodeAt(i+2)      : 0);
                                              for(var j = 0; j < 4; j++)
                                              {
                                                if(i * 8 + j * 6 > input.length * 8) output += b64pad;
                                                else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
                                              }
                                            }
                                            return output;
                                          }
                                          
                                          /*
                                           * Convert a raw string to an arbitrary string encoding
                                           */
                                          function rstr2any(input, encoding)
                                          {
                                            var divisor = encoding.length;
                                            var i, j, q, x, quotient;
                                          
                                            /* Convert to an array of 16-bit big-endian values, forming the dividend */
                                            var dividend = Array(Math.ceil(input.length / 2));
                                            for(i = 0; i < dividend.length; i++)
                                            {
                                              dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
                                            }
                                          
                                            /*
                                             * Repeatedly perform a long division. The binary array forms the dividend,
                                             * the length of the encoding is the divisor. Once computed, the quotient
                                             * forms the dividend for the next step. All remainders are stored for later
                                             * use.
                                             */
                                            var full_length = Math.ceil(input.length * 8 /
                                                                              (Math.log(encoding.length) / Math.log(2)));
                                            var remainders = Array(full_length);
                                            for(j = 0; j < full_length; j++)
                                            {
                                              quotient = Array();
                                              x = 0;
                                              for(i = 0; i < dividend.length; i++)
                                              {
                                                x = (x << 16) + dividend[i];
                                                q = Math.floor(x / divisor);
                                                x -= q * divisor;
                                                if(quotient.length > 0 || q > 0)
                                                  quotient[quotient.length] = q;
                                              }
                                              remainders[j] = x;
                                              dividend = quotient;
                                            }
                                          
                                            /* Convert the remainders to the output string */
                                            var output = "";
                                            for(i = remainders.length - 1; i >= 0; i--)
                                              output += encoding.charAt(remainders[i]);
                                          
                                            return output;
                                          }
                                          
                                          /*
                                           * Encode a string as utf-8.
                                           * For efficiency, this assumes the input is valid utf-16.
                                           */
                                          function str2rstr_utf8(input)
                                          {
                                            var output = "";
                                            var i = -1;
                                            var x, y;
                                          
                                            while(++i < input.length)
                                            {
                                              /* Decode utf-16 surrogate pairs */
                                              x = input.charCodeAt(i);
                                              y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
                                              if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF)
                                              {
                                                x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
                                                i++;
                                              }
                                          
                                              /* Encode output as utf-8 */
                                              if(x <= 0x7F)
                                                output += String.fromCharCode(x);
                                              else if(x <= 0x7FF)
                                                output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
                                                                              0x80 | ( x         & 0x3F));
                                              else if(x <= 0xFFFF)
                                                output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
                                                                              0x80 | ((x >>> 6 ) & 0x3F),
                                                                              0x80 | ( x         & 0x3F));
                                              else if(x <= 0x1FFFFF)
                                                output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
                                                                              0x80 | ((x >>> 12) & 0x3F),
                                                                              0x80 | ((x >>> 6 ) & 0x3F),
                                                                              0x80 | ( x         & 0x3F));
                                            }
                                            return output;
                                          }
                                          
                                          /*
                                           * Encode a string as utf-16
                                           */
                                          function str2rstr_utf16le(input)
                                          {
                                            var output = "";
                                            for(var i = 0; i < input.length; i++)
                                              output += String.fromCharCode( input.charCodeAt(i)        & 0xFF,
                                                                            (input.charCodeAt(i) >>> 8) & 0xFF);
                                            return output;
                                          }
                                          
                                          function str2rstr_utf16be(input)
                                          {
                                            var output = "";
                                            for(var i = 0; i < input.length; i++)
                                              output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
                                                                             input.charCodeAt(i)        & 0xFF);
                                            return output;
                                          }
                                          
                                          /*
                                           * Convert a raw string to an array of little-endian words
                                           * Characters >255 have their high-byte silently ignored.
                                           */
                                          function rstr2binl(input)
                                          {
                                            var output = Array(input.length >> 2);
                                            for(var i = 0; i < output.length; i++)
                                              output[i] = 0;
                                            for(var i = 0; i < input.length * 8; i += 8)
                                              output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32);
                                            return output;
                                          }
                                          
                                          /*
                                           * Convert an array of little-endian words to a string
                                           */
                                          function binl2rstr(input)
                                          {
                                            var output = "";
                                            for(var i = 0; i < input.length * 32; i += 8)
                                              output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF);
                                            return output;
                                          }
                                          
                                          /*
                                           * Calculate the MD5 of an array of little-endian words, and a bit length.
                                           */
                                          function binl_md5(x, len)
                                          {
                                            /* append padding */
                                            x[len >> 5] |= 0x80 << ((len) % 32);
                                            x[(((len + 64) >>> 9) << 4) + 14] = len;
                                          
                                            var a =  1732584193;
                                            var b = -271733879;
                                            var c = -1732584194;
                                            var d =  271733878;
                                          
                                            for(var i = 0; i < x.length; i += 16)
                                            {
                                              var olda = a;
                                              var oldb = b;
                                              var oldc = c;
                                              var oldd = d;
                                          
                                              a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
                                              d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
                                              c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
                                              b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
                                              a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
                                              d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
                                              c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
                                              b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
                                              a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
                                              d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
                                              c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
                                              b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
                                              a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
                                              d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
                                              c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
                                              b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);
                                          
                                              a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
                                              d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
                                              c = md5_gg(c, d, a, b, x[i+11], 14,  643717713);
                                              b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
                                              a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
                                              d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
                                              c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
                                              b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
                                              a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
                                              d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
                                              c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
                                              b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
                                              a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
                                              d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
                                              c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
                                              b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
                                          
                                              a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
                                              d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
                                              c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562);
                                              b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
                                              a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
                                              d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
                                              c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
                                              b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
                                              a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
                                              d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
                                              c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
                                              b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
                                              a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
                                              d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
                                              c = md5_hh(c, d, a, b, x[i+15], 16,  530742520);
                                              b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
                                          
                                              a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
                                              d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
                                              c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
                                              b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
                                              a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
                                              d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
                                              c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
                                              b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
                                              a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
                                              d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
                                              c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
                                              b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649);
                                              a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
                                              d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
                                              c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
                                              b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
                                          
                                              a = safe_add(a, olda);
                                              b = safe_add(b, oldb);
                                              c = safe_add(c, oldc);
                                              d = safe_add(d, oldd);
                                            }
                                            return Array(a, b, c, d);
                                          }
                                          
                                          /*
                                           * These functions implement the four basic operations the algorithm uses.
                                           */
                                          function md5_cmn(q, a, b, x, s, t)
                                          {
                                            return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
                                          }
                                          function md5_ff(a, b, c, d, x, s, t)
                                          {
                                            return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
                                          }
                                          function md5_gg(a, b, c, d, x, s, t)
                                          {
                                            return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
                                          }
                                          function md5_hh(a, b, c, d, x, s, t)
                                          {
                                            return md5_cmn(b ^ c ^ d, a, b, x, s, t);
                                          }
                                          function md5_ii(a, b, c, d, x, s, t)
                                          {
                                            return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
                                          }
                                          
                                          /*
                                           * Add integers, wrapping at 2^32. This uses 16-bit operations internally
                                           * to work around bugs in some JS interpreters.
                                           */
                                          function safe_add(x, y)
                                          {
                                            var lsw = (x & 0xFFFF) + (y & 0xFFFF);
                                            var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
                                            return (msw << 16) | (lsw & 0xFFFF);
                                          }
                                          
                                          /*
                                           * Bitwise rotate a 32-bit number to the left.
                                           */
                                          function bit_rol(num, cnt)
                                          {
                                            return (num << cnt) | (num >>> (32 - cnt));
                                          }
                                          

                                          Ursprung
                                          Das Script basiert auf einem Post den ich mal gefunden habe und zwar hier:
                                          https://community.openhab.org/t/disable-internet-connection-of-specific-echo-device-on-fritz-box-via-script/91374
                                          Das ist nur ein 5 Zeilen Shell Script und ich habe mir gedacht dass das auch in JavaScript gehen müsste - tut es auch :-)

                                          Funktionsweise
                                          Das Script läuft in mehreren Stufen ab ... Erst muss eine "Challange" von der FB abgeholt werden. Damit wird dann zusammen mit dem Passwort ein MD5 Hash gebildet.
                                          Das nutzt man dann wiederum um die SID von der Fritzbox zu bekommen. Jetzt kann man mit der SID diverse Anfragen an die FB stellen.
                                          Ich lese dann z.B. alle verfügbaren Filter Profile aus und die bekannten Geräte in der Fritzbox nebst ihren IDs.
                                          Dieser Part ist in dem ursprünglichen Script etwas rudimentär. Da geht es dann mit F12 und Developer Tools ans eingemachte. Aber das lasse ich hier erstmal weg.
                                          Am Ende ruft das Script dann eine Seite der FB auf und setzt damit dann den neuen Filter für das Device.

                                          Ich sage es mal gleich vorweg ... Die ist keine FB API ! Im Grunde ist es ein Hack der den Login und die Datenbewegung der FB Webseite nutzt - nur eben ohne die Webseite.
                                          Und ja ... Man kann mit diesem "Toolset" noch mehr anstellen. Ich kann z.B. alle Geräte der FB lesen mit ihren IPs. Im Grunde muss man über die Developer Tools nur mal schauen was die Webseite so an Daten schiebt wenn man etwas einstellt.
                                          Daraus kann man dann interessante Rückschlüsse ziehen. Aber das ist out of Scope hier ...

                                          Einrichtung und Nutzung
                                          Tja ihr müsst das Script kopieren und im JavaScript Adapter ein neues JavaScript erstellen. Da dann den Inhalt rein kopieren. 90% erledigt :-)
                                          Jetzt etwas "Schnüffeln" und Settings setzen.

                                          • Zum Testen solltet ihr erstmal die "Static Version" nutzen. Damit läuft das Script nur 1x durch. Wie man das aktiviert steht im Script. Wenn das Script dann sauber läuft kann man auf die "Object Trigger Version" umschwenken und alles über einen Datenpunkt in ioB steuern. Infos dazu stehen im Script.
                                          • Erstmal müsst ihr natürlich bei FbIp und FbPassword die entsprechenden Werte eintragen. Also einmal die FB IP und das FB Passwort.
                                          • Wenn der Login auf eure FritzBox mittels User und Passwort erfolgt, dann muss in FbUser der User noch eingetragen werden. Ansonsten dieses Feld einfach leer lassen.
                                          • FbListOnly jetzt auf true setzen. Denn wir wollen erstmal nur sehen ob es a) klappt und b) die Filter und Devices listen.
                                          • Wenn alles eingetragen ist (FbDevice & FbProfile sind an dieser Stelle noch unwichtig) dann mal das Script abspulen lassen ...
                                          • Ihr bekommt jetzt im Logging diverse Ausgaben (hoffentlich keine Fehler). Einmal folgendes:
                                          06:29:58.055	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: > Decode Filters
                                          06:29:58.056	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Filter named 'Standard' has ID : filtprof1
                                          06:29:58.057	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Filter named 'Gast' has ID : filtprof2
                                          06:29:58.057	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Filter named 'Unbeschränkt' has ID : filtprof3
                                          06:29:58.057	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Filter named 'Gesperrt' has ID : filtprof4
                                          

                                          Und dann noch sowas:

                                          06:30:01.191	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Device named 'Comp-L-Acer-L' has ID : user2482
                                          06:30:01.191	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Device named 'Comp-L-Pi' has ID : landevice37174
                                          06:30:01.192	info	javascript.0 (20276) script.js.Fritzbox.CurlTestFB: Device named 'Comp-M-Tablet-W' has ID : landevice2671
                                          

                                          Wenn das gelistet wird dann funktioniert def. schon mal der Zugriff auf die FB. Wenn nicht ... Nun dann müssen wir mal guggn :-)

                                          • Was wir jetzt brauchen ist erstmal das Gerät was wir einstellen wollen. Ihr nehmt also aus der Device Liste die ID.
                                            Beispiel:
                                            Device named 'Comp-L-Acer-L' has ID : user2482
                                            Wir brauchen den Namen und NICHT die ID!! Also kopieren wir uns Comp-L-Acer-L als Beispiel.
                                            Diesen Namen kopieren wir im Script hinter FbDevice.
                                          • Jetzt brauchen wir noch den Filter. Auch die wurden ja im ersten Lauf gelistet.
                                            Beispiel:
                                            Filter named 'Gesperrt' has ID : filtprof4
                                            Wir brauchen die ID und NICHT den Namen. Wir kopieren uns also filtprof4 als Beispiel.
                                            Diese ID tragen wir dann bei FbProfile ein.
                                            Anmerkung ... Ok das könnte man noch auf den Namen umstellen merke ich gerade :-)
                                          • FbListOnly jetzt auf false setzen.
                                          • Jetzt kommt der Teil wo die Kuh ins Gras beisst :-) Wir lassen das Script laufen.
                                            Und wenn nicht alles daneben geht, dann ändert sich wie von Zauberhand der Filter für den entsprechenden Rechner.
                                            Und in meinem Fall gingen 2 Jahre Lösungssuche für dieses Problem zu Ende ....

                                          Hinweise
                                          Mir ist bewusst das man an dem Script noch einiges verbessern könnte. Und ich würde es demnächst auch in github einstellen inkl. Anleitung.
                                          Man könnte es auch in einen Adapter überführen. Aber erstmal wäre gut zu wissen ob es bei anderen auch klappt ...
                                          Wenn man das Script mit der VIS verheiraten will, dann muss man da noch etwas dran umbauen. Da braucht es dann 2-3 Datenpunkte.
                                          Aber ein riesen Drama sollte das nicht sein ...

                                          Ok jetzt bin ich gespannt auf das Feedback :-)

                                          Bis dahin ...

                                          amg_666A Offline
                                          amg_666A Offline
                                          amg_666
                                          schrieb am zuletzt editiert von
                                          #123

                                          @moelski Cool, bin da grade drauf gestoßen und hab nach deiner Anleitung mal mit static und FbListOnly=True gestartet. Das dauert schon ein bisschen bis die Infos im Log kommen aber es lief ohne Probleme durch. Werd ich am Wochenende mal weiter verproben.

                                          Mein Usecase :-) :
                                          Kinder hab ich zwar aber Kindersicherung tricksen die mir eh aus (beide >=15, da kann man nix mehr machen)...
                                          Aaaber: Ich hab diverse geflashte Sonoffs im Einsatz auch Shelly (die ersten beiden geflasht, der Rest mit Shelly FW) plus Kameras etc. ALLE Geräte sind in der FB vom Internet getrennt (die haben bei mir feste IPs und in der FB das Zugangsprofil "gesperrt") Datum/Uhrzeit kriegen sie von der FB. Das läuft auch soweit alles gut bis auf die Shellys mit original FW, die können sich kein Update ziehen. Wenn ich dran denke schalte ich die in der FB sporadisch auf Zugangsprofil "Standard" und dann nach einem Shelly-Update wieder auf gesperrt. Und da werde ich mich mal dransetzen das zu automatisieren.

                                          Von daher: Tolle Arbeit, danke!!!

                                          iobroker auf proxmox container

                                          1 Antwort Letzte Antwort
                                          0
                                          Antworten
                                          • In einem neuen Thema antworten
                                          Anmelden zum Antworten
                                          • Älteste zuerst
                                          • Neuste zuerst
                                          • Meiste Stimmen


                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          680

                                          Online

                                          32.4k

                                          Benutzer

                                          81.5k

                                          Themen

                                          1.3m

                                          Beiträge
                                          Community
                                          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
                                          ioBroker Community 2014-2025
                                          logo
                                          • Anmelden

                                          • Du hast noch kein Konto? Registrieren

                                          • Anmelden oder registrieren, um zu suchen
                                          • Erster Beitrag
                                            Letzter Beitrag
                                          0
                                          • Home
                                          • Aktuell
                                          • Tags
                                          • Ungelesen 0
                                          • Kategorien
                                          • Unreplied
                                          • Beliebt
                                          • GitHub
                                          • Docu
                                          • Hilfe