It's been like that from day 1. If you don't want to set the interface property, just set the device string with an image as stated previously.
Announcement
Collapse
No announcement yet.
Script create device
Collapse
X
-
Originally posted by donstephens View PostWhat is the syntax for writing a set of Status text from a script. I've created the device to hold a list now I'd like to put them into the device so I can use that device to populate a drop down list.
Comment
-
Yeah, I have a bad habit of poor descriptions.
I have a device called XM Music Selector that has a drop down list of stations. I have a script that pulls the station names and numbers from a database and I'd like to populate the drop down list with the station names. I'm trying to convert a script that I had in HS2 but the architecture is so much different than HS3.
Hopefully that is a bit clearer...
Thanks for the look.Don
Comment
-
Right it can get a bit terrifying here and I don't always know this myself - I take it that you are expecting this list to change and/or the list is too large to do manually? Some times that is just easier but if not then you will need to look at adding each as a separate Value/Status pair. I would suggest going through the database and trying to add them on each iteration of the database reader and then something like this (not tested at all) every time you have a record. You might be able to shortcut it if you already have a station number but I would ensure that the number is formatted correctly/converted to an integer.
Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
Pair.PairType = VSVGPairType.SingleValue
Pair.Value = StationNumber
Pair.Render = Enums.CAPIControlType.Single_Text_from_List
Pair.Status = "Station Name"
hs.DeviceVSP_AddPair(dv.Ref(hs), Pair)
Post what you have if you struggle might be able to help...
Comment
-
Here is a bit of my code; it chokes on the first pair statement. This sub is called everytime I loop through the database
PHP Code:Sub ModDev(station As String)
Dim myRef As Integer = hs.GetDeviceRefByName("Home Theater XM Music Selector")
Dim i As Integer = 0
If myRef > 0 Then
hs.Writelog(ID, "Found Station " & station & " , Populating")
Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both) 'errors here
REM Pair.PairType = VSVGPairType.SingleValue
REM Pair.Value = StationNumber
REM Pair.Render = Enums.CAPIControlType.Single_Text_from_List
REM 'Pair.Status = "Station Name"
REM Pair.Status = station
REM hs.DeviceVSP_AddPair(dv.Ref(hs), Pair)
REM Else
REM hs.Writelog(ID, "Can not find Device Home Theater XM Music Selector")
REM Exit Sub
End If
End Sub
PHP Code:Mar-22 3:12:48 PM Error Compiling script C:\HomeSeer HS3\scripts\XMButton.vb: 'Pair' is a type and cannot be used as an expression.
Mar-22 3:12:48 PM Error Compiling script C:\HomeSeer HS3\scripts\XMButton.vb: Variable 'arrData' is used before it has been assigned a value. A null reference exception could result at runtime.
Mar-22 3:12:48 PM Error Compiling script C:\HomeSeer HS3\scripts\XMButton.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
ThanksDon
Comment
-
Now, that's embarrassing... humble pie.
Thanks Al and Adam
Script did populate device. On to breaking something else.Last edited by donstephens; March 22, 2015, 05:29 PM.Don
Comment
-
Al is on the money, something like this should do what you are after I think, it adds the values and I get the drop list
Code:'Insert Any Comments Here Sub Main(ByVal Parm As Object) Try Dim TitleString() As String = {"Radio 1", "Radio 2", "Radio 3", "Radio 4"} Dim i As Byte = 0 Dim dvRef As Integer = 6476 Dim Pair As VSPair For Each StationName As String In TitleString Log("Adding StationName: " & StationName & " Value: " & i) Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both) Pair.PairType = VSVGPairType.SingleValue Pair.Value = i Pair.Render = Enums.CAPIControlType.Single_Text_from_List Pair.Status = StationName hs.DeviceVSP_AddPair(dvRef, Pair) i += 1 Next Catch ex As Exception Log("Exception: " & ex.Message.ToString) End Try End Sub Sub Log(ByVal ParStr As String) hs.writelog("Startup", ParStr) End Sub
Comment
Comment