Announcement

Collapse
No announcement yet.

Sample code for device control

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

  • Sample code for device control

    I had downloaded some sample code about a year or so from somewhere on homeseer showing how to control device with CAPI. I have been using CAPI to turn devices on and off for quite a while. Now I want to control a device that dims and set it to a specific dim value. I cannot get this to work with my current code. I can't find the code that I downloaded previously. Does anyone remember where this sample code is located? I believe that it was in some kind of article written my Rich. Or, some other sample code would work as well.

  • #2
    Are you using the CAPIControl.vb script that Rich posted some time back?

    If so you can use it to turn lights on/off/dim. Posted below is a screen shot of 3 test events using the script.

    The example on event turns on the device named "Button A - Table Light (MS)".
    The example off event turns off the device named "Button A - Table Light (MS)".
    The example dim event dims the device named "Button A - Table Light (MS)" to 33%.

    I also attached the VB script as a text file (remove the .txt extension)

    Click image for larger version

Name:	event.jpg
Views:	1
Size:	108.0 KB
ID:	1187178

    Hope this helps.
    Billy Draper

    Comment


    • #3
      Here's an example of a small script that sets a dim value using CAPI:

      Code:
      Sub Main(ByVal Parms as String)
      
      	Dim ParmArray() as String
      	ParmArray = Parms.tostring.split(",")
      	dim targetDev as Double = CDbl(ParmArray(0))		'reference ID of the device to use for existing value
      	dim targetDim as Double = CDbl(ParmArray(1))		'reference ID of the device to set based on value of targetDev1 
      	hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev,false,targetDim,false,true))
      	hs.writelog("Dim Script","Set New Dim: " & targetDim)
      
      End Sub
      HS 3.0.0.532: 1963 Devices 1141 Events
      Z-Wave 3.0.1.261: 122 Nodes on one Z-Net

      Comment


      • #4
        You may also find that tenScriptAid is a useful tool.
        Mike____________________________________________________________ __________________
        HS3 Pro Edition 3.0.0.548

        HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3

        Comment


        • #5
          I got it working

          Originally posted by bdraper View Post
          Are you using the CAPIControl.vb script that Rich posted some time back?

          If so you can use it to turn lights on/off/dim. Posted below is a screen shot of 3 test events using the script.

          The example on event turns on the device named "Button A - Table Light (MS)".
          The example off event turns off the device named "Button A - Table Light (MS)".
          The example dim event dims the device named "Button A - Table Light (MS)" to 33%.

          I also attached the VB script as a text file (remove the .txt extension)

          [ATTACH]56722[/ATTACH]

          Hope this helps.
          I got it working using the sample. The script attachment was exactly what I was talking about in the original post. I will put that in a safe place for future reference.

          Comment


          • #6
            Originally posted by jimbell View Post
            I got it working using the sample. The script attachment was exactly what I was talking about in the original post. I will put that in a safe place for future reference.
            Good deal, glad you got it working.
            Billy Draper

            Comment


            • #7
              Thank for the info

              Originally posted by Uncle Michael View Post
              You may also find that tenScriptAid is a useful tool.
              I am a big fan of Ed Tenholder's Tenscripting tool. I use it for all my vb development. Makes the effort so much easier.

              I was not aware of the TenScriptAid tool. Looks like another great tool from Ed for Homeseer vb development.

              Thanks

              Comment


              • #8
                Originally posted by jimbell View Post
                I am a big fan of Ed Tenholder's Tenscripting tool. I use it for all my vb development. Makes the effort so much easier.

                I was not aware of the TenScriptAid tool. Looks like another great tool from Ed for Homeseer vb development.

                Thanks
                Jim,

                The support request you sent me had a bad return email address. Let me know if you got my response.

                tenholde
                tenholde

                Comment

                Working...
                X