Hi Jungs,
auf die Schnelle.
aus beiliegendem Archiv die Dateien
[ul]
[li]class_Sosumi.ips.php (zwingend da etliche Anpassungen durchgeführt wurden)
[/li][li]func_distance.ips.php
[/li][li]IPSInstaller.ips.php (nur wenn noch nicht vorhanden, Danke Brownson)
[/li][/ul]in den Skriptordner von IPS kopieren.
Den Ordner iPhone aus dem Archiv in den webfront/user-Ordner.
Folgendes Skript unter einer Dummy-Instance (Name egal) erstellen und folgende Anpassung machen.
Eure Heimatkoordinaten (Zeile 8 und 9)
$loc_lat_home = 48.000000000; // Latitude Zuhause
$loc_lon_home = 11.0000000000; // Longitude Zuhause
Die Apple-Account-Daten
$ssm = new Sosumi('Apple-ID', 'Apple-Passwort', $debug); // Apple-Account, Account-Passwort
Anschließend 1x starten.
<?
// Usage:
// $ssm = new Sosumi('username', 'password');
// $location_info = $ssm->locate(<device number>);
// $ssm->sendMessage('Your Message', true, <device number>, 'Important Message');
//
$loc_lat_home = 48.178579276867; // Latitude Zuhause
$loc_lon_home = 11.189966808125; // Longitude Zuhause
$debug = false; // echo-Meldungen zu debugging aktivieren
include("func_distance.ips.php"); // Function zur Berechnung
include("class_Sosumi.ips.php"); // MobilMe-API
include("IPSInstaller.ips.php");
$ssm = new Sosumi('Apple-ID', 'Passwort', $debug); // Apple-Account, Account-Passwort
$loc = $ssm->locate(0, 5);
//$ssm->sendMessage('Testnachricht', false, 0, 'Testbetreff');
// Ab hier theoretisch nichts mehr ändern
$parent_id = IPS_GetParent($IPS_SELF);
IPS_SetPosition($IPS_SELF, 999);
IPS_SetHidden($IPS_SELF, true);
$devicename = UTF8_Decode($loc['name']);
if($debug) {
echo $loc['latitude'];
echo "
";
echo $loc['longitude'];
echo "
";
echo ($loc['timestamp']);
echo "
";
echo $loc['accuracy'];
echo "
";
echo date("H:i:s");
echo "
";
echo $loc['exception'];
echo "
";
echo UTF8_Decode($loc['name']);
echo "
";
echo $loc['charging'];
echo "
";
echo $loc['battlevel'];
echo "
";
echo $loc['status'];
echo "
";
}
$Profil_Name = array('Zuhause', 'Abwesend');
$Profil_Color = array(0 => 0xaaaaaa, 1 => 0xaaaaaa);
CreateProfile_Associations(".SosumiZuhause", $Profil_Name, "", $Profil_Color);
SetValue(CreateVariable("Maps", 3, $parent_id, 30, "~HTMLBox"), "<iframe src=\"user/iphone/map.php?lat=".$loc['latitude']."&lng=".$loc['longitude']."&devicename=".$devicename."&altitude=".$loc['accuracy']."&date=".$loc['timestamp']."\" border=\"0\" frameborder=\"0\" style=\"top:0pt; bottom:0pt; left:0pt; right:0pt; width:100%; height:400px;\"/></iframe>");
//SetValueString(36289 /*[Test\iPhone Suche\iPhone Suche\Maps]*/ , "<iframe src=\"user/iphone/map.php?lat=".$loc['latitude']."&lng=".$loc['longitude']."&devicename=".$devicename."&altitude=".$loc['accuracy']."&date=".$loc['timestamp']."\" border=\"0\" frameborder=\"0\" style=\"top:0pt; bottom:0pt; left:0pt; right:0pt; width:100%; height:400px;\"/></iframe>");
$diff = distance($loc_lat_home, $loc_lon_home, $loc['latitude'], $loc['longitude']);
//$diff = 5.1;
if($debug) echo $diff;
SetValue(CreateVariable("Entfernung", 2, $parent_id, 24, ""), $diff);
//SetValue(55107 /*[Test\iPhone Suche\iPhone Suche\Entfernung]*/, $diff);
if($diff > 1.0) { // Wenn Entfernung größer 1.0km dann abwesend
SetValue(CreateVariable("Zuhause", 1, $parent_id, 10, ".SosumiZuhause"), 1);
//SetValue(56926 /*[Test\iPhone Suche\iPhone Suche\Zuhause]*/, false);
}
else
{
SetValue(CreateVariable("Zuhause", 1, $parent_id, 10, ".SosumiZuhause"), 0);
// SetValue(56926 /*[Test\iPhone Suche\iPhone Suche\Zuhause]*/, true);
}
SetValue(CreateVariable("Latitude", 2, $parent_id, 110, ""), $loc['latitude']);
SetValue(CreateVariable("Longitude", 2, $parent_id, 120, ""), $loc['longitude']);
SetValue(CreateVariable("Timestamp", 3, $parent_id, 130, "~String"), $loc['timestamp']);
SetValue(CreateVariable("Meldung", 3, $parent_id, 25, "~String"), $loc['exception']);
$timer = CreateTimer_CyclicByMinutes("Timer for iPhone", $IPS_SELF, 15);
if($debug) echo $timer;
// Wenn Entfernung > Value dann Zyklus der Positionsmeldung auf 30 Minuten
if ($diff > 10.0) {
$minute = 15;
IPS_SetEventCyclic($timer, 0, 0, 0, 2, 2 , $minute); //Alle 30 Minuten
}
else
{
$minute = 2;
IPS_SetEventCyclic($timer, 0, 0, 0, 2, 2 , $minute); //Alle 1 Minuten
}
SetValue(CreateVariable("Abfragezyklus", 1, $parent_id, 26, ""), $minute);
?>
Legt die erforderliche Struktur an.
Beim ersten Asuführen kommen ein paar Warning seitens PHP die aber beim weiteren Verlauf nicht mehr auftreten.
Hoffe das war es :rolleyes: