Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • 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

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. JavaScript
  5. Javascript für CURL Aufruf

NEWS

  • Weihnachtsangebot 2025! 🎄
    BluefoxB
    Bluefox
    21
    1
    949

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

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    14
    1
    2.4k

Javascript für CURL Aufruf

Scheduled Pinned Locked Moved JavaScript
6 Posts 2 Posters 930 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • cashC Offline
    cashC Offline
    cash
    Most Active
    wrote on last edited by cash
    #1

    Ich bräuchte da mal etwas Hilfe. Ich bekomme Morgen eine Elgato Key Ligtht Air. Das ist eine Videoleuchte die per WLAN im Netz hängt. Ich will das Licht für die Beleuchtung meines Schreibtisches nutzen und falls nötig auch mal als Videolicht.

    Ich habe im Netz gefunden, dass man das Licht über eine Rest Api steuern kann. Dort gibt es eine Anleitung damit man das ganze in die Touchbar vom Mac bekommt. Ich möchte das natürlich über ioBroker steuern.
    Das Licht soll dann Morgens bei Arbeitsbeginn automatisch angehen.

    Für die besagte Anleitung Anleitung soll man eine Datei erstellen elgato-on.sh
    Inhalt:

    #!/bin/bash
    curl --location --request PUT 'http://<your lights ip>:9123/elgato/lights' \
    --header 'Content-Type: application/json' \
    --data-raw '{"lights":[{"brightness":10,"temperature":162,"on":1}],"numberOfLights":1}'
    

    Daraus will ich ein Javascript basteln. Nur weiß ich leider nicht wie. Ich habe so etwas ähnliches für eine Foscam

    **************************
    * Schaltet die Elgato Key Light Air 
    *
    * 29.01.21 V1.00    Erste Version
    
    **************************/
    var logging = true;
    var URL;
    
    function func_Elagto_an(){
        
            URL = "http://192.168.178.230:9123/elgato/lights";
           
            request.get(URL).on('error', function(error){
                if(error){
                    log(error, 'error');
                }
            });
            
            if(logging){       
                log('Elgato Key Light Air wurde eingeschaltet.');
            }
           
    
    
    }
    

    Wie bekommt man den Header bzw data-raw in die url übergeben?

    Alternativ habe ich noch diese Hinweise gefunden:

    After doing some exploration, I discovered that the Key Light Air devices actually have a web server built in, exposing a REST API.

    Key Light Air has an HTTP listener on TCP 9123
    An HTTP API is available at /elgato/lights
    The “lights” API accepts a payload (body) with several parameters

    Here’s an example of what the JSON payload looks like for controlling the Elgato Key Light Air.

    {
      "Lights": [
        {
          "Temperature": 344,
          "Brightness": 100,
          "On": 1
        }
      ],
      "NumberOfLights": 1
    }
    

    Through some trial and error, I discovered that:

    Brightness can only be set to a value between 3 and 100
    The color temperature field can be 143 (7000K) to 344 (2900K)

    On is either 0 or 1, depending on whether you want to switch the light on or off

    Würde mich freuen wenn mir jemand helfen kann.

    Grüße

    cashC 1 Reply Last reply
    0
    • cashC cash

      Ich bräuchte da mal etwas Hilfe. Ich bekomme Morgen eine Elgato Key Ligtht Air. Das ist eine Videoleuchte die per WLAN im Netz hängt. Ich will das Licht für die Beleuchtung meines Schreibtisches nutzen und falls nötig auch mal als Videolicht.

      Ich habe im Netz gefunden, dass man das Licht über eine Rest Api steuern kann. Dort gibt es eine Anleitung damit man das ganze in die Touchbar vom Mac bekommt. Ich möchte das natürlich über ioBroker steuern.
      Das Licht soll dann Morgens bei Arbeitsbeginn automatisch angehen.

      Für die besagte Anleitung Anleitung soll man eine Datei erstellen elgato-on.sh
      Inhalt:

      #!/bin/bash
      curl --location --request PUT 'http://<your lights ip>:9123/elgato/lights' \
      --header 'Content-Type: application/json' \
      --data-raw '{"lights":[{"brightness":10,"temperature":162,"on":1}],"numberOfLights":1}'
      

      Daraus will ich ein Javascript basteln. Nur weiß ich leider nicht wie. Ich habe so etwas ähnliches für eine Foscam

      **************************
      * Schaltet die Elgato Key Light Air 
      *
      * 29.01.21 V1.00    Erste Version
      
      **************************/
      var logging = true;
      var URL;
      
      function func_Elagto_an(){
          
              URL = "http://192.168.178.230:9123/elgato/lights";
             
              request.get(URL).on('error', function(error){
                  if(error){
                      log(error, 'error');
                  }
              });
              
              if(logging){       
                  log('Elgato Key Light Air wurde eingeschaltet.');
              }
             
      
      
      }
      

      Wie bekommt man den Header bzw data-raw in die url übergeben?

      Alternativ habe ich noch diese Hinweise gefunden:

      After doing some exploration, I discovered that the Key Light Air devices actually have a web server built in, exposing a REST API.

      Key Light Air has an HTTP listener on TCP 9123
      An HTTP API is available at /elgato/lights
      The “lights” API accepts a payload (body) with several parameters

      Here’s an example of what the JSON payload looks like for controlling the Elgato Key Light Air.

      {
        "Lights": [
          {
            "Temperature": 344,
            "Brightness": 100,
            "On": 1
          }
        ],
        "NumberOfLights": 1
      }
      

      Through some trial and error, I discovered that:

      Brightness can only be set to a value between 3 and 100
      The color temperature field can be 143 (7000K) to 344 (2900K)

      On is either 0 or 1, depending on whether you want to switch the light on or off

      Würde mich freuen wenn mir jemand helfen kann.

      Grüße

      cashC Offline
      cashC Offline
      cash
      Most Active
      wrote on last edited by
      #2

      So Lampe ist heute gekommen. Was ich bisher geschafft habe:

      function func_Elagto_an(){
          
              URL = "http://192.168.178.75:9123/elgato/lights";
             
          request({url : URL},
              function (error, response, body) {
                  
                  
                  if(error){
                      log('error: ' + error);
                  } else {
                  const Inhalt = body.split(",");
                  const on = Inhalt[1].split(":") 
                  const brightness = Inhalt[2].split(":")    
                  const temperature = Inhalt[3].split(":")   
                   
                  log(typeof(temperature[1]));
                  log('ON: ' +on[2]);
                  log('Brightness: ' +brightness[1]);
                  log('Temperatur: ' +temperature[1]);
                      
                          log('body: ' + body);
                          
                          //log('response: ' + JSON.stringify(response));
                      
                  }
              }
          );
              
             
      
      
      }
      

      Als Log kommt

      javascript.2	2021-01-30 15:47:42.057	info	(787) script.js.Büro.Videolicht: Temperatur: 186}]}
      javascript.2	2021-01-30 15:47:42.057	info	(787) script.js.Büro.Videolicht: Brightness: 63
      javascript.2	2021-01-30 15:47:42.056	info	(787) script.js.Büro.Videolicht: ON: 0
      javascript.2	2021-01-30 15:47:42.056	info	(787) script.js.Büro.Videolicht: string
      

      Jetzt muss ich nur noch irgendwie nicht nur die Antwort empfangen sondern auch etwas senden.

      cashC 1 Reply Last reply
      0
      • cashC cash

        So Lampe ist heute gekommen. Was ich bisher geschafft habe:

        function func_Elagto_an(){
            
                URL = "http://192.168.178.75:9123/elgato/lights";
               
            request({url : URL},
                function (error, response, body) {
                    
                    
                    if(error){
                        log('error: ' + error);
                    } else {
                    const Inhalt = body.split(",");
                    const on = Inhalt[1].split(":") 
                    const brightness = Inhalt[2].split(":")    
                    const temperature = Inhalt[3].split(":")   
                     
                    log(typeof(temperature[1]));
                    log('ON: ' +on[2]);
                    log('Brightness: ' +brightness[1]);
                    log('Temperatur: ' +temperature[1]);
                        
                            log('body: ' + body);
                            
                            //log('response: ' + JSON.stringify(response));
                        
                    }
                }
            );
                
               
        
        
        }
        

        Als Log kommt

        javascript.2	2021-01-30 15:47:42.057	info	(787) script.js.Büro.Videolicht: Temperatur: 186}]}
        javascript.2	2021-01-30 15:47:42.057	info	(787) script.js.Büro.Videolicht: Brightness: 63
        javascript.2	2021-01-30 15:47:42.056	info	(787) script.js.Büro.Videolicht: ON: 0
        javascript.2	2021-01-30 15:47:42.056	info	(787) script.js.Büro.Videolicht: string
        

        Jetzt muss ich nur noch irgendwie nicht nur die Antwort empfangen sondern auch etwas senden.

        cashC Offline
        cashC Offline
        cash
        Most Active
        wrote on last edited by
        #3

        Quick & Dirty habe ich es jetzt hinbekommen. Ich habe die sh Datei ins ioBroker Verzeichnis kopiert

        function func_elgato_on(){
            exec('bash elgato_on.sh');
            
          
        }
        

        Gefällt mir zwar irgendwie nicht so gut aber für den Anfang reicht es. Falls hier noch jemand eine Lösung für mich hat würde ich mich freuen

        E 1 Reply Last reply
        0
        • cashC cash

          Quick & Dirty habe ich es jetzt hinbekommen. Ich habe die sh Datei ins ioBroker Verzeichnis kopiert

          function func_elgato_on(){
              exec('bash elgato_on.sh');
              
            
          }
          

          Gefällt mir zwar irgendwie nicht so gut aber für den Anfang reicht es. Falls hier noch jemand eine Lösung für mich hat würde ich mich freuen

          E Offline
          E Offline
          Eric
          wrote on last edited by
          #4

          @cash Wärest Du so nett den Inhalt Deiner sh Datei zu teilen? Das wäre großartig.

          cashC 1 Reply Last reply
          0
          • E Eric

            @cash Wärest Du so nett den Inhalt Deiner sh Datei zu teilen? Das wäre großartig.

            cashC Offline
            cashC Offline
            cash
            Most Active
            wrote on last edited by
            #5

            @eric ??? Den Inhalt der sh-Datei habe ich im ersten Post erwähnt. Mittlerweile erledige ich das ganze aber komplett über Javascript mit axios. Dazu habe ich hier auch einen Thread eröffnet ebenfalls mit dem fertigen Javascript zum steuern.

            E 1 Reply Last reply
            0
            • cashC cash

              @eric ??? Den Inhalt der sh-Datei habe ich im ersten Post erwähnt. Mittlerweile erledige ich das ganze aber komplett über Javascript mit axios. Dazu habe ich hier auch einen Thread eröffnet ebenfalls mit dem fertigen Javascript zum steuern.

              E Offline
              E Offline
              Eric
              wrote on last edited by
              #6

              @cash Danke vielmals! Hatte es in der Tat übersehen. Sorry. Ich schaue mir auch Deinen anderen Thread an und gebe Bescheid falls ich auch noch etwas beitragen kann :-)

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              Support us

              ioBroker
              Community Adapters
              Donate

              346

              Online

              32.5k

              Users

              81.6k

              Topics

              1.3m

              Posts
              Community
              Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
              ioBroker Community 2014-2025
              logo
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Home
              • Recent
              • Tags
              • Unread 0
              • Categories
              • Unreplied
              • Popular
              • GitHub
              • Docu
              • Hilfe