No announcement yet.

Script for 2-way volume over serial?

  • 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:

    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))
    End Sub
    Pass the new volume in the event to the script and then
    HS 1990 Devices 1172 Events
    Z-Wave 126 Nodes on one Z-Net


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