Your Mac Knows When You're Home
Pages: 1, 2
Next, open the Proximity application on your Mac. Choose Preferences from the Proximity menu item in your menu bar (look towards the right end of the menu bar to find it), then do the following:
Proximity can also execute a script when it stops detecting your device, which you configure with the "Out of Range Script" option, but I haven't found this useful for home automation. The reason is that Bluetooth's range is rather limited, so you can't reliably infer that you've left home simply because your device has moved out of range. You might have only gone to the kitchen for another cup of coffee.
Instead of using Bluetooth to guess when I'm gone, I manually tell my home automation system that I have left. This is nearly automatic for me because my home alarm system sends a signal to XTension when I turn it on. But, before I had the alarm system, I accomplished the same thing using an AppleScript that was triggered by pushing a button on a remote control I kept near the front door.
The AppleScript that you specified in Proximity is where all the magic happens, and here is your opportunity to really get creative. Anything you can accomplish with AppleScript you can have automatically done when you, carrying your Bluetooth device, get within sensing range of your Mac.
My Proximity script is shown in Figure 2. It performs several actions in sequence, some of which use conditions that are tracked for me by XTension. The first thing that happens is that the current time is after sunset, a lamp in the entryway is turned on. Not only is this welcoming, it provides a subtle visual cue that my Mac has recognized me and has started the script.
Next, the Mac uses text-to-speech to tell me how many phone calls I missed while I was gone. This information is tracked by XTension using PhoneValet ($169.96) to monitor incoming calls. The extra spaces before words that you see in the sayString variable are necessary to allow text-to-speech to correctly read the assembled message after the variables are substituted. If you accidentally leave the spaces out, parts of your messages will be spelled letter-by-letter instead of spoken.
Then, finally, the Mac announces how many unread email messages I have waiting. It determines this by asking Mail for the contents of a mailbox that only contains messages sent to me by people that I've assigned to a group in Address Book. This is accomplished by a rule that I have defined in Mail. These are all standard techniques but, as with much of home automation, it's the ability to connect existing pieces in new and convenient ways that creates value and adds convenience.
Now that you know to trigger actions automatically, the hard part is deciding on the most useful things to have happen. Perhaps you want to have Safari load your favorite web sites, or you could have appointments read from iCal. It's also good to think about the other people who share your home, perhaps the script should do something different if their cell phone is detected, too. The limit is your imagination, AppleScript ability, and the fun you find in experimenting with different approaches.
MarcoPolo
blueproximity