Find my iPhone funktioniert eigentlich perfekt.
Um den Akku zu schonen frag ich einfach in unterschiedlichen Intervallen ab. Je weiter ich von zu Hause weg bin, desto weniger fragt er ab. Komm ich näher, geht’s runter bis auf 1 Anfrage pro Minute.
Wenn ich zu Hause bin poste ich mal den Code vom Script.
Nachtrag (Die Abfragen, also die Push-Meldungen würd ich abschalten, die sind Akkulastig und hatte ich nur zum Testen verwendet. Entfernung Strasse funktioniert nicht, da hatte ich noch keine Zeit drüber zu schauen):
<?
include(„IPSInstaller.ips.php“);
require ‚class.sosumi.php‘;
include(„func_distance.ips.php“);
$aktiv = GetValueBoolean(45304 /[Hardware\Telefone\Mobil\iPhone Suche\Aktiv?]/ );
if ($aktiv == true) {
$ssm = new Sosumi('APPLE ACCOUNT MAIL', 'APPLE ACCOUNT PW');
$loc = $ssm->locate();
$loc_lat_home = xx.xxxxxx;
$loc_lon_home = xx.xxxxxx;
$parent_id = IPS_GetParent($IPS_SELF);
IPS_SetPosition($IPS_SELF, 999);
IPS_SetHidden($IPS_SELF, true);
$devicename = 'WIE AUCH IMMER';
$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>"
);
$mapsurl = 'http://maps.google.de/maps/nav?q=from:'.$loc_lat_home.','.$loc_lon_home.'%20to:'.$loc['latitude'].','.$loc['longitude'].'';
$mapsresult = file_get_contents($mapsurl);
$mapsdata = json_decode(utf8_encode($mapsresult), true);
$placemark = $mapsdata['Placemark'];
$strasse = $placemark[1]['address'];
$directions = $mapsdata['Directions'];
$meter = $directions['Distance']['meters'];
$zeit = $directions['Duration']['html'];
$km = $meter / 1000;
$diff = distance($loc_lat_home, $loc_lon_home, $loc['latitude'], $loc['longitude']);
SetValue(CreateVariable("Entfernung Luftlinie", 2, $parent_id, 24, ""), $diff);
if($diff > 0.05) {
// Wenn Entfernung größer 1.0km dann abwesend
SetValue(CreateVariable("Zuhause", 1, $parent_id, 10, ".SosumiZuhause"), 1);
//SetValue(56926, false);
}
else
{
SetValue(CreateVariable("Zuhause", 1, $parent_id, 10, ".SosumiZuhause"), 0);
// SetValue(56926, true);
}
SetValue(CreateVariable("Latitude", 2, $parent_id, 110, ""), $loc['latitude']);
SetValue(CreateVariable("Longitude", 2, $parent_id, 120, ""), $loc['longitude']);
SetValue(CreateVariable("Letzte Abfrage", 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 ($diff > 0.05) {
$minute = 1;
IPS_SetEventCyclic($timer, 0, 0, 0, 2, 2 , $minute);
$ssm->sendMessage('Du bist '.$diff.' km Luftlinie und '.$km.' KM Strasse von zu Hause ( Das sind '.$zeit.') entfernt. Naechste Abfrage in '.$minute.' Minuten.', 0);
}
elseif ($diff > 1.0)
{
$minute = 3;
IPS_SetEventCyclic($timer, 0, 0, 0, 2, 2 , $minute);
$ssm->sendMessage('Du bist '.$diff.' km Luftlinie und '.$km.' KM Straße von zu Hause ( Das sind '.$zeit.') entfernt. Naechste Abfrage in '.$minute.' Minuten.', 0);
}
elseif ($diff > 3.0)
{
$minute = 5;
IPS_SetEventCyclic($timer, 0, 0, 0, 2, 2 , $minute);
$ssm->sendMessage('Du bist '.$diff.' km Luftlinie und '.$km.' KM Straße von zu Hause ( Das sind '.$zeit.') entfernt. Naechste Abfrage in '.$minute.' Minuten.', 0);
}
elseif ($diff > 5.0)
{
$minute = 7;
IPS_SetEventCyclic($timer, 0, 0, 0, 2, 2 , $minute);
$ssm->sendMessage('Du bist '.$diff.' km Luftlinie und '.$km.' KM Straße von zu Hause ( Das sind '.$zeit.') entfernt. Naechste Abfrage in '.$minute.' Minuten.', 0);
}
elseif ($diff > 10.0) {
$minute = 10;
IPS_SetEventCyclic($timer, 0, 0, 0, 2, 2 , $minute);
$ssm->sendMessage('Du bist '.$diff.' km Luftlinie und '.$km.' KM Straße von zu Hause ( Das sind '.$zeit.') entfernt. Naechste Abfrage in '.$minute.' Minuten.', 0);
}
elseif ($diff > 15.0) {
$minute = 15;
IPS_SetEventCyclic($timer, 0, 0, 0, 2, 2 , $minute);
$ssm->sendMessage('Du bist '.$diff.' Luftlinie und '.$km.' KM Straße von zu Hause ( Das sind '.$zeit.') entfernt. Naechste Abfrage in '.$minute.' Minuten.', 0);
}
else
{
$minute = 5;
IPS_SetEventCyclic($timer, 0, 0, 0, 2, 2 , $minute);
$ssm->sendMessage('Du bist zu Hause.', 0);
}
SetValue(CreateVariable("Abfragezyklus", 1, $parent_id, 26, ""), $minute);
}
?>