DarkSky and Apple

Hey, with everything going on right now, I don't think anything is 100% certain. But then again, if that happens, I don't think we'll be too worried about the weather either. :wink:

I took a quick look at the API and it looks to be a little TOO detailed. You can't do a direct call based on location info (lat/long or city name). You have to query the API with your location to get the grid reference in their system and the office name that handles your area. Both are necessary to query for your location's info. I also haven't figured out a way to get anything but forecast info. Nothing on current conditions yet. So, this is way above my head, unfortunately. On the plus side, the API does provide a direct link to a weather icon. So, no translating necessary there. However, the icons are all square and pretty bad. But what do you want for government work. :wink: Really big plus side...no API key necessary. You can just start querying to your hearts content.

I use a nifty Android app, NWS Now (https://www.nwsnow.net/), that uses the weather.gov data API. Maybe someone could reverse engineer this app? It has location by GPS, ZIP, or weather station (airport) ID.

1 Like

NOAA can be a bit confusing. I think you pretty much have to do a zip-lookup for LAT/LON, then, get a station ID for current conditions. Once you have that, you can get all the forecast info needed.

They used to have a static-URL XML generator that was pretty clean, but I don’t think that’s around anymore, and it’s all JSON now. :slight_smile:

I’m glad I’m not the only one who thinks their API is confusing haha

Here is an example of current conditions here in Bismarck:
https://api.weather.gov/stations/kbis/observations/current

1 Like

Figured I'd give weather.gov a quick look this morning. I got it to connect and get the json. My problem is always getting the data out of it! lol

I can connect, download the json (even log the json data) but when I try to pull out the fields I want. I get null's. I've tried all kinds of combinations and each time I get errors like, 'No such field' or 'No such property'. But with the way I have below there are no errors but no data either, just 'null'. :wink:

My log showing the json file, 'cwa' is the field that I'm trying to get in my examples:

Summary

My Code:

Summary
httpGet(requestParams) { response ->
            if(logEnable) log.info "In getPointsData - response: ${response.status}"
            
            if(response.status == 200) {	
                //log.info "${response.data}"
                def office = response.data.properties.cwa
                log.info "Office: ${office}"
                sendEvent(name: "office", value: office)

My log:

Summary

Any ideas!?

BTW, I do use this json-parser to get the json formatting.

I think you need to parse the response in JSON before trying to pull the data out. Something like:

obs = parseJson(response.data)
def office = obs.properties.cwa
log.info "Office: ${office}"

That should parse the JSON response and allow you to pull out the daata. Although I can't see the top of the JSON so I don't know if you need a 2nd "data" in the def office line.

Thanks, getting an error with that code... it doen't get past the 'obs = parseJson(response.data)'
groovy.lang.MissingMethodException: No signature of method: user_driver_BPTWorld_Weather_Gov_Driver_872.parseJson() is applicable for argument types: (java.io.ByteArrayInputStream) values: [java.io.ByteArrayInputStream@abd76b]

Another json screenshot using the json parser:

sorry...do you have
import groovy.transform.Field
at the top? You probably need to have that to use the parseJson command.
What's the URL you are requesting? That way I can spit-ball myself rather than forcing you to do it. :wink:

BAM! That did it... no parseJson needed. I'm off to the races, lol

Thanks again

1 Like

YAY! Glad I could help.

:slight_smile:

1 Like

Wow, this gives a ton of data! Should have something out later today.

example of forecast data:

https://api.weather.gov/gridpoints/BOX/59,88/forecast

2 Likes

Yeah, I was looking at it yesterday. It's almost too much data though. Have you looked at the local current observations?

Summary
{
    "@context": [
        "https://raw.githubusercontent.com/geojson/geojson-ld/master/contexts/geojson-base.jsonld",
        {
            "wx": "https://api.weather.gov/ontology#",
            "s": "https://schema.org/",
            "geo": "http://www.opengis.net/ont/geosparql#",
            "unit": "http://codes.wmo.int/common/unit/",
            "@vocab": "https://api.weather.gov/ontology#",
            "geometry": {
                "@id": "s:GeoCoordinates",
                "@type": "geo:wktLiteral"
            },
            "city": "s:addressLocality",
            "state": "s:addressRegion",
            "distance": {
                "@id": "s:Distance",
                "@type": "s:QuantitativeValue"
            },
            "bearing": {
                "@type": "s:QuantitativeValue"
            },
            "value": {
                "@id": "s:value"
            },
            "unitCode": {
                "@id": "s:unitCode",
                "@type": "@id"
            },
            "forecastOffice": {
                "@type": "@id"
            },
            "forecastGridData": {
                "@type": "@id"
            },
            "publicZone": {
                "@type": "@id"
            },
            "county": {
                "@type": "@id"
            }
        }
    ],
    "id": "https://api.weather.gov/stations/KBIS/observations/2020-04-03T14:52:00+00:00",
    "type": "Feature",
    "geometry": {
        "type": "Point",
        "coordinates": [
            -100.75,
            46.770000000000003
        ]
    },
    "properties": {
        "@id": "https://api.weather.gov/stations/KBIS/observations/2020-04-03T14:52:00+00:00",
        "@type": "wx:ObservationStation",
        "elevation": {
            "value": 506,
            "unitCode": "unit:m"
        },
        "station": "https://api.weather.gov/stations/KBIS",
        "timestamp": "2020-04-03T14:52:00+00:00",
        "rawMessage": "KBIS 031452Z 30006KT 10SM CLR M08/M16 A3030 RMK AO2 SLP294 T10831161 51007",
        "textDescription": "Clear",
        "icon": "https://api.weather.gov/icons/land/day/skc?size=medium",
        "presentWeather": [],
        "temperature": {
            "value": -8.2999999999999545,
            "unitCode": "unit:degC",
            "qualityControl": "qc:V"
        },
        "dewpoint": {
            "value": -16.099999999999966,
            "unitCode": "unit:degC",
            "qualityControl": "qc:V"
        },
        "windDirection": {
            "value": 300,
            "unitCode": "unit:degree_(angle)",
            "qualityControl": "qc:V"
        },
        "windSpeed": {
            "value": 3.1000000000000001,
            "unitCode": "unit:m_s-1",
            "qualityControl": "qc:V"
        },
        "windGust": {
            "value": null,
            "unitCode": "unit:m_s-1",
            "qualityControl": "qc:Z"
        },
        "barometricPressure": {
            "value": 102610,
            "unitCode": "unit:Pa",
            "qualityControl": "qc:V"
        },
        "seaLevelPressure": {
            "value": 102940,
            "unitCode": "unit:Pa",
            "qualityControl": "qc:V"
        },
        "visibility": {
            "value": 16090,
            "unitCode": "unit:m",
            "qualityControl": "qc:C"
        },
        "maxTemperatureLast24Hours": {
            "value": null,
            "unitCode": "unit:degC",
            "qualityControl": null
        },
        "minTemperatureLast24Hours": {
            "value": null,
            "unitCode": "unit:degC",
            "qualityControl": null
        },
        "precipitationLastHour": {
            "value": null,
            "unitCode": "unit:m",
            "qualityControl": "qc:Z"
        },
        "precipitationLast3Hours": {
            "value": null,
            "unitCode": "unit:m",
            "qualityControl": "qc:Z"
        },
        "precipitationLast6Hours": {
            "value": null,
            "unitCode": "unit:m",
            "qualityControl": "qc:Z"
        },
        "relativeHumidity": {
            "value": 53.408724232471876,
            "unitCode": "unit:percent",
            "qualityControl": "qc:C"
        },
        "windChill": {
            "value": -13.583246923922673,
            "unitCode": "unit:degC",
            "qualityControl": "qc:V"
        },
        "heatIndex": {
            "value": null,
            "unitCode": "unit:degC",
            "qualityControl": "qc:V"
        },
        "cloudLayers": [
            {
                "base": {
                    "value": null,
                    "unitCode": "unit:m"
                },
                "amount": "CLR"
            }
        ]
    }
}

Every "attribute" has a value key, a unit key and a QC key. I mean, I'm sure this is important to a meteorologist but I just wanna know what the temp is! :wink:

I was able to parse out international WorldWeather info earlier today, too. :slight_smile: Turns out, none of this was as difficult as I thought it would be. Didn't have to use any import functions, either—Hubitat's HTTPGet was able to parse everything natively.

4 Likes

Looking forward to seeing the whole thing. I only got to see a few minutes in the middle, wife had me doing things today.

1 Like

First alpha of the Weather.gov driver is now available on this thread.

4 Likes

I think you have it misfiled in apps. Couldn't find it at first.

Nope, app to follow. If look around my github, I keep related app and drivers together under apps. Only drivers that are just drivers go into the driver section.

Remember this is an ALPHA

Well, I couldn't find it.
:man_shrugging:

Won't bother you again.

...and here we go.

2 Likes

Not sure if useful:

https://openweather.co.uk/blog/post/new-one-call-api-essential-weather-data

my darksky finally stopped working today. last report was last night.. rip

1 Like