Announcement

Collapse
No announcement yet.

Screensaver Scripting for HSTouch

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Screensaver Scripting for HSTouch

    Hello all,

    I've decided to make my own simple screen saver for use with HS Touch. Due to the buggy and/or poorly documented state of HSTouch, I'm having to do some funky workarounds but overall it seems working.

    In short, I have three text boxes the width of the display positioned as TOP, MIDDLE, and BOTTOM. I've got 9 buttons in HSTouch that control what is displayed on each of these text boxes. Each of the buttons represent:
    • upper left, upper middle, upper right
    • middle left, middle middle, middle right
    • lower left, lower middle, lower right

    Each of the above buttons enters a value (ie- the time) in the appropriate box, and removes the value from the other two. The way that I "approximate" the horizontal spacing is by adding spaces before the time. Hack...i know.

    I have 9 corresponding manually triggered events in HS3 that simulate a button press on each of the above 9 buttons effectively allowing me to "position" the text on the screen from one of the 9 positions.

    I'm trying to figure out a 10th event that can randomly run one of the other 9 events all within the same group.

    Can someone suggest how to script this?

    thanks,

    Marco

  • #2
    Can't think of any way to do this in an event, but you could probably do it in a script by using the rand.Next function in vb.net. A pretty good example can be found at:
    http://stackoverflow.com/questions/2...riables-values
    I think you'd want to generate a random number between 0 and 10 (that gives you 1 to 9 as integers), then use that in the script to choose which of your nine events to run.
    Fred

    HomeSeer Pro 3.0.0.478, HS3Touch, Zwave 3.0.1.252, Envisalink DSC 3.0.0.40, WeatherXML, Z-stick, HS phone, Way2Call

    Comment


    • #3
      I decided this would make a nice programming exercise, so I created the script below. You just need to substitute the names of your events where I have "testevent1", etc. and create a virtual device to enable/disable the running of this script. Replace the references in this script to ref id 222 with the ref id of your virtual device.

      To keep this from being a never-ending program, it runs only while a virtual device (ref id 222 in this example) is on, then ends within 5 seconds if the device turns off. You could have it automatically start when Homeseer starts by having the startup script turn on the device and then run an event that calls this script. To have it automatically stop when Homeseer stops, just add a line to the shutdown script to turn off the enabling device.

      For debugging, you can un-comment the log writes and the updating of device 221.

      Code:
      ' Run 9 events randomly, waiting 5 seconds between runs
      ' run as long as the "run screensaver script" device is on
      
      Sub Main (ByVal Parms As Object)
      
      	Dim intRandomNumber as integer
      	Dim LastEvent as integer
              Dim rnd As New Random()
      
      	' hs.WriteLogEx("randomrange script", "starting", "#008000")
      
      	'keep repeating the loop as long as the "run screensaver script" device is on
      	While hs.DeviceValue(222) > 0
      
      		'since a true random number might yield the same number multiple times, this while loop
      		'makes sure the new number isn't the same as the last number
      		While intRandomNumber = LastEvent
      			intRandomNumber = rnd.Next(1, 10)	'assign random number between 1 and 9
      		End While
      
      		LastEvent = intRandomNumber			
      
      		' hs.SetDeviceValueByRef(221, intRandomNumber, True)	'put the random number in a device value for testing
      
      		' hs.WriteLogEx("randomrange script", intRandomNumber, "#008000")
      
      		Select Case intRandomNumber
      
      			Case 1
      				hs.TriggerEvent("testevent1")
      			Case 2
      				hs.TriggerEvent("testevent2")
      			Case 3
      				hs.TriggerEvent("testevent3")
      			Case 4
      				hs.TriggerEvent("testevent4")
      			Case 5
      				hs.TriggerEvent("testevent5")
      			Case 6
      				hs.TriggerEvent("testevent6")
      			Case 7
      				hs.TriggerEvent("testevent7")
      			Case 8
      				hs.TriggerEvent("testevent8")
      			Case 9
      				hs.TriggerEvent("testevent9")
      			Case else
      				hs.WriteLogEx("randomrange script", "number not 1 to 9", "#008000")
      		End Select
      
      		System.Threading.Thread.Sleep(5000)	' wait for 5 seconds
      
              End While
      
      	' hs.WriteLogEx("randomrange script", "ended normally", "#008000")
      End Sub
      Last edited by ITguyHS; May 22nd, 2016, 10:01 AM. Reason: improved version
      Fred

      HomeSeer Pro 3.0.0.478, HS3Touch, Zwave 3.0.1.252, Envisalink DSC 3.0.0.40, WeatherXML, Z-stick, HS phone, Way2Call

      Comment


      • #4
        Nice work ITguyS! Marco, if you get this going could you post a screen shot of it.


        Sent from my iPhone
        Tom
        baby steps...starting again with HS3
        HS3Pro: Z-NET & 80 Z wave Devices,
        HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
        Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
        In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
        System: XP on Fanless Mini-ITX w/ SSD

        Comment


        • #5
          Marco,
          I'd love to see how you did this in HStouch! Can you post a few screenshots?
          Fred

          HomeSeer Pro 3.0.0.478, HS3Touch, Zwave 3.0.1.252, Envisalink DSC 3.0.0.40, WeatherXML, Z-stick, HS phone, Way2Call

          Comment


          • #6
            Replaced the original script in first post with an improved version that uses a virtual device to enable/disable the script.
            Fred

            HomeSeer Pro 3.0.0.478, HS3Touch, Zwave 3.0.1.252, Envisalink DSC 3.0.0.40, WeatherXML, Z-stick, HS phone, Way2Call

            Comment


            • #7
              Tom/Fred,

              sorry for the delay in responding. Thanks Fred for the ping... I've been traveling lately and had not gotten around to posting.

              My goal for the screensaver was to have a black screen, with the time and date on the screen. The problem I ran into was moving the text around the screen to prevent burn-in, and I didn't want to use the scrolling feature in HSTouch because it would be hard to read from across the room.

              I experimented with any of the actions available in HSTouch that sounded like they would work. For example, I tried the hide/show, enable/disable, etc. and none seem to work on a text element. So, I improvised and came up with an ugly workaround which I'll explain in a minute. I'm also including a picture of the finished product.

              I'll state that this works, but I'm hopeful that one of you would come up with something cleaner and/or better.

              Step 1. Layout.
              From the example illustration I provided, there are basically three blocks where the text is displayed. Each block is actually TWO text fields. The date is in blue an in smaller text on top, and the time is white, bigger text, on the bottom. I labeled my fields date_top, date_mid, and date_bottom, the same with time_top, time_mid, and time_bottom. Their initial values are all BLANK. In order to achieve positioning along the screen (such as left, middle, and right), I'm padding the time/date values with spaces. My goal was the text to fit, and start where the purple boxes are so as to give the "illusion" of left/center/right alignment. So in all, there are 9 possible positions for the date/time to be displayed.

              Step 2. trigger buttons
              I have a screen which is not visible with 9 buttons. Each button changes the elements text values of all elements EXCEPT for the one I need to blank, and then sets the selected element's text value to the corresponding date/time (and appropriate number of spaces for padding). Once all actions are set-up, clicking on each of these buttons makes the date/time display where I want it to.

              Step 3. From HS Touch, I had to create 9 events, each one simulating the button press corresponding to each of the 9 HSTouch buttons.
              Lastly, I created a script to randomly run one of the events. I was able to find a random script and adapted it for my use. This is what I came up with:

              Code:
               
               Sub Main()
               ' Initialize the random-number generator. 
              Randomize() 
               ' Generate random value between 1 and 9. 
              Dim value 
               value = CInt(Int((9 * Rnd()) + 1))
               If value = 1 then
               hs.TriggerEvent "Position UR"
              Elseif value = 2 then
               hs.TriggerEvent "Position LL"
              Elseif value = 3 then
               hs.TriggerEvent "Position LM"
              Elseif value = 4 then
               hs.TriggerEvent "Position LR"
              Elseif value = 5 then
               hs.TriggerEvent "Position ML"
              Elseif value = 6 then
               hs.TriggerEvent "Position MM"
              Elseif value = 7 then
               hs.TriggerEvent "Position MR"
              Elseif value = 8 then
               hs.TriggerEvent "Position UL"
              Else
               hs.TriggerEvent "Position UM"
              End If
              hs.WriteLog "Event", "The random value is " & value
               
              End Sub
              Step 4. Back to HS Touch
              Configure the "screensaver" screen to be the HEME screen (basically, the one the client displays WHEN the timeout occurs from the project preferences. Then go and place an invisible button on top of the whole screen with the click action to take you to your normal "home" screen. This means that when you touch the screensaver, it "wakes up", and takes you to the main screen.

              Let me know your thoughts and/or ideas on this.

              thanks,

              Marco


              So there you go... a working
              Attached Files

              Comment


              • #8
                Nice Marco, & thanks! What kind of tablet is that and how did you mount it. Looks like you went into drywall?


                Sent from my iPhone
                Tom
                baby steps...starting again with HS3
                HS3Pro: Z-NET & 80 Z wave Devices,
                HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
                Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
                In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
                System: XP on Fanless Mini-ITX w/ SSD

                Comment


                • #9
                  http://www.cnsibo.cc/manufacturer-90...ome-automation

                  They make a wall-mounted android tablet. Bought 4 of them for my home. I also bought 2 tabletop units. Not super cheap, but pretty decent. I got the POE versions to make the cabling clean.

                  they are available on alibaba.

                  Comment


                  • #10
                    Oh yes sibo, the manufacture of the hs3 tabletop units. It looks very clean and nice on your wall. Nice job!


                    Sent from my iPhone
                    Tom
                    baby steps...starting again with HS3
                    HS3Pro: Z-NET & 80 Z wave Devices,
                    HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
                    Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
                    In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
                    System: XP on Fanless Mini-ITX w/ SSD

                    Comment


                    • #11
                      Really nice, Marco! What method are you using to update the date/time into the field? Maybe you could post just one of your events as an example?

                      Thanks!
                      Fred

                      HomeSeer Pro 3.0.0.478, HS3Touch, Zwave 3.0.1.252, Envisalink DSC 3.0.0.40, WeatherXML, Z-stick, HS phone, Way2Call

                      Comment


                      • #12
                        This is a frustrating defect with HSTouch.

                        Text does not hide/unhide when using a time and date script (I guess because it is updating)

                        Code:
                        [$TIME=hh:mm tt]
                        Code:
                        [$TIME=dd MMMM yy]
                        Therefore you can hide/unhide pictures and static text.
                        But time and date script text must be SET to an empty field, clear does not work either.

                        Good tutorial by Marco
                        and thanks Fred for the script - I use it which now makes the screen go blank or run a screensaver and I can use a toggle button from the settings page to control the virtual device "HSTouch Screensaver".
                        Last edited by smokeycoles; July 30th, 2016, 08:47 AM.

                        Comment

                        Working...
                        X