Announcement

Collapse
No announcement yet.

Someone has a script to copy a virtual device?

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

    Someone has a script to copy a virtual device?

    I know it can be done but I hoped someone already did it so I can adapt it for my task.
    The situation is as follows. I have a virtual device to control my heating and it has a couple of child virtual devices I linked with (Jon00Grouping.aspx).

    The problem is that I need to copy this base virtual device a couple of times and doing it via the web interface is an uggly slow task to tackle.

    Basically I just need to copy the vd and rename the devices locations and address.

    If someone can help me with that please or I will have a long night a head of me


    #2
    I clearly don't understand what it is you want to do, because copying a device two times is hardly what I would call slow, especially compared to writing a script to do it. I can't comment on the 'ugly' part. That's a matter of taste.
    Can you explain why copying using the HS web page is problematic?
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.548, NUC i3

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

    Comment


      #3
      Originally posted by Uncle Michael View Post
      I clearly don't understand what it is you want to do, because copying a device two times is hardly what I would call slow, especially compared to writing a script to do it. I can't comment on the 'ugly' part. That's a matter of taste.
      Can you explain why copying using the HS web page is problematic?
      I have a script that looks for names like Setpoint/Zone 01. If I copy that device then i becomes Setpoint/Zone 01 (copy). I have 10 virtual devices per zone and 20 zones. Thats editing 20 times 10 names. I think I can do it quicker with a script.

      Comment


        #4
        I find copying through the web interface to be extremely easy and fast.
        1. Select the check mark beside the device(s) to be copied
        2. Select copy from the drop down
        3. select the same location you are using for the source so it copies in place
        4. click on the name of the copied device (it will be the original name appended with Copy(1))
        5. rename the device, set the new location(s) and click Done
        I do this all the time and it takes less time than would modifying a script for new new names and locations. I have groups of devices I use for templates and sometimes copy the entire group this way. I can copy and rename 5 devices in a matter of minutes.
        Randy Prade
        Aurora, CO
        Prades.net

        PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

        Comment


          #5
          There's no simple script command to copy a device. You have to create the device, then add Value Status pairs and Value Graphics pairs and potentially other settings like relationships. I have some scripts that include device creation, but nothing that copies them. Let me know if you want to see one of those to help point you in the right direction.
          HS 3.0.0.548: 1990 Devices 1172 Events
          Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

          Comment


            #6
            Just realized that I had a script that copies VS/VG pairs from one device to another: https://forums.homeseer.com/forum/de...ice-to-another. Should get you part way there.
            HS 3.0.0.548: 1990 Devices 1172 Events
            Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

            Comment


              #7
              Originally posted by sparkman View Post
              Just realized that I had a script that copies VS/VG pairs from one device to another: https://forums.homeseer.com/forum/de...ice-to-another. Should get you part way there.
              Thx!! I will look into that

              Question do you have a script (or a code snippet) that creates a vd?

              Comment


                #8
                Originally posted by deloosem View Post

                Thx!! I will look into that

                Question do you have a script (or a code snippet) that creates a vd?
                Here's one example:

                Code:
                Sub Main(ByVal player As String)
                    Dim logName As String = "LG Pairing Device Create"            'set log name for HS log
                    Dim Debug As Boolean = False
                
                    Dim dv As Scheduler.Classes.DeviceClass = Nothing
                
                    Dim PlayerIP() As String
                    PlayerIP = player.split(".")
                
                    Dim pcDev As Long = hs.DeviceExistsAddress("LG" & PlayerIP(3) & "PC" , True)
                    If pcDev = -1 Then
                        dv = hs.GetDeviceByRef(hs.NewDeviceRef("LG TV Pairing Code"))
                        dv.Address(hs) = "LG" & PlayerIP(3) & "PC"
                        dv.Location(hs) = "LG TV"
                        dv.Location2(hs) = "LG TV"
                        dv.Last_Change(hs) = Now
                        dv.Device_Type_String(hs) = "LG TV Device"
                        dv.MISC_Set(hs, Enums.dvMISC.SHOW_VALUES)
                        hs.DeviceVGP_ClearAll(dv.Ref(hs), True)
                        hs.DeviceVSP_ClearAll(dv.Ref(hs), True)
                        pcDev = hs.DeviceExistsAddress("LG" & PlayerIP(3) & "PC" , True)
                    End If
                
                    dim GPair as VGPair
                    dim SPair as VSPair
                
                    SPair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
                    SPair.PairType = VSVGPairType.SingleValue
                    SPair.Value = 102
                    SPair.Status = ""
                    SPair.Render = Enums.CAPIControlType.TextBox_String
                    Spair.Render_Location.Row = 1
                    Spair.Render_Location.Column = 1
                    Spair.Render_Location.ColumnSpan = 4
                    GPair = New VGPair
                    GPair.PairType = VSVGPairType.SingleValue
                    GPair.Set_Value = 1
                    GPair.Graphic = "/images/lgtv/lg.png"
                    hs.DeviceVGP_AddPair(pcDev, GPair)
                    hs.DeviceVSP_AddPair(pcDev, SPair)
                
                    SPair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
                    SPair.PairType = VSVGPairType.SingleValue
                    SPair.Value = 100
                    SPair.Status = "Display Pairing Code"
                    Spair.Render_Location.Row = 2
                    Spair.Render_Location.Column = 1
                    Spair.Render_Location.ColumnSpan = 2
                    Spair.Render = 5
                    GPair = New VGPair
                    GPair.PairType = VSVGPairType.SingleValue
                    GPair.Set_Value = 100
                    GPair.Graphic = "/images/lgtv/lg.png"
                    hs.DeviceVGP_AddPair(pcDev, GPair)
                    hs.DeviceVSP_AddPair(pcDev, SPair)
                
                    SPair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
                    SPair.PairType = VSVGPairType.SingleValue
                    SPair.Value = 101
                    SPair.Status = "Pair"
                    Spair.Render_Location.Row = 2
                    Spair.Render_Location.Column = 3
                    Spair.Render_Location.ColumnSpan = 2
                    Spair.Render = 5
                    GPair = New VGPair
                    GPair.PairType = VSVGPairType.SingleValue
                    GPair.Set_Value = 101
                    GPair.Graphic = "/images/lgtv/lg.png"
                    hs.DeviceVGP_AddPair(pcDev, GPair)
                    hs.DeviceVSP_AddPair(pcDev, SPair)
                
                    hs.SetDeviceValueByRef(pcDev, 1, True)
                
                End Sub
                HS 3.0.0.548: 1990 Devices 1172 Events
                Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

                Comment


                  #9
                  Originally posted by sparkman View Post

                  Here's one example:

                  ]
                  Thx I started converting your cpy example to a sub/function so I can use it in a create script. The above example is mega usefull.

                  Comment

                  Working...
                  X