No, but as far I can see you try to get the host entry by Index and not by IPAdress.
-
Fritzbox WLAN Script SomeOneAtHome
-
IPAdress is not important I search for MAC Adress. Will take a look later.
-
Oh, I see. Then i guess it must be
GetSpecificHostEntry
and notGetGenericHostEntry
andNewMACAddress
and notNewIndex
But didnt work for me… -
Is there a well document for this? Found only AVM and this is not specified enough.
-
I found only this https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/hostsSCPD.pdf
and nearly the same here http://www.wehavemorefun.de/fritzbox/HostsSCPD.xml -
That will work now! Important! Not IP Address is needed. Argument must be a MACAddress.
#!/usr/bin/php <?php if(empty($argv[1])){ die("Arguments missing."); } $uri = "urn:dslforum-org:service:Hosts:1"; $location = "http://fritz.box: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']; ?>
-
@Swen
For me MAC-Adress is better as IP-Adress because my phone have a problem when i give it always the same IP-Adress.Great work!
-
This script is faster then with a for loop. MACAddress is the only way to get device info.
-
Yeah! Great work!
-
Hello,
i have read this Thread and find it cool, because i have the same problem with my phones and the ping presence…
I have create a phone-presence.php in the home directory and copy the last script (with MAC-Adress) in my php skript. I also add a Shell Sensor in pimatic with the command: /home/pi/phone-presence.php 34:E2:FD:68:16:72 1 0 (mac-adress for my phone).
But i always get this error in pimatic:error [pimatic-shell-execute,ShellPresenceSensor]: Error getting attribute value mein-handy.presence: undefined error [pimatic-shell-execute]: [ShellPresenceSensor#mein-handy] Error: Command failed: /bin/sh -c /home/pi/phone-presence.php 34:E2:FD:68:16:72 1 0 /bin/sh: 1: /home/pi/phone-presence.php: Permission denied
I run Pimatic as an unprivileged
but when i run the command in the shell sensor with “sudo bash” i get another error:
error [pimatic-shell-execute]: [ShellPresenceSensor#mein-handy] Error: Command failed: /bin/sh -c sudo bash /home/pi/phone-presence.php 34:E2:FD:68:16:72 1 0 /home/pi/phone-presence.php: Zeile 2: ?php: Datei oder Verzeichnis nicht gefunden /home/pi/phone-presence.php: Zeile 3: Syntaxfehler beim unerwarteten Wort `$argv[1]' /home/pi/phone-presence.php: Zeile 3: `if(empty($argv[1])){'
What i´m doing wrong? Can somebody help me?
Thank you
-
@Masterplayer
You don`t Need the “1 0” at the end. Please test it so:/home/pi/phone-presence.php 34:E2:FD:68:16:72
And in an ssh bash you call it with the same command, without “sudo bash”.
Please look if you have php installed, I have to install it first:ls /usr/bin/php
If there cames an error you may have to install php first.
-
There are many points:
-1 0 will be ignored
-please install php I will look to create python as my free time let me do this- don’t forget bash line with #!
-this php run as same as batch file bud it needs its rights for execution chmod +x
Check this first please. If you have a problem withit let me know.
- don’t forget bash line with #!
-
@Masterplayer said in Fritzbox WLAN Script SomeOneAtHome:
error [pimatic-shell-execute,ShellPresenceSensor]: Error getting attribute value mein-handy.presence: undefined
error [pimatic-shell-execute]: [ShellPresenceSensor#mein-handy] Error: Command failed: /bin/sh -c /home/pi/phone-presence.php 34:E2:FD:68:16:72 1 0
/bin/sh: 1: /home/pi/phone-presence.php: Permission deniedi had the same Problem, if you are using “pi” as User is enough to set the “RUN” Permissions to “Everyone” of the PHP-File. If you have a GUI Installed, right click on the File -> Permissions.
-
Thank you, now it works like a charm…
I haven´t install php…
I have install it and change the permissions and now it works!THANK YOU!
-
Thank you for you feedback.
-
Great works fine!
-
Since I use the FritzBox Version 6.83 I got sometimes this error message:
error [pimatic-shell-execute]: [ShellPresenceSensor#iphone] Error: Command failed: /bin/sh -c /home/pi/someOneAtHome_new.php AA:BB:CC:DD:EE:FF PHP Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /home/pi/someOneAtHome_new.php:19 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://fritz.bo...', 'urn:dslforum-or...', 1, 0) #1 /home/pi/someOneAtHome_new.php(19): SoapClient->__call('GetSpecificHost...', Array) #2 /home/pi/someOneAtHome_new.php(19): SoapClient->GetSpecificHostEntry(Object(SoapParam)) #3 {main} thrown in /home/pi/someOneAtHome_new.php on line 19
It must some kind of timeout of the Fritzbox because the connection is established.
Has anyone else this error? -
What interval settings are you set for your device? If interval is to short, you can get a timeout, 'cause the box is busy.
This script will start with each request from pimatic. If the request time (interval) is to short in the meanwhile you ask to much often and don’t get an answer. The result is a timeout. My interval time is set to 60000 and works very well.
-
The interval is set to 30000, which worked for some months.
But i found out that i have some packet drops on the connection between pimatic and fritzbox.
I try to fix this and have a look if it still happens. -
If you really have drop packages then sort this issue out, otherwise i recommend to set interval to 60000. Each minute is enough time to check if device is in network or not. The fritzbox has so many features and all this features takes cpu time also. And the CPU in this box has much to do with other things. So my suggestion is to set interval settings higher that the box will not get so much pressure. But you can try it out when the box will not respond by manual execute via console on your pi. Start request in short times and sort out the limit. I investigate this in throttling up request and best value is 60000.
I’m not totally an expert with soap requests and i don’t know why the box will sometimes not respond on querys. Otherwise i can modify the code to check if a response is given, when not take the script in a waiting position an try again. PHP on console via bash is able to work like a c or python code. This #!/usr/bin/php opens so much doors that you can run php like a normal program. But if we do that we must secure that not a second request comes up we need also time in interval settings. Otherwise we can run a php as program and php write a file like a json to request in realtime if a network device is on or of… But this are ways they we don’t need in real time and break out the hole system… I don’t have any experience in coffee script to write a plugin…