Been trying to find online documentation that allows me to only update switch is its actually Off if its On and switch it On if its Off rather then update it every minute regardless of state.
Code: Select all
#!/usr/bin/php
<?php
$ctx = stream_context_create(array('http'=>array('timeout' => 3,)));
$domoticzurl='http://127.0.0.1:8080/';
$denon_address = 'http://192.168.1.12';
$time=$_SERVER['REQUEST_TIME'];
function Schakel($idx,$cmd) {
global $domoticzurl;
$reply=json_decode(file_get_contents($domoticzurl.'json.htm?type=command¶m=switchlight&idx='.$idx.'&switchcmd='.$cmd.'&level=0&passcode='),true);
if($reply['status']=='OK') $reply='OK';else $reply='ERROR';
return $reply;
}
$denonmain=json_decode(json_encode(simplexml_load_string(file_get_contents($denon_address.'/goform/formMainZone_MainZoneXml.xml?_='.$time,false,$ctx))),TRUE);
if($denonmain['ZonePower']['value']=='ON') Schakel(216,'On');
else Schakel(216,'Off');