Jump to content

How to trigger a program using iPhone as a FOB


ahwman

Recommended Posts

I have written two programs for my security system, one to enable and another to disable it. Sometimes I forget when leaving the house to enable it or when returning I forget to disable it. That being said, I was thinking it would be very convenient if somehow there was a way to ping my iPhone via Bluetooth/Wi-Fi to determine whether it was in proximity and therefore either engage or disengage the security system program via the ISY 99. Any ideas on how this might be accomplished?

Link to comment

I'm not an iPhone developer but as I understand it an app can't run in the background. I think when you exit an App it goes into suspended mode and is not allowed to run. This means you would always have to have any software that might do this running in the foreground which would prevent your phone from doing most anything else.

 

Contrary to the marketing hype iOS is not a true multi-tasking OS.

Link to comment

ahwman,

 

I've played around with the same idea. You won't be able to use wifi, as the iphone seems to turn off it's network connection when it sleeps. Presumably to save the battery.

 

Bluetooth seems to always be active. You can't connect to it via the isy-99i itself. I tested one setup, with a program that ran on a PC with a bluetooth adapter. The program is originally designed to lock/unlock a windows session based on proximity of the phone. If you stepped away from your desk it would lock, get back in range it would unlock. It could also run an external program.

 

I created a small script, that would send a REST command to the isy-99i, and then trigger some "I'm home" program. Based on the presence of my phone it would run the "lock" or "unlock" script, which in turn updated the isy-99i.

 

It had a few problems. My PC wasn't centrally located, so it would connect/disconnect more often then I wanted. It also has a limited range. Then I had problems with the PC when it was on, and it might sleep, and then the program wouldn't always run.

 

I'm working on a Linux solution, on a small server. I'm hoping I can get a longer range bluetooth adapter, and also get the antenna centrally located. I think I can get it between the ceiling of my first and second floor and that might work better.

 

It's a work in progress at this point.

Link to comment

Thanks for the reply. I remember reading about the program your referring to allowing one to log into a computer using an iPhone as a proximity sensor but couldn't remember where I saw it so we're thinking along the same lines. I was also a bit concerned about the range of the Bluetooth and now you have confirmed those concerns. Perhaps it's more trouble than it's worth, I just thought it would be a neat timesaver.

 

Please keep me posted on your progress.

Link to comment

I do something similar, but it requires a little work and changing of your thinking. I look a little more passively. I "screen scrape" the "associated clients" on my wifi for the iPhone's Mac address. I have two wifi access points and can do an "or" to check both of the, to see if I'm home

Hope this helps

 

 

 

Sent from my iPad using Tapatalk HD

Link to comment
  • 3 months later...

Bcrawfo2,

 

Sorry for the late replay. Can you elaborate a bit more about how you monitor connected Mac addresses.

 

I had thought that creating something along the lines of an auto profiler, which bases my phones ring/vibrate upon wifi or cell towers might be a helpful insight as to setting scenes and managing energy conservation. However Mac addresses would really be the way to go since it can look at several users and determine who is home and who is not.

 

My initial solution was phone based, being that each phone had to run a command. Your idea is system based which potentially is much more robust. I've love the concept. Its got my wheels turning.

 

Note: I still do see use for phone location based programs. An example being that as my phone enters cell towers increasingly closer to home (at certain time of the day) the driveway lights fade on and the garage door opens. Please know I am more concerned with convenience than security (cameras and locks take care of that), my garages are separated from the house, and my house is hidden a 1/4 mile away from the publics eyes.

 

Thanks,

Matt

Link to comment

So...right now I'm not updating my ISY with this status...I'm more in an asterisk mode...but you can get the idea. Instead of running update_blf.sh...you would run a wget command to update your ISY variables.

 

A rundown of this code. I have two wifi access points. One in my bedroom and one in the living room. On their main page....they show a list of connect users (including mac addresses). I take the output from that first page and concatenate them. I then make two passes thru it. First looking for my wife's MAC address. Then looking for my MAC address.

If there is a change in status....I update a light on my asterisk phone and touch an operating system file (so other programs can understand phone status by looking for files in the /tmp directory).

Let me know if you have any more questions.

 

[root@racky isy]# more find_iphones_on_wifi.pl

#!/usr/bin/perl

use File::Touch;

$kate_file = "/tmp/kate_iphone_";

$scott_file = "/tmp/scott_iphone_";

 

$count = 3;

$errors = `/usr/bin/wget 192.168.101.2 -o /tmp/errors -O /tmp/bedroom.html`;

open FILE, "/tmp/bedroom.html" or die "Couldn't open file: $!";

$output = join("", );

$errors = `/usr/bin/wget 192.168.101.3 -o /tmp/errors -O /tmp/living.html`;

open FILE, "/tmp/living.html" or die "Couldn't open file: $!";

$output2 = join("", );

$output_joined = $output . $output2;

process ("68:FF",$output_joined,$kate_file,"kate");

process ("74:E8",$output_joined,$scott_file,"scott");

 

sub process

{

$mac = shift;

$output = shift;

$file = shift;

$user = shift;

$cmd = "/etc/asterisk/update_blf.sh " . $user;

if ($output =~ /$mac/)

{

if (-f ($file . "home"))

{

}

else

{

touch ($file . "home");

$cmd .= " 1";

printf "$cmd";

system($cmd);

}

unlink ($file . "away");

}

else

{

if (-f ($file . "away"))

{

}

else

{

touch ($file . "away");

$cmd .= " 2";

system($cmd);

}

unlink ($file . "home");

}

}

 

[root@racky isy]#

Link to comment

bcrawfo2 - I'm curious how quickly the router updates with the MAC address. My experience so far with the iphone, is that unless it needs wifi, it won't connect immediately when I get in range - at least while it's in "sleep" or whatever it's called.

 

I've had some luck with bluetooth, and I'm trying to get a fully working program to monitor multiple iphones and update some isy variables. If I could use wifi, that would give me much better range, so I'm interested in your progress.

Link to comment

Mine shows up pretty quickly. It could be the mix of apps I have cause a lot of traffic and thus make it connect quickly. Maybe that's why my iphone battery life is terrible. :)

 

I used to have it text me as I came and went......I think it was a matter of seconds.

Link to comment

Bcrawfo2,

 

Sorry for the double post. My lightening fast copy and paste skills must have failed me. Actually, I have no clue what happened.

 

Thanks for all of the info. Some of it I understand, yet other things are still a bit foreign to me. I am going to study and research what you have posted before I ask any elementary questions.

 

From what I can initially tell, it is written in the exactly way I was hoping. Scanning for each person will allow different settings depending on whos home. Me, Her, Both, None, & Guest/!Intruder! Now I ?-simply-? need to GET the info from each of my access points.

 

Have you found any usefullness for the knowing of what AP the phone is entering? At first thought, it sounds like it might be nice to know that I am out working in my shop (Shop AP) and since she isn't home, the house is in Energy Saving mode.

 

At my second thought, I know that my APs often fight to hold onto there 'customers' before handing off to the next AP. I currently run 3 APs on staggered channels. One on each floor, plus one for the Shop and the back yard.

 

I will be adding a forth AP (far enough from interfering channels) in a new, larger shop that I am building. A proud picture is attached. From Rubble to a soothing yet manly mix of steel, wood, brick, and concrete. Notice all of the conduit that will be headed to the house. Opps soory for the side track.

 

Thanks again,

Matt

post-1311-140474156126_thumb.jpg

post-1311-140474156128_thumb.jpg

post-1311-140474156129_thumb.jpg

Link to comment
  • 2 weeks later...

The problem with watching the arp is that you might not have an arp entry for the device. They do timeout. Then you say....I can ping it periodically. So...how frequently? What does that "active" check do to your battery life?

Same with Bluetooth ping. What does pinging frequently do to you?

My approach uses not extra battery and seems to be pretty quick recognizing change of state for me

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...