No announcement yet.

Google Latitude script

  • Filter
  • Time
  • Show
Clear All
new posts

    Google Latitude script

    I wrote this script to read my location from Google latitude and put it into HS devices. I am an RTL/HVL coder by trade-- so the code many not be the world's most efficient. But the concept here is fantastic.

    Google latitude is a program which allows your position to be updated to Google's servers.
    If you run Google maps, it will update your position from your phone.

    For the iPhone, I use a program called Laitudie which runs in the background and updates my position to the server whenever I move significantly. It was around $2.

    For Android phones, I think it is built in.

    You need a Google account and need to enable latitude, and your latitude badge. To update your badge- go to...."

    and select enable and show best location.

    In the window below will be your bade- showing your user number. Mine is 19 digits. Copy that and put that into the constant userID in the script." width="180" height="300"

    Next, pick some codes and create some virtual devices. I pick Z1-Z5 as shown in the script header. Pick some that fit your setup, create them, name them appropriately, and change the script to match.

    Next, copy script to scripts directory and have an event call it every minute or so. This will read in your Latitude/Longitude, position name, and time/date of update.

    You can then use that position to enable other Homeseer events. For example, when I get to "Marlborough, MA, USA", my air conditioning switches off. When I enter my Hometown of Lincoln, it switches on. When I leave the state, or goes to vacation mode.

    I still have things I'd like to add, such as defining areas; like my wife works in my town so it would be nice if her location could be more closely defined. I'd love to hear more ideas as I think this could be enormously useful to a lot of people.

    Version .2- This will show distances between you and fixed points. I show it with three points- but you can add more (or less). It shows you the distance in miles. I do not take into account the error right now-- but will add that later.

    You can easily change the units to metres, kilometeres or whatever by changing the earth radius field.
    Version .3-- This will allow you to add more users. In this file-- I have two users with two badges. I have 4 positions that I measure the distance from.

    This version also includes a number of decimal places to round to. This will round to that number of decimal places the string for the distance.

    In addition, this new distance is also loaded as a value to the device. This need to be a whole number, so it will be in the decimal units you described. For example, if you want 2 decimal points (100th of miles/metres) then that value will be in 100th of miles.

    For example, if your decimal places are 2, and you are 2 miles from work-- the value will be 200. This can then be used for event triggering.

    Also below, I measure distance from places and use it to set devices.
    Version .4-- this will add some devices to keep track of the names of the locations you go to. It includes address, city, and zip. Don't forget to add them to HS manually.

    Also included are some devices which will switch on or off based on your distance to your locations. You may need to edit the if statements are the end to suit your needs.

    I added a HS icon for touch to look like a satelitte for those that use blue neon.

    Also, the text of the home device will be set to where you are. It status goes on and off though-- this allows you to drop it into HS.
    Version .5-- this will fix an issue for European users who get some miscalculation of distances. This applies to users whose number system uses a comma to separate the decimals from the integer portion of the number.

    This requires the periodSeperatedDecimal to be kept at zero for US and other users who aren't having problems. For people getting gross error reading in their distances-- set this to a 1.
    Version .6-- this will remove many of the error messages from the log file when the XML pages cannot be loaded and will replace them with (tan) warning messages.
    Attached Files
    Last edited by wpiman; September 1, 2010, 08:37 AM.
    HS3 Pro Edition (Windows Server 8.1 on ESXi box)

    Plug-Ins Enabled:
    weatherXML:,JowiHue:,APCUPSD:,PHLocation:,Chromecast:,EasyTr igger: