Announcement

Collapse
No announcement yet.

Really.. Scripting 101 and I feel so stupid

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

    Really.. Scripting 101 and I feel so stupid

    I must be missing something fundamental with scripting.. I have a script that can fetch the value of a light. Fine.

    It also takes the current value and add 25 to it. Also fine.

    But i cannot for the life of me figure out how to use CAPI to send the value back to the device?

    I fount tenscripting and tenscriptingaid. But still.. i can use "on" and "off". But i can not figure out how to send a dim value??

    Code:
    Class BedroomSwipeToggleFloorLight
        Public Sub Main(ByVal theDevice As String)
            ''
            '' Toggle the Specified Device ON/OFF
            '' DIM is considered ON
            ''
            '' Specify the Device Name, including Locations, as a Parm
            Dim devValue As Double
            ''
    
            '' Get the Device Status
    
    
            devValue = hs.DeviceValue(theDevice)
    
    
    
            '' Toggle it
            hs.WriteLog("SampleScript", devValue.ToString)  '@DONOTEXPORT
            Select Case devValue
                Case Is < 100
                    devValue = devValue + 25
                    hs.WriteLog("SampleScript", devValue.ToString)  '@DONOTEXPORT
                    If devValue > 99 Then
                        devValue = 99
                    End If
                    hs.WriteLog("SampleScript", devValue.ToString)  '@DONOTEXPORT
                    hs.CAPIControlHandler(hs.CAPIGetSingleControl(theDevice, True, "99%", False, False)) #<-- This is what i cannot get working, no set of the "99" parameter regardles of casting etc gets me what i wantr.
    
    
                Case Is = 99
                    hs.CAPIControlHandler(hs.CAPIGetSingleControl(theDevice, True, "off", False, False))
    
            End Select
        End Sub
    End Class
    Again, if i use

    hs.CAPIControlHandler(hs.CAPIGetSingleControl(theDevice, True, "on", False, False)) it works...

    #2
    The first thing to confirm is that your device is set to be a dimmable device and there is a dimming range specified on the Status Graphics page.

    Then, when you call up TenScriptAid your should see something like the image below, along with sample code to enter a dim level.
    Attached Files
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.548, NUC i3

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

    Comment


      #3
      Originally posted by Uncle Michael View Post
      The first thing to confirm is that your device is set to be a dimmable device and there is a dimming range specified on the Status Graphics page.

      Then, when you call up TenScriptAid your should see something like the image below, along with sample code to enter a dim level.

      Yeah, i have all that. WHat i cannot figure out is how to convert that code into something that accepts an arbitrary integer 0-99 there is something about the variable expansion that i simply am not grasping,.

      Or wait.. are all thre lines needed? I assumed that the (value)% was a place holder?

      Comment


        #4
        Well I'll be... all lines was needed.

        Strange, but now it works. Yey.

        Comment

        Working...
        X