Announcement

Collapse
No announcement yet.

Help with getting data from website

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

    #16
    yup now it pulls the data from the page...

    Dec-27 7:16:38 PM Fridge Temperature: 3
    Dec-27 7:16:38 PM Freezer Temperature: -18
    Dec-27 7:16:38 PM Hugo's Room Temperature: 27
    Dec-27 7:16:38 PM Fridge Temperature: 2
    Dec-27 7:16:38 PM Fridge Temperature: 2
    Dec-27 7:16:38 PM Freezer Temperature: -19
    Dec-27 7:16:38 PM Hugo's Room Temperature: 28
    Dec-27 7:16:38 PM Freezer Temperature: -20
    Dec-27 7:16:38 PM Hugo's Room Temperature: 30
    Dec-27 7:16:38 PM Garage Temperature: 2
    Dec-27 7:16:37 PM Event Running script in background: C:/Program Files (x86)/HomeSeer HS3/scripts/mrhappy.vb
    Dec-27 7:16:37 PM Event Event Trigger "scripts MrHappy"
    Dec-27 7:16:37 PM Event Event scripts MrHappy triggered by the event page 'Run' button.

    Comment


      #17
      OK i have been playing with this for a while and ive come to realize i have no clue what im doing. I tried the setdevicestring etc etc and cant get anything right.

      Comment


        #18
        What is the syntax you are using to set the device string?
        Don

        Comment


          #19
          Hers the script, as you can see from the thread its all MrHappy's, but for the one line in red which is where im attempting to send the data to a devices I created called fridge with a device cod of A100.

          Sub Main(ByVal Parms As Object)

          Dim inputStr As String = hs.GetUrl("192.168.1.11", "/SS.htm", False, 80)

          Dim rows() As String = Split(inputStr, "<tr>")
          Dim divisions() As String

          For i As Integer = 0 To rows.getupperbound(0)
          If rows(i).contains("Fridge") Then
          divisions = Split(rows(i), "<td>")
          divisions(5) = divisions(5).Replace("</td>", "")
          hs.writelog("Fridge", "Temperature: " & convert.toint32(divisions(5)))

          End If
          If rows(i).contains("Garage") Then
          divisions = Split(rows(i), "<td>")
          divisions(5) = divisions(5).Replace("</td>", "")
          hs.writelog("Garage", "Temperature: " & convert.toint32(divisions(5)))
          hs.SetDeviceString "A100", Motion Detected", True

          If rows(i).contains("Freezer") Then
          divisions = Split(rows(i), "<td>")
          divisions(5) = divisions(5).Replace("</td>", "")
          hs.writelog("Freezer", "Temperature: " & convert.toint32(divisions(5)))
          End If
          If rows(i).contains("HRoom") Then
          divisions = Split(rows(i), "<td>")
          divisions(5) = divisions(5).Replace("</td>", "")
          hs.writelog("Hugo's Room", "Temperature: " & convert.toint32(divisions(5)))
          End If
          Next

          End Sub

          Comment


            #20
            The error is because it should be surrounded in brackets

            hs.SetDeviceString("A100", Motion Detected", True)

            However, in HS3 "A100" is not valid as it expects a reference (a number) whereas A100 is a code. You would need to get the reference using something like hs.GetDeviceRef and provide it with an address. I can't see a method of getting the reference by code alone. HS has changed a fair bit in terms of devices and the aim more so now is to use values rather than strings.

            Comment


              #21
              Would you be interested in completing this script for payment? im obviously in way over my head, or do you know of others on the forums that may be want to do it?

              Comment


                #22
                It is more of a question of the unknowns becoming known, you could spend ages getting something to work only for an extra row/column of data to appear in the table that you did not expect and then it is broken again. I have been there enough times going backwards and forwards looking for the extra html tag that some developer has put in to ruin my day. I personally absolutely hate doing web page parsing if I can help it, you only have to ask Jon00 how many times he has patiently upgraded and updated his BBC weather script because they have messed with the site. I wrote a script to just get the pollen count from the BBC, lasted a month and it is broken again. People more adept at it than me do know how to handle it better than me though.

                Anyway enough about the history, does whatever device this is have any other form of API/documentation? I am wondering whether if you could pass it a query by URL for a specific device then get a table of that device, then it might just make things slightly easier.

                Comment


                  #23
                  Thanks for the reply, I will email and ask if they have any API information although I doubt it as its a very basic device and by the looks of the page not an overly complex setup. I do however know that the table is static to the last 10 devices that reported so if the script reads all 10 no mater if the number of devices increase or change the page itself will not change..Your welcome to Teamviewer my computer if you'd like to see more detail?

                  Comment

                  Working...
                  X