HTTP Device - URL to get value (JSON parse)
Posted: 21 Jun 2015 16:19
Hi gents,
I'm trying to use the "HTTP Device" app to control a remote device using GET and JSON.
I can easily turn the remote device On or Off by using the following URLs.
On: http://IP_ADDRESS/JSON?request=controldevicebyvalue&ref=58&value=255
Off: http://IP_ADDRESS/JSON?request=controldevicebyvalue&ref=58&value=0
But when it comes to the "URL to get value" option I'm having difficulties to parse the correct value from the url to the HTTP Device.
The URL I use for getting the device value is this : http://IP_ADDRESS/JSON?request=getstatus&ref=58
that gives me this information:
The information I want to parse is the ""value": 0" field so when the value is 0 the light is off, when it is 255 the light is on. Can anyone show me the correct way of doing this using javascript.
My next question will be on how to do the dimming devices (switchMultilevel), but first things first.
Thanks
I'm trying to use the "HTTP Device" app to control a remote device using GET and JSON.
I can easily turn the remote device On or Off by using the following URLs.
On: http://IP_ADDRESS/JSON?request=controldevicebyvalue&ref=58&value=255
Off: http://IP_ADDRESS/JSON?request=controldevicebyvalue&ref=58&value=0
But when it comes to the "URL to get value" option I'm having difficulties to parse the correct value from the url to the HTTP Device.
The URL I use for getting the device value is this : http://IP_ADDRESS/JSON?request=getstatus&ref=58
that gives me this information:
Code: Select all
// 20150621151221
// http://IP_ADDRESS/JSON?request=getstatus&ref=58
{
"Name": "HomeSeer Devices",
"Version": "1.0",
"Devices": [
{
"ref": 58,
"name": "Spotlights",
"location": "TV Stue",
"location2": "Lys",
"value": 0,
"status": "Off",
"device_type_string": "Z-Wave Switch Multilevel",
"last_change": "/Date(1434841201998)/",
"relationship": 3,
"hide_from_view": false,
"associated_devices": [
],
"device_type": {
"Device_API": 4,
"Device_API_Description": "Plug-In API",
"Device_Type": 999,
"Device_Type_Description": "Plug-In Root Device",
"Device_SubType": 17,
"Device_SubType_Description": ""
},
"device_image": ""
}
]
}
My next question will be on how to do the dimming devices (switchMultilevel), but first things first.

Thanks