So hab das Skript, so angepasst das ich das ab Zeile 60 auskommentiert habe:
<?php
/*
switch a Fritz AHA Device (Fritz Powerline 546E, Fritz Dect200) from IPSymcon
http://www.tdressler.net/ipsymcon
V2.2 16.01.2016
see also
http://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AVM_Technical_Note_-_Session_ID.pdf
http://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AHA-HTTP-Interface.pdf
*/
if (!function_exists('mb_convert_encoding')) {
IPS_LogMessage ("FritzAHA Switch","Error:Need mbstring_extension!
");
return;
}
if (!function_exists('simplexml_load_string')) {
IPS_LogMessage("FritzAHA Switch","Error:Need SimpleXML functions(simplexml_load_string)!
");
return;
}
/* config section, pls adopt this for your device
credential array array('<1.host/ip>' =>array('user'=>'<login name1>','password'=>'<secret>')
,'<2.host/ip>' =>array('user'=>'<login name2>','password'=>'<secret2>')
,..
);
if no login name is needed/applicable, set the name to an empty string ('')!
*/
$logins=array('172.16.1.2'=>array('user'=>'','password'=>'start') //sample entry for fritzbox
/* ,'192.168.170.211'=>array('user'=>'','password'=>'xyz123') //sample entry for another host,maybe fritz546 */
);
$id=31887 /*[FRITZ Smarthome\ TV Beleuchtung\Status]*/; //test variable for execute
/* end config section */
//check caller
$sender=$_IPS['SENDER'];
switch ($sender) {
case "WebFront":
$me=$_IPS['VARIABLE'];
$val=$_IPS['VALUE'];
SetValue($me, $val); //doing will be done by variable change
return;
break; //not reached
case "Variable":
$me=$_IPS['VARIABLE'];
$val=$_IPS['VALUE'];
break;
case "Execute":
$me=$id;
$val=@GetValue($me);
break;
default:
IPS_LogMessage("FritzAHA Switch", "Error: unknown Sender '$sender'");
return;
}
$state=$val;
IPS_LogMessage("FritzAHA Switch","Switch ID ".$me." to ".($state?'ON':'OFF'));
/*
//check varable is right
$name='fritz_aha_reader';
if ($name != "Switch Status") {
IPS_LogMessage("FritzAHA Switch","Error: Action from wrong variable ".$_IPS['VARIABLE']);
return;
}
//get parameter from IPS
$parent=IPS_GetParent($me);
$host=getVarValue('Device Host',$parent);
$ain=getVarValue('Device AIN',$parent);
//checks
if (!$host || !$ain) {
IPS_LogMessage("FritzAHA Switch","Error: Parameter host($host) or AIN($ain) missed");
return;
}
//get password using ID host
$username=$logins[$host]['user'];
$password=$logins[$host]['password'];
if (!$password) {
IPS_LogMessage("FritzAHA Switch","Error: password for '$host' not defined");
return;
}
//build urls and login
$loginurl="http://".$host."/login_sid.lua";//login_sid.lua for fritzos 5.50+
$ahaurl="http://".$host."/webservices/homeautoswitch.lua";//api url
$sid=get_sid($loginurl,$username,$password);
if (!isset($sid)) {
IPS_LogMessage("FritzAHA Switch", "Error: Login invalid or failed");
return;
}
//query actual state
$url=$ahaurl.'?ain='.rawurlencode($ain).'&sid='.$sid.'&switchcmd=getswitchstate';
$answer=chop(@file_get_contents($url));
$response=$http_response_header[0];
if (!preg_match("/200\s+OK$/",$response)){
IPS_LogMessage("FritzAHA Switch", "Error: Query ($url) failed, Response: $response ");
return;
}
IPS_LogMessage("FritzAHA Switch", "Actor $ain actual state:".($answer?"ON":"OFF"));
if ((($answer=="1")!=$state) || ($sender == "Execute")) {
//execute query
$cmd=($state==true)?'setswitchon':'setswitchoff';
IPS_LogMessage("FritzAHA Switch", "Actor $ain execute cmd:".$cmd);
$url=$ahaurl.'?ain='.rawurlencode($ain).'&sid='.$sid.'&switchcmd='.$cmd;
$answer=@file_get_contents($url);
$response=$http_response_header[0];
if (!preg_match("/200\s+OK$/",$response)) {
IPS_LogMessage("FritzAHA Switch", "Error: Update Actor $ain failed, Response: $response");
return;
}
IPS_LogMessage("FritzAHA Switch", "New Status for Actor $ain:".($answer?"ON":"OFF"));
}else{
IPS_LogMessage("FritzAHA Switch", "No need to switch Actor $ain");
}
*/
//-------------------------------------------------------------------------------
/**
* login into fritz and get sid
* @param string loginurl url for accessing device
* @param string username Username to login, if needed or empty
* @param string password password for login
* @return string sid
*/
function get_sid ($loginurl,$username,$password) {
if (is_null($username)) $username='';
$sid='';
// get challenge string
$http_response = file_get_contents($loginurl);
$response=$http_response_header[0];
if (preg_match("/200\s+OK$/",$response)) {
$xml = simplexml_load_string($http_response);
$challenge=(string)$xml->Challenge;
$sid=(string)$xml->SID;
}else{
IPS_LogMessage("FritzAHA Switch", "Error: GetSid with $loginurl failed, Response: $response");
}
if ((strlen($sid)>0) && (preg_match("/^[0]+$/",$sid)) && $challenge) {
//sid is null, got challenge
$sid="";
//build password response
$pass=$challenge."-".$password;
//UTF-16LE encoding as required
$pass=mb_convert_encoding($pass, "UTF-16LE");
//md5hash on top
$md5 = md5($pass);
//final answer string
$challenge_response = $challenge."-".$md5;
//send to box
$url=$loginurl."?username=".$username."&response=".$challenge_response;
$http_response = file_get_contents($url);
//check answer
$xml = simplexml_load_string($http_response);
$sid=(string)$xml->SID;
if ((strlen($sid)>0) && !preg_match("/^[0]+$/",$sid)) {
//is not null, bingo!
return $sid;
}
}else {
//use existing sid if $sid matches an hex string
if ((strlen($sid)>0) && (preg_match("/^[0-9a-f]+$/",$sid))) return $sid;
}
return null;
}//function
//-------------------------------------------------------------------------------
/**
* get varable value by name referencing parent
* @param string $name Name of variable
* @param integer $par ID of parent (category)
* @return variant value of selected variable or null
*/
function getVarValue($name,$par) {
$value=null;
$vid = @IPS_GetVariableIDByName($name, $par);
if ($vid)
$value=GetValue($vid);
return $value;
}
?>
Jetzt kommt im Log auch keine Meldung mehr , aber es passiert leider immer noch nix 