Announcement

Collapse
No announcement yet.

Get local weather data by Big5 and API (no equipment needed)

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

    Get local weather data by Big5 and API (no equipment needed)

    Here is a use case of how to get weather data from API using Big5. We will get the wind speed as a matter of example. Other data such as temperature, humidity, wind direction, visibility etc, can be easily collected following the example.

    1. Get a free account at https://openweathermap.org and log-in
    2. Get API key
    3. Set HTTP profile at Big5 setup

    Name: Weather-wind
    GET
    http://api.openweathermap.org/data/2...rial&APPID=xyz
    (where lat and lon are the latitude and longitude of your location and xyz is your personal API key (see above)
    Device value expression: JSON_Num(input, "wind.speed")

    4. Setup and run HS3 event that uses Big5 HTTP action and sends empty string to profile "Weather-wind" that you created

    Voila - you will get the wind speed in a dedicated HS3 device created/updated automatically by Big5

    Floor: Big5
    Room: HTTP
    Name: Weather-wind

    Use the above URL in a browser to verify that everything is properly setup and to see the JSON response by the API.
    Knowing JSON response you can easily setup other Big5 profiles to fetch additional weather data such as temperature, humidity, wind direction, visibility etc.

    Now that practically everything is available as an API Big5 opens unlimited opportunities.

    With the $70 that you will save by not buying a weather station from Costco you can buy Big5 plug-in and treat yourself with few beers.

    Update: Big 5 v 1.20 makes it even better see below.
    Last edited by risquare; November 5, 2018, 11:09 PM. Reason: update about the new version Big 5 v 1.20

    #2
    Life got better after the release of Big5 v1.20. Now you can parse the whole JSON API at once and create/update as many HS3 devices at once.

    All you need to do is to separate Name Expressions and Device expressions with && (see below)

    In the example below we chose to create 4 HS3 devices.


    Example:

    This is the API as it comes from the Weather data provider


    {
    "coord":{
    "lon":-117.18,
    "lat":33.01
    },
    "weather":[
    {
    "id":741,
    "main":"Fog",
    "description":"fog",
    "icon":"50n"
    }
    ],
    "base":"stations",
    "main":{
    "temp":67.24,
    "pressure":1014,
    "humidity":46,
    "temp_min":62.06,
    "temp_max":75.2
    },
    "visibility":16093,
    "wind":{
    "speed":4.7,
    "deg":310
    },
    "clouds":{
    "all":1
    },
    "dt":1541296560,
    "sys":{
    "type":1,
    "id":425,
    "message":0.0041,
    "country":"US",
    "sunrise":1541340574,
    "sunset":1541379272
    },
    "id":5347315,
    "name":"Fairbanks Ranch",
    "cod":200
    }

    Device name expressions

    "Temperature" && "Pressure" && "Humidity" && "Community"

    Device Value Expressions

    JSON(input, "main.temp") && JSON(input, "main.pressure") && JSON(input, "main.humidity") && JSON(input, "name")

    This produces 4 HS3 devices each containing value if the RegEx result is numerical and string if the RegEx result is a string

    Click image for larger version

Name:	Screenshot (136).png
Views:	1024
Size:	77.4 KB
ID:	1257048

    Comment


      #3
      Yeah got it ! Thanks.




      Attached Files

      Comment


        #4
        How can I change the the mph to kmh ? And fahrenheit to celcius?

        Comment


          #5
          a recuring event of 15 min is ok?

          Comment


            #6
            There is “units=imperial” in the URI replace it with “units=metric” to get metrics.
            yes any frequence you choose is good and 15 min is a good practical value.
            there is time reference in the API of when data was updated by the service provider. Unfortunately it is in UNIX format that’s hard to convert in HS3.

            Comment


              #7
              yes just saw it :P Examples of API calls:

              standard api.openweathermap.org/data/2.5/find?q=London

              metric api.openweathermap.org/data/2.5/find?q=London&units=metric

              imperial api.openweathermap.org/data/2.5/find?q=London&units=imperial



              thank you

              Comment


                #8
                This start to be off topic but is this a bug ? This is directly from the api

                "wind":{"speed":1.46, metric
                "wind":{"speed":3.27, imperial



                edit : here is the cause :

                wind.speed Wind speed. Unit Default: meter/sec, Metric: meter/sec, Imperial: miles/hour.

                --------


                so... to get Km/h instead of M/s .....the value would need to be:

                JSON(input, "wind.speed") *3.6


                is there a way to multiply by 3.6?

                Last edited by ; November 4, 2018, 06:01 PM.

                Comment


                  #9
                  Try JSON_Num(input, "wind.speed") *3.6

                  Comment


                    #10
                    That works thank you

                    Comment


                      #11
                      If in doubt than use the sand box to check. Paste the whole JSON file in the input field and enter ${JSON_Num(input, "wind.speed") *3.6} or any formula that you want to test. Remember to strip the ${ } brackets when going back to Big5 profile setup.

                      Comment


                        #12
                        ok will do.

                        But when you want to get the forecast for 5 days https://samples.openweathermap.org/d...e88b30761fae22

                        How do you do?

                        I mean... this is huge..https://openweathermap.org/forecast5

                        Comment


                          #13
                          Find a good online JSON fomatter to take a structured view. Here is one https://jsonformatter.curiousconcept.com/ You'll notice that the API although large is pretty uniform. They use Epoch time (Unix style time), which is pretty annoying and difficult to work with but you're Unix guy. Still plenty of data to gather. If you want say 6 parameters for 5 days ahead that's 30 values to gather. Good test for Big5. Let us know how it went if you decide to do it.

                          Comment


                            #14
                            !! thank you for this formatter.


                            What i am wondering is how to diferenciate the days ? I see the dt value...and i ( eg"dt":1486090800).....but how do i use this with your plugin? After conting the number of dt value It seems they are 3hours interval each.. so i am at a lost lol
                            I would just need one example of a device (in this context of multiple days with the same syntaxt), and i'm ready to go


                            and is there a way to use their icon?

                            "id":800,
                            "main":"Clear",
                            "description":"clear sky",
                            "icon":"01n"
                            Last edited by ; November 5, 2018, 06:23 PM.

                            Comment


                              #15
                              Here is a 7 days forecast. https://samples.openweathermap.org/d...429c1c50c122a1

                              But the api is paid. Guess i'll scratch that. Will chek to get the data from the 5 days forecast at the same hour every day. But need to figure out this dt thing

                              Comment

                              Working...
                              X