I found a way via fritz.box to hack and check if a device is present or not without ping. Works nice with iphone also. Magic thing is here soapclient. I start to investigate that to get WLAN device in sleep mode and it seems to work good. This php script need login and password setting then you can try to get it via yourscript.php IP. Add a shell presents device and with an interval you need.
EDIT:02.02.2017 This script is updated now and need a MACAddress!!! Login is not needed in this case. Important thing is that php is preinstalled.
EDIT: 28.05.2017 Script support now more then one fritz.box for use: yourscript.php macadress boxip1:boxip2:boxip3…
Important thing is that you separate by double point all different box ip addresses. If you use only one box please use only one box ip without double point is possible.
EDIT: 06.03.2018 Follow this Tutorial/HowTo https://forum.pimatic.org/topic/4201/reliably-check-iphone-presence-in-your-fritzbox-network-step-by-step-guide Thanks to @cherberg If you have support or further questions. Don’t hesitate and ask in this thread. Via HowTo you wouldn’t get help.
#!/usr/bin/php
<?php
if(empty($argv[1])){
die("MAC address missing");
}else{
$mac = $argv[1];
}
if(empty($argv[2])){
die("BOX IP or IPs missing");
}else{
$ipList = explode(":",$argv[2]);
}
function checkDevice($ip,$mac){
$result = "";
$uri = "urn:dslforum-org:service:Hosts:1";
$location = "http://".$ip.":49000/upnp/control/hosts";
$client = new SoapClient(
null,
array(
'location' => $location,
'uri' => $uri,
'noroot' => True,
'login' => "",
'password' => "",
'connection_timeout' => 5
)
);
try{
$query = $client->GetSpecificHostEntry(new SoapParam($mac,'NewMACAddress'));
$result = $query['NewActive'];
}catch(SoapFault $fault){
$result = 0;
}
return $result;
}
function checkAllDevices($ipList,$mac){
$result = 0;
foreach($ipList as $ip){
$resultCheck = checkDevice($ip,$mac);
if($resultCheck == 1){
$result = 1;
}
}
return $result;
}
echo checkAllDevices($ipList,$mac);
?>