Alex Kurz' EMail Scripts for HomeSeer (V1.21) These script was written because I wanted a more flexible way to handle HS email requests. After several days I've got a quite satisfying solution with the following features: - Only one HS event needed. All security related information (who is allowed to send requests etc.) is stored in an external config file. - Built-In help functionality. The help text is also stored in an external file and is therefore easy to modify. - Very easy syntax (at least I find it easy. No wonder, as I've created it :) - Unlimited number of commands per email - Support for On, Off and Dim commands with confirmation email. - Status request with confirmation email. - Special short syntax for mails coming from cell phones (SMS). The script is definitely not error free, so please write me a mail if you miss something or if you find a bug. Let's get started... Contents: Part 1: Prerequisites Part 2: Installation Part 3: Usage Part 4: Known Issues Part 1: Prerequisites The only prerequisite is that you use the MAPI functionality to check your mail. The script will not work if you use POP/SNMP directly. This is due to a limitation of the HS VBScript objects. Part 2: Installation In the .zip file you can find the following files 1. ak_email.txt - the script 2. ak_email_help.cfg - help text 3. ak_email_addresses.cfg - address definitions Copy them to the :\program files\homeseer\scripts\ directory. Modify the ak_email.txt script file to your needs. There are two settings that need to be set directly in the script file: - Email Confirmation. if you want HS to send a confirmation email after every command, set the parameter "EmailConfirmation" to "1". To turn the feature off, set the variable to "0". - TimeSetting. Due to the different time formats around the globe I had to add this parameter. If you experience error messages like "Script error File: ak_email.txt:13:Type mismatch´:"StringMailDate" in line xx" then change the variable "TimeSetting" from 12 to 24. - LogLevel. For standard logging set the parameter to "0". For extended logging set it to "1". Modify the ak_email_addresses.cfg file to your needs. It is a standard text file with the following syntax: Segment 1: Own address. This part defines your own address. This entry is used in the help file and should represent the address where HS is reachable. [own address] HSAddress@someprovider.com Segment 2: email Addresses. Place all addresses that are allowed to issue commands to HS. [email addresses] user1@someprovider.net user2@someprovider.com user3@anotherprovider.com Segment 3: cell phone addresses. You need to enter the email addresses of you cell phones. These addresses are defined by the SMS-email gateway of your call provider. At Mannesmann D2 they look like this: @d2-message.de. Addresses that are placed in this segment don't need to be repeated in the [email addresses] part. They are automatically added to the allowed addresses. [cell phone] 123456789@cellprovider.com 987654321@cellprovider.com Create a HS event (call it "EMail Handling" or whatever you like) with the following settings: - Type: Recurring, Run every 1 minutes. The "1 minute" setting is just a suggestion, but keep in mind that in the worst case the time to execute the actual command is an addition of this setting and the "Check for mail every XX minutes" value from your EMAIL Setup. - Check the "Do not log this event" box. The script itself will write all necessary information to the HS log. - At the "Scripts/Speech" Tab select the "ak_email.txt" script. That's it. Important: If the script doesn't work and you keep getting error messages like "Script error File: ak_email.txt:13:Type mismatch´:"StringMailDate" in line xx" then edit the file "ak_email.txt" and change the variable "TimeSetting" from 12 to 24. This should do the trick. Part 3: Usage One very important thing first: If you already have Email Reception events enabled in your system, please disable them for the testing period. I am sure that you will be very happy to delete them after the testing. Now send an email with the subject "Homeseer Help" to your own email address. You will receive an answer that looks like this: ---------------------------------------------------- Subject: HomeSeer EMail Interface Help ---------------------------------------------------- Usage of HomeSeer EMail Interface Send an email to your@email.com with the Subject 'HomeSeer Command' (not case sensitive. 'homeseer command' or 'HoMeSeEr CoMmAnD' would do as well.) The actual command should be written into the message body. Command Syntax: , - Device Name: Combination of Device Location and Device Name - Command: on, off, dimXXX (XXX = number between 0 and 100) and so on.... ---------------------------------------------------- Just have a look at this mail and you will know how the rest works :) Part 4: Known Issues There is only one problem that I could not solve: while checking the emails it was necessary to open the subject of every email coming from an address that is listed in the ak_email_addresses.cfg file. The effect is that all mails with one of these addresses will be marked as read, even if they don't contain any HS command. Emails from other addresses are not touched. That was the serious part of the scripts. Now test out the functionality of the scripts and enjoy! If you have any questions or suggestions, don't hesitate to contact me (akurz@gmx.net). Part 5: History Fixed/Changed in V 1.21: - confirmation emails are now optional Fixed/Changed in V 1.2: - added a variable for 12/24 hour time settings. The script should now definitely work on every system. - fixed a bug that made it impossible to operate 2-digit device codes (like A10) Fixed/Changed in V 1.1: - fixed error with AM/PM time strings cu Alex Kurz http://control.doesntexist.com