If you have a Tesla Model S you may or may not be aware that Tesla exposes an API that lets you get, among other things, the location of the car at any given time. The values are returned as GPS coordinates. This is quite handy for setting up something like a geofence whereby you can have actions occur when you hit certain distances from your house. This is similar to the geofencing others have described this works very well given that the Tesla can very acccurately tell you where it is.
I'm attaching my scripts (cleaned of my location data/passwords/private stuff) by which I track where my car is and speed up polling as I approach home. Note you should not poll too quickly (> once every 10 seconds) or Tesla will block your IP (and then you have to reset your cablemodem and other funky things). Note you'll need to find similar landmarks near your house via google maps or apple maps and then grab the coordinates from the map to plug into this script similar to this format:
There's two parts to this system. One is the AppleScript which manages Indigo and the triggers/variables, and the other which is a shell script which calls the Applescript at set times (again, never > once every 10 seconds). The shell script is running continuously, in the background. Note this also ties in to the I/O Linc that controls my garage door opener.
Also note that I have a second Mac that gets sent the Tesla's location. It then opens up Apple Maps (on my non-primary Mac) and shows the location of the Tesla.
Hit me up with questions if you have any.
and install teslams. I chose to install it in
/Users/tornado/development/teslams-master/ so that is where my applescript will look for it unless you change it on your Mac.
checkTeslaAtPollRate.sh (should be put in your
homedir/scripts folder or someplace similar), and make it executable (
chmod +x checkTeslaAtPollRate.sh)
Locate Tesla.scpt (Also put in homedir/scripts folder)
create files in
pollRate.txt and put this number in it:
lastTimePolledReadable.txt and put this number in it :
lastTimePolled.txt and put this number in it:
Create these variables in Indigo:
isGarageDoorOpen (if you have the IO/Linc)
Put the three sounds in :
/Library/Application Support/Perceptive Automation/Indigo 6/IndigoWebServer/sounds/
(Create the sounds folder if it's not already there)
Run it by going to /Users/yourhomedir/scripts/ via Terminal and typing