Announcement

Collapse
No announcement yet.

Is it possible to trap errors in URLAction GET?

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

    Is it possible to trap errors in URLAction GET?

    I use several different controllers (a Vera, and a CAI Webcontrol) to manage a few specific devices, and I use Homeseer to retrieve data from these "secondary controllers" via the LAN. Sometime these secondary controllers will go down, and the only way Homeseer can tell is if the URLAction (Get) command fails. When it does fail I get an error message in the log noting the failure.

    Is there any way to trap the error so I can eliminate the logged error message? I don't need this for my script to work properly, because if the GET fails it returns a unique value i can identify. The only purpose of trapping the error is to clean up the log file, so it's not a big deal. But - it would be nice to do.

    Any thoughts?

    Thanks in advance for your help.

    #2
    Originally posted by jwshome2 View Post
    Any thoughts?
    .
    Rather than using "hs.get", you could write the "get" using explicit VB script. Then you can "trap" the errors as you see fit.

    Example:

    Code:
    Imports System.Net
    Imports System.IO
    ...
      Dim request As WebRequest, response As WebResponse, ds As Stream, reader As StreamReader, sUrlResponse As String
      Dim url As String = "http://192.168.0.68/..."
      Try
        request = WebRequest.Create(url)
        request.Method = "GET"
        request.ContentType = "application/json"
        response = request.GetResponse()
        ds = response.GetResponseStream()
        reader = New StreamReader(ds)
        sUrlResponse = reader.ReadToEnd()
        reader.Close()
        response.Close()
        hs.writelog("GetStatus", sUrlResponse)
      Catch ex As Exception
        hs.writelog("GS Err", ex.ToString)
      End Try

    Comment


      #3
      Excellent - this works perfectly, thanks.

      Comment


        #4
        I have a followup question - is there a way to execute this code in an .asp page on Homeseer? I could have the asp page call the script to update a homeseer device and then have the page read the device value, but is there a more direct way to do this in asp itself?

        Comment

        Working...
        X