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...
So what is the manual creation using the GUI doing that I am not doing in my code?
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
Comment