Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. JSON Post

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    JSON Post

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

      Hallo zusammen

      Ich bin gerade dabei meine komplette Videodatenbank zu HEVC zu konvertieren.
      Hierfür verwende ich ein Tool namens Tdarr.

      Gerne würde ich es so einrichten, dass die Codierung jeweils beginnt, wenn ich das Haus verlasse oder schlafen gehe.
      Leider komme ich aktuell nur mit Blockly zurecht und habe noch so meine Probleme mit Javascript.

      Könntet ihr mir hier bitte auf die Sprünge helfen, was ich genau im Script falsch gemacht habe?

      Laut Manual müsste ich folgendes per JSON an die angegebene URL Senden:

      http://192.168.1.214:8102/api/v2/alter-worker-limit
      
        "data": {
          "nodeID": "local",
          "process": "increase",
          "workerType": "transcodecpu"
        }
      

      Mein Code:

      on({id: "javascript.0.Devices.Tdarr.Worker", change: 'any'}, function (obj) {
      
      
      var request = require('request');
       
          var options = {
          url: 'http://192.168.1.214:8102/api/v2/alter-worker-limit',
          method: 'POST',
          form:myObj 
      };
       
      request(options,function (error, response, body){
       
        "data": {
          "nodeID": "local",
          "process": "increase",
          "workerType": "transcodecpu"
        }
       
      });
      
      );
      

      Fehlermeldung:
      Screenshot_15.jpg

      E 1 Reply Last reply Reply Quote 0
      • E
        ente34 @wizzardking last edited by ente34

        @wizzardking
        Nicht gerade mein Spezialgebiet, aber versuche es mal so.
        Eventuell form durch data ersetzen
        (Warnung: Im Trigger wertest Du obj nicht aus)

        
        var request = require('request');
        
        on({id: "javascript.0.Devices.Tdarr.Worker", change: 'any'}, function (obj) {
         
            const myObj = {
                "nodeID": "local",
                "process": "increase",
                "workerType": "transcodecpu"
            };
            
            const options = {
                url: 'http://192.168.1.214:8102/api/v2/alter-worker-limit',
                method: 'POST',
                form:myObj 
            };
            
            request(options,function (error, response, body){
                error && console.log('error:'+error);
                response && console.log('response:'+response);
                body && console.log('body:'+body);
            
            });
        
        });
        
        
        OliverIO 1 Reply Last reply Reply Quote 0
        • OliverIO
          OliverIO @ente34 last edited by

          @ente34 sagte in JSON Post:

          
          var request = require('request');
          
          on({id: "javascript.0.Devices.Tdarr.Worker", change: 'any'}, function (obj) {
           
              const myObj = {
                  "nodeID": "local",
                  "process": "increase",
                  "workerType": "transcodecpu"
              };
              
              const options = {
                  url: 'http://192.168.1.214:8102/api/v2/alter-worker-limit',
                  method: 'POST',
                  body:myObj,
                  json:true 
              };
              
              request(options,function (error, response, body){
                  error && console.log('error:'+error);
                  response && console.log('response:'+response);
                  body && console.log('body:'+body);
              
              });
          
          });
          
          

          Rtfm
          Gemäß der doku muss es body und json heißen.
          Hab den Code angepasst
          https://github.com/request/request#requestoptions-callback

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

          Support us

          ioBroker
          Community Adapters
          Donate

          470
          Online

          31.8k
          Users

          80.0k
          Topics

          1.3m
          Posts

          3
          3
          184
          Loading More Posts
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes
          Reply
          • Reply as topic
          Log in to reply
          Community
          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
          The ioBroker Community 2014-2023
          logo