I am trying to monitor the available storage on an AJA Ki pro and this is what i can do

by using this http request: http://device_ip/values?eParamID_CurrentMediaAvailable

i get this in response: var param_val = { name:"Media Available", value:"73" };

This works in a web browser.

Any way i can use that response i am getting and pull the number from the value and setup a channel?


Article Comments

Hi,
are you getting back pure JSON e.g.

{ name:"Media Available", value:"73" }

or are you getting back the full line

var param_val = { name:"Media Available", value:"73" };

?


Feb, 2015 - Permalink

I am getting back the full line. I have been trying different sensor and getting error messages with "The format of the URI could not be determined."

Was able to get the data in a different format:

[ {value:"78", text:"78", selected: "true"} ];

Not sure if that's any easier. Thanks for your help!


Feb, 2015 - Permalink

The second data format would be quite easier to handle. But as it is still not native JSON, a custom sensor might be necessary. Please check the below code, which should work out pf the box (only with given example):

param(
    [string]$url="http://127.0.0.1"
)
$page = $(Invoke-WebRequest "https://10.0.2.140/public/test_cust.htm")
$JSON = $page.Trim(";", " ") | ConvertFrom-Json
Write-Host ("{0}:Value" -f $JSON.value)
Exit 0

The script takes the parameter -url "YOUR_URL" which can be provided in the section Parameters on tab Settings of the EXE/Script Sensor.
Above Script is written in Powershell, the script file has to be named accordingly, e.g. SCRIPT.ps1 and the execution policy of the powershell has to vbe set to unrestricted or remote-signed.


Feb, 2015 - Permalink