I'm stumped and need help finding the issue with this script! This is my first semi complex script, so it's entirely possible I made a mistake or added a function mono doesn't support. This script was made and tested in tenScripting (Visual Studio 2013) and ran fine in the developer but when copied to HS the following logs are received.
My system is a HomeTroller SEL on 3.0.0.313.
Are there any commands not recognized by Mono? Odd that it ran fine in tenScripting but fails when moved to HS.
Below is the script.
My system is a HomeTroller SEL on 3.0.0.313.
Are there any commands not recognized by Mono? Odd that it ran fine in tenScripting but fails when moved to HS.
Code:
Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: 'End Namespace' must be preceded by a matching 'Namespace'. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Identifier expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Expected 'End'. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Expected 'End'. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Expected 'End'. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: CHANGEME Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Expected 'End'. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: End of statement expected. Apr-03 23:42:13 Error Compiling script /usr/local/HomeSeer/scripts/MatchDevice.vb: Expected ')'.
Code:
Sub Main(ByVal parm As String) 'Description: ----------------------------------------------------------- 'This script is ran by an event and evaluates devices (parameter 3 - N) and tallies the 'number of devices that contain one of the search strings (parameter 1) and are 'on' 'and adds the tally and list of names names as value and string to a virtual device '(parameter 0). This virtual devices can then be used in HSTouch to display the on 'status for several devices at once. For example, this script can show the status of all lights 'Parameters: ------------------------------------------------------------ 'all parameters are separated by | (pipe) except the second parameter (1) 'first parameter (0) is the virtual device to set value and string 'second parameter (1) is the search strings separated by ?. Example light?fan 'third parameter (2) is True to enable debug or False to disable 'remaining parameters (3 - N) are the devices to evaluate 'Example parameter: 376|light?ceiling?fan|False|170|164|167|44 Dim logName As String = "HS3 MatchDevice" Dim matchCount As Integer = 0 Dim matchDeviceNames As String = "None" If parm.Length > 0 Then Dim parmArray() As String = parm.ToString.Split(New Char() {"|"c}) Dim StatusDevice As Integer = CType(parmArray(0), Integer) Dim matchText As String = parmArray(1) Dim matchTextArray() As String = matchText.ToString.Split(New Char() {"?"c}) Dim Debug As Boolean = CType(parmArray(2), Boolean) If Debug Then 'Debug print raw parameters in HS log hs.WriteLog(logName, "Raw Parameter: " + parm) 'Debug print number of characters in parameter in HS log hs.WriteLog(logName, "Characters in Parameter: " + CType(parm.Length, String)) hs.WriteLog(logName, "---------------------------------") 'Debug print each parm to HS log For index As Integer = 0 To parmArray.GetUpperBound(0) hs.WriteLog(logName, "Parm" + CType(index, String) + ": " + parmArray(index)) Next hs.WriteLog(logName, "---------------------------------") 'Debug print device that will receive the value and string to HS log hs.WriteLog(logName, "Status Device: " + parmArray(0)) 'Debug print match strings in HS log For j As Integer = 0 To matchTextArray.GetUpperBound(0) hs.WriteLog(logName, "Match String: " + CType(j, String) + ": " + matchTextArray(j)) Next For index As Integer = 3 To parmArray.GetUpperBound(0) hs.WriteLog(logName, "Device: " + CType(index - 3, String) + ": " + parmArray(index)) Next hs.WriteLog(logName, "---------------------------------") End If Try 'search for string in names of passed in devices For index As Integer = 3 To parmArray.GetUpperBound(0) 'get name of device Dim dv As Scheduler.Classes.DeviceClass dv = CType(hs.GetDeviceByRef(CInt(parmArray(index))), Scheduler.Classes.DeviceClass) Dim strDevName As String = dv.Name(hs) Dim strDevLoc1 As String = dv.Location(hs) 'do case insensitive search for matchTextArray If matchTextArray.Any(Function(b) strDevName.IndexOf(b, StringComparison.CurrentCultureIgnoreCase) >= 0) Then 'is device on? If hs.DeviceValueEx(CInt(parmArray(index))) > 0 Then matchCount = matchCount + 1 If Debug Then hs.WriteLog(logName, matchCount.ToString) 'first match singular If matchCount = 1 Then matchDeviceNames = strDevLoc1 + " " + strDevName 'last match ElseIf matchCount = parmArray.GetUpperBound(0) Then matchDeviceNames = matchDeviceNames + ", " + strDevLoc1 + " " + strDevName + "." 'all other matches Else matchDeviceNames = matchDeviceNames + ", " + strDevLoc1 + " " + strDevName End If End If End If Next 'output number of matches and names to HS log If Debug Then If Debug Then hs.WriteLog(logName, "Number of " + matchText + "s On: " + matchCount.ToString + " - Names: " + matchDeviceNames) End If 'set value and string of 'Lights On' device hs.SetDeviceValueByRef(StatusDevice, matchCount, True) hs.SetDeviceString(StatusDevice, matchDeviceNames, False) Catch ex As Exception hs.WriteLog(logName, ex.Message) End Try Else hs.WriteLog(logName, "-------------------------------------------------------") hs.WriteLog(logName, "Example parameter: 376|light?ceiling?fan|False|170|164|167|44") hs.WriteLog(logName, "remaining parameters (3 - N) are the devices to evaluate") hs.WriteLog(logName, "third parameter (2) is True to enable debug or False to disable") hs.WriteLog(logName, "second parameter (1) is the search strings separated by ?. Example light?fan") hs.WriteLog(logName, "first parameter (0) is the virtual device to set value and string") hs.WriteLog(logName, "all parameters are separated by | (pipe) except the second parameter (1)") hs.WriteLog(logName, "At least the first four parameters (0-3) are required") hs.WriteLog(logName, "-------------------------------------------------------") hs.WriteLog(logName, "No Parameters Specified.") hs.WriteLog(logName, "-------------------------------------------------------") End If End Sub
Comment