Script & Plug-In LibraryIf you have a script for HomeSeer that you would like to share, please post it here. This forum is for scripts only, and no replies are allowed here. You may discuss these scripts in the Scripts Discussion forum.
Attached is version 1.9 of Snevl Latitude, a script and web page package which builds on the absolutely brilliant idea from wpiman (his script posted here: http://board.homeseer.com/showthread.php?t=143249) to use Google Latitude to bring locations of your family and friends into Homeseer. Completely configured and maintained via the included web page. Features:
You can track as many people (Google latitude "badges") as you want, and designate several devices to display location information on each person. Some of the device strings are also hyperlinks to pop up a Google Map of the location.
You can have as many known "places" as you want (e.g. home, husbands work, the mall, etc.). Each place can have it's own maximum near distance, and any badges within that distance of that place will be designated 'near'.
You can pick which people and places you want to track the distance between, e.g. Steve from Home, again in device strings if you wish. The device will be turned ON when the person is near the place, and OFF when it is not near.
Can optionally create a static Google map image for each person, either showing the current location (a map pin on the map), or a track of the most recent N locations where N is 5,10,15, or 20 points. An example is shown below.
You can also create a static Google map showing the current locations of multiple badges, so you can show in one image the location of everyone in your family.
I'm using the .NET libraries locale handling of numbers and date/times, so I'm hoping this works for my friends in Europe as well.
Installation should be pretty simple (README included). If you are upgrading from a previous verison, do not over-write your database file in the data subdirectory. You should only need the script and web page.
The ZIP attached to the first message of this thread has been replaced with v1.2. I think I've addressed most of the issues, and added a couple of features:
The culture differences in decimal points is finally fixed (thanks Moskus for beta testing).
Fixed the last-update time, so it should now report a time in your local timezone. I'm not sure I got it right, so please let me know.
The reverse-geocoding (looking up the address, city, and zip) has been completely re-done, and should do a pretty good job of pulling out all the data if Google provides it.
In the process, the reverse-geocoding should no longer cause the script to abort if data isn't found for a field as expected.
Actually using the "maximum near" distance from the config to mark "near" in the track history (it was actually hard-coded in v1.1).
Added a "test" link button to the badge table in the web page. This was another great idea from wpiman. Once you put in a Google badge # (User ID), you can click this button to verify that Google Latitude recognizes it. If you get no updates for a new badge, you might want to use this button to see if the problem is on the Google end rather than the script.
The distance devices are now turned ON and OFF based on the distance. If the distance is no more than the "max near" distance in the config, the device is turned ON, otherwise it will be OFF. The status changes in this device can be used to trigger other events, such as occupancy.
The ZIP attached to the first message of this thread has been replaced with the new version 1.3 ZIP. Sorry to post a new version again so soon, but there are quite a few changes, mostly enhancements requested in the discussion thread:
Create the distance devices in the OFF state, and turn it off if it is found to be in an unknown state.
More tuning of the reverse-geocoding, to better extract address, city, and postal code info
Add a 'maximum near distance' for each place, so near can be be different for each. Use the previous field in the config editor as the default for new places.
Use culture-independent distance calculation for European users
Added optional 'near' device for each badge, to show what places are near that person.
Extended the database fields for Position and Address to 100 characters in the track history database, to avoid having to clip off these fields that can be long (previously limited to 50 characters).
Added auto-upgrade of the database, for longer Position and Address fields, new near device code on badges table, and new max near field on places.
If upgrading, you should only have to replace the ASPX web page and the VB script. Your old database file (in data\SnevlLatitude) should automatically be upgraded the first time the script runs.
Added lots more reverse-geocoding, made it pretty fault-tolerant, and put in debug to trace where it finds what. It should find good addresses in most cases now.
If for some reason we fail to get the ATOM Latitude data from Google, we don't check the distances for "near". This was causing an error in the log.
ZIP now includes a starter database with v2 schema. The schema changed in Snevl Latitude v1.3, and I had included an auto-update in v1.3 to upgrade the database to the v2 schema. However, I forgot to include the new version for fresh installs, which made it a little difficult.
Improved the database schema auto-upgrade to be more forgiving and fault-tolerant.
Improved handling of new observations to allow for large uncertainty radius. See the discussion thread for details. Basically, any new observation is compared to the last known location. If both locations are within the error radius of either one, we assume the badge didn't actually move. However, if the new observation is more accurate than the old one, we take it's location (lat/lon, city, address, postal code) as actual location of the badge. The track log will not show that it moved, but it should have a more accurate location. If the new location is less accurate, we basically ignore it, except to increment the number of observations at the last location.
Added lots more debug. If you turn debug on, the debug log will grow pretty fast, so be aware.
Again, if you are upgrading you should only install the web page (ASPX) and the script (VB). Be careful not to overwrite your existing database, else you will have to re-enter everything.
Post any comments or questions in the discussion thread.
The ZIP attached to the first message of this thread has been replaced with v1.5. Changes in this version:
I hope I am finally pulling everything that is available from the Reverse Geocode KML. If the Street Address, City, or Postal Code is missing in your track, it wasn't reported by Google.
A new option lets you choose to reject / ignore Google Latitude observations that are very inaccurate, represented by a accuracy radius greater than some amount.
Use the "Position" from the Reverse Geocode if it is available. This is much more verbose position, and sometimes even includes things like the name of the place (e.g., airport, mall, etc.).
There is now two formats to choose from for the track history table. One is the same as previous versions, showing the Street Address, City, and Postal Code. The new option adds the "First Seen" column (the first report date/time), and replaces the other location info with the "Position".
There are also two formats to choose from for the display of the tracks on the Google Map. The previous format used color gradients to show the newest to oldest. The new second format uses the same color for all the map markers (green), but puts a numerical label on each marker.
The first post in this thread has been updated with the ZIP for v1.6. Changes in v1.6 include:
The track history part of the web page now includes a third optional format for the history table (selected from the config section). This third option drops the Latitude and Longitude fields and adds a distance / speed field. The speed is computed based on the time difference betewen the "Last Seen" time for the previous point to "First Seen" time for the current location. This is my new favorite format.
Also in the track history table, the latitude, longitude, and position fields are now hyperlinks. Clicking on one will bring up a Google Map in a new window showing the location of that point, whereby you can zoom in, pan, change to satellite view, etc.
Many of the location device strings are also now hyperlinks to bring up a Google Map.
There are a number of options now to choose from for the color of the current location map pin and the track map pins.
The track history plot on the static Google Map can now be 5,10,15, or 20 points long (instead of just 10 in previous versions).
If you are upgrading, only copy over the ASPX web page and the VB script.
The ZIP in the first post of this thread has been replaced with the one for v1.7. Not many changes in this version, but had to get something out to fix the bug that codemonkey reported in the discussion thread. Changes in v1.7:
Correctly saving the map width selection from the config page to the INI file. In previous version it wasn't being saved, and so defaulted to 400 pixels width.
Don't update devices if fail to get latitude data.
Broke out as a separate option the saving of the XML data (Latitude and Reverse Geocoding) for debug. This allows for the logging of debug information without filling you Logs directory with XML files.
Added an optional "tweak" to the algorithm that turns distance devices ON (when the badge is near the place) and OFF when the badge moves away from the place. The tweak is a little complicated, but hopefully the config page explains it sufficiently.
Only copy over the ASPX web page and the VB script if you are upgrading from a previous version.
The first message in this thread has been updated with the ZIP file for v1.8 of SnevlLatitude. The changes in v1.8 include:
There is a new option to define the map type for the static map display. The choices are roadmap (the only choice previous to v1.8), terrain, sattelite, or hybrid. The choice affects all of the maps created by SnevlLatitude.
For maps that are only displaying the current location rather than a track, there is now an option to define the default zoom level for the map.
A new tab on the main web page now allows you to create a multi-badge map to show the locations of multiple people in one display. It does not show tracks, but can show (for example) the location for all the members of your family on one map. You can also specify a device to store the image in the device string, suitable for use with HSTouch.
An option has been added to discard / ignore new observations if their location and time would imply an unreasonable speed of travel. You can turn this feature on or off, and you can specify the maximum allowed speed to accept (in kph or mph, consistent with your other settings).
The near "tweak" that was added in v1.7 had a bug which initialized two of the tweak settings from the INI backwards. This has been corrected in v1.8.