Announcement

Collapse
No announcement yet.

CAPI for idiots like me

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

    CAPI for idiots like me

    Attached Files
    -Rick

    #2
    You can read the existing value using hs.DeviceValue and then increase/decrease the number that is returned by it before setting the device using CAPI. Here's a code snippet that should get you started (this increases is by 5):

    Code:
    	devValue = hs.DeviceValue(targetDev)
    	newDevValue = devValue + 5
    	hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev, false, CStr(newDevValue), false, true))
    You'll probably want to build some checks in to ensure it doesn't exceed the maximum allowed value or go below the minimum allowed.

    Cheers
    Al
    HS 3.0.0.548: 1990 Devices 1172 Events
    Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

    Comment


      #3
      Originally posted by rmorton27 View Post
      . . .and the CAPI stuff really gives me conniptions.
      I do see some wonderful potential in HS3 buts it's tough getting there from a mature HS2 system.
      I feel your pain, having gone through the process a year ago. You are right, though. It is definitely worth the trouble.

      Regarding CAPI, are you familiar with the TenScriptAid tool? If not, I'd recommend you try it. It's an excellent way to gain insight into CAPI commands.
      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


        #4
        Uncle Michael - Thanks, I had started some time ago down that route and got distracted with other Alligators, I will make the effort, though...

        Sparkman, again you pointed the way forward and I now have a working prototype only the first two rows work but they work! Not too happy with my layout but that just exposes another weak point in my abysmal skills.

        Thanks again.
        Attached Files
        -Rick

        Comment


          #5
          Originally posted by rmorton27 View Post
          Sparkman, again you pointed the way forward and I now have a working prototype only the first two rows work but they work! Not too happy with my layout but that just exposes another weak point in my abysmal skills.

          Thanks again.
          Great, glad that was of help to you!

          Cheers
          Al
          HS 3.0.0.548: 1990 Devices 1172 Events
          Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

          Comment


            #6
            Hi,

            I have taken the suggestion to try out TenScriptAid and I can see its utility. It gives new insights. However, with this knowledge comes new challenges because it gives code snippets in vb. For example, I have discovered decisive that I have the same problem that many have had with Z-Wave thermostats that you can set the set points but they don't result in convincing the thermostat to execute them. TenScripAid can interrogate the thermostats (HS3) setpoint, it generates the code stub and it works.

            Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(111, True, "(value) F", False, False)
            cc.ControlValue = 74
            Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)

            My new problem that I am confronted with is to try and translate the VB code into VBScript. I wonder if someone might be able to show me the way with this snippet to unwind the VB into VBScript?

            -Rick
            -Rick

            Comment


              #7
              Hello,

              I use this script to set my Heating Setpoint in my Zwave thermostat SRT323:

              Sub Main(ByVal Parm As Object)
              dim Value_temp as double
              Value_temp = Parm
              Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(hs.GetDeviceRefByName("Regulation Chauffage Couloir Haut Heating Setpoint"), True, "(value) C", False, False)
              cc.ControlValue = Value_temp
              Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
              Log("Valeur SetPoint Etage" & cr)
              End Sub
              Sub Log(ByVal ParStr As String)
              hs.WriteLog("Thermostat", ParStr)
              End Sub
              I pass the heating setpoint temperature by variable in an event

              Jean-Francois
              Attached Files

              Comment


                #8
                Seeing Jean-Francois suggestion gave me an idea. Could I call this vb routine from my asp page, so I created a file called SetHeat.vb in my script folder based on tenScriptAid and Jean-Francois's samples.

                Sub Main(ByVal Parm As Object)

                dim Value_temp as double
                Value_temp = Parm

                Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(111), True, "(value) F", False, False)
                cc.ControlValue = Value_temp

                Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)

                End Sub

                This is my asp code

                theDevice = 111
                devValue = hs.DeviceValue(theDevice)
                devValue=devValue+1
                if devValue > 81 then devValue=72
                if devValue < 59 then devValue=72
                newDevValue=devValue
                hs.runscriptfunc "SetHeat.vb", "Main",newDevValue

                and I get an error in my asp page when I clik the button that assigns this value.

                Script error: Invalid procedure call or argument: 'hs.runscriptfunc'

                hs.runscriptfunc "SetHeat.vb", "Main",newDevValue
                hs.writelog "increase heat setpoint",cstr(newDevValue)

                So I wonder if anyone can point out the problem?

                -Rick
                -Rick

                Comment


                  #9
                  Runscriptfunc has 5 parameters so try:

                  hs.runscriptfunc "SetHeat.vb", "Main",newDevValue, false, false

                  http://homeseer.com/support/homeseer...scriptfunc.htm
                  Jon

                  Comment


                    #10
                    I'm beyond excited. With tenScriptAid and this bit of magic from jon00, I can now set the setpoints for thermostats and I image most any CAPI device. While I am still very much in the dark about vb.net syntax CAPI and all of that I have a way to actually do stuff and not be the pain the ***. I hope this exuberance ins;t short lived...

                    My ASP:
                    theDevice = 111
                    devValue = hs.DeviceValue(theDevice
                    devValue=devValue+1
                    if devValue > 81 then devValue=72
                    if devValue < 59 then devValue=72
                    newDevValue=devValue
                    hs.runscriptfunc "SetHeat1.vb", "Main",newDevValue, false,

                    My VB.net:
                    Sub Main(ByVal Parm As Object)
                    dim Value_temp as double
                    Value_temp = Parmhs.writelog("fromsetheat1",cstr(Value_temp))
                    Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(111, True, "(value) F", False, False)
                    cc.ControlValue = Value_temp
                    Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
                    End Sub

                    Note tenScriptAid creates these code snip with constants so I replaced it with Value_temp and all seems good.
                    -Rick

                    Comment

                    Working...
                    X