Hallo zusammen,
ich habe eine Script erstellt was die folgenden Variablen schaltbar machen soll:
> Türöffner
> Reboot Raspberry
> restart Service DoorPI
und die Statis
>Gespräch aktiv
anzeigen kann. Leider funktioniert nur die DTMF übergabe nicht. Probiert doch bitte mal aus ob es bei euch klappt.
Installation:
> Integer Profil anlegen (s. Bild)
> Script anlegen und folgenden Inhalt einfügen und konfigurieren
<?
//***** Konfigurationsbereich *************************************************
$doorname = 'Haustür';
$doornr = '**620';
$fritzbox_ip = '192.168.1.1';
$password = 'password';
//***** Scriptbereich *********************************************************
//INSTALLER
if ($_IPS['SENDER'] == "Execute")
{
$object = IPS_GetObject($_IPS['SELF']); // Hole alle Scripteigenschaften
$ishidden = $object['ObjectIsHidden']; // Script versteckt?
if (!$ishidden)
{
$device = IPS_CreateInstance("{485D0419-BE97-4548-AA9C-C083EB82E61E}");
if (IPS_ApplyChanges($device))
{
$parent = IPS_GetParent($_IPS['SELF']);
IPS_SetName($device, $doorname);
IPS_SetParent($device, $parent);
IPS_SetParent($_IPS['SELF'], $device);
IPS_SetHidden($_IPS['SELF'], true);
$restart = IPS_CreateVariable(1);
IPS_SetParent($restart, $device);
IPS_SetIdent($restart, "restart");
IPS_SetName($restart, "DoorPI Service neu starten");
IPS_SetPosition($restart, 1);
IPS_SetVariableCustomAction($restart, $_IPS['SELF']);
IPS_SetVariableCustomProfile($restart, "DoorPI");
$reboot = IPS_CreateVariable(1);
IPS_SetParent($reboot, $device);
IPS_SetIdent($reboot, "reboot");
IPS_SetName($reboot, "Raspberry neu starten");
IPS_SetPosition($reboot, 2);
IPS_SetVariableCustomAction($reboot, $_IPS['SELF']);
IPS_SetVariableCustomProfile($reboot, "DoorPI");
$door = IPS_CreateVariable(1);
IPS_SetParent($door, $device);
IPS_SetIdent($door, "door");
IPS_SetName($door, "Tür öffnen");
IPS_SetPosition($door, 3);
IPS_SetVariableCustomAction($door, $_IPS['SELF']);
IPS_SetVariableCustomProfile($door, "DoorPI");
$talk = IPS_CreateVariable(0);
IPS_SetParent($talk, $device);
IPS_SetIdent($talk, "talk");
IPS_SetName($talk, "Kommunikation aktiv");
IPS_SetPosition($talk, 4);
IPS_SetVariableCustomAction($talk, $_IPS['SELF']);
IPS_SetVariableCustomProfile($talk, "~Switch");
};
};
};
//=============================================================================
$ch = curl_init('http://' .$fritzbox_ip. '/login_sid.lua');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$login = curl_exec($ch);
$session_status_simplexml = simplexml_load_string($login);
if ($session_status_simplexml->SID != '0000000000000000')
{
$SID = $session_status_simplexml->SID;
}
else
{
$challenge = $session_status_simplexml->Challenge;
$response = $challenge . '-' . md5(mb_convert_encoding($challenge . '-' . $password, "UCS-2LE", "UTF-8"));
curl_setopt($ch, CURLOPT_POSTFIELDS, "response={$response}&page=/login_sid.lua");
$sendlogin = curl_exec($ch);
$session_status_simplexml = simplexml_load_string($sendlogin);
if ($session_status_simplexml->SID != '0000000000000000')
{
$SID = $session_status_simplexml->SID;
}
else
{
echo "Fehler: Login fehlgeschlagen";
return;
}
}
curl_close($ch);
//=============================================================================
$deviceid = IPS_GetParent($_IPS['SELF']);
$restartID = IPS_GetObjectIDByIdent("restart", $deviceid);
$rebootID = IPS_GetObjectIDByIdent("reboot", $deviceid);
$doorID = IPS_GetObjectIDByIdent("door", $deviceid);
$talkID = IPS_GetObjectIDByIdent("talk", $deviceid);
//=============================================================================
if($IPS_SENDER == "WebFront")
{
SetValue($IPS_VARIABLE, $IPS_VALUE);
}
if($IPS_VARIABLE == $restartID) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://$fritzbox_ip/fon_num/dial_foncalls.lua?sid={$SID}&dial=$doornr**7378278*&xhr=1&t1359124076683=nocache");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
curl_close($ch);
}
if($IPS_VARIABLE == $rebootID) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://$fritzbox_ip/fon_num/dial_foncalls.lua?sid={$SID}&dial=$doornr**732668*&xhr=1&t1359124076683=nocache");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
curl_close($ch);
}
if($IPS_VARIABLE == $doorID) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://$fritzbox_ip/fon_num/dial_foncalls.lua?sid={$SID}&dial=$doornr#&xhr=1&t1359124076683=nocache");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
curl_close($ch);
}
?>
- Script ausführen (Fehler sind normal und können ignoriert werden)
- Testen
VG
Andreas