Announcement

Collapse
No announcement yet.

Script for 2-way volume over serial?

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

  • Script for 2-way volume over serial?

    I'm controlling an old Rotel preamp via serial with drhsIPplugin. I'm reading the output from the receiver and pushing it into a virtual device - range from 0-80 or something like that. I'm using a "Vol Up" and "Vol Dn" event because there is no "go to volume NN" option available. In theory, it seems like I should be able to take the target volume (say, 52) and find how far above or below the current volume is then send the appropriate amount of "up" or "down" commands until the feedback is the requested number. Except that I'm terrible with scripts / code. My only shot is to take apart something similar and make it work; and I haven't found something similar yet. Help?

  • #2
    You could do something like this:

    Code:
    Sub Main(ByVal NewVolumeStr As String)
        Dim Debug As Boolean = True
        Dim logName As String = "Volume"
    
        Dim OldVolume As Integer = hs.devicevalue(xxxx) 'replace xxxx with reference ID of the device that holds the current volume
        Dim NewVolume As Integer = CInt(NewVolumeStr)
        Dim VolumeStep As Integer = 1
        If NewVolume < OldVolume Then VolumeStep = -1
        If Debug Then hs.writelog(logName,"Old Vol:" & CStr(OldVolume))
        If Debug Then hs.writelog(logName,"New Vol:" & CStr(NewVolume))
        If Debug Then hs.writelog(logName,"Vol Step:" & CStr(VolumeStep))
    
        Dim i As Integer = 0
        For i = OldVolume To NewVolume Step VolumeStep
            'code to set volume
            If Debug Then hs.writelog(logName,"Cur Vol:" & CStr(i))
        Next
    
    End Sub
    Pass the new volume in the event to the script and then
    HS 3.0.0.548: 1976 Devices 1156 Events
    Z-Wave 3.0.1.262: 123 Nodes on one Z-Net

    Comment


    • #3
      sparkman , that should get me started. Thank you. I'll start tinkering!

      Comment

      Working...
      X