Announcement

Collapse
No announcement yet.

Z-wave Dim/Bright Script

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

  • Z-wave Dim/Bright Script

    I'm trying to use the script in post four here:
    http://board.homeseer.com/showthread.php?t=128127

    It gives me an error on Line 10, which is the first line of code, that it expected ")".

    It is rather annoying that I can't even get past the first line of code during my troubleshooting.

    I'm using a USB-UIRT for an IR Match to trigger an event for my Z-wave adapter to dim or brighten by 10% for each button press. I'll have a code for Dim and a code for Bright mapped on my remote for each light. I'm sending the following optional parameters ("Main","-10/Q6") with the dim_bright.txt script. The light I'm testing is Q6.

    I'm new to Homeseer scripting so any help would be appreciated.

    Code:
    ' adjust light level up/down 10% based on input parameter
    ' string containing dim/bright value and device code
    
    ' Thanks to initial script from huggy_d1 (2008/04/28)
    ' Modified by CheeryFool (2008/05/12) to use two concatenated event 
    ' input parameters (relative dim value and device code), which are
    ' parsed into variables.
    
    
    Sub Main(ByVal inputparms as String)
    
            dim pos = InStr(inputparms, "/")
            dim strSize = Len(inputparms)
            dim valchg as String = Left(inputparms, pos - 1)
            dim varLight as String = Right(inputparms, strSize - pos)   
    
      
            dim debugmode as Boolean = vbFalse
            dim lDimLevel as Long
    
    
            '---device status code
            '0 = All Units Off
            '2 = ON 
            '3 = OFF
            '4 = DIM
            
                'store current dim level
                lDimLevel = hs.DeviceValue(varLight)
    
                'if debug mode ouput current values to log
    
            if debugmode then hs.writelog( "Harmony Lights", varLight & " Dim Level     = " & lDimLevel )
            if debugmode then hs.writelog( "Harmony Lights", varLight & " Device Status = " & hs.DeviceStatus(varLight) )
            if debugmode then hs.writelog( "Harmony Lights", varLight & " Device Value  = " & hs.DeviceValue(varLight) )
        
                'max out new dim level at 100% and set to ON
    
            if lDimLevel + valchg > 100 then
                lDimLevel = 100
                hs.ExecX10( varLight,"On",,,vbTrue )
                hs.SetDeviceStatus( varLight, 2 )
                hs.SetDeviceValue( varLight, lDimLevel)
    
                'min out new dim level at 0% and set to OFF
    
            elseif lDimLevel + valchg < 0 then
                lDimLevel = 0
                hs.ExecX10( varLight,"Off",,,vbTrue )
                hs.SetDeviceStatus( varLight, 3 )
                hs.SetDeviceValue( varLight, lDimLevel)
    
                'else set new dim level, device value and device status
           
            else lDimLevel = lDimLevel + valchg
                hs.ExecX10( varLight,"DDim", lDimLevel,,vbTrue )
                hs.SetDeviceStatus( varLight, 4 )
                hs.SetDeviceValue( varLight, lDimLevel) 
    
            end if
           
    
    'if debug mode output end values to log
           
    if debugmode then hs.writelog( "Harmony Lights", varLight & " Dim Level     = " & lDimLevel )
    if debugmode then hs.writelog( "Harmony Lights", varLight & " Device Status = " & hs.DeviceStatus(varLight) )
    if debugmode then hs.writelog( "Harmony Lights", varLight & " Device Value  = " & hs.DeviceValue(varLight) )
    
    end sub

  • #2
    What extension did you put on the script?
    -Rupp
    sigpic

    Comment


    • #3
      Originally posted by Rupp View Post
      What extension did you put on the script?
      As usual I solved my problem after posting.

      I renamed it from .txt to .vb and it worked. Now I just have to learn a ton of IR codes and I'll be set.

      Comment

      Working...
      X