Announcement

Collapse
No announcement yet.

Help with implementing sparkmans Script to update Weather Underground

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

    Help with implementing sparkmans Script to update Weather Underground

    I've recently started to implement HS3. I have an Oregon weather station and I use an app called Weather Station Data Logger to upload dato to Weather Underground. I stumbled upon sparkmans script here: http://board.homeseer.com/showthread.php?t=172082

    Unfortunelately, I can't make it work, and I don't understand the error messages...

    Here is the edited script I am using; I'd be very grateful if someone can help me debug this.
    This is the error message: Running script, script run or compile error in file: C:/...ulscript.txt1006:Expected ')' in line 2 More info: Expected ')'


    Sub Main(Parms As Object)
    'http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol

    Dim Debug as Boolean = False
    Dim logName As String = "WUnderground" 'set log name for HS log

    Dim cDateTime As Date = Now.ToUniversalTime() 'retrieve current time and convert to UTC
    If Debug Then hs.writelog(logName,CStr(cDateTime))
    Dim sDateTime As String = cDateTime.ToString("yyyy-MM-dd+HH:mm:ss") 'change time to format required by WUnderground
    sDateTime = Replace(sDateTime,":","%3A") 'URLEncode :
    If Debug Then hs.writelog(logName,sDateTime)

    Dim httpCommand As String = "/weatherstation/updateweatherstation.php?ID=xxx&PASSWORD=xxx" 'Change to use your own station ID and password
    httpCommand = httpCommand & "&dateutc=" & sDateTime


    If hs.DeviceString(45) <> "Communication Failure" Then httpCommand = httpCommand & "&tempf=" & CStr(CDbl((hs.DeviceValueEx(45) * 9/5) + 32))
    If hs.DeviceString(44) <> "Communication Failure" Then httpCommand = httpCommand & "&humidity=" & CStr(hs.DeviceValueEx(44))


    httpCommand = httpCommand & "&softwaretype=hs"
    httpCommand = httpCommand & "&action=updateraw"
    If Debug Then hs.writelog(logName, httpCommand)

    Dim info2 As String = hs.GetURL("weatherstation.wunderground.com",httpCommand,Fals e,80)
    If InStr(info2,"success") > 0 Then
    hs.writelog(logName, "Successfully Updated")
    Else
    hs.writelog(logName, info2)
    End If
    End Sub

    #2
    Try renaming the file to have a .vb extension, you look to have it set to .txt and there is a good amount of vb.net in that script. Naming it .vb causes it to be run as .net whereas .txt causes it to go through the VBScript compiler and VBScript is structured differently.

    Comment


      #3
      As mrhappy said, it is a vb.net script and needs to have a .vb extension. I'll update the original post to indicate that. Let me know if it works for you.

      Cheers
      Al
      HS 4.2.8.0: 2134 Devices 1252 Events
      Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

      Comment


        #4
        Thanks, I'll try this when I get home from work

        Comment


          #5
          Originally posted by sparkman View Post
          As mrhappy said, it is a vb.net script and needs to have a .vb extension. I'll update the original post to indicate that. Let me know if it works for you.

          Cheers
          Al
          It works now, at least partially. Haven't got time to investigate more until later in the week.

          Comment


            #6
            The script is communicating with weatherunderground, but it is uploading wrong values. Could it be something with Celsius (I'm using Celsius) / Fahrenheit, or perhaps I'm using wrong device ID?

            Here is what WU is displaying:


            I'm using the reference ID 45 as device ID in the script:

            Comment


              #7
              Can you change "Dim Debug As Boolean = False" to "Dim Debug As Boolean = True" and post the output from the HS log? I use Celsius as well, but WUnderground needs the data in Fahrenheit, which is why there's a conversion formula. I expect WUnderground needs a . as the decimal separator rather than a , so you will likely need to add some script commands to have the script change that for you.

              Cheers
              Al
              HS 4.2.8.0: 2134 Devices 1252 Events
              Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

              Comment


                #8
                Here it is. Humidity seems correct, but temp is off. edit, the formula convertion C to F is correct, 7,7F is correct. So the issue might be the decimab separator? I'll try to change the settings on my server and see if I can use that as work around.

                /weatherstation/updateweatherstation.php?ID=yyyyy&PASSWORD=xxx&dateutc=2016-01-20+12%3A59%3A40&tempf=7,7&humidity=80&softwaretype=hs&action =updateraw
                Last edited by HAorso33; January 20, 2016, 08:17 AM.

                Comment


                  #9
                  You could just manually modify the url to change the , to a . and then paste into a browser as a test. I expect that will resolve the issue. It would be a simple change to the script to automatically replace it.

                  Cheers
                  Al


                  Sent from my iPhone using Tapatalk
                  HS 4.2.8.0: 2134 Devices 1252 Events
                  Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                  Comment


                    #10
                    Yes, that did it! I changed the settings in windows, and now it is reporting correctly:



                    Thanks alot for helping!! If you know how to convert to period in the script I'll be happy to test for you

                    Comment


                      #11
                      Originally posted by HAorso33 View Post
                      Yes, that did it! I changed the settings in windows, and now it is reporting correctly:

                      Thanks alot for helping!! If you know how to convert to period in the script I'll be happy to test for you
                      No problem. I've updated the original script with the changes. Take a look and let me know if that works.

                      Cheers
                      Al
                      HS 4.2.8.0: 2134 Devices 1252 Events
                      Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                      Comment


                        #12
                        I tested it now, and can confirm it works! Thanks again!

                        Comment

                        Working...
                        X