NEWS


  • Hallo,

    in diesem Beitrag https://forum.iobroker.net/topic/9808/status-einlesen-und-in-einzelne-variablen-zerlegen ist dieses Script:

    var alwx, carx, etox, etoxd, nrg, nrg_7x, nrg_8x, nrg_9x, nrg_11x, dwsx, ampx, apiurl = "http://192.168.1.15/status"
    // Trigger 1 min
    schedule("*/1 * * * *", function () {
      try {
         require("request")('http://192.168.1.15/status', function (error, response, result) {
           setState("javascript.0.GoE_Charger.Objekt", result, true);
           }).on("error", function (e) {console.error(e);});
       } catch (e) { console.error(e); }  
    
      data = (function () { 
          try {
              return JSON.parse(getState("javascript.0.GoE_Charger.Objekt").val)
          ;} 
          catch(e) {
              return {};
          }
        })();
    
    var alwx = parseInt(data["alw"]);
    setState("javascript.0.GoE_Charger.alw_0", alwx, true);
    
    var ampx = parseInt(data["amp"]);
    setState("javascript.0.GoE_Charger.amp_0", ampx, true);
    
    var dwsx = parseInt(data["dws"]);
    setState("javascript.0.GoE_Charger.dws_0", dwsx/360000, true);
    
    var carx = parseInt(data["car"]);
    setState("javascript.0.GoE_Charger.LadeStatus", carx, true);
    
    var etoxd = parseInt(data["eto"]);
    //Umrechnung in 1kWh
    var etox = etoxd / 100 / 60 / 60;
    setState("javascript.0.GoE_Charger.eto_0", etox, true);
    
    var nrg = data["nrg"];
    //console.log(nrg);
    
    var nrg_7x = parseInt(nrg[7]);
    //Umrechnung in 1kW
    setState("javascript.0.GoE_Charger.nrg_7", nrg_7x/10, true);
    
    var nrg_8x = parseInt(nrg[8]);
    //Umrechnung in 1kW
    setState("javascript.0.GoE_Charger.nrg_8", nrg_8x/10, true);
    
    var nrg_9x = parseInt(nrg[9]);
    //Umrechnung in 1kW
    setState("javascript.0.GoE_Charger.nrg_9", nrg_9x/10, true);
    
    var nrg_11x = parseInt(nrg[11]);
    //Umrechnung in 1kW
    setState("javascript.0.GoE_Charger.nrg_11", nrg_11x/100, true);
    });
    

    Allerdings bekomme ich Fehlermeldungen und der erste Teil schägt schon fehl, wo das Script das Json aus der API in einen Datenpunkt schreiben soll. Der Datenpunkt vom Typ Objekt ist aber leer.

    Kann mir dabei jemand helfen?

    Von der Api kommt das hier:

    {"version":"B","tme":"1106201029","rbc":"11","rbt":"51739065","car":"4","amp":"8","err":"0","ast":"0","alw":"0","stp":"0","cbl":"32","pha":"56","tmp":"22","tma":[23.75,23.38,23.75,23.50],"amt":"32","dws":"14137","dwo":"0","adi":"0","uby":"0","eto":"20","wst":"3","txi":"0","nrg":[218,216,217,1,0,0,0,0,0,0,0,0,0,0,0,0],"fwv":"033","sse":"010958","wss":"WLAN-3E6435","wke":"************","wen":"1","cdi":"0","tof":"101","tds":"1","lbr":"50","aho":"3","afi":"7","azo":"0","ama":"32","al1":"6","al2":"8","al3":"10","al4":"12","al5":"14","cid":"255","cch":"65535","cfi":"65280","lse":"0","ust":"1","wak":"92da1ad9d0","r1x":"0","dto":"0","nmo":"0","sch":"AAAAAAAAAAAAAAAA","sdp":"0","eca":"0","ecr":"0","ecd":"0","ec4":"0","ec5":"0","ec6":"0","ec7":"0","ec8":"0","ec9":"0","ec1":"0","rca":"B91720B5","rcr":"","rcd":"","rc4":"","rc5":"","rc6":"","rc7":"","rc8":"","rc9":"","rc1":"","rna":"","rnm":"","rne":"","rn4":"","rn5":"","rn6":"","rn7":"","rn8":"","rn9":"","rn1":"","loe":0,"lot":0,"lom":0,"lop":0,"log":"","lon":0,"lof":0,"loa":0,"lch":50507,"mce":0,"mcs":"test.mosquitto.org","mcp":1883,"mcu":"","mck":"","mcc":0}                                                
    

    Fehlermedung ist das:

    Danke und viele Grüße
    Marcel

  • Starter

    @Jautze sagte in Json in Datenpunkt funktioiert nicht:

    getState("javascript.0.GoE_Charger.Objekt").val

    Ist der DP überhaupt angelegt, da es kein CreateState in dem Script gibt und die Fehlermeldung besagt, dass er den Wert nicht finden kann?
    Wenn man in den Objekten schaut:
    javascript.0
    --- GoE_Charger.
    ------ Objekt

    Ist diese Struktur da?

Suggested Topics

  • 1
  • 8
  • 5
  • 10
  • 17
  • 8
  • 11
  • 7

2.6k
Online

35.1k
Users

41.0k
Topics

564.4k
Posts