Announcement

Collapse
No announcement yet.

Zee S2 script failures

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

    Zee S2 script failures

    In the following simple vb.net script I get run time errors or compile errors when the commented lines are run:

    Sub Main(ByVal strDevRef As String)
    Dim dvRef as Integer
    Dim room As String = "Family Room "
    Dim dev_nam As String
    dev_nam = room & strDevRef

    dvRef = hs.GetDeviceRefByName(dev_nam)

    If dvRef > 0 Then
    hs.WriteLog("more_test1","Good device name:|" & dev_nam & "| dvRef=" & dvRef )

    Dim MyPair As VSPair()
    ''MyPair = hs.DeviceVSP_Get(dvRef) ''Cannot find the requested class member.
    ''MyPair = hs.DeviceVSP_Get(dvRef, 1, "Both") ''Cannot find the requested class member.
    ''Dim dev_nam As String = hs.DeviceName(dvRef)) ''does NOT compile
    End If
    End Sub

    I have this line in the settings.ini file: ScriptingReferences=System.Management;System.Management.dll, System.Drawing;System.Drawing.dll,System.Net;System.Net.dll

    Can anyone tell me what I'm doing wrong? The HomeSeer on-line documentation is less-than-helpful.

    Config: HomeSeer Version: HS3 ZEE S2 Edition 3.0.0.258
    Linux version: Linux HomeTrollerZeeS2 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l GNU/Linux System

    Thanks.

    #2
    Here's the syntax I'm using in one of my scripts:

    Code:
    	dim GPair as VGPair
    	dim SPair as VSPair
    
    	SPair = New VSPair (HomeSeerAPI.ePairStatusControl.Both)
    	SPair.PairType = VSVGPairType.SingleValue
    	Spair.Render_Location.Row = row
    	Spair.Render_Location.Column = col
    	Spair.Render_Location.ColumnSpan = colspan
    	Spair.Value = vsValue
    	Spair.Status = vsName
    	Spair.Render = 5
    	Spair.PairButtonImageType = 1
    		
    	GPair = New VGPair
    	GPair.PairType = VSVGPairType.SingleValue
    	GPair.Set_Value = vsValue
    
    	hs.DeviceVGP_AddPair(refDev, GPair)
    	hs.DeviceVSP_AddPair(refDev, SPair)
    Maybe that helps. Can you explain what you are trying to do? Also would help if you'd posted your actual errors.

    Cheers
    Al
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      Thanks for the quick reply

      I was not actually trying to play w/ VG VS Pairs (but thanks for the great example). I was going thru the on-line documentation and noticing that many (more than half?) of the examples either do not compile or fail on execution--quite often w/:

      Compiling script /usr/local/HomeSeer/scripts/i_enumer1.vb: The import 'System.Core' could not be found. I don't know where that should come from, I guess there should be a reference to some .dll in the ScriptingReferences=System.Management;System.Management.dll, System.Drawing;System.Drawing.dll,System.Net;System.Net.dll line in settings.ini.

      I was trying to enumerate all the devices making a list of room/name w/ a script like this:
      Sub Main(ByVal strDevRef As String)
      hs.WriteLogEx("enumer1", "========= Running enumer1 =========" , "#F000F0")
      Dim enx As Scheduler.clsDeviceEnumeration ' 'clsDeviceEnumeration' is not a member of 'Global.Scheduler'.
      Dim dv As Scheduler.Classes.DeviceClass
      Dim CS As ICAPIStatus 'CAPIStatus' is not a member of 'Global.Scheduler'
      Dim s As String

      enx = hs.GetDeviceEnumerator()
      if enx Is Nothing Then
      Else
      hs.WriteLogEx("enumer1", "It is not an object." , "#FF0000")
      End If

      Do While enx.Finished = False
      dv = enx.GetNext()
      If Not dv Is Nothing Then
      CS = hs.CAPIGetStatus(dv.ref)
      s = "Device " & dv.location & " " & dv.Name
      s &= ". Status=" & CS.Status & ". Image=" & CS.ImageFile
      hs.WriteLogEx("enumer1", s , "#000088")
      End If
      Loop
      End Sub

      This script is from the example at: http://homeseer.com/support/homeseer...igetstatus.htm

      I get these errors:
      Jun-27 11:07:56 AM

      Error
      Compiling script /usr/local/HomeSeer/scripts/i_enumer1.vb: 'clsDeviceEnumeration' is not a member of 'Global.Scheduler'.

      Jun-27 11:07:56 AM

      Error
      Compiling script /usr/local/HomeSeer/scripts/i_enumer1.vb: The import 'System.Core' could not be found.
      Any help would be appreciated. Thanks.

      Comment


        #4
        For enumerating all devices, here's an example from a battery reporting script that was posted on the board:

        Code:
                Try
                    Dim dv As Scheduler.Classes.DeviceClass
                    Dim EN As Scheduler.Classes.clsDeviceEnumeration
                    EN = hs.GetDeviceEnumerator
                    If EN Is Nothing Then
                        hs.WriteLog("BatteryReport", "Error getting Enumerator")
                        Exit Sub
                    End If
        
                    Do
                        dv = EN.GetNext
                        If dv Is Nothing Then Continue Do
        
                        ' Add to array if device type contains 'battery'
                        If InStr(UCase(dv.Device_Type_String(Nothing)), "BATTERY") > 1 And dv.MISC_Check(hs, Enums.dvMISC.HIDDEN) = False Then
                            ReDim Preserve myArray(UBound(myArray) + 1)
                            myArray(UBound(myArray) - 1) = New BatteryDevice
        
                            myArray(UBound(myArray) - 1).refID = ("[" & dv.Ref(Nothing).ToString & "]").PadLeft(6) & vbTab
                            If dv.devValue(Nothing) = 255 Then ' if battery value is 255, battery low warning
                                myArray(UBound(myArray) - 1).devValue = "  Battery Low Warning" & vbTab & vbTab
                            ElseIf dv.devValue(Nothing) > 100 Then ' if battery value is larger than 100(%), battery is invalid state
                                myArray(UBound(myArray) - 1).devValue = "  ERROR" & vbTab & vbTab
                            Else
                                myArray(UBound(myArray) - 1).devValue = (dv.devValue(Nothing).ToString & "%").PadLeft(7) & vbTab & vbTab
                            End If
                            ' Determine max length of device loc/name string (for formatting)
                            If (dv.Location2(Nothing) & " " & dv.Location(Nothing) & " " & dv.Name(Nothing)).Length > MaxNameLen Then
                                MaxNameLen = (dv.Location2(Nothing) & " " & dv.Location(Nothing) & " " & dv.Name(Nothing)).Length
                            End If
                            myArray(UBound(myArray) - 1).devName = dv.Location2(Nothing) & " " & dv.Location(Nothing) & " " & dv.Name(Nothing)
                            myArray(UBound(myArray) - 1).lastChange = dv.Last_Change(Nothing).ToString.PadRight(22)
        
                        End If
                    Loop Until EN.Finished
        It does not require any additional references than what you already have.

        Cheers
        Al
        HS 4.2.8.0: 2134 Devices 1252 Events
        Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

        Comment


          #5
          Tried the scroipt

          added sub/end and closed out catch. (Complete script is in attachment.)
          Got these compile errors:
          Jun-27 2:31:08 PM Error Compiling script /usr/local/HomeSeer/scripts/i_enumer2.vb: Could not resolve the name 'BatteryDevice' Jun-27 2:31:08 PM Error Compiling script /usr/local/HomeSeer/scripts/i_enumer2.vb: The import 'System.Core' could not be found.
          If I get by these compile errors, this script appears to be visual basic. I'm running a Zee S2 which is a unix Raspberry Pi2. It only does vb.net. So stmts like "InStr" will not work. I can convert vb to vb.net.

          The sticking point is the 'System.Core' could not be found.

          Thanks


          Attached Files

          Comment


            #6
            Add this to the script:

            Code:
                Public Class BatteryDevice
                    Implements IComparable(Of BatteryDevice)
            
                    Public refID As String
                    Public devValue As String
                    Public lastChange As String
                    Public devName As String
            
                    Public Function CompareTo(ByVal other As BatteryDevice) As Integer Implements IComparable(Of BatteryDevice).CompareTo
                        Return Me.devValue.CompareTo(other.devValue)
                    End Function
                End Class
            The script is vb.net and Instr should work in it. It's common to get this " Error Compiling script /usr/local/HomeSeer/scripts/i_enumer2.vb: The import 'System.Core' could not be found. " with other errors. Once you fix the other errors, that error will disappear as well. I've attached the full script for reference in case there's something else important missing

            Cheers
            Al
            Attached Files
            HS 4.2.8.0: 2134 Devices 1252 Events
            Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

            Comment


              #7
              Success!

              I striped your script down to its essentials. The 'System.Core' could not be found. problem went away and it worked like a charm!

              Thanks for the help. I was stuck on this for days!
              Attached Files

              Comment


                #8
                Originally posted by jeffstalzer View Post
                I striped your script down to its essentials. The 'System.Core' could not be found. problem went away and it worked like a charm!

                Thanks for the help. I was stuck on this for days!
                Great, glad I could help.

                Cheers
                Al
                HS 4.2.8.0: 2134 Devices 1252 Events
                Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                Comment

                Working...
                X