Okay heres my first attempt, just add the names and mac addresses into the table and your good to go. tested on Rasp PI after installing arping (sudo apt-get install arping)
lets see if this works for the apple stuff..I suspect they will stop responding on standby but time will tell!
Garry.
-- Presence detection via wifi
module(...,package.seeall)
require("xap")
require("xap.bsc")
require("string")
info={
version="1.0", description="Presence Detection via Wifi"
}
local endpoints = {GarryPhone = "xx:xx:xx:09:33:1B", GarryIpad = "xx:xx:xx:xx:82:BA"}
function Detection(timer, self)
local msg = "arping -c 1 -i eth0 -q "..self.address
-- print("msg"..msg)
retval = os.execute(msg)
if (retval == 0) then state = "on" else state = "off" end
self:setState(state)
self:sendEvent()
timer:reset()
end
function init()
for k,v in pairs(endpoints) do
k = bsc.Endpoint{instance="Presence:"..k, direction=bsc.INPUT, type=bsc.BINARY, address=v}
xap.Timer(Detection, 60, k):start(true)
end
end