Announcement

Collapse
No announcement yet.

Help with parsing return of a GetURL call

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

    Help with parsing return of a GetURL call

    Hello all,
    I'm trying to get the status of my Blue Iris system into a HS device value. The following does just as expected which is to return several values, one of which is the profile. I've been running it as an immediate command in an event. I really need to get that profile value (1 in this example) into a device but I don't know how to get the return of the GetURL and then parse into a variable.

    Here is the command command:
    &hs.GetURL("http://192.168.2.3:1234","/admin?&user=myuser&pw=mypass",TRUE,80)

    Here is the return (seen when I run it from a browser):
    signal=green
    profile=1
    lock=1​

    Any help will be appreciated!
    Robert

    #2
    Give this script a try. The parsing is very primitive but should work in this case.

    Choose either one of the methods to set the device value, and delete or comment out the one you don't use.

    Code:
    Imports System.Text.RegularExpressions
    
    Sub Main(p As String)
    
        ' set these as appropriate
        Dim host As String = "192.168.1.118"
        Dim page As String = "/admin?&user=myuser&pw=mypass"
        Dim port As Integer = 8000
    
        Dim strip_tags As Boolean = False   ' don't strip HTML tags
        Dim resp As String = hs.GetURL(host, page, strip_tags, port)
    
        ' parse response for "profile" keyword
        Dim token As String() = Regex.Split(resp, "\W+")
    ​    Dim profile As Integer = 0
        For ix As Integer = token.GetLowerBound(0) To token.GetUpperBound(0) - 1
            If token(ix).ToLower = "profile" Then profile = CInt(token(ix + 1))
        Next
    
        ' assign the parsed value to the device -
        ' either by device reference
        Dim dvRef As Integer = 1234
        hs.SetDeviceValueByRef(dvRef, profile, True)
    
        ' or by device name
        Dim dvName As String = "My Device Name"
        hs.SetDeviceValueByName(dvName, profile)
    
    End Sub​

    Comment


      #3
      Wow, thanks much! I'll try it tomorrow and will report back.

      Comment


        #4
        zwolfpack

        Thanks so very much for taking your time and creating this script! It worked perfectly. This was my last item needed to be resolved before I deprecated the (now unsupported) Blue Iris plugin. I now use only HTTP commands between HS3 and BI4.

        Comment


          #5
          Great!

          Comment


            #6
            You may also try Big6 plug-in that can send out HTTP GET, PUT, POST (your choice) and parse the response. You can set it up to create/update HS4 devices based on the response.

            Comment

            Working...
            X