Announcement

Collapse
No announcement yet.

Weird behavior trying to create a virtual device in script... no controls

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

  • mittelhauser
    replied
    Thanks Jon. That did it.

    Not the most obvious setting to find buried in the Device object. lol

    -Jon

    Leave a comment:


  • jon00
    replied
    You would need to add:

    objDev.MISC_Set(hs, Enums.dvMISC.SHOW_VALUES)

    See: http://homeseer.com/support/homeseer...elp/dvmisc.htm

    Leave a comment:


  • mittelhauser
    replied
    To clarify:

    If I initially create the device in the script, then I never get any controls... no matter what else I do via the script or the GUI...

    If I initially create the device in the GUI, then it immediately has the default On/Off controls and I can programmatically change everything to what I want...

    SO... I could go create a 100+ devices manually in the GUI and then write scripts to set them up the way I want... but that would be insane.

    Leave a comment:


  • Weird behavior trying to create a virtual device in script... no controls

    Ok. I'm officially pulling my hair out on this one. I'm trying to do what I assume is a fairly typical operation... create a virtual device that I will then use other scripts and plugins to operate. In my case, it is for an old HomeWorks system. I bought Homeseer thinking it was supported but it turns out it isn't in HS3 so I figured I would just do it myself... I'm an experienced programmer (although not in vb) so no biggie...

    Here's the issue. If I create a device programmatically, then I never get any of the controls (buttons/sliders) and other programs (like imperiHome) don't see it. As far as I can tell from the example/sample code/etc that I have found, I am including everything necessary.



    The interesting/annoying thing is that if I create an empty virtual device manually and then run every part of the code to configure that device, it all works fine...

    Code:
    Sub Main(param As Object)
        Dim devref as long
    	Dim objDev As Object
    	Dim vsp As VSPair
    	Dim CStatus As ePairStatusControl
    	
        hs.WriteLog("Setup HWI", "foo")
    			
    	If hs.DeviceExistsAddress("03:08:01:16",false) = -1 Then
    		devref = hs.NewDeviceRef("Office Hall")
    		objDev = hs.GetDevicebyRef(devref)
    		If objDev Is Nothing Then
    			hs.WriteLog("DevInfo","Invalid device ref: " & DevRef)		
    		Else
    			objDev.Address(hs) = "03:08:01:16"
    			objDev.Code(hs) = "HWI"
    			objDev.Name(hs) = "Hall"
    			objDev.Location(hs) = "Foyer"
    			objDev.Location2(hs) = "First Floor"
    			objDev.Status_Support(hs) = False
                            objDev.Last_Change(hs) = Now
    			'objDev.Interface(hs) = IFACE_NAME
    			'objDev.InterfaceInstance(hs) = "Jon"
    			objDev.Device_Type_String(hs) = "HWI"
    			
    			Dim DT As New DeviceTypeInfo
    			DT.Device_API = DeviceTypeInfo.eDeviceAPI.No_API
    			objDev.DeviceType_Set(hs) = DT
    			
    			Dim Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
    			Pair.PairType = VSVGPairType.SingleValue
    			Pair.Value = 100
    			Pair.Status = "On"
    			Pair.Render = Enums.CAPIControlType.Button
    			hs.DeviceVSP_AddPair(devref, Pair)
    
    			Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
    			Pair.PairType = VSVGPairType.SingleValue
    			Pair.Value = 0
    			Pair.Status = "Off"
    			Pair.Render = Enums.CAPIControlType.Button
    			hs.DeviceVSP_AddPair(devref, Pair)
    
    			Pair = New VSPair(ePairStatusControl.Both)
    			Pair.PairType = VSVGPairType.Range
    			Pair.RangeStart = 1
    			Pair.RangeEnd = 99
    			Pair.RangeStatusPrefix = "Dim "
    			Pair.RangeStatusSuffix = "%"
    			Pair.ControlUse = ePairControlUse._Dim
    			Pair.Render = Enums.CAPIControlType.ValuesRangeSlider
    			hs.DeviceVSP_AddPair(devref, Pair)
    			
    		End If
    	Else 
    		hs.WriteLog("Setup HWI", "Device exists already")
    	End If   
    End Sub
    So what is the manual creation using the GUI doing that I am not doing in my code?
Working...
X