ph_huerawcmd PowerHome formula function
Description
Sends raw command directly to a Philips
Hue bridge
Syntax
ph_huerawcmd ( as_ctlr, as_method, as_command, as_data, ai_rettype )
Argument | Description |
as_ctlr | String. The controller ID of the Hue Bridge
you wish to send commands to |
as_method | String. The HTTP method to use. Valid values
are "GET", "PUT", "POST", and "DELETE". See the Hue API for more details on these methods |
as_command | String. The raw Hue command you wish to send |
as_data | String. Additional data that may be required
for the specific command |
ai_rettype | Integer. Specifies how the return data should be formatted |
Return value
String. Returns the resultant HTTP
data from the raw command request based
upon the ai_rettype
Usage
Use this function to easily format and send
commands to a Philips Hue bridge controller that is defined and active
within PowerHome. This function ultimately uses the ph_httprequest function with
a timeout of 5000 and uses the C# HttpWebRequest object ignoring SSL certificate
errors. This function will automatically format the HTTP request using the IP
and username defined in the Hue controller ID specified in the
as_ctlr parameter.
Valid values for the ai_rettype parameter are:
0 - Return the raw JSON data unformatted
1 - Flattens the JSON data using the ph_flattenjson( ) function with an ai_type parameter of 0
2 - Flattens the JSON data using the ph_flattenjson( ) function with an ai_type parameter of 1
3 - Flattens the JSON data using the ph_flattenjson( )
function with an ai_type parameter of 2
Examples
The following examples demonstrate typical syntax/usage for this function.
• ph_huerawcmd("HUE","GET","/lights","",2) - This
example will construct an HTTP request using the IP and username defined in
the PowerHome HUE controller that looks like this: "https://<ip>/api/<username>/lights".
Assuming the command works, the example will return flattened JSON
containing all of the lights currently defined in the specified HUE
controller.