Announcement

Collapse
No announcement yet.

Someone has a script to copy a virtual device?

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

  • deloosem
    replied
    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.

    Leave a comment:


  • sparkman
    replied
    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

    Leave a comment:


  • deloosem
    replied
    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?

    Leave a comment:


  • sparkman
    replied
    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.

    Leave a comment:


  • sparkman
    replied
    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.

    Leave a comment:


  • randy
    replied
    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.

    Leave a comment:


  • deloosem
    replied
    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.

    Leave a comment:


  • Uncle Michael
    replied
    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?

    Leave a comment:


  • deloosem
    started a topic Someone has a script to copy a virtual device?

    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

Working...
X