Announcement

Collapse
No announcement yet.

How to Setup a Basic .ASP Page to Access HS?

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

    #16
    jon00,
    I have the page all working with 3 thermostats(but only setting the HS device, not the actual hardware device). Now I'm trying converting all my "SetDeviceValueByRef" to CAPI Object code. Will the CAPI Objects work properly in VBScript?

    I seem to be having issues where the Object is not being setup(i.e. following code throws a "Script error: Object required: 'cc' " ):

    cc=hs.CAPIGetSingleControl(485, True, "(value) F", False, False)
    cc.ControlValue = 76
    cr = hs.CAPIControlHandler(cc)

    Comment


      #17
      Originally posted by BobSpen View Post
      jon00,
      I have the page all working with 3 thermostats(but only setting the HS device, not the actual hardware device). Now I'm trying converting all my "SetDeviceValueByRef" to CAPI Object code. Will the CAPI Objects work properly in VBScript?

      I seem to be having issues where the Object is not being setup(i.e. following code throws a "Script error: Object required: 'cc' " ):

      cc=hs.CAPIGetSingleControl(485, True, "(value) F", False, False)
      cc.ControlValue = 76
      cr = hs.CAPIControlHandler(cc)
      Whilst that works in .NET, for VBScript, referencing the CAPI object seems to be an issue.

      You may need to do something like:

      Code:
      X = 76
      hs.CAPIControlHandler (hs.CAPIGetSingleControl(485, True, X & " F", False, False))
      Jon

      Comment


        #18
        jon00,
        Thanks for your help I got a bit further.

        I am NOT getting the script error with your suggestion, but the CAPI control does NOTHING to the HS device or to the physical thermostat. I've tried every combination of the "value" parameter(that I can think of) but nothing seems to get through to HS:

        X = "75 F"
        hs.CAPIControlHandler (hs.CAPIGetSingleControl(485, True, X, False, False))
        or
        X = 76
        hs.CAPIControlHandler (hs.CAPIGetSingleControl(485, True, X & " F", False, False))

        The one that DOES work in VB.NET(tenScriptAid) looks like:
        Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(485, True, "(value) F", False, False)
        cc.ControlValue = 75
        Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)

        Do you have another idea I might try?

        Comment


          #19
          Yes, but before I do, have you checked the format of the CAPI control text in an event is the same as the formatting used in the script? If you were going to set the temperature via an event, what is the exact text shown in the drop down? If it is something like '76 F' then I'll suggest another way.
          Jon

          Comment


            #20
            jon00,
            The format in the drop-down is "76 F"(no quote marks).

            Comment


              #21
              OK, let's try a remote script in VB.NET

              Add the following to your asp page:

              Code:
              Dim TSData(1)
              TSData(0)=485
              TSData(1)=76
              hs.Runscriptfunc("TStat.vb","Main",TSData,True,False)
              Then create a script called TStat.vb in your scripts directory:

              Code:
              Sub Main (byVal TSData As Object)
              
              Dim RefNo As Integer = TSData(0)
              Dim TempVal As Double = TSData(1)
              Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(RefNo, True, "(value) F", False, False)
              cc.ControlValue = TempVal
              Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
              
              End Sub
              You can call the same routine with your other Thermostats, changing the ref no.
              Jon

              Comment


                #22
                jon00,
                OK, that mostly works [I had to remove the "( )" around the Runscriptfunc] in my .asp code; but immediately after the Runscriptfunc I read all the HS devices(including the one('s) I just set) to update the "form". Apparently the Runscriptfunc has not yet executed in HS so the device I am setting to a new value still has it's previous value so my "form" shows the previous value. Maybe I can delay the .asp routine? or figure out how to change the logic. So I'm getting close--thank you.

                Comment


                  #23
                  Change the script to a function:


                  Code:
                  Function Main (byVal TSData As Object) As String
                  Dim RefNo As Integer = TSData(0)
                  Dim TempVal As Double = TSData(1)
                  Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(RefNo, True, "(value) F", False, False)
                  cc.ControlValue = TempVal
                  Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
                  Return ""
                  End Function
                  Any difference?
                  Jon

                  Comment


                    #24
                    No difference.
                    I call the function 6 times in a row(since I send all setpoints for 3 Thermostats) and I have to add about 1/2 to 1 second "wait" after all 6 calls so that my form updates with the current values from HS. Is CAPI pretty slow?

                    Comment


                      #25
                      Originally posted by BobSpen View Post
                      No difference.
                      I call the function 6 times in a row(since I send all setpoints for 3 Thermostats) and I have to add about 1/2 to 1 second "wait" after all 6 calls so that my form updates with the current values from HS. Is CAPI pretty slow?
                      It must be. Why not also set the device values (first) so you should not have to wait?
                      Jon

                      Comment


                        #26
                        I'm not sure I understand your question. On first load of the page I read all six setpoints and the "form" is displayed. After the user modifies one or more of the setponts, the page is refreshed and I write the new values to HS(and CAPI) thru the "function" calls and thru the same code, read the values of the six HS setpoints, again after waiting 1 second.

                        I suppose I could add some logic to NOT change the "form" on the refresh but there is some value(to me) to actually see that the HS device was in fact changed.

                        btw, I am trying to add a small image to the page and it will not load: always shows the "alt" text. I've done this many times before on .aspx and .htm pages---is there anything different about an .asp page?

                        Comment


                          #27
                          The form reads the device values to update the setpoints, right? At the moment, you are using CAPI to control these setpoint devices which in turn updates their device values with the changes. This is causing your issue and why you need to add a delay. Therefore, if you set the device values before the CAPI routine executes (both to the new setpoint values), you don't have to wait for CAPI to update the device values. As you have already changed the device value in code, the page can be refreshed immediately and the new device values read.

                          You would need to post the code you are using for the image issue.
                          Jon

                          Comment


                            #28
                            Here is the Image code:

                            CODE on .asp PAGE
                            <img alt="ok" src=”/Images/253.gif” id="activeSymbolgreat" style="width:50px; background-color:aqua;">

                            EDIT: I'm not sure the below error came from above; I now don't seem to be getting any LOG error when loading the page but still get the "alt" text---"ok"

                            LOG:
                            Warning File does not exist: C:\Homeseer HS3\html\rgshome\”\Images\253.gif”

                            Comment


                              #29
                              From the lack of response from my last post, I assume you still don't get what I was trying to explain?

                              Regarding the image issue, the reason you are not seeing the image is that you have not used quotation marks to define the src= entry.
                              Code:
                              src=/Images/253.gif
                              Should be:

                              Code:
                              src="/Images/253.gif"
                              You typically get this when M$ Word is involved.

                              Also, what are you trying to use the alt tag for? If it is to show "OK" as a tool-tip then the use of that tag is WRONG and something implemented by M$ for Internet Explorer. It's intended usage is to show its defined text if the image is not available (which is what you are currently seeing due to your issue).

                              The correct tag for tooltip use is to use title="OK"

                              Try the corrected entry:

                              Code:
                              <img title="ok" src="/Images/253.gif" id="activeSymbolgreat" style="width:50px; background-color:aqua;">
                              Jon

                              Comment


                                #30
                                jon00,
                                I will respond to the "delay" issue after I have had a chance to flow chart and try to understand what you are suggesting.

                                RE: the image display; I have no clue where those quote marks came from. I don't use MS Word. I only use NotePad and I don't see the 'angled" quote marks anywhere else in the code. I changed the line to what you posted(copy/paste) and it now looks correct, BUT still does not display the image. I did copy/paste the original line to an existing .htm page and it displays fine???????

                                Comment

                                Working...
                                X