@Swen i use your Script. But i have the same Error when i start your script as bash.
@mwittig my php version is: PHP 5.6.30-0+deb8u1
-
Fritzbox WLAN Script SomeOneAtHome
-
@philreis said in Fritzbox WLAN Script SomeOneAtHome:
When i start the php Script i become this Output:
user@raspberry:~ $ php /home/pi/Presence.php AC:37:43:A0:19:B9
Illegal instructioni get this Error in Putty and in Pimatic.
Why is the User “user” and not “pi”? (“user@raspberry:~ $”) you try to run a script in a homedir from a other user… Linux is everytime hard to deal with permissions, maybe there is the Problem?
mabye check it as root, you can switch to root with “sudo su”.
I use the same script and it works fine by me! But i run it over the User “pi” and pimatic also uses the user “pi”.
-
I have change this to “user” before i post it.
I run the script with user pi too -
Ah okay… i google a little bit … but i only found this:
https://bugs.launchpad.net/raspbian/+bug/1598867
But this not really usefull
-
syntax error, unexpected ‘=’ in /etc/php5/cli/conf.d/20-apcu.ini on line 8
That makes me headache… Can you deactivate apcu module and try again?
Otherwise, how did you create your php file? Can you post your php via paste bin or can you upload you php?
-
This is my php file:
#!/usr/bin/php
<?php
if(empty($argv[1])){
die(“Arguments missing.”);
}
$uri = “urn:dslforum-org:service:Hosts:1”;
$location = “http://192.168.1.1:49000/upnp/control/hosts”;
$echo = 0;
$client = new SoapClient(
null,
array(
‘location’ => $location,
‘uri’ => $uri,
‘noroot’ => True,
‘login’ => “”,//empty, not needed
’password’ => “”//empty, not needed
)
);
$result = $client->GetSpecificHostEntry(new SoapParam($argv[1],‘NewMACAddress’));
//print_r($result);
echo $result[‘NewActive’];
?>I have php-apcu not installed.
-
Crazy, i have removed php from my system and start the script as bash.
Now it works. -
There is another php version up and running.
-
this PHP script is running really awesome on my pi v1… thank you for this.
BUT:
CPU is running nearly 100% now, before was always 3-5% - what did I possibly wrong?Method is:
/home/pi/pimatic-app/presence.php 28:5A:EB:2F:CA:FE
Interval: 60000btw: running PHP 5.6.30
-
Check via console and command top. Check which process really exhaust you cpu. If it’s really PHP then you have a bug in PHP. Normally php don’t need so much power on one user action. By the why post your top here and please tell me which Pi version are you using (1,2,3…) and version of PHP. Also tell me if you use bash on first line and how you execute script.
-
Hello, i have in my Network three Fritz Box.
The Smartphone change the network already to the best WLAN. But the Script check the Status only on one Fritz Box. So the Smartphone is in Pimatic only present when the Smartphone is connected to the “Master” Fritz Box.
Have someone a Idea how i can ask all three FritzBox and used this in Pimatic?With Regaards
-
If you have three boxes in your network and you want to ask all then you must set a loop and set three different locations.
The bestway is to have a function for this. Are you able to extend my code?
-
Setup your the device 3 times for each fritzbox once, then create a dummy Switch “somewhereathome” make a rule that “if one of the 3 Sensors is present then switch the dummy on”. Make a 2nd rule “if all 3 sensors not present for 120sec(or so, this time is for time your phone is Switching between your boxes) switch the dummy off”…so it will be work without a new script. Use only Dummy for your rules whats happend if you are Home or your not at home.
-
@Swen
I am a beginnner in progranning. I can try it. But ist takes some time.
Good idea. But the Variant from Swen is cleaner.
-
Please try this script. Execute -> script.php macadress BOXip1:BOXip2:BOXip3:…
#!/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 ) ); echo $ip." ".$mac."\r\n"; 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); ?>
And remember to let the script it’s time. There is a timeout of 5 seconds. This timeout will increase with more IP addresses.
-
Hello, thanks for the Script. But i have a Error when i execute it:
root@Server:~# ./SomeOneAtHome.php 28:5A:EB:75:78:24 192.168.10.1:192.168.10.2:192.168.10.3
PHP Fatal error: Uncaught Error: Class ‘SoapClient’ not found in /root/SomeOneAtHome.php:19
Stack trace:
#0 /root/SomeOneAtHome.php(44): checkDevice(‘192.168.10.1’, ‘28:5A:EB:75:78:…’)
#1 /root/SomeOneAtHome.php(52): checkAllDevices(Array, ‘28:5A:EB:75:78:…’)
#2 {main}
thrown in /root/SomeOneAtHome.php on line 19 -
Same Error when i execute it with php.
php SomeOneAtHome.php 28:5A:EB:75:78:24 192.168.10.1:192.168.10.2:192.168.10.3
-
Did my old script work before? The class is missing. That confuse me a bit.
-
If the class is missing you must install the soap client for your php version.
-
Ok, you are right.
I have try it on my Server and there was php installed but not php-soap…
After i have it install your Script works fine.Thank you very much!
With Regaards,
Phil