-
Platform information:
- Hardware: pi3+
- OS: raspbian stretch
- Java Runtime Environment: zulu
- openHAB version: 2
-
Issue of the topic:
Hello ,
I am using following script to determine if a network device is present or not
#!/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);
?>
how can I integrate this script which returns 0 or 1 as a presence sensor in my openhab??? Can you help me?
Thanks