The solution to this is to use something that does
request a reply from your phone (or another device) and will get a response whether the device active or not. Arp-requests are generally answered by all phones, so why not use this? Indeed, checking with 'arp', only performs a lookup in an existing table in the OS.
But, there is a tool called 'arping' which will send an arp-whois and report the response. Use it like this:
Code: Select all
$ sudo apt-get update
$ sudo apt-get install arping
$ sudo arping 192.168.1.1
I've altered the script from https://www.domoticz.com/wiki/Presence_detection
to use arping as it is much more reliable AND will detect when a device is disconnected / leaves the network.
: I've installed Domoticz on a Raspberry Pi, so above mentioned method may or may not work for you. Arping is available on most OS's though.
: arping uses a system call that requires root-access, so you need to prepend 'sudo' to the command.