Announcement

Collapse
No announcement yet.

System.Core scripting error - solved

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

    System.Core scripting error - solved

    I have been testing the Device History plugin for a couple days now. I was struggling with this error for quite a while trying to run an event script using the GetRangeStats plugin function.

    Jan-05 17:19:49 Error Compiling script /usr/local/HomeSeer/scripts/TestGenDivHistChart.vb: http://mono-project.com/Bugs)
    Jan-05 17:19:49 Error Compiling script /usr/local/HomeSeer/scripts/TestGenDivHistChart.vb: The import 'System.Core' could not be found.

    I found several threads in other forums mentioning the System.Core error, but none had a real solution other than suggesting it was some issue in the script.

    My initial script passed an array of strings inside curly braces in the function call, just like in the user guide and an example I found in the forum.

    I tried lots of different changes like using literals, defining string variables, using the toString() function on other variables. But the only way I found to get rid of the error was to define a separate array object (arrStrings in my test script below) and pass it in the function call.

    Since my initial script was based on sample code in the plugin user guide, I wanted to share the solution in case it helps others.

    I don't know if this issue is unique to the Linux (I'm running a HomeTrollerZee).

    Here is the working code.

    Code:
    Sub Main(ByVal Parm As String)
    
      Dim dtFromDate as Date = DateTime.Now.AddDays(-1)
      Dim dtToDate as Date = DateTime.Now
      
      ' Define the array object
      Dim arrStrings = New String() {"88", dtFromDate.toString(), dtToDate.toString()}
    
      Dim strRangeVals as String
      strRangeVals = hs.PluginFunction("Device History", "", "GetRangeStats", arrStrings)
      hs.writelog("test","Range Stats = " & strRangeVals)
    
    End Sub
    Thanks,
    Dave

    HomeSeer Version: HS3 ZEE S2 Edition 3.0.0.368
    Linux version: Linux HomeTrollerZeeS2V2 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linux System Uptime: 3 Days 23 Hours 50 Minutes 34 Seconds

    Enabled Plug-Ins
    1.2.2.0: Device History
    3.0.1.130: Z-Wave

    #2
    Thanks for providing the updated script - sounds like an issue in Mono for Linux-based HS3 servers. I'll update the example in the documentation with a new example that works around that bug...

    Comment


      #3
      Originally posted by diesnon View Post
      I have been testing the Device History plugin for a couple days now. I was struggling with this error for quite a while trying to run an event script using the GetRangeStats plugin function.

      ...
      But the only way I found to get rid of the error was to define a separate array object (arrStrings in my test script below) and pass it in the function call.

      ...
      I spent all weekend struggling with exactly the same problem. It appears to be a mono related issue that affects Linux.

      Your solution works on my RPi system using the MaxMin script in another thread.

      Thanks for a 'Gold Star' solution

      A

      Comment


        #4
        Apologies if I should post this elsewhere, but I'm pretty sure I'm experiencing the same issue, but having problems fixing it. The script works perfectly in the tenscript environment, but when I copy it over to my HomeSeer machine running on Linux I get the same error mentioned here;

        Jan-16 9:41:06 AM Error Compiling script keypaddigit.vb: http://mono-project.com/Bugs)
        Jan-16 9:41:06 AM Error Compiling script keypaddigit.vb: The import 'System.Core' could not be found.

        Any chance someone could point me in the right direction to fix the below code that operates the alarm pad on my HSTouch interface? Thank you in advance.

        Code:
        Class Keypad
        Public Sub Main(ByVal Parms As Object)
        Dim digit As String
        Dim InputArray() As String
        Dim whichkey As Integer
        Dim arm_function As Integer
        Dim digit_display As String
        Dim digit_display_count As Integer
        Dim whichkeyString As String
        'Dim objCAPIControl As CAPIControl
        
        InputArray = CType(Parms, String())
        whichkey = Convert.ToInt32(InputArray(0))
        whichkeyString = Convert.ToString(whichkey)
        digit_display_count = hs.DeviceValue(603)
        
        digit = ""
        If whichkey = 11 Then
        
        hs.SetDeviceStringByName("keypad_v1", "", True)
        hs.SetDeviceStringByName("keypad_v2", "", True)
        hs.SetDeviceStringByName("keypad_v3", "", True)
        
        hs.SetDeviceValueByRef(599, 0, True)
        hs.SetDeviceValueByRef(601, 0, True)
        hs.SetDeviceValueByRef(603, 0, True)
        
        ElseIf whichkey >= 1 And whichkey <= 10 And digit_display_count < 6 Then
        
        If whichkey = 10 Then
        
        whichkey = 0
        whichkeyString = "0"
        
        
        End If
        
        digit = hs.DeviceStringByName("keypad_v1")
        digit = (digit & whichkeyString)
        hs.SetDeviceStringByName("keypad_v1", digit, True)
        
        digit_display = hs.DeviceStringByName("keypad_v3")
        digit_display = (digit_display & "*")
        hs.SetDeviceStringByName("keypad_v3", digit_display, True)
        
        digit_display_count = hs.DeviceValue(603)
        digit_display_count = digit_display_count + 1
        hs.SetDeviceValueByRef(603, digit_display_count, True)
        
        
        ElseIf whichkey >= 12 And whichkey <= 18 Then
        
        If whichkey = 12 Then
        arm_function = 0
        
        ElseIf whichkey = 13 Then
        arm_function = 1
        
        ElseIf whichkey = 14 Then
        arm_function = 2
        
        ElseIf whichkey = 15 Then
        arm_function = 3
        
        ElseIf whichkey = 16 Then
        arm_function = 4
        
        ElseIf whichkey = 17 Then
        arm_function = 5
        
        ElseIf whichkey = 18 Then
        arm_function = 6
        
        End If
        digit = hs.DeviceStringByName("keypad_v1")
        hs.PluginFunction("UltraM1G3", "", "AreaAlarmAction", {"Area01", arm_function, digit})
        
        hs.SetDeviceString(599, "", True)
        hs.SetDeviceString(601, "", True)
        hs.SetDeviceString(603, "", True)
        
        hs.SetDeviceValueByRef(599, 0, True)
        hs.SetDeviceValueByRef(601, 0, True)
        hs.SetDeviceValueByRef(603, 0, True)
        
        End If
        End Sub
        End Class

        Comment


          #5
          Ugh. The move to this new BB system has been disastrous. Any edit posts are gone... including the one that showed the solution for this type of problem!

          i'm pretty sure that the resolution to this Linux/Mono bug was that this line:

          hs.PluginFunction("UltraM1G3", "", "AreaAlarmAction", {"Area01", arm_function, digit})


          Should be:

          hs.PluginFunction("UltraM1G3", "", "AreaAlarmAction", New Object()
          {"Area01", arm_function, digit})

          Comment


            #6
            Thank you! That worked. I'm sorry the move to the new BB system has been such a headache, but at least I'm not crazy because I was searching everywhere for the solution that was going to be added to the script help file.

            Comment


              #7
              I've updated the examples in the 1.3.6 release. (But please note: I'm talking about the documentation for this plugin specifically, which your code doesn't seem to be using. Your issue just happened the be the same cause as what had already been discovered by someone using this plugin earlier!)

              Comment

              Working...
              X