www.homeseer.com    
 

Go Back   HomeSeer Message Board > Developer Support > Scripts & Plug-Ins:Development and Libraries > HS3 Scripting

HS3 Scripting Discussions related to the scripting under HS3.

Reply
 
Thread Tools Display Modes
  #1  
Old June 6th, 2016, 11:37 AM
mittelhauser mittelhauser is offline
Seer
 
Join Date: May 2016
Location: CA - California
Posts: 25
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?
Reply With Quote
  #2  
Old June 6th, 2016, 11:42 AM
mittelhauser mittelhauser is offline
Seer
 
Join Date: May 2016
Location: CA - California
Posts: 25
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.
Reply With Quote
  #3  
Old June 6th, 2016, 11:45 AM
jon00's Avatar
jon00 jon00 is offline
OverSeer
 
Join Date: Jan 2002
Location: London UK
Posts: 11,495
You would need to add:

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

See: https://homeseer.com/support/homeseer...elp/dvmisc.htm
__________________
Jon

Reply With Quote
  #4  
Old June 6th, 2016, 11:53 AM
mittelhauser mittelhauser is offline
Seer
 
Join Date: May 2016
Location: CA - California
Posts: 25
Thanks Jon. That did it.

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

-Jon
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create a virtual device (switch) mikee123 HomeSeer General Discussion Area 4 May 30th, 2016 09:36 AM
HS3 Script Syntax to copy one virtual device status string to another virtual device pjohnson HS3 Scripting 8 December 31st, 2014 02:48 PM
Create my own virtual device gpdemarco RFXCOM Plug-In (3P) 3 August 12th, 2014 08:48 PM
Create virtual device from plugin Agwan HS3 Plug-In Development 2 August 10th, 2014 02:59 AM
Virtual Device Behavior JB NY BLRadar (3P) 9 January 16th, 2014 05:03 PM


All times are GMT -4. The time now is 01:53 AM.


Copyright HomeSeer Technologies, LLC