Suppose you want to get the status of a particular HomeSeer device. Below is the URI to request the status:
http:// HOMESEER-IP-ADDRESS/JSON?request=getstatus&ref=349
"349" above is the HomeSeer reference ID of the device. Of course, your actual device's reference number will be different.
So, above URL will return a structure similar to:
{
"Name": "HomeSeer Devices",
"Version": "1.0",
"Devices": [
{
"ref": 349,
"name": "Alert - Sensor Color",
"location": "Virtual",
"location2": "Alerts",
"value": 0,
"status": "Off",
"device_type_string": "",
"last_change": "/Date(1599661839059-0400)/",
"relationship": 0,
"hide_from_view": false,
"associated_devices": [],
"device_type": {
"Device_API": 0,
"Device_API_Description": "No API",
"Device_Type": 0,
"Device_Type_Description": "Type 0",
"Device_SubType": 0,
"Device_SubType_Description": ""
},
"device_type_values": null,
"UserNote": "",
"UserAccess": "Any",
"status_image": "images/HomeSeer/contemporary/off.gif",
"voice_command": "",
"misc": 4368,
"interface_name": ""
}
]
}
What you care about is the Devices[0].value above.
Your Javascript would be similar to the pseudo-code below. At this time, I don't have access to the PC that I use for my Pronto, so the code below hasn't been tested, but should be close enough to get you going:
var HomeSeer = {};
HomeSeer.IP = "x.x.x.x"; // assign HomeSeer IP here
// Below example assumes that HomeSeer is
// configured to not require user/password when
// request coming from local LAN:
HomeSeer.msgPrefix = "http://" + HomeSeer.IP + "/JSON?request=";
...
# ref is the HomeSeer Ref # of the device.
function getStatus(ref)
{
var msg = "", msgSuffix = "";
msgSuffix = "getstatus&ref=" + ref;
msg = HomeSeer.msgPrefix + msgSuffix;
com.philips.HttpLibrary.getHTTP(msg, processResponse);
}
// This is the callback
function processResponse(rcvd)
{
var jsonObj = JSON.parse(rcvd);
var status = jsonObj.Devices[0].value;
}
Once you have the device's status in the status variable, you can then do what you need with status, such as what Lyndel had suggested earlier:
GUI.widget("MyLabel").label = status;