DarkSky/ ForecastIo weatherdata : self parsing of the JSON

Though apparently it is possible to use DarkSky (ForecastIo) through the weather binding, I never had much succes with that binding, so (with a lot of direction given by @rlkoshak ) I used the http.cfg to parse my own Weatherunderground JSON.
With Weatherunderground stopping their free API, I went to DarkSky and adapted the parsing of the JSON.

This is how I do it:




Number vWeather_TempC "Outside Temperature [%.1f °C]"   <temperature>    { http="<[weatherConditions:420000:JSONPATH($.currently.temperature)]" }
String vWeather_Conditions "Current weatherr [%s]"  <sun_clouds>   { http="<[weatherConditions:420000:JSONPATH($.currently.summary)]" }    
Number vWeather_Humidity "Humidity [%s]"   <humidity>   { http="<[weatherConditions:420000:JSONPATH($.currently.humidity)]" }
Number vWeather_Degree "Wind direction [%.0f °]" <windrose>   { http="<[weatherConditions:420000:JSONPATH($.currently.windBearing)]" }
Number vWeather_Wind_MS "Wind speed [%.1f m/s]" <wind>   { http="<[weatherConditions:420000:JSONPATH($.currently.windSpeed)]" }
Number vWeather_Wind_Gusts_MS "Wind gusts [%.1f m/s]" <wind>      { http="<[weatherConditions:420000:JSONPATH($.currently.windGust)]" }
Number vWeather_Pressure_MB "Airpressure [%.1f Hp]"   <line>    { http="<[weatherConditions:420000:JSONPATH($.currently.pressure)]" }
Number vWeather_Dewpoint_C "Dewpoint [%.1f °C]"   <dewpoint>  { http="<[weatherConditions:420000:JSONPATH($.currently.dewPoint)]" }
Number vWeather_FeelC "Apparent temperature [%.0f °C]" <temperature>   { http="<[weatherConditions:420000:JSONPATH($.currently.apparentTemperature)]" }
Number vWeather_Visibility_k "Visibility [%.1f km]"    <visibility>    { http="<[weatherConditions:420000:JSONPATH($.currently.visibility)]" }    
Number vWeather_Ozone "Ozone [%.2f]" <ozone>  { http="<[weatherConditions:420000:JSONPATH($.currently.ozone)]" } 
Number vWeather_UV "UV Index [%.0f]" <uvi>  { http="<[weatherConditions:420000:JSONPATH($.currently.uvIndex)]" }
String vWeather_Precip1hr "hourly precipitation [%s mm]" <rain> { http="<[weatherConditions:420000:JSONPATH($.currently.precipIntensity)]" }

The JSON contains much more info, but these are the basics.
If for instance you would like to include the weather for tomorrow, do:

String vWeather_morgen "Tomorrow [%s]" <sun_clouds> {http="<[weatherConditions:420000:JSONPATH($.daily.data[1].summary)]"

The humidity is given as a fraction, so if you want it as percentage you will need to multiply it by hundred. Normally I would do that with a rule, but I am quite sure somehow it is possible to do it in-line with the item statement.-maybe as a MAP or Java script) need to look into that.

The value of the Ozone concentration is usually expressed in ppm. However, the values given by DarkSky make me think they use Dobson Units

One can add GET statements to the API call (the commands behind the ‘?’) to switch to SI units and to exclude some parts of the JSON one does not need, or to switch language. The JSON is quite big).
DarkSky allows 1000 calls/day, thats 41 calls/hr, that is 1 call every 1.4 minutes or 1 call every 86 seconds. Weather does not change that fast.
In the http.cfg I specified an update every 420 sec=7 min
See DarkSky Docs for further info


A binding was recently put together too…

Had not seen that one, Thanks, will have a look, but given my earlier struggle with the weatherbinding, I like to be in control myself :slight_smile: