Announcement

Collapse
No announcement yet.

Script create device

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

    #16
    It's been like that from day 1. If you don't want to set the interface property, just set the device string with an image as stated previously.
    Jon

    Comment


      #17
      Wish I'd come across this thread a few weeks ago. It would have saved me many hours of digging, searching and experimenting with the sample plugins.
      Real courage is not securing your Wi-Fi network.

      Comment


        #18
        What is the syntax for writing a set of Status text from a script. I've created the device to hold a list now I'd like to put them into the device so I can use that device to populate a drop down list.
        Don

        Comment


          #19
          Originally posted by donstephens View Post
          What is the syntax for writing a set of Status text from a script. I've created the device to hold a list now I'd like to put them into the device so I can use that device to populate a drop down list.
          I have lost you a bit I am afraid Don in terms of what you are trying to do, if you are trying to set the device to show a particular status then you need to set the device value to that particular value for the status and it will then show that status.

          Comment


            #20
            Yeah, I have a bad habit of poor descriptions.

            I have a device called XM Music Selector that has a drop down list of stations. I have a script that pulls the station names and numbers from a database and I'd like to populate the drop down list with the station names. I'm trying to convert a script that I had in HS2 but the architecture is so much different than HS3.

            Hopefully that is a bit clearer...

            Thanks for the look.
            Don

            Comment


              #21
              Right it can get a bit terrifying here and I don't always know this myself - I take it that you are expecting this list to change and/or the list is too large to do manually? Some times that is just easier but if not then you will need to look at adding each as a separate Value/Status pair. I would suggest going through the database and trying to add them on each iteration of the database reader and then something like this (not tested at all) every time you have a record. You might be able to shortcut it if you already have a station number but I would ensure that the number is formatted correctly/converted to an integer.

              Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
              Pair.PairType = VSVGPairType.SingleValue
              Pair.Value = StationNumber
              Pair.Render = Enums.CAPIControlType.Single_Text_from_List
              Pair.Status = "Station Name"
              hs.DeviceVSP_AddPair(dv.Ref(hs), Pair)

              Post what you have if you struggle might be able to help...

              Comment


                #22
                Here is a bit of my code; it chokes on the first pair statement. This sub is called everytime I loop through the database

                PHP Code:
                Sub ModDev(station As String)

                    
                Dim myRef As Integer hs.GetDeviceRefByName("Home Theater XM Music Selector")
                    
                Dim i As Integer 0

                    
                If myRef 0 Then
                        hs
                .Writelog(ID"Found Station " station " , Populating")

                        
                Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both'errors here

                        REM Pair.PairType = VSVGPairType.SingleValue
                        REM Pair.Value = StationNumber
                        REM Pair.Render = Enums.CAPIControlType.Single_Text_from_List
                        REM '
                Pair.Status "Station Name"
                        
                REM Pair.Status station
                        REM hs
                .DeviceVSP_AddPair(dv.Ref(hs), Pair)
                        
                    
                REM Else
                        
                REM hs.Writelog(ID"Can not find Device Home Theater XM Music Selector")
                        
                REM Exit Sub
                    End 
                If

                End Sub 
                I commented out stuff until I found the offending line, which gives the following errors (must be Swahili, makes no sense to me)

                PHP Code:
                Mar-22 3:12:48 PM         Error    Compiling script C:\HomeSeer HS3\scripts\XMButton.vb'Pair' is a type and cannot be used as an expression.
                Mar-22 3:12:48 PM         Error    Compiling script C:\HomeSeer HS3\scripts\XMButton.vbVariable 'arrData' is used before it has been assigned a valueA null reference exception could result at runtime.
                Mar-22 3:12:48 PM         Error    Compiling script C:\HomeSeer HS3\scripts\XMButton.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn'use any aliases
                Any suggestions?

                Thanks
                Don

                Comment


                  #23
                  Perhaps:

                  Code:
                  Dim Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
                  or

                  Code:
                  Dim Pair As VSPair
                  Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)

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

                  Comment


                    #24
                    Now, that's embarrassing... humble pie.

                    Thanks Al and Adam

                    Script did populate device. On to breaking something else.
                    Last edited by donstephens; March 22, 2015, 05:29 PM.
                    Don

                    Comment


                      #25
                      Al is on the money, something like this should do what you are after I think, it adds the values and I get the drop list

                      Code:
                      'Insert Any Comments Here
                      
                      Sub Main(ByVal Parm As Object)
                      
                          Try
                              Dim TitleString() As String = {"Radio 1", "Radio 2", "Radio 3", "Radio 4"}
                              Dim i As Byte = 0
                              Dim dvRef As Integer = 6476
                              Dim Pair As VSPair
                      
                      
                              For Each StationName As String In TitleString
                      
                                  Log("Adding StationName: " & StationName & " Value: " & i)
                      
                                  Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
                                  Pair.PairType = VSVGPairType.SingleValue
                                  Pair.Value = i
                                  Pair.Render = Enums.CAPIControlType.Single_Text_from_List
                                  Pair.Status = StationName
                                  hs.DeviceVSP_AddPair(dvRef, Pair)
                      
                                  i += 1
                              Next
                              
                      
                          Catch ex As Exception
                              Log("Exception: " & ex.Message.ToString)
                          End Try
                      
                      End Sub
                      
                      Sub Log(ByVal ParStr As String)
                          hs.writelog("Startup", ParStr)
                      End Sub

                      Comment

                      Working...
                      X