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.
Member for
15 years 7 monthswell I shouldnt be
well I shouldnt be surprised!. iphone doesnt respond to arping on standby.
have installed arp-scan (sudo apt-get install arp-scan) on the Pi and modded the scripts as follows to see if this is any better? NOTE HEX mac address needs to be lower case.
-- Presence detection via wifi
module(...,package.seeall)
require("xap")
require("xap.bsc")
require("string")
info={
version="2.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 = "sudo arp-scan 192.168.0.3-192.168.0.20 |grep "..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
Member for
15 years 1 monthGarry what type of iPhone do
Garry what type of iPhone do you have?
As I said in the other thread, my wife's 4S responds to WiFi pings when asleep but my 3GS does not. I use both arp-scan and l2ping in a python script to detect presence and switch on bluetooth on the 3GS.
Incidentally, I use the return code to increment an absence counter or reset it to 0 if a zero return code is received. This works OK-ish for longer absences but I don't think it's ever going to be able to switch a light on when I return home because it's just too slow a respone.
Member for
15 years 7 monthsThanks Allanstill at the
Thanks Allan
I'm still at the playing around stage but some sort of counter is a good idea, I have a 5s.
Here is the xively plot for the arp-scan code over the last 45mins. Iphone in stanby unused the whole time!? Looks too flaky to be useful?
any other ideas folks?
Member for
15 years 7 monthsBetter than nothing!
Ok added a fifteen minute timeout and poll every 45secs and this seems robust on mine ant the wife's iPhone 5S.
Probably good enough for heating and water, etc but not really responsive enough for lighting.
Member for
15 years 1 monthLooks good
Because I use the raspi to do the detection at the moment and then fire the result off in a UDP packet I don't bother with actual times. I just increment a tick on the HAH and reset it to 0 if I get a hit on WiFi (or bluetooth on my 3GS). As you say OK for detecting longish absences for dealing with heating etc. but not much use for lights.
I was going to play with geofenced reminders on SWMBO's iPhone to see if I could generate anything useful (perhaps via IFTTT) but I'm not sure she's too happy with me knowing when she's arriving and leaving!! I'll have to wait a while until I inherit her phone :-( so it probably won't be anytime soon!
Member for
14 years 5 monthsarping
Garry
I had to use the IP rather than MAC address and use arping rather than arp-scan but working fine here.
Thanks for the code
Mark