Announcement

Collapse
No announcement yet.

Find all possible values of a device

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

    #16
    Here's the piece in Tink's script that I thought could do what you needed:

    Code:
        Dim arrCC() As HomeSeerAPI.CAPI.CAPIControl = Nothing
        Try
            arrCC = hs.CAPIGetControl(dvRef)
        Catch ex As Exception
            arrCC = Nothing
        End Try
    
        If arrCC Is Nothing Then
            Log("ControlDeviceNameAndLabelValue", "No CAPI Controls were found in " & hs.DeviceName(dvRef), COLOR_RED)
            Exit Sub
        End If
    
        Dim Resp As HomeSeerAPI.CAPI.CAPIControlResponse = HomeSeerAPI.CAPIControlResponse.Indeterminate
        Dim CC As HomeSeerAPI.CAPI.CAPIControl = Nothing
    
        Dim Found As Boolean = False
        For Each CC In arrCC
            If CC Is Nothing Then Continue For
            If CC.Label Is Nothing Then Continue For
            If GotValue Then
                If CC.Range IsNot Nothing Then
                    If Value >= CC.Range.RangeStart AndAlso Value <= CC.Range.RangeEnd Then
                        Found = True
                        Exit For
                    End If
                Else
                    If CC.ControlValue = Value Then
                        Found = True
                        Exit For
                    End If
                End If
            Else
                If CC.Label.Trim.ToLower = Label.Trim.ToLower Then
                    Found = True
                    Exit For
                End If
            End If
        Next
    This will only return the possible values that can be controlled.

    Cheers
    Al
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #17
      Thanks for the post Al. Adam's example is a great start for me. Tink's code is just too overwhelming for a rookie like me.

      I really appreciate you guys helping.
      Don

      Comment


        #18
        To satisfy my own curiosity to see if it would work with Tink's methods, I created a complete script using the CAPI commands that prints all the Status-Value pairs to the log that have a Status-Control of Both or just Control. To use the script just pass the device reference to it from an event.

        Code:
        Sub Main(ByVal Parm As String)
        	Dim Debug As Boolean = False
        	Dim logName As String = "Find All CAPI"
        	Dim arrCC() As HomeSeerAPI.CAPI.CAPIControl = Nothing
        	Dim CC As HomeSeerAPI.CAPI.CAPIControl = Nothing
        	Dim dvRef As Integer
        	Try
        		dvRef = CInt(Parm)
        		arrCC = hs.CAPIGetControl(dvRef)
        
        		For Each CC In arrCC
        			If CC IsNot Nothing And CC.Label IsNot Nothing Then hs.writelog(logName,CC.Label & " (" & CStr(CC.ControlValue) & ")")
        		Next
        	Catch ex As Exception
        		hs.WriteLog(logname, "Exception " & ex.ToString)
        	End Try
        End Sub
        Cheers
        Al
        HS 4.2.8.0: 2134 Devices 1252 Events
        Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

        Comment


          #19
          Sweet! I've been trying to pull both the values and labels from Adam's example.

          I owe you one.

          Thanks
          Don

          Comment

          Working...
          X