Announcement

Collapse
No announcement yet.

Sample Creating a Device

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Originally posted by Rick Tinker View Post
    Wade I think is working on a simplification of the Sample plug-in (thanks Wade) but for those of you having trouble with device creation, let me see if this sample code snippet helps...

    It is also as a VB module in the enclosed zip so you can add it to a plug-in and view it in all its full color glory (and copy/paste as desired!)


    Code:
            Dim dvRef As Integer
            Try
                dvRef = hs.NewDeviceRef("My Device Name")
            Catch ex As Exception
                dvRef = -1
            End Try
            If dvRef < 1 Then
                ' Log an error
                Exit Sub
            End If
    
            ' Force HomeSeer to save changes to devices and events so we can find our new device
            hs.SaveEventsDevices()
    
            ' Get the new device.
            Dim dv As Scheduler.Classes.DeviceClass = Nothing
            Try
                dv = hs.GetDeviceByRef(dvRef)
            Catch ex As Exception
                dv = Nothing
            End Try
            If dv Is Nothing Then
                ' Log an error
                Exit Sub
            End If
    
            ' Make the value/status pairs show drop-down control options.
            dv.MISC_Set(hs, Enums.dvMISC.SHOW_VALUES)
    
            dv.Location(hs) = "My Plugin Location"
            dv.Location2(hs) = "First Floor"
            dv.Interface(hs) = IFACE_NAME
            dv.InterfaceInstance(hs) = "Instance, if applicable"
            dv.Address(hs) = "XYZ-04-PDQ"
            dv.Code(hs) = hs.GetNextVirtualCode
    
            Dim DT As New DeviceTypeInfo
            DT.Device_API = DeviceTypeInfo.eDeviceAPI.Security
            DT.Device_Type = DeviceTypeInfo.eDeviceType_Security.Keypad
            DT.Device_SubType = 4
            DT.Device_SubType_Description = "Keypad Address 4"
            dv.DeviceType_Set(hs) = DT
            dv.Device_Type_String(hs) = IFACE_NAME & " Keypad"
    
            ' Make sure we can have control options on this device by verifying that the status only bit is cleared.
            dv.MISC_Clear(hs, Enums.dvMISC.STATUS_ONLY)
            ' Also make sure that the option to prevent the value/status pairs from displaying as trigger options is cleared.
            dv.MISC_Clear(hs, Enums.dvMISC.NO_STATUS_TRIGGER)
    
    
            ' Mark the device that we can be polled for status.
            dv.Status_Support(hs) = True
    
            ' Make sure our device's string value is not set, as that will override the value/status pairs:
            hs.SetDeviceString(dvRef, "", False)
    
            ' This device is a child device, the parent being the root device for the entire security system. 
            ' As such, this device needs to be associated with the root (Parent) device.
            If dvParent.AssociatedDevices_Count(hs) < 1 Then
                ' There are none added, so it is OK to add this one.
                dvParent.AssociatedDevice_Add(hs, dvRef)
            Else
                Dim Found As Boolean = False
                For Each ref As Integer In dvParent.AssociatedDevices(hs)
                    If ref = dvRef Then
                        Found = True
                        Exit For
                    End If
                Next
                If Not Found Then
                    dvParent.AssociatedDevice_Add(hs, dvRef)
                Else
                    ' This is an error condition likely as this device's reference ID should not already be associated.
                End If
            End If
    
            ' Now, we want to make sure our child device also reflects the relationship by adding the parent to
            '   the child's associations.
            dv.AssociatedDevice_ClearAll(hs)  ' There can be only one parent, so make sure by wiping these out.
            dv.AssociatedDevice_Add(hs, dvParent.Ref(hs))
    
            ' Now, let's store some information our plug-in uses in the device...
            Dim PData As clsPlugExtraData = Nothing
            PData = dv.PlugExtraData_Get(hs)
            If PData Is Nothing Then PData = New clsPlugExtraData
            ' I am going to store the security keypad codes in the device - nobody would think to look there! 
            PData.AddNamed("KeyPadData", SecurityData)
            ' Now we need to put the data back...
            dv.PlugExtraData_Set(hs) = PData
    
            ' OK, now we need to add our status and control pairs....
            ' In this part of the demo, we are going to set it up as if it were something that shows us 
            '   the temperature, but has a control option for requesting a temperature update, just to make it
            '   interesting because I could not think of a good example for a 'range' value/status pair continuing
            '   with the security system example!
            Dim Pair As VSPair = Nothing
            Dim GPair As VGPair = Nothing
    
            ' First, clear away anything that was put there by default by HomeSeer
            hs.DeviceVSP_ClearAll(dvRef, True)
    
            ' This pair will display the temperature.
            Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Status)
            Pair.PairType = VSVGPairType.Range
            Pair.RangeStart = -500  'This is a bit chilly
            Pair.RangeEnd = 1000  'This is pretty warm!
            Pair.RangeStatusPrefix = ""
            Pair.RangeStatusSuffix = " " & VSPair.ScaleReplace
            Pair.IncludeValues = True
            Pair.ValueOffset = 0
            Pair.HasScale = True
            If Not hs.DeviceVSP_AddPair(dvRef, Pair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding pair failed.", COLOR_RED)
    
            ' These two pairs will result in a control button (Update) being available, and when that is selected
            '   the status will change to "Getting Temperature..." until a new temperature is set.
            Pair = New VSPair(ePairStatusControl.Control)   ' This is what appears in the device actions...
            Pair.PairType = VSVGPairType.SingleValue
            Pair.Render = VSVGPairRender.Button
            Pair.Status = "Update"
            Pair.Value = -1000 ' This is outside the range used by temperature.
            If Not hs.DeviceVSP_AddPair(dvRef, Pair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding pair failed.", COLOR_RED)
    
            Pair = New VSPair(ePairStatusControl.Status)  ' This is what appears for the status...
            Pair.PairType = VSVGPairType.SingleValue
            Pair.Status = "Getting Temperature..."
            Pair.Value = -1000 ' This is outside the range used by temperature.
            If Not hs.DeviceVSP_AddPair(dvRef, Pair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding pair failed.", COLOR_RED)
    
    
    
    
            ' Now, let's set up the graphics, but first we need to wipe out the HomeSeer defaults...
            hs.DeviceVGP_ClearAll(dvRef, True)
    
            ' We won't bother setting up a graphic for the -1000 value (update) as it should not be displayed for very long.
    
            ' Set up the ranges for Fahrenheit for the graphics.
            GPair = New VGPair()
            GPair.PairType = VSVGPairType.Range
            GPair.RangeStart = -50
            GPair.RangeEnd = 5
            GPair.Graphic = "/images/HomeSeer/status/Thermometer-00.png"
            If Not hs.DeviceVGP_AddPair(dvRef, GPair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding graphic pair failed.", COLOR_RED)
    
            GPair = New VGPair()
            GPair.PairType = VSVGPairType.Range
            GPair.RangeStart = 5.00000001
            GPair.RangeEnd = 15.99999999
            GPair.Graphic = "/images/HomeSeer/status/Thermometer-10.png"
            If Not hs.DeviceVGP_AddPair(dvRef, GPair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding graphic pair failed.", COLOR_RED)
    
            GPair = New VGPair()
            GPair.PairType = VSVGPairType.Range
            GPair.RangeStart = 16
            GPair.RangeEnd = 25.99999999
            GPair.Graphic = "/images/HomeSeer/status/Thermometer-20.png"
            If Not hs.DeviceVGP_AddPair(dvRef, GPair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding graphic pair failed.", COLOR_RED)
    
            GPair = New VGPair()
            GPair.PairType = VSVGPairType.Range
            GPair.RangeStart = 26
            GPair.RangeEnd = 35.99999999
            GPair.Graphic = "/images/HomeSeer/status/Thermometer-30.png"
            If Not hs.DeviceVGP_AddPair(dvRef, GPair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding graphic pair failed.", COLOR_RED)
    
            GPair = New VGPair()
            GPair.PairType = VSVGPairType.Range
            GPair.RangeStart = 36
            GPair.RangeEnd = 45.99999999
            GPair.Graphic = "/images/HomeSeer/status/Thermometer-40.png"
            If Not hs.DeviceVGP_AddPair(dvRef, GPair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding graphic pair failed.", COLOR_RED)
    
            GPair = New VGPair()
            GPair.PairType = VSVGPairType.Range
            GPair.RangeStart = 46
            GPair.RangeEnd = 55.99999999
            GPair.Graphic = "/images/HomeSeer/status/Thermometer-50.png"
            If Not hs.DeviceVGP_AddPair(dvRef, GPair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding graphic pair failed.", COLOR_RED)
    
            GPair = New VGPair()
            GPair.PairType = VSVGPairType.Range
            GPair.RangeStart = 56
            GPair.RangeEnd = 65.99999999
            GPair.Graphic = "/images/HomeSeer/status/Thermometer-60.png"
            If Not hs.DeviceVGP_AddPair(dvRef, GPair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding graphic pair failed.", COLOR_RED)
    
            GPair = New VGPair()
            GPair.PairType = VSVGPairType.Range
            GPair.RangeStart = 66
            GPair.RangeEnd = 75.99999999
            GPair.Graphic = "/images/HomeSeer/status/Thermometer-70.png"
            If Not hs.DeviceVGP_AddPair(dvRef, GPair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding graphic pair failed.", COLOR_RED)
    
            GPair = New VGPair()
            GPair.PairType = VSVGPairType.Range
            GPair.RangeStart = 76
            GPair.RangeEnd = 85.99999999
            GPair.Graphic = "/images/HomeSeer/status/Thermometer-80.png"
            If Not hs.DeviceVGP_AddPair(dvRef, GPair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding graphic pair failed.", COLOR_RED)
    
            GPair = New VGPair()
            GPair.PairType = VSVGPairType.Range
            GPair.RangeStart = 86
            GPair.RangeEnd = 95.99999999
            GPair.Graphic = "/images/HomeSeer/status/Thermometer-90.png"
            If Not hs.DeviceVGP_AddPair(dvRef, GPair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding graphic pair failed.", COLOR_RED)
    
            GPair = New VGPair()
            GPair.PairType = VSVGPairType.Range
            GPair.RangeStart = 96
            GPair.RangeEnd = 104.99999999
            GPair.Graphic = "/images/HomeSeer/status/Thermometer-100.png"
            If Not hs.DeviceVGP_AddPair(dvRef, GPair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding graphic pair failed.", COLOR_RED)
    
            GPair = New VGPair()
            GPair.PairType = VSVGPairType.Range
            GPair.RangeStart = 105
            GPair.RangeEnd = 150.99999999
            GPair.Graphic = "/images/HomeSeer/status/Thermometer-110.png"
            If Not hs.DeviceVGP_AddPair(dvRef, GPair) Then hs.WriteLogEx(IFACE_NAME & " Error", "Adding graphic pair failed.", COLOR_RED)
    is there something missing in this example? Where is dvParent being assigned?

    Dirk

    Comment


      #17
      Originally posted by dcorsus View Post
      is there something missing in this example? Where is dvParent being assigned?

      Dirk
      Think I figured it out. dvParent is supposed to be pointing to

      dvParent = hs.GetDeviceByRef(parentDevice)

      where parentDevice is the reference to the parent

      Dirk

      Comment


        #18
        Yes, dvParent is no different than dv - just the name I gave to an object that is DeviceClass.

        Note the AssociatedDevices calls - this is where the actual relationship is set up. The system does not prevent you from associating 5 devices to 5 other devices each, but what I refer to as a true parent/child relationship is where the parent is associated with all of the child devices (so its AssociatedDevices contains several entries) but each child only has one association, which is to the parent device.

        Code:
               ' This device is a child device, the parent being the root device for the entire security system. 
                ' As such, this device needs to be associated with the root (Parent) device.
                If dvParent.AssociatedDevices_Count(hs) < 1 Then
                    ' There are none added, so it is OK to add this one.
                    dvParent.AssociatedDevice_Add(hs, dvRef)
                Else
                    Dim Found As Boolean = False
                    For Each ref As Integer In dvParent.AssociatedDevices(hs)
                        If ref = dvRef Then
                            Found = True
                            Exit For
                        End If
                    Next
                    If Not Found Then
                        dvParent.AssociatedDevice_Add(hs, dvRef)
                    Else
                        ' This is an error condition likely as this device's reference ID should not already be associated.
                    End If
                End If
        Regards,

        Rick Tinker (a.k.a. "Tink")

        Comment


          #19
          Originally posted by Rick Tinker View Post
          Did you ever wonder where the programming language "C" got its name?
          Because the language it was based on was B.
          Wade

          sigpic

          website | products | support | youtube
          I know nothing...., nothing!!!

          Comment


            #20
            Originally posted by Sgt. Shultz View Post
            Because the language it was based on was B.
            Which was based upon A, but the point is, programmers do not like typing so they used a single letter for the new language they developed! Those whacky Bell Labs people...
            Regards,

            Rick Tinker (a.k.a. "Tink")

            Comment


              #21
              Actually, B was based on BCPL, which was in turn based on CPL. There was no A.
              Wade

              sigpic

              website | products | support | youtube
              I know nothing...., nothing!!!

              Comment


                #22
                Originally posted by Rick Tinker View Post
                Which was based upon A, but the point is, programmers do not like typing so they used a single letter for the new language they developed! Those whacky Bell Labs people...
                ... which is why even lazier programmers created IntelliSense.
                HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
                Running on Windows 10 (64) virtualized
                on ESXi (Fujitsu Primergy TX150 S8).
                WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

                Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

                Comment


                  #23
                  Originally posted by Sgt. Shultz View Post
                  Actually, B was based on BCPL, which was in turn based on CPL. There was no A.
                  I know nut-ting.... NUT-TING!!!! Harrrumph!
                  Regards,

                  Rick Tinker (a.k.a. "Tink")

                  Comment


                    #24
                    Standard On, Off btns and Dim Level Dropdown?

                    are these no longer created by default on new devices that are set to Enums.dvMISC.SHOW_VALUES

                    If i create a device manually from the ui, it creates an On and Off btn with a blank dropdown after that. What's that

                    so what's the recommended approach here:
                    Add my own On, Off and Range list?

                    how do i create a range that increments by 10?I don't want values 0 to 100 by 1s
                    Mark

                    HS3 Pro 3.0.0.534
                    Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
                    Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
                    Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

                    Comment


                      #25
                      Mark,

                      If the device is owned by a plug-in (Interface property is not empty) then HomeSeer will assign default value/status pairs.

                      Yes, you should set up your own. Here is some code you can copy - this sets up a Z-Wave device with standard options, so it is pretty close to the same as the HomeSeer standard device. The difference being that the HomeSeer device treats 100 as full on, and this treats 99 as full on, and 255 has a special meaning too. In fact, 255 has different text for the control button than what it shows for the status, so you can see how you can set up special situations like that - when you control a device to set it to the value 255, the button displays "On Last Level" (turns it on to the level it was last left at), but if the value read from the device is 255, it shows "On".

                      In this case here, just like with HomeSeer, I give it a single value range for the dim values and the HomeSeer UI takes care of creating the drop-down list. If the difference between the upper and lower end of the range is too large, HomeSeer automatically divides up the range into values that will allow for a drop-list that does not have too many values. If you wanted to do your own, you can do that, but keep in mind that if you set the values 5, 10, 15 etc. and then set the value to 7, it will not display a status. If you want 5, 10, 15 specifically and do want to be able to set values such as 7, then you create multiple range entries such as 0 through 4.999999, 5 through 9.999999, 10 through 14.999999 - etc. Look at the graphic pairs in the example below to see that.

                      The Default_VS_Pairs_AddUpdateUtil I can post if you need it but I think it is in the sample plug-ins. It just verifies that the pair does not already exist before adding it.


                      Code:
                                  Dim Pair As VSPair = Nothing
                                  Dim GPair As VGPair = Nothing
                      
                                  If Dimmable Then
                                      Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Control)
                                      Pair.PairType = VSVGPairType.SingleValue
                                      Pair.Value = 255
                                      Pair.Status = "On Last Level"
                                      Pair.Render = Enums.CAPIControlType.Button
                                      Pair.Render_Location.Row = 1
                                      Pair.Render_Location.Column = 3
                                      Default_VS_Pairs_AddUpdateUtil(zd.dvRef, Pair)
                      
                                      Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Status)
                                      Pair.PairType = VSVGPairType.SingleValue
                                      Pair.Value = 255
                                      Pair.Status = "On"
                                      Pair.Render = Enums.CAPIControlType.Button
                                      Pair.Render_Location.Row = 1
                                      Pair.Render_Location.Column = 2
                                      Default_VS_Pairs_AddUpdateUtil(zd.dvRef, Pair)
                      
                                      Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
                                      Pair.PairType = VSVGPairType.SingleValue
                                      Pair.Value = 99
                                      Pair.Status = "On"
                                      Pair.Render = Enums.CAPIControlType.Button
                                      Pair.Render_Location.Row = 1
                                      Pair.Render_Location.Column = 2
                                      Default_VS_Pairs_AddUpdateUtil(zd.dvRef, Pair)
                                  Else
                                      Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
                                      Pair.PairType = VSVGPairType.SingleValue
                                      Pair.Value = 255
                                      Pair.Status = "On"
                                      Pair.Render = Enums.CAPIControlType.Button
                                      Pair.Render_Location.Row = 1
                                      Pair.Render_Location.Column = 2
                                      Default_VS_Pairs_AddUpdateUtil(zd.dvRef, Pair)
                                  End If
                      
                                  Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
                                  Pair.PairType = VSVGPairType.SingleValue
                                  Pair.Value = 0
                                  Pair.Status = "Off"
                                  Pair.Render = Enums.CAPIControlType.Button
                                  Pair.Render_Location.Row = 1
                                  Pair.Render_Location.Column = 1
                                  Default_VS_Pairs_AddUpdateUtil(zd.dvRef, Pair)
                      
                                  If Dimmable Then
                                      Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
                                      Pair.PairType = VSVGPairType.Range
                                      Pair.RangeStart = 1
                                      Pair.RangeEnd = 99
                                      Pair.RangeStatusPrefix = "Dim "
                                      Pair.RangeStatusSuffix = "%"
                                      Pair.Render = Enums.CAPIControlType.ValuesRangeSlider
                                      Pair.Render_Location.Row = 2
                                      Pair.Render_Location.Column = 1
                                      Pair.Render_Location.ColumnSpan = 3
                                      Default_VS_Pairs_AddUpdateUtil(zd.dvRef, Pair)
                                  End If
                      
                                  ' --------------------- GRAPHIC PAIRS -----------------------------
                      
                                  If Dimmable Then
                                      GPair = New VGPair
                                      GPair.PairType = VSVGPairType.SingleValue
                                      GPair.Set_Value = 99
                                      GPair.Graphic = "/images/HomeSeer/status/on.gif"
                                      Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                                  End If
                                  GPair = New VGPair
                                  GPair.PairType = VSVGPairType.SingleValue
                                  GPair.Set_Value = 255
                                  GPair.Graphic = "/images/HomeSeer/status/on.gif"
                                  Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                      
                                  GPair = New VGPair
                                  GPair.PairType = VSVGPairType.SingleValue
                                  GPair.Set_Value = 0
                                  GPair.Graphic = "/images/HomeSeer/status/off.gif"
                                  Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                      
                      
                                  If Dimmable Then
                                      GPair = New VGPair()
                                      GPair.PairType = VSVGPairType.Range
                                      GPair.RangeStart = 1
                                      GPair.RangeEnd = 5.99999999
                                      GPair.Graphic = "/images/HomeSeer/status/dim-00.gif"
                                      Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                      
                                      GPair = New VGPair()
                                      GPair.PairType = VSVGPairType.Range
                                      GPair.RangeStart = 6
                                      GPair.RangeEnd = 15.99999999
                                      GPair.Graphic = "/images/HomeSeer/status/dim-10.gif"
                                      Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                      
                                      GPair = New VGPair()
                                      GPair.PairType = VSVGPairType.Range
                                      GPair.RangeStart = 16
                                      GPair.RangeEnd = 25.99999999
                                      GPair.Graphic = "/images/HomeSeer/status/dim-20.gif"
                                      Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                      
                                      GPair = New VGPair()
                                      GPair.PairType = VSVGPairType.Range
                                      GPair.RangeStart = 26
                                      GPair.RangeEnd = 35.99999999
                                      GPair.Graphic = "/images/HomeSeer/status/dim-30.gif"
                                      Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                      
                                      GPair = New VGPair()
                                      GPair.PairType = VSVGPairType.Range
                                      GPair.RangeStart = 36
                                      GPair.RangeEnd = 45.99999999
                                      GPair.Graphic = "/images/HomeSeer/status/dim-40.gif"
                                      Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                      
                                      GPair = New VGPair()
                                      GPair.PairType = VSVGPairType.Range
                                      GPair.RangeStart = 46
                                      GPair.RangeEnd = 55.99999999
                                      GPair.Graphic = "/images/HomeSeer/status/dim-50.gif"
                                      Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                      
                                      GPair = New VGPair()
                                      GPair.PairType = VSVGPairType.Range
                                      GPair.RangeStart = 56
                                      GPair.RangeEnd = 65.99999999
                                      GPair.Graphic = "/images/HomeSeer/status/dim-60.gif"
                                      Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                      
                                      GPair = New VGPair()
                                      GPair.PairType = VSVGPairType.Range
                                      GPair.RangeStart = 66
                                      GPair.RangeEnd = 75.99999999
                                      GPair.Graphic = "/images/HomeSeer/status/dim-70.gif"
                                      Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                      
                                      GPair = New VGPair()
                                      GPair.PairType = VSVGPairType.Range
                                      GPair.RangeStart = 76
                                      GPair.RangeEnd = 85.99999999
                                      GPair.Graphic = "/images/HomeSeer/status/dim-80.gif"
                                      Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                      
                                      GPair = New VGPair()
                                      GPair.PairType = VSVGPairType.Range
                                      GPair.RangeStart = 86
                                      GPair.RangeEnd = 95.99999999
                                      GPair.Graphic = "/images/HomeSeer/status/dim-90.gif"
                                      Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                      
                                      GPair = New VGPair()
                                      GPair.PairType = VSVGPairType.Range
                                      GPair.RangeStart = 96
                                      GPair.RangeEnd = 98.99999999
                                      GPair.Graphic = "/images/HomeSeer/status/on.gif"
                                      Default_VG_Pairs_AddUpdateUtil(zd.dvRef, GPair)
                      
                                  End If
                      Regards,

                      Rick Tinker (a.k.a. "Tink")

                      Comment


                        #26
                        Thanks for posting.
                        #1 I tried the range code. How does HS know to increment by 3 each time, how can i make it increment by 10?

                        Code:
                         Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
                        Pair.PairType = VSVGPairType.Range
                        Pair.RangeStart = 1
                        Pair.RangeEnd = 99
                        Pair.RangeStatusPrefix = "Dim "
                        Pair.RangeStatusSuffix = "%"
                        Pair.Render = Enums.CAPIControlType.ValuesRangeSlider
                        hs.DeviceVSP_AddPair(dv.Ref(hs), Pair)
                        #2. also, i tried a single loop: 0 to 100 step 10 to add unique values instead. the values were not ordered correctly in the dropdown. do i need to tell each value what its order is in the list?
                        Mark

                        HS3 Pro 3.0.0.534
                        Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
                        Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
                        Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

                        Comment


                          #27
                          Originally posted by mnsandler View Post
                          Thanks for posting.
                          #1 I tried the range code. How does HS know to increment by 3 each time, how can i make it increment by 10?

                          #2. also, i tried a single loop: 0 to 100 step 10 to add unique values instead. the values were not ordered correctly in the dropdown. do i need to tell each value what its order is in the list?
                          You are right, you have to do it manually if you want it in increments by 10. HomeSeer has a number (forget what it is right now) on how many entries in a drop-down list so that the page does not take long to load all of the options. Taking the difference between the upper boundary of the range and the lower boundary, and dividing by that number, it came up with the step 3. It seems weird for 0-100, but for something such as a scientific temperature sensor that has a range from -4 billion to 4 billion, it handles things nicely. Again, doing it "manually" is perfectly fine.

                          The ordering problem is due to a change somebody made without checking with me that I have to undo, so do nothing about it right now and I will have it fixed in the next release.
                          Regards,

                          Rick Tinker (a.k.a. "Tink")

                          Comment


                            #28
                            Originally posted by Rick Tinker View Post
                            Pair.Render_Location.Row = 1
                            Pair.Render_Location.Column = 3
                            Rick,

                            I see this in your code, but it doesn't do anything for me. Is this part of v.11 or a yet-to-be-released version of HS3?

                            Thanks

                            Dirk

                            Comment


                              #29
                              Originally posted by dcorsus View Post
                              I see this in your code, but it doesn't do anything for me. Is this part of v.11 or a yet-to-be-released version of HS3?
                              I just mentioned those in the other thread... They are named differently and are not in a structure in .11 (and I think a release before that) but they have been there for a while. I added ColumnSpan, and when I did that I shortened the names and put all 3 inside a structure. So other than that, the code will work.

                              The new feature that caused the change in those is a ColumnSpan giving you more control over the placement of the controls (buttons, sliders, drop-lists) generated from the value/status pairs.

                              The render type ValuesSlider I think is in .11 as well - you might like that - especially for relatively low ranges of values (e.g. 0 to 100) it draws a slider rather than drop-downs for selecting dim levels, and in your case, volume levels!
                              Regards,

                              Rick Tinker (a.k.a. "Tink")

                              Comment


                                #30
                                Originally posted by Rick Tinker View Post
                                I just mentioned those in the other thread... They are named differently and are not in a structure in .11 (and I think a release before that) but they have been there for a while. I added ColumnSpan, and when I did that I shortened the names and put all 3 inside a structure. So other than that, the code will work.

                                The new feature that caused the change in those is a ColumnSpan giving you more control over the placement of the controls (buttons, sliders, drop-lists) generated from the value/status pairs.

                                The render type ValuesSlider I think is in .11 as well - you might like that - especially for relatively low ranges of values (e.g. 0 to 100) it draws a slider rather than drop-downs for selecting dim levels, and in your case, volume levels!
                                I definitely need to try the slider, that would be an awesome addition for volume controls or track position controls.

                                Now I need to figure out why my code is not working, neither for these icons nor for the row/column thing. I'm going to post my code tonight for you to look at, I think there are others who struggle with the same (the icons thing that is).

                                Dirk

                                Comment

                                Working...
                                X