Hi All
Thanks for this great Idea ! I had no clue about the possibilities of this.
On win10 x64 platform (full updated) i implemented arp lookup in LUA
Now i am doing some test and it looks promising.
When doing plain Ping test for presence with android (diff versions : jelly-been to oreo) in dose/sleep state does not get a respond.
Somehow the ARP table keeps the entry also in this state, and the regular wake up of android for checks is enough to keep the entry in the ARP table: normaly based on ping, over night you will see a sequence of ON / OFF in the dummy switch log.
With ARP it stays On the complete night !
But when i turn wifi off the enty disapears in ARP after 5 minutes ...
- A clear benefit for presence detection.
- Another benefit is you can lookup the ARP table against the MAC adress what makes it IP undependent (DHCP can be used vs Static assignment)
- It is very fast ! not depending on external factors, just internal table lookup (no Phone interaction needed)
I Love the idea and will keep on testing for next couple of days.
Below the code replace xx with your mac lookup, It runs the batch file below.
Code: Select all
commando='findmac.bat xx-xx-xx-xx-xx-xx'
content=os.capture(commando)
if string.len(content)>10 then
findm=true
if otherdevices['Arp M']=="Off" then
commandArray['Arp M']="On"
NMA("Mherkend")
end
else
if otherdevices['Arp M']=="On" then commandArray['Arp M']="Off" end
end
Lua Helper function i use for more OS captures on my system to read results
Code: Select all
function os.capture(cmd, raw) -- os.command uitvoeren en resultaat daarvan lezen in string
local f=assert(io.popen(cmd, 'r'))
local s=assert(f:read('*a'))
f:close()
if raw then return s end
s=string.gsub(s, '^%s+', '')
s=string.gsub(s, '%s+$', '')
s=string.gsub(s, '[\n\r]+', ' ')
return s
end
Windows batch file in domoticz dir. It is important where you place this file to make it reachable for Lua
It returns an empty string when the ARP entry is not found (checked in LUA on length of the string)
It returns IP and Mac when the entry is found in the ARP table.
Code: Select all
@ECHO OFF
SET macd="%1"
ARP -a |find %macd%
I keep you posted with the results ( for my purpose this seems much better usable vs the ping aproach...)
EDIT :
I need the pinger to make some kind of connection , if not it takes long before the arp catches the MAC.
But with pinger enabled to the phone it works perfectly and more reliable.
Due to the pinger i slill need to assign a DHCP fixed IP binding to the phone.
So i am trying now a network monitor to see if this is enough for getting the phone in the ARP table
First test looks promising, but need to test longer (goal to not ping any more at all)
Keep you posted
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)