Announcement

Collapse
No announcement yet.

Help setting VS/VG pairs in existing devices via script

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

    Help setting VS/VG pairs in existing devices via script

    I have about 100 devices created by a plug-in. These devices can have one of three values assigned to them. I would like to set the same status text and graphics to all of them.

    Since I am very weak at scripting I would appreciate some help. I don't want to automate all of them at once, but would like to pass a RefID to a script and have that script assign the text and graphics to the three values at once. Running the script manually on each device would still be less tedious than setting the devices manually one by one.
    HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

    #2
    Hi Randy,

    Here's a sub-routine that I have used for creating VS/VG pairs. The subroutine requires 7 parameters to be passed to it. They should all be self-explanatory, but if not, let me know.

    Cheers
    Al

    Code:
    Sub CreateVSVG(ByVal Parms As String)
    
    	Dim ParmArray() As String = Parms.tostring.split(",")		'split parameter into an array
    	Dim refDev As Integer = CInt(ParmArray(0))		' dev code
    	Dim vsName As String = ParmArray(1)		
    	Dim vsValue As Integer = CInt(ParmArray(2))		
    	Dim row As Integer = Cint(ParmArray(3))
    	Dim col As Integer = Cint(ParmArray(4))
    	Dim colspan As Integer = Cint(ParmArray(5))
    	Dim iconName As String = ParmArray(6)		
    
    	dim GPair as VGPair
    	dim SPair as VSPair
    
    	SPair = New VSPair (HomeSeerAPI.ePairStatusControl.Both)
    	SPair.PairType = VSVGPairType.SingleValue
    	Spair.Render_Location.Row = row
    	Spair.Render_Location.Column = col
    	Spair.Render_Location.ColumnSpan = colspan
    	Spair.Value = vsValue
    	Spair.Status = vsName
    		
    	If iconName > "" Then 
    		Spair.Render = 5
    		Spair.PairButtonImageType = 1
    		GPair = New VGPair
    		GPair.PairType = VSVGPairType.SingleValue
    		GPair.Set_Value = vsValue
    		GPair.Graphic = "/images/wdtv/remote/" & iconName & ".png"
    		hs.DeviceVGP_AddPair(refDev, GPair)
    	End If 
    	hs.DeviceVSP_AddPair(refDev, SPair)
    
    end sub
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      Originally posted by sparkman View Post
      Hi Randy,

      Here's a sub-routine that I have used for creating VS/VG pairs. The subroutine requires 7 parameters to be passed to it. They should all be self-explanatory, but if not, let me know.

      Cheers
      Al
      Thanks. It all makes sense to me. I'll give it a go in a little bit. I'll post back if any questions.
      Last edited by randy; March 19, 2017, 04:17 PM.
      HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

      Comment

      Working...
      X