All scripts must reside in the scripts folder in the HomeSeer application directory. Scripts commonly have the extension ".txt" or ".vbs" or ".vb" (for vb.net scripts) or .cs for C# scripts, and are simple text files. You can edit your scripts in this directory. Here are the steps to create a simple script that turns a light off if it's on:
In the Events View, expand a group, then click the + button to create a new event, the event opens.
A box will display to name the event, give the event a name like "light on test".
Under the "IF" drop list, select "manually triggered" so the event is only triggered when we run it manually.
Click the drop list next to the "THEN" to select an action and select "Run a script or script command".
Click the red airplane icon to go into advanced mode so we can input a script. Click the Edit button to select a script. In the window that pops up, add "light_test.txt" to end of the path, then click "Submit" to close the dialog.
Now expand the actions again to view the script edit box. Paste in the code below and click "Save Script Edits" to save the script.
The script already has the main subroutine defined for you. Modify the script so it looks like this:
To run the script, click the blue run button, check the event log for errors.
VB.NET scripts use a slightly different format. The script is always passed a "parms" object which will be an array of objects that are the parameters. The object will be nothing if no parameters are supplied. The above script would be formatted as follows, and the name of the script needs to have a .vb extension.
You can test script statements using the Control screen. Select the Control Panel link from the Tools menu. In the "Immediate Script Command" box, enter your script command. For example, to speak a phrase enter
The system should speak. If you want to get the value of a HomeSeer device (for example, the current light value from a HSM100 sensor), first get the name of the device. If your light device was named "Family Room Light", then enter this command in the Script Command box:
Check your event log, you should see an entry like:
9/19/2009 12:45:18 PM - msg - 98