Announcement

Collapse
No announcement yet.

help with Script and Log Issues

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    help with Script and Log Issues

    Hi All

    I'm running Pro 2.5.0.52 and discovered yet another regression. The log view in the HSConsole that used to be about 6 lines is now 1 lone which is totally useless.

    My bigger problem is that log entries from scripts no longer seem to work

    I'm trying to write a script that changes the dim level of a device up or down. Given i have no log entries anymore I'm really struggling to debug. Is there any other way? Anyone see what's up with my script?

    My event script parameter is: ("main","Q14|Down")

    Code:
    sub main(ByVal Parms As Object)
            ' Example Q14|Up
            ' first param should be device ref 
            ' second param should be up or down
            
    		hs.writelog( "Dim", "In script " )
    		
    		Dim DimValue as long
    		Dim CurrentDeviceValue as long
            
    		Dim ParmArray() As String
            ParmArray = Parms.ToString.Split("|")
            
            Dim DeviceRef As String
            DeviceRef = ParmArray(0)
    
            Dim Direction As String
            Direction = ParmArray(1)
    	
    	hs.writelog( "Dim", "Device Ref: " &  chr(34) & DeviceRef & chr(34) & " Direction: " &  chr(34) & Direction & chr(34))
    		
    	Select Direction   
    		 Case "Up"
    			DimValue = 10
    		Else
    			DimValue = -10
    	End Select
    	
    	If hs.DeviceExistsRef(DeviceRef) = True  Then
    			CurrentDeviceValue = hs.DeviceValue(DeviceRef)
    			hs.writelog( "DIM", "Changing Dim level of device : " & DeviceRef & " from " & CurrentDeviceValue & " to " CurrentDeviceValue + DimLevel)
    			If CurrentDeviceValue < 1  THEN
    				hs.writelog( "DIM", "Dim: " & chr(34) & DeviceRef & chr(34) & " ignoring: device is off")
    			Else ' Device exists
    				' Change dim level or upor down
    				hs.SetDeviceValue DeviceRef, CurrentDeviceValue + Dim Level
    			End if ' Dim Level
    		Else ' Device does not exist
    			hs.writelog( "DIM", "No DeviceRef Matching " & chr(34) & DeviceRef & chr(34) & " Exists")
    		End If ' Device Exists
     end sub
    ________________________

    Dell Zino HD - HSPRo 2.x
    HSTouch - iPhone 3GS, 4S, iPad2 and iPad 3, 3xKindle Fire (Wall mounted)
    2 x Brultech ECM1240 with UltraECM
    USB UIRT
    Cooper Aspire Z-Wave Switches
    WGL800 w ACRF2 and 3xDS10a (Sump Level/Activity sensing)
    HM ST812-2 Flood Sensor
    HSM100 - Motion Detector with Light and Temperature
    2GIG Thermostat
    BLDSC - Alarm Plug-in
    BLUPS
    UltraLog (SQL2008)
    Jon00 Plugins
    Host XR3 BT and Jon00 BT Proximity
    Global Cache IP2IR
    Foscam FI8918W

    #2
    Hi Mark,

    One issue I spotted was an extra space in the DimLevel variable when you use it here:

    Code:
    			Else ' Device exists
    				' Change dim level or upor down
    				hs.SetDeviceValue DeviceRef, CurrentDeviceValue + Dim Level
    Also, you call it DimValue in a few spots and DimLevel in others.

    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
      Originally posted by sparkman View Post
      Hi Mark,

      One issue I spotted was an extra space in the DimLevel variable when you use it here:

      Code:
      			Else ' Device exists
      				' Change dim level or upor down
      				hs.SetDeviceValue DeviceRef, CurrentDeviceValue + Dim Level
      Also, you call it DimValue in a few spots and DimLevel in others.

      Cheers
      Al
      Thanks Al

      Got the logging working. for some reason it got turned off when .52 was installed. Found the errors you mentioned and fixing now. Will post working version when complete
      ________________________

      Dell Zino HD - HSPRo 2.x
      HSTouch - iPhone 3GS, 4S, iPad2 and iPad 3, 3xKindle Fire (Wall mounted)
      2 x Brultech ECM1240 with UltraECM
      USB UIRT
      Cooper Aspire Z-Wave Switches
      WGL800 w ACRF2 and 3xDS10a (Sump Level/Activity sensing)
      HM ST812-2 Flood Sensor
      HSM100 - Motion Detector with Light and Temperature
      2GIG Thermostat
      BLDSC - Alarm Plug-in
      BLUPS
      UltraLog (SQL2008)
      Jon00 Plugins
      Host XR3 BT and Jon00 BT Proximity
      Global Cache IP2IR
      Foscam FI8918W

      Comment


        #4
        Got it working

        Code:
        sub main(ByVal Parms As Object)
                ' Example Q14|Up
                ' first param should be device ref 
                ' second param should be up or down
                
        		hs.writelog( "Dim", "In script " )
        		
        		Dim DimValue as long
        		Dim CurrentDeviceValue as long
                
        		Dim ParmArray() As String
                ParmArray = Parms.ToString.Split("|")
                
                Dim DeviceRef As String
                DeviceRef = ParmArray(0)
        
                Dim Direction As String
                Direction = ParmArray(1)
        	
        	hs.writelog( "Dim", "Device Ref: " &  chr(34) & DeviceRef & chr(34) & " Direction: " &  chr(34) & Direction & chr(34))
        		
        	Select Direction   
        		 Case "Up"
        			DimValue = 10
        		Case Else
        			DimValue = -10
        	End Select
        	
        	If hs.DeviceExistsRef(DeviceRef) <> -1  Then
        			CurrentDeviceValue = hs.DeviceValue(DeviceRef)
        			hs.writelog( "DIM", "Changing Dim level of device : " & DeviceRef & " from " & CurrentDeviceValue & " to " & CurrentDeviceValue + DimValue)
        			If CurrentDeviceValue < 1  THEN
        				hs.writelog( "DIM", "Dim: " & chr(34) & DeviceRef & chr(34) & " ignoring: device is off")
        			Else ' Device exists
        				' Change dim level or upor down
        				hs.ExecX10(DeviceRef,"Dim",CurrentDeviceValue + DimValue)
        			End if ' Dim Level
        		Else ' Device does not exist
        			hs.writelog( "DIM", "No DeviceRef Matching " & chr(34) & DeviceRef & chr(34) & " Exists")
        		End If ' Device Exists
         end sub
        ________________________

        Dell Zino HD - HSPRo 2.x
        HSTouch - iPhone 3GS, 4S, iPad2 and iPad 3, 3xKindle Fire (Wall mounted)
        2 x Brultech ECM1240 with UltraECM
        USB UIRT
        Cooper Aspire Z-Wave Switches
        WGL800 w ACRF2 and 3xDS10a (Sump Level/Activity sensing)
        HM ST812-2 Flood Sensor
        HSM100 - Motion Detector with Light and Temperature
        2GIG Thermostat
        BLDSC - Alarm Plug-in
        BLUPS
        UltraLog (SQL2008)
        Jon00 Plugins
        Host XR3 BT and Jon00 BT Proximity
        Global Cache IP2IR
        Foscam FI8918W

        Comment


          #5
          Much simpler way to debug your scripts, including dynamic display of all log entries:

          http://tenholder.net/tenWare2/tenScripting/default.aspx

          tenholde
          tenholde

          Comment

          Working...
          X