Announcement

Collapse
No announcement yet.

Scipt to pull data from the new WU API

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

    #16
    Okay. I should have looked at the rest for you. Some things are directly under observations, and others are under imperial.

    Try this.

    Code:
           UpdateNlog("O112",jcData.observations(0).imperial.temp,"",0)
           UpdateNlog("O113",jcData.observations(0).imperial.heatIndex,"",0)
           UpdateNlog("O114",jcData.observations(0).imperial.dewpt,"",0)
           UpdateNlog("O115",jcData.observations(0).imperial.windChill,"",0)
           UpdateNlog("O116",jcData.observations(0).imperial.windSpeed,"",0)
           UpdateNlog("O117",jcData.observations(0).imperial.windGust,"",0)
           UpdateNlog("O123",jcData.observations(0).winddir,"",0)
           UpdateNlog("O118",jcData.observations(0).imperial.pressure,"",0)
           UpdateNlog("O119",jcData.observations(0).imperial.precipRate,"",0)
           UpdateNlog("O120",jcData.observations(0).imperial.precipTotal,"",0)
           UpdateNlog("O121",jcData.observations(0).imperial.elev,"",0)
           UpdateNlog("O122",jcData.observations(0).humidity,"",0)
           UpdateNlog("O124",jcData.observations(0).uv,"",0)

    Comment


      #17
      Also, you need to add

      Code:
      ScriptingReferences=System.Web.Script.Serialization;System.Web.Extensions.dll
      to your settings.ini file in your HS3 config directory. I added it somewhere (near the end) in the [settings] block.

      Comment


        #18
        Originally posted by joegr View Post
        Also, you need to add

        Code:
        ScriptingReferences=System.Web.Script.Serialization;System.Web.Extensions.dll
        to your settings.ini file in your HS3 config directory. I added it somewhere (near the end) in the [settings] block.
        To add to that, you need to shut down HS before editing that file.
        HS 4.2.8.0: 2134 Devices 1252 Events
        Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

        Comment


          #19
          I have made the changes, restarted HS3 to see if that gets rid of the errors but it didnt..
          Sep-25 21:12:22 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: Type 'JavaScriptSerializer' is not defined.
          Sep-25 21:12:22 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: Namespace or type specified in the Imports 'System.Web.Script.Serialization' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
          Sep-25 21:12:22 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases
          this might give us a clue, just seen it in the log:
          Sep-25 21:16:07 Warning INI setting could not read setting scriptingreferences,skipping:Item has already been added. Key in dictionary: 'scriptingreferences' Key being added: 'scriptingreferences
          in my settings ini, it looks like this:

          [Settings]
          ScriptingReferences=System.Web;System.web.dll
          gLastShutdownOK=False
          ...
          ScriptingReferences=System.Web.Script.Serialization;System.W eb.Extensions.dll
          [Display]
          gSelectedGroupWeb=All Groups
          ...

          I shut down HS3, added the line to the settings.ini, restarted, and run the script. I get above errors. But on checking the settings.ini, the line is not there any more

          Comment


            #20
            Replace your line
            Code:
            ScriptingReferences=System.Web;System.web.dll
            with
            Code:
            ScriptingReferences=System.Web.Script.Serialization;System.Web.Extensions.dll
            instead of adding a new line.
            Make sure there is no space in .W eb. , should be .Web.

            Comment


              #21
              OK, nearly there. No errors any more. Data seems to be pulled in and shows in my devices. Now its getting it to display properly. Its all showing as Dim...

              Also it seems to be pulling in the temperatures as F instead of C... or do I have to calculate that to convert ?

              And how often should I run this script ? Every minute max ?
              Attached Files

              Comment


                #22
                You will have to do the math in the script to convert the F readings to C, if that is what you need. To get them to display as the units they are instead of dim values, you will have to finish the definitions of the devices. This is on the status graphics tab of each device. Some examples below. It's the entries for status text that are important. The graphics ones are just eye candy.

                Click image for larger version

Name:	tempexample.png
Views:	134
Size:	313.6 KB
ID:	1328801Click image for larger version

Name:	windexample.png
Views:	130
Size:	298.0 KB
ID:	1328802

                Comment


                  #23
                  How often depends on how often your weather station updates WU, and how fresh you need the data to be. I think that every minute will be okay, but every five minutes may be more realistic. If you pull too often, WU will lock you out for the rest of the day.

                  Try this for temperature in C

                  Code:
                  UpdateNlog("O112",(jcData.observations(0).imperial.temp - 32)/1.8,"",0)

                  Comment


                    #24
                    The API allows pulling of non-imperial data. I believe you just need to change these from:

                    Code:
                     
                     UpdateNlog("O112",jcData.observations(0).imperial.temp,"",0)
                    to

                    Code:
                     
                     UpdateNlog("O112",jcData.observations(0).temp,"",0)
                    HS 4.2.8.0: 2134 Devices 1252 Events
                    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                    Comment


                      #25
                      Ok I just worked out how to display (set values etc...) I like your 'eyecandy' png's. Where did you get them from ?

                      Where in the script would I add the calculation ? I tried adding

                      temp = (temp-32) * 5/9

                      under the
                      UpdateNlog("O112",jcData.observations(0).imperial.temp,"",0) but it does not calculate. Its still displaying as F value

                      Comment


                        #26
                        Originally posted by sparkman View Post
                        The API allows pulling of non-imperial data. I believe you just need to change these from:

                        Code:
                        UpdateNlog("O112",jcData.observations(0).imperial.temp,"",0)
                        to

                        Code:
                        UpdateNlog("O112",jcData.observations(0).temp,"",0)
                        Maybe for you, but there is no such field in the json I am receiving.
                        observations
                        0
                        stationID "KMSGULFP21"
                        obsTimeUtc "2019-09-25T21:29:25Z"
                        obsTimeLocal "2019-09-25 16:29:25"
                        neighborhood " Oakleigh Manor"
                        softwareType "Custom version1.5"
                        country "US"
                        solarRadiation null
                        lon -89.01924896
                        realtimeFrequency null
                        epoch 1569446965
                        lat 30.44963074
                        uv null
                        winddir 180
                        humidity 45
                        qcStatus 1
                        imperial
                        temp 95
                        heatIndex 101
                        dewpt 74
                        windChill 95
                        windSpeed 2
                        windGust 4
                        pressure 29.84
                        precipRate 0
                        precipTotal 0
                        elev 16

                        Comment


                          #27
                          Originally posted by sparkman View Post
                          The API allows pulling of non-imperial data. I believe you just need to change these from:

                          Code:
                          UpdateNlog("O112",jcData.observations(0).imperial.temp,"",0)
                          to

                          Code:
                          UpdateNlog("O112",jcData.observations(0).temp,"",0)
                          I tried that. Didnt work
                          Sep-25 22:34:57 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: 'temp' is not a member of 'scriptcode31.VBWrapper.Observation'.
                          Sep-25 22:34:57 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases

                          Comment


                            #28
                            Originally posted by mikee123 View Post
                            Ok I just worked out how to display (set values etc...) I like your 'eyecandy' png's. Where did you get them from ?

                            Where in the script would I add the calculation ? I tried adding

                            temp = (temp-32) * 5/9

                            under the
                            UpdateNlog("O112",jcData.observations(0).imperial.temp,"",0) but it does not calculate. Its still displaying as F value
                            See my post above for the temperature calculation. I added after posting, but I though that maybe you hadn't seen that post yet.

                            I found weather icons in various places on the web and grabbed the ones I liked. Some may have also come from HS2. I'm been building the collection for a while.

                            Comment


                              #29
                              Originally posted by mikee123 View Post

                              I tried that. Didnt work
                              Sep-25 22:34:57 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: 'temp' is not a member of 'scriptcode31.VBWrapper.Observation'.
                              Sep-25 22:34:57 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases
                              You would have to add the new "temp" field in the Public Class Observation section. I didn't because at least for me, the api does not return that field. You can put your api URL in the address field of FireFox and it will show you the decoded json to see if you have that field.

                              Comment


                                #30
                                The URL for FireFox would be:
                                Code:
                                https://api.weather.com/v2/pws/observations/current?stationId=xxx&format=json&units=e&apiKey=xxxx
                                just put your station and key in.

                                Comment

                                Working...
                                X