Code: Select all
wget -O - --no-check-certificate --header "Authorization: Basic $authStr" 'https://${Server}/json.htm?type=command¶m=switchlight&idx=30&switchcmd=Off'
Code: Select all
HTTP request sent, awaiting response... 200 OK
Length: 51 [application/json]
Saving to: ‘STDOUT’
{
"status" : "OK",
"title" : "SwitchLight"
}
Code: Select all
function get_json($url) {
global $JSON_User,$JSON_Password,$JSON_Base;
$service_url = "${JSON_Base}?$url";
$curl = curl_init($service_url);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "$JSON_User:$JSON_Password");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FAILONERROR,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
$curl_response = curl_exec($curl);
if (!$curl_response) {
$response['status']='Err';
$response['message']="JSON get failed: ".curl_error($curl);
} else {
$response = json_decode($curl_response);
}
curl_close($curl);
return $response;
} # get_json
Code: Select all
{"message":"Error sending switch command, check device\/hardware !","status":"ERROR","title":"SwitchLight"}
In both cases I get the following showing in /var/log/domoticz.log
Code: Select all
User: JSONRemote initiated a switch command (30/DM1_Gary/off)