No announcement yet.

Using List Boxes with HomeSeer Data

This topic is closed.
This is a sticky topic.
  • Filter
  • Time
  • Show
Clear All
new posts

    Using List Boxes with HomeSeer Data

    This How To will describe how you can load a list box in HSTouch with data from HomeSeer and process user selections.

    The List Box in HSTouch can be used to hold name/value pairs of data. For example, the box may display "lights 10%" and the value for this display could be the number "10". These name/values can be added to the list box manually in the designer (if they are static data), or can be dynamically assigned from data in HomeSeer (in the case where the data can change). Here we show you how to create the data in HomeSeer, assign it to a list box, detect user selections, and process the data in a HomeSeer script.

    1) Create the data in HomeSeer. If you already have a device that holds name/value pairs, then skip to step 2. If you need to create the data, you can use a script. Create a virtual device, assign it a code of G1. Run the following script from an event to create the data:

    sub main()
    hs.DeviceValuesAdd "G1", "My On" & chr(2) & "1" & chr(1) & "My Off" & chr(2) & "2", true
    end sub

    This script assigns 2 pairs of data named "My On" and "My Off" and assigns values to them of 1 and 2.

    2) In the HSTouch Designer, add a List Box to your screen, click on "Status Tracking" in the properties and assign the G1 device to the list box.

    3) With the list box selected click on the "Actions When Selected" and add a "Run a HomeSeer Script" action. Select the script you want to run when the selection changes (in this test, our script is named "from_hstouch.txt"), in the parameter 1 box, select the list box.

    When a selection is clicked in the list box, the script "from_hstouch.txt" is run and its passed the selection string.

    4) In HomeSeer, create a new event, set the action to run a script, enter a new script name of "from_hstouch.txt". Enter the following script:

    sub main(parm)
    msgbox parm
    end sub

    Save the script and save the event. (the event is not really needed, it just gives us a way to quickly edit the script)

    Now save the project in the HSTouch Designer, and run the HSTouch Client. The list box should list our 2 selections "My On" and "My Off". If you select either one, a message box will appear on the HomeSeer system showing you the item that was selected.

    You can modify the "from_hstouch.txt" script to process the selections and perform any needed actions.
    website | buy now | support | youtube