Jump to content

Geo fence


diggler

Recommended Posts

If you can find me a way to poll and API at Google or something that can read your device location, I can make it happen for you.

 

I've got a whole other thread on proximity detection and a well developing app that does exactly that.

 

You also could use Bluetooth and wifi and means of checking to see if your home and have it turn on the lights.... that's how I was doing it for years before I started working on the iCloud API method. In fact I'm actually still using Wi-Fi and Bluetooth along with it.

 

 

Sent from my iPhone using Tapatalk

Link to comment

What did u use for wifi setup

 

Sent from my SM-G900P using Tapatalk

 

I run the OpenWRT firmware on my router, and I've previously run DD-WRT as well... and depending on your setup you may even be able to run the script on another host somewhere in your network, but that's a little iffy and sometimes doesn't really work. The best way to do it is to run something like OpenWRT on your router so you have the ability to SSH into and run shell scripts.

 

I have an entire bash script written, probably about 150 lines of code so not TOO big, and basically it runs the "arp -a" command which shows the MAC address of every device that's recently passed traffic through it (usually an ARP entry sticks around for 3 - 10 minutes after the last bit of traffic is seen). It then uses the "grep" command to check the output for the MAC address of your phones wifi radio (which I type into the script before running it) and if it sees the MAC, it knows the device is on your network so it hits the ISY API and sets a variable to "1", then it keeps checking... mine checks once every 2 - 5 seconds... once it no longer sees the MAC address is starts counting, if it doesn't see it 3 times in a row, it sets the ISY variable to "0".

 

So basically, now your ISY will know if your device is home and in range of your wifi or not... and I even have another script written in python that will do basically the same thing with Bluetooth. You put a cheap bluetooth dongle in a raspberry pi, then pair the phone to it and on the raspberry pi, set the device as "trusted". This allows the raspberry pi to hit the bluetooth radio of the phone without it being rejected. So there's a command line tool for bluetooth management of devices in linux called "hcitool", so I run the command "hcitool -a hci0 -n AA:BB:CC:11:22:33" (you'd be entering in the MAC of your smartphone there in a config file before running), and that command sends a name request out to the device of that MAC address. In my case, the name of my phone is simply "Steve's iPhone", so I just get the output from that command and scan the text, if the word "iPhone" appears, then the script knows I'm in range via bluetooth and it sets a different variable on the ISY to "1", as soon as it doesn't see the word "iPhone" anymore, or the command just fails if the device is totally gone, it sets the variable back to "0".

 

The only hard part with bluetooth is that it has limited range... so in my case, I live in a 1200 sq foot condo, one centrally places raspberry pi is enough to catch my phone within range at the absolute corners of my entire place... the only place I've had it go out of range for testing was to put it under my mattress in the master bedroom all the way across the condo. However, at my brother-in-laws house, they have a 3 floor 3,000 sq foot place, backyard, garage, etc.... basically for him, we built 6 raspberry pi's, 3 of them are in different places in the house, 1 right back the back door and the other 2 out in the detached garage and shed. Each one of them is set to update a different variable on the ISY, so there are 6 possible "1" or "0" indicators.

 

Then I wrote an ISY program for him that control a 7th variable based on the first 6. The first 6 are named BTSensor01, BTSensor02, etc.... and the 7th is named BTInRange.... and basically the program is pretty simple, it just says "If BTSensor01 OR 02 or 03 or 04 (etc....) == 1 THEN set BTInRange to 1 ELSE set BTInRange to 0"

 

So basically, if any one of the 6 sensors can see the phone, the ISY knows it's in range.

 

Based on just Wifi and Bluetooth you can have your ISY know if your device is home... with 1 slight caveat... smartphones, to save battery, will drop off of wifi a lot, and sometimes even power down they bluetooth radio, however... they do wake up every once in a while to do some quick checks, GPS, wifi connection, poll for email, verify they're own IP address, etc... I've seen iPhone stay off wifi for almost 30 minutes sometimes, and some androids up to 45 minutes. Bluetooth powers down much less often since it's so low energy anyway, it only shuts off for 2 - 3 minutes max from my testing on both iOS devices and Android based devices.

 

So in order to really be used for "proximity" to tell your ISY if you're home or not... you pretty have to let the ISY know you're home immediately upon seeing either the wifi or bluetooth radios, BUT... if the sensors and scripts report to the ISY that they're gone, you have to program in a little delay... mine is set for 1 hour. If the ISY doesn't see Wifi or Bluetooth for a device for an entire hour, then it marks it as totally gone.

 

That's the reason I started writing my GPS script... waiting for an hour isn't bad to turn off lights, change temp settings for your heat/AC, etc... but I wanted it to be much more sensitive so I could forward my work phone, lock doors, I even have it cut power to my computer monitors so nobody can even see the screen without plugging it into another outlook. I also have it set so if the ISY thinks I'm not home and any motion detectors get tripped, switches get turned on or off, or even door sensors detect an open outside door, it uses Network Resources to shoot a command over to my security cameras, snap a picture and email it to me.... yes, I'm a little bit of a security nut... but I wanted those things to happen right away, not 1 hour after I leave.... now with the GPS script enabled everything is on lockdown and secure within about 3 minutes of the last person leaving home.  

Link to comment

Archived

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


  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

    • There are no registered users currently online
  • Forum Statistics

    • Total Topics
      36.9k
    • Total Posts
      370.2k
×
×
  • Create New...