travisc wrote:@bluenoisebluenoise wrote:I just got this working (I think) under Lion, but I have some questions.
It created variables as described, but those variables don't seem to reflect what is really happening. Currently, for instance, my iPhone (of three being tracked) is home. In the device list, mine is "home" while the other two are "away." But, in the variable list, all three <iPhoneName>Home variables are "true." Additionally, until just a moment ago, AllPhonesAway was true, in spite of mine being known as "home" in the device list. Lastly, though it says all three phones are home (according to the variable list), AllPhonesHome is "false." Is there something I need to do to ensure those variables are updated properly?
I tested this today before I uploaded v1.0.0, I can't reproduce it. Are you sure "Create Variables" was still checked in the config? If you uncheck it the variables will not be deleted, but they won't be updated. If you see this popup again and can reproduce it let me know and I'll check it out.
Travis
BeNoOne wrote:Oké, just came accross this thread en was very interested what solution was being used to detect an iPhone/iPad. I already used some proximity detection in the past, but this was via Bluetooth. Although this was working fine, the range was very limited. Also the application (Salling Clicker) I used doesn't support iOS devices.
So in my search for alternatives I wanted to use WiFi.
At the moment I'm using a very simple Python script to do just that. Only I do it the other way around. I'm pulling the info from my 2 Airports with a snmpwalk command.
In the past, pre iOS5, this resulted sometimes in false aways on my iPhone, but worked flawless on my iPad if I turned my 3G radio off. Now I have a new iPhone and iOS5, and as of yet haven't had a false away. And I'm not using any time filtering or other trickery to keep the connection alive. Also this method doesn't need any configuration of ports of some sorts. U only need to turn allow snmp on in your Airport.
I don't know if this helps to build a better plugin, but below U see a snippet of my code.
- Code: Select all
"""
MAC adres iPhone : 00:00:00:00:00:00 hex = 000.000.000.000.000 decimal
"""
import subprocess
myVar = indigo.variables[123]
def mySnmp(adr='Primair-eXtreme.local', pwd='######'):
cmd = 'snmpwalk', '-m', 'AIRPORT-BASESTATION-3-MIB', '-Os', '-v', '2c', '-c', '%s' % (pwd), '%s' % (adr), '1.3.6.1.4.1.63.501.3.2'
try:
p = subprocess.Popen(cmd, stdout= subprocess.PIPE, stderr= subprocess.STDOUT)
return p.stdout.read()
except:
indigo.server.log("********Airport Down********")
return 'something'
if '"00:00:00:00:00:00"' in mySnmp():
indigo.variable.updateValue(myVar, "true")
elif '000.000.000.000.000.000' in mySnmp('AirPort-Express.local', '######'):
indigo.variable.updateValue(myVar, "true")
else:
indigo.variable.updateValue(myVar, "false")
I wanted to use subprocess.check_output(cmd), but Indigo uses an old version of Python.
Grts,
import subprocess
myVar = indigo.variables[123]
def mySnmp(adr='Primair-eXtreme.local', pwd='######'):
cmd = 'snmpwalk', '-m', 'AIRPORT-BASESTATION-3-MIB', '-Os', '-v', '2c', '-c', '%s' % (pwd), '%s' % (adr), '1.3.6.1.4.1.63.501.3.2'
try:
p = subprocess.Popen(cmd, stdout= subprocess.PIPE, stderr= subprocess.STDOUT)
return p.stdout.read()
except:
indigo.server.log("********Airport Down********")
return 'something'
if '"00:00:00:00:00:00"' in mySnmp():
indigo.variable.updateValue(myVar, "true")
else:
indigo.variable.updateValue(myVar, "false")
travisc wrote:@BeNoOne
Thanks for sharing! We may have no choice but to go the snmp route for the Airport base stations. I'll look into implementing something based on this when I get some time.
How long after the iOS device leaves until the snmpwalk no longer contains the MAC?
import subprocess
aaa_iphone = '"AA:AA:AA:AA:AA:AA"'
bbb_iphone = '"BB:BB:BB:BB:BB:BB"'
ccc_iphone = '"CC:CC:CC:CC:CC:CC"'
aaa_iPhone_home = indigo.variables[123]
bbb_iPhone_home = indigo.variables[234]
ccc_iPhone_home = indigo.variables[345]
# adr = Bonjour name, as shown in Airport Utility
# pwd = SNMP Community String, shown under the Advanced Tab in Airport Utility
# Enable 'Allow SNMP' under the same tab in Airport Utility
def mySnmp(adr='xxxxx.local', pwd='xxxxx'):
cmd = 'snmpwalk', '-m', 'AIRPORT-BASESTATION-3-MIB', '-Os', '-v', '2c', '-c', '%s' % (pwd), '%s' % (adr), '1.3.6.1.4.1.63.501.3.2'
try:
p = subprocess.Popen(cmd, stdout= subprocess.PIPE, stderr= subprocess.STDOUT)
return p.stdout.read()
except:
indigo.server.log("******** Airport Down ********")
return 'something'
if aaa_iphone in mySnmp():
indigo.variable.updateValue(aaa_iPhone_home, "true")
else:
indigo.variable.updateValue(aaa_iPhone_home, "false")
if bbb_iphone in mySnmp():
indigo.variable.updateValue(bbb_iPhone_home, "true")
else:
indigo.variable.updateValue(bbb_iPhone_home, "false")
if ccc_iphone in mySnmp():
indigo.variable.updateValue(ccc_iPhone_home, "true")
else:
indigo.variable.updateValue(ccc_iPhone_home, "false")
loafbread wrote:Travisc and BeNoOne,
I think the snmp data coincides with the associated and disassociated entries in the Airport base station log file. I am running a test to see if my iPhone 4S stays associated the whole time I am home and always reports disassociated when I am gone. If it does, then a plugin that set a variable "Home" with Associated log entries and set it "Away" with Disassociated entries would be pretty nice.
Example log entries:
Dec 13 19:11:02 BaseStationName 80211: Associated with station d0:23:db:68:ea:a6
Dec 13 20:15:34 BaseStationName 80211: Disassociated with station d0:23:db:68:ea:a6
BeNoOne wrote:Please note:
The information snmp returns is the same Smartphone Radar is getting out of the logging.
So it's not more or less reliable. It's only another (simpler) way to get the same information.
Users browsing this forum: No registered users and 1 guest