Announcement

Collapse
No announcement yet.

Datascraper rounding of number

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

    Datascraper rounding of number

    jon00 I have pulled the number 549213 from a site perfectly using DataScaper. But I need the actually the value in homeseer to be 0.00549213

    How can i make this adjustment please? I tried multiplying and dividing and using round9 (but i dont think your round command works higher than round2)

    Is there a way to reformat the Device Value? I tried [0 *100000000, /100000000, round9, -1]

    Also can I use the value from one grab in another? e.g. Grab1 gets me a value from one site, and Grab2 a value from another site. I need to have in Homeseer the value of Grab1*Grab2

    Thank you.

    #2
    If the value is 549213 then just dividing by 100000000 will give the desired result i.e.

    [0 /100000000]

    Regarding using two grab values, look at example 1b in the Mathematical, Conversion & String Expressions section. Check you are running at least V1.0.28


    Jon

    Comment


      #3
      Thank You Jon. I read 1b but don’t know how that would allow me to work with two values which have been from different grabs?

      I could see how it would work with two result from the same grab.

      But I need one [0] from [Grab1] multiplied by [0] from [Grab2]

      Hope that makes sense.

      Comment


        #4
        Also Jon [0 /100000000] for my result changes your value 0.02 so something isn’t working right. Thank you.

        Comment


          #5
          Originally posted by barto View Post
          Also Jon [0 /100000000] for my result changes your value 0.02 so something isn’t working right. Thank you.
          Add the following to your [GrabX] entry:

          DecimalPlaces=8

          See if that resolves the issue.
          Jon

          Comment


            #6
            Originally posted by barto View Post
            Thank You Jon. I read 1b but don’t know how that would allow me to work with two values which have been from different grabs?

            I could see how it would work with two result from the same grab.

            But I need one [0] from [Grab1] multiplied by [0] from [Grab2]

            Hope that makes sense.
            OK, yes I forgot it was 2 different grabs.

            In that case you will need to use the scripting func to do this.

            For one of the Grab2 devices you wish to create, something like:

            [0 func DS1.vb Main]

            And then create a script called DS1.vb with the following code:

            Code:
            Function Main (ByVal Parms As String) As String
                Try
                    Dim Grab1 As String = hs.GetIniSetting("Grab1Data","0","","Jon00DataScraperData.ini")
                    Return CDec(Parms) * CDec(Grab1)
                Catch Ex As Exception
                    hs.Writelog("Error","Error in DS1.vb: " & Ex.ToString)
                End Try
                Return "0"
            End Function
            That will pass Grab2 [0] value to the script. Grab1 [0] is read directly from the ini file and both multiplied together.
            Jon

            Comment


              #7
              As always Jon it works perfect. Thank you - you are a legend!

              Comment

              Working...
              X