Announcement

Collapse
No announcement yet.

Find all possible values of a device

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

    Find all possible values of a device

    I know how to find the current value of a device, but would like to find all the possible values.

    I'm butchering together a script that will take an input of say 'TV off' and send a numeric string, like '53' to the plugin via

    Dim bSuccess as Boolean = hs.PluginFunction("UltraGCIR3", "", "SendIRById", New Object() {controlId})

    where the value is plugged into the controlId

    Is this possible?
    Don

    #2
    You mean like a list from a string? Something like this can do it;

    Code:
    Dim InputStr As String = "TV Off"
    Dim ControlID As Byte = 0
    
    Select Case InputStr
    Case "TV Off" : ControlID = 52
    Case "TV On" : ControlID = 53
    Case "TV Mute" : ControlID = 54
    End Select
    
    Dim bSuccess as Boolean = hs.PluginFunction("UltraGCIR3", "", "SendIRById", New Object() {ControlID})

    Comment


      #3
      Something like that Adam, but I was hoping to put all the possible value pairs into a couple of arrays, such that I wouldn't have to hard code all the possible values from the device. Does that make sense?


      Originally posted by mrhappy View Post
      You mean like a list from a string? Something like this can do it;

      Code:
      Dim InputStr As String = "TV Off"
      Dim ControlID As Byte = 0
      
      Select Case InputStr
      Case "TV Off" : ControlID = 52
      Case "TV On" : ControlID = 53
      Case "TV Mute" : ControlID = 54
      End Select
      
      Dim bSuccess as Boolean = hs.PluginFunction("UltraGCIR3", "", "SendIRById", New Object() {ControlID})
      Don

      Comment


        #4
        Originally posted by donstephens View Post
        Something like that Adam, but I was hoping to put all the possible value pairs into a couple of arrays, such that I wouldn't have to hard code all the possible values from the device. Does that make sense?
        I was thinking this may have been what you are after but was not sure that the VSPairs matched what the plugin was expecting, so if I am right you want to take a string and find which value that particular string label relates to on the device?

        My thinking would be;

        CAPIGetControl returns an array of the controls for a given device reference
        Go through each control until CAPIControl.Label matched your input string, then use CAPIControl.ControlValue to find the value and then pass it into the plugin.

        I am not sure DeviceVSP_GetAllStatus will work unless they are marked status/both as opposed to just control.

        I am not sure if this will work and I think you would need to be careful to match the string exactly for it to work but you could give it a go...

        Comment


          #5
          Ironically, I found one of your script examples that works great.

          Thanks.
          Don

          Comment


            #6
            So, I'm going nuts. I've figured this out and forgotten how.

            I have a new project that is trying to put all the possible values of a device into an array that I can randomly pick a value.

            I've been all over the device section of the scripting help page, but nothing pops up.

            Anyone have a lead for me?

            Thanks (embarrased old f#rt)
            Don

            Comment


              #7
              Bump
              Don

              Comment


                #8
                Originally posted by donstephens View Post
                Bump
                Hey Don, take a look at the script posted here: https://forums.homeseer.com/showpost...5&postcount=10. It should contain code to do what you want. If not, I can take a look this weekend for something.

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

                Comment


                  #9
                  Thanks Al;

                  Took a look at Tink's code and wow. I think I'll need to spend some time with this.
                  Last edited by donstephens; March 2, 2017, 11:41 PM.
                  Don

                  Comment


                    #10
                    After looking at this, I can't make heads or tails out of it. Tried running the subs, got nowhere. If you have a simpler example, I'd love to see it.

                    Thank you
                    Don

                    Comment


                      #11
                      Just thinking here Don but if you weren't aware that HS3 you can set the device value to anything that is a valid double (-1.79769313486232e308 to + 1.79769313486232e308!!), if you used hs.setdevicevalue on a device and gave it a ridiculous value then the value should change on the device - the thing is whether or not HS has a corresponding value/status pair for that particular value. If you change the value to something that is outside the defined values then IIRC it will just appear blank as it does not know how to represent it.

                      Trying to get a list of valid status pair values should be possible, however looking at the help file I am unsure if that functionality is complete, there is DeviceVSP_GetAllStatus which appears to get either pairs defined as status or both but there does not appear to be a GetAll or a GetAllControl unless it has not been documented. As such you would be reliant on the devices you wished to test not being set to control only, if you did try that then you could look through all the status pairs, check whether the pairs are single/range values and then populate a list of values.

                      Comment


                        #12
                        OK, Ill look into that.

                        Thanks
                        Don

                        Comment


                          #13
                          Thanks for locating that function. I should have found it...
                          PHP Code:
                          Dim ref As Integer 2065
                              Dim MyPair 
                          As Object
                              hs
                          .WriteLog("TEST","The Device " hs.DeviceName(ref) & " has " hs.DeviceVSP_CountAll(ref) & " pairs")
                              
                          MyPair hs.DeviceVSP_Get(ref)
                              
                              If 
                          MyPair Is Nothing OrElse MyPair.Length 1 Then
                                  hs
                          .WriteLog("Error","No pairs are assigned to device " hs.DeviceName(ref))
                                  Exit 
                          Sub
                              End 
                          If
                              For 
                          Each P As VSPair In MyPair
                                  
                          '...
                              Next 
                          I ahve been trying to run the example but if errors on the statement below saying'MyPair is not declared.
                          PHP Code:
                          MyPair hs.DeviceVSP_Get(ref
                          Do you have any idea what it should be declared as?

                          Thanks again.
                          Don

                          Comment


                            #14
                            Try this...not your fault because the help file is wrong and appears to be using an example for another command.

                            Code:
                            Sub Main(ByVal Parms As Object)
                            
                                Try
                            
                                Dim ref As Integer = 1729 
                                Dim MyPairs() As VSPair
                            
                                hs.WriteLog("ValueCheck","The Device " & hs.DeviceName(ref) & " has " & hs.DeviceVSP_CountAll(ref) & " pairs")
                            
                                MyPairs = hs.DeviceVSP_GetAllStatus(ref) 
                                  
                                For Each P As VSPair In MyPairs
                            
                                    If P.PairType = 1 Then
                                        hs.writelog("ValueCheck", "-> Single Value Pair")
                                        hs.writelog("ValueCheck", "--> Value For This Pair: " & P.Value)
                                    ElseIf P.PairType = 2 Then
                                        hs.writelog("ValueCheck", "-> Range Value Pair")
                                        hs.writelog("ValueCheck", "--> START Value For This Pair: " & P.RangeStart)
                                        hs.writelog("ValueCheck", "--> END Value For This Pair: " & P.RangeEnd)
                                    Else
                                        hs.writelog("ValueCheck", "-> Other Value Pair")
                                    End If
                                    
                                Next  
                            
                                Catch ex As Exception : hs.writelog("ValueCheck", "Exception: " & ex.message)
                                End Try
                            
                            End Sub
                            I've checked and it will only get pairs that are set to be status or both (not control only) and I've also checked through Visual Studio that there is no DeviceVSP_GetAll or DeviceVSP_GetAllControl so I'm not sure if this is functionality that has been not added deliberately or just missed.

                            Comment


                              #15
                              Thanks! I never thought the docs would be wrong, or looking in VS.

                              So appreciate it.
                              Don

                              Comment

                              Working...
                              X