I know I can get a sensors value via:

http://192.168.1.13/api/getsensordetails.json?id=2247&username=xxx&passhash=xxx

but I can't figure out how to get the channel values?

Any help would be great!

Thanks


Article Comments

Hi,

in order to get the channel data, use the following API call: http://192.168.1.13/api/table.json?content=channels&output=json&columns=name,lastvalue_&id=2247

The result will look like this:

{  
   "prtg-version":"15.4.21.5636",
   "treesize":0,
   "channels":[  
      {  
         "name":"Available Memory",
         "lastvalue":"8.325 MByte",
         "lastvalue_raw":87297228800.0000
      },
      {  
         "name":"Downtime",
         "lastvalue":""
      },
      {  
         "name":"Percent Available Memory",
         "lastvalue":"51 %",
         "lastvalue_raw":500.9934
      },
      {  
         "name":"Total Memory",
         "lastvalue":"16.326 MByte",
         "lastvalue_raw":171193139200.0000
      }
   ]
}

Jan, 2016 - Permalink

That sort of worked, but I'm getting funny raw values:

{ prtg-version: "15.4.21.5215", treesize: 0, channels: [ { name: "Downtime", lastvalue: "" }, { name: "Humidity", lastvalue: "93.4 %", lastvalue_raw: 930.4 }, { name: "Light", lastvalue: "82 %", lastvalue_raw: 820 }, { name: "Reservoir", lastvalue: "Reservoir Level OK", lastvalue_raw: 1 }, { name: "Temperature", lastvalue: "5.6 °C", lastvalue_raw: 50.6 } ] }

Why is the temperature 5.6 getting a raw value of 50.6?


Jan, 2016 - Permalink

Not sure why, dividing them by 10 gets you the correct values anyway :)


Jan, 2016 - Permalink

Unfortunately it's not that simple. I need to do a string replace on "0." and replace it with ".". Dividing by 10 would make the units wrong by10.


Jan, 2016 - Permalink

Ah, you're right, but your solution should work fine :)


Jan, 2016 - Permalink