No announcement yet.

Smooth volume - Best with an Event, IR Repeating or ASP loop?

  • Filter
  • Time
  • Show
Clear All
new posts

    Smooth volume - Best with an Event, IR Repeating or ASP loop?

    Hi guys,
    Just a post to get peoples opinions and experiences.
    I'm looking to get smooth volume (and later channel up/down) control on my TV's using an iTach in combination with an HTML/Ajax/ASP web solution (I don't like HS Touch, too buggy), and I've been thinking about a few different methods and wanted to get peoples opinions based on what they experienced.

    So what do people think works best:
    - An event that I call on an onMouseDown, and kill the IR's using an onMouseUp.
    - A Larger repeat count on the IR signal and kill it on the onMouseUp (problem here is, do you set the count to 100 or 25, if you do 25 and you want to make a larger adjustment, you have to press the button again)
    - An asp Do or For loop that runs based on a variable set to True onMouseDown, but False onMouseDown (I foresee problems with properly executing this, don't know why).

    Also, on any sort of loop, do I essentially slow down the repeat of the signal, I'm concerned sending too many commands in a short amount of time, essentially hanging up the system or causing other problems.

    Thanks, I appreciate the input,


    I have no first-hand experience, but my opinion would be to use an Event and *maybe* couple it with scripting. My reason for the Event method is because it has the "Do not retrigger for xx seconds" *and* you could enforce a Max/Min amount for volume.
    HS4Pro on a Raspberry Pi4
    54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
    Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

    HSTouch Clients: 1 Android


      Makes sense, based on the Global Cache manual, it'll probably be a combination of an event and a low amount of the repeatcount in the sinal itself.



        So the one thing I'm not figuring out is how to loop the event while the button is pressed (or how at all) and stop it when released.

        I seem to have to do it by running a script, but I'm having problems passing the variables (I wish you could just log / trace how variables are coming in, rather than to have to guess)

        Additionally, how do I post a variable to a script that's already running, since re-sending a command to the script seems to run a second instance of the script.

        Perhaps I should look at Global Variables?


          Not sure how you would execute multiple events on the HS server based on the client holding down a button. I would like to know how this is accomplished
          HS4Pro on a Raspberry Pi4
          54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
          Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

          HSTouch Clients: 1 Android


            Just a quick update,
            I am having success, but I'm telling an html file to access an ASP file that then speaks to a script in Homeseer in combination with a virtual device that acts as a global variable, since this seems to be the only way to really do this.

            I'm wondering if I should just move the script to the ASP since I am essentially adding an extra step.

            Another problem I'm running into is that mobile browsers don't like the finger to stay pressed, they give nasty pop-ups asking to save the image etc.

            Once I figure out a bypass to this pesky little problem, I'll upload the code.


              OK, I managed to get this done early last week, just hadn't had the time to clean up the code.

              I looked at examples / board questions of a lot of people, so just a general shout out to everybody that's helping other people out on the web with their questions.

              As far as what I did, I created a virtual device that I set to be ON or OFF, using this as a global variable for my loop script to check if it should keep running.

              Then using jquery mobile ( I managed to bypass the touch screen issues I had, so thanks to those guys for working so hard to get that nice piece of scripting together.

              What you need:
              - Jquery (.js download from
              - Jquery mobile (download .js and .css from

              There are 3 scripts:

              -- 1 remote.html --

              <!DOCTYPE html>
              <title>Volume Testing</title>
              <meta name="viewport" content="width=device-width, initial-scale=1">
              <link rel="stylesheet" href="" />
              <script src="jquery-1.7.1.min.js"/></script>
              <script src=""/></script>

              <!-- Using jQuery Mobile, for explenation of the div tags and all additional attributes, please check -->


              <div data-role="page">

              <div data-role="header">
              <h1>Samsung TV</h1>
              </div><!-- /header -->

              <div data-role="content">
              <p>Volume Control Test</p>

              <table border="0" cellpadding="0" cellspacing="0">
              <td>Volume Up:&nbsp;</td><td><button type="button" id="SamsungVolUp" data-theme="a" data-icon="arrow-u" data-inline="true" data-iconpos="top"></button></td></tr>
              <td>Volume Down:&nbsp;</td><td><button type="button" id="SamsungVolDown" data-theme="a" data-icon="arrow-d" data-inline="true" data-iconpos="bottom"></button></td></tr>
              <script type="text/javascript">
              // the functions neeed to go into the bottom of the div tag, if they go into the head, jquery mobile will ignore them, hence, a script per button (unfortunately)
              // touchstart, touchend and touchcancel are jquery mobile versins for when you start or stop touching the touchscreen
              // for a mouse/desktop interface, use vmousedown vmouseup and vmousecancel.
              $("#SamsungVolUp").bind('touchstart touchend touchcancel', function (event) {
              if (event.type == 'touchstart') {
              url: "script.asp?GlobalVar=A1&Action=ON&Equipment=Samsung_TV&irCo mmand=Volume_Up",
              // executing script.asp, sending variables Globalvar (the virtual device, in my case, A1, equipment as it is in the IR setups for Homeseer, mine is called 'Samsung TV'
              // but I have to add the underscore for Homeseer to recognize it, and the IR Command as set in Homeseer, here it's 'Volume Up', again, having to add an underscore.
              } else if (event.type == 'touchend'){
              url: "script.asp?GlobalVar=A1&Action=OFF&Equipment=&irCommand =",
              // turning off the GlobalVar, thus stopping the loop in the script.
              } else if (event.type == 'touchcancel'){
              url: "script.asp?GlobalVar=A1&Action=OFF&Equipment=&irCommand =",

              $("#SamsungVolDown").bind('vmousedown vmouseup vmousecancel', function (event) {
              if (event.type == 'vmousedown') {
              url: "script.asp?GlobalVar=A1&Action=ON&Equipment=Samsung_TV&irCo mmand=Volume_Down",
              } else if (event.type == 'vmouseup'){
              url: "script.asp?GlobalVar=A1&Action=OFF&Equipment=&irCommand =",
              } else if (event.type == 'vmousecancel'){
              url: "script.asp?GlobalVar=A1&Action=OFF&Equipment=&irCommand =",
              </div><!-- /content-->

              </div><!-- /page -->


              -- 2 script.asp --

              ' Pulling the variables from ajax, based on the url to this script
              ' (as sent through the url: "script.asp?Equipment=" + Equipment + "&irCommand=" + irCommand," command

              GlobalVar = Request.QueryString("GlobalVar")
              Action = Request.QueryString("Action")
              Equipment = Request.QueryString("Equipment")
              irCommand = Request.QueryString("irCommand")

              ' If we're turning the volume to 'on', we need to set the Global Variable as well as execute the script.
              If Action = "ON" then
              hs.Transmit GlobalVar,Action

              ' sending the variables to homeseer
              ' repeatIR.vb is the homeseer script I'm executing
              ' volume is the function within that script
              ' DeviceCode and Action are what is needed for the IR Command as set up in the Global Cache Infrared Signals page
              ' and HomeSeer/Tools/Infrared Signals page. BE SURE TO REPLACE SPACES WITH UNDERSCORES
              ' three quotes are needed because the string needs to see the quotes as a character
              ' and asp needs two quotes to show up as one as a string
              ' the ; between the variables will be used in the hs script to split the variables appart again
              ' this can be anything you want, as long as the used character matches in both scripts
              hs.Run ("repeatIR.vb(""volume"","""+GlobalVar+";"+Equipment+";"+irC ommand+""")")

              ' Otherwise, we only need to change the variable.
              hs.Transmit GlobalVar,Action
              End If


              -- 3 repeatIR.vb --

              '''''' This is line 14 - for debugging purposes, anything in the homeseer log starts 14 lines in (for some stupid reason)
              '' Put this script in the Homeseer/Scripts folder

              ' bringing the variables from asp into the function using p

              function volume(p)

              ' splitting the variables from p into individual variables using an array and ; (this could be any character you want, as long as it matches in the asp string)
              dim arrP = Split(p, ";")
              dim GlobalVar = arrP(0)
              dim Equipment = arrP(1)
              dim irCommand = arrP(2)

              ' setting additional variables
              dim GVarStat as Integer
              dim LoopTime as Integer = 0 'used for debugging purposes

              ' debugging steps here = converting device status into a string so you can call it through the hs.speak method
              ' Getting the status of the GlobalVar, we just need to know if it's 2 (on) or 3 (off).
              ' It comes as an integer so we to make it a string for debugging purposes. Once the full script is in place, we can comment this out.
              ' dim GVarStat as Integer = hs.DeviceStatus (GlobalVar)
              ' dim GVar
              ' If GVarStat = 2 Then
              ' GVar = "On"
              ' ElseIf GVarStat = 3 Then
              ' GVar = "Off"
              ' Else
              ' GVar = "Unknown"
              ' End If
              ' hs.speak ("device is "+GVar)

              ' Looping the IR while the button is pressed (device/GVarStat is on), stopping when you release the screen (device/GVarStat is off)
              GVarStat = hs.DeviceStatus (GlobalVar)

              If GVarStat = 2 Then
              ElseIf GVarStat = 3 Then
              Exit Do
              End If
              Loop while GVarStat = 2

              end function


              That's it, should work just fine for anybody as long as you have all the IR commands set up in homeseer.


                Pretty cool - using jquery/ajax to handle?
                HS4Pro on a Raspberry Pi4
                54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                HSTouch Clients: 1 Android


                  Yup, using ASP and VB as a middle man.
                  Easy enough to convert for regular toggle switches too, just replace the loop with an if/then statement.