@@ -61,11 +61,17 @@ void WundergroundClient::updateForecast(String apiKey, String language, String c
6161 doUpdate (" /api/" + apiKey + " /forecast10day/lang:" + language + " /q/" + country + " /" + city + " .json" );
6262}
6363
64+
6465void WundergroundClient::updateForecastPWS (String apiKey, String language, String pws) {
6566 isForecast = true ;
6667 doUpdate (" /api/" + apiKey + " /forecast10day/lang:" + language + " /q/pws:" + pws + " .json" );
6768}
6869
70+ void WundergroundClient::updateForecastZMW (String apiKey, String language, String zmwCode) {
71+ isForecast = true ;
72+ doUpdate (" /api/" + apiKey + " /forecast10day/lang:" + language + " /q/zmw:" + zmwCode + " .json" );
73+ }
74+
6975// JJG added ////////////////////////////////
7076void WundergroundClient::updateAstronomy (String apiKey, String language, String country, String city) {
7177 isForecast = true ;
@@ -200,7 +206,7 @@ void WundergroundClient::key(String key) {
200206 isForecast = false ;
201207 isAlerts = true ;
202208 }
203- // end fowlerk add
209+ // end fowlerk add
204210}
205211
206212void WundergroundClient::value (String value) {
@@ -278,7 +284,7 @@ void WundergroundClient::value(String value) {
278284 else isPM = false ;
279285 char tempHourBuff[3 ] = " " ; // fowlerk add for formatting, 12/22/16
280286 sprintf (tempHourBuff, " %2d" , tempHour); // fowlerk add for formatting, 12/22/16
281- moonriseTime = String (tempHourBuff); // fowlerk add for formatting, 12/22/16
287+ moonriseTime = String (tempHourBuff); // fowlerk add for formatting, 12/22/16
282288 // moonriseTime = value;
283289 }
284290 if (currentKey == " minute" ) {
@@ -294,7 +300,7 @@ void WundergroundClient::value(String value) {
294300 if (currentKey == " hour" ) {
295301 char tempHourBuff[3 ] = " " ; // fowlerk add for formatting, 12/22/16
296302 sprintf (tempHourBuff, " %2d" , value.toInt ()); // fowlerk add for formatting, 12/22/16
297- moonsetTime = String (tempHourBuff); // fowlerk add for formatting, 12/22/16
303+ moonsetTime = String (tempHourBuff); // fowlerk add for formatting, 12/22/16
298304 }
299305 if (currentKey == " minute" ) {
300306 char tempMinBuff[3 ] = " " ; // fowlerk add for formatting, 12/22/16
@@ -303,8 +309,12 @@ void WundergroundClient::value(String value) {
303309 }
304310 }
305311
306- if (currentKey == " wind_mph" ) {
307- windSpeed = value;
312+ if (currentKey == " wind_mph" && !isMetric) {
313+ windSpeed = value + " mph" ;
314+ }
315+
316+ if (currentKey == " wind_kph" && isMetric) {
317+ windSpeed = value + " km/h" ;
308318 }
309319
310320 if (currentKey == " wind_dir" ) {
@@ -313,15 +323,19 @@ void WundergroundClient::value(String value) {
313323
314324// end JJG add ////////////////////////////////////////////////////////////////////
315325
316- if (currentKey == " observation_time_rfc822 " ) {
326+ if (currentKey == " local_time_rfc822 " ) {
317327 date = value.substring (0 , 16 );
318328 }
319- // Begin add, fowlerk...04-Dec-2016
329+
330+ if (currentKey == " observation_time_rfc822" ) {
331+ observationDate = value.substring (0 , 16 );
332+ }
333+ // Begin add, fowlerk...04-Dec-2016
320334 if (currentKey == " observation_time" ) {
321335 observationTime = value;
322336 }
323- // end add, fowlerk
324-
337+ // end add, fowlerk
338+
325339 if (currentKey == " temp_f" && !isMetric) {
326340 currentTemp = value;
327341 }
@@ -354,15 +368,15 @@ void WundergroundClient::value(String value) {
354368 if (currentKey == " feelslike_f" && !isMetric) {
355369 feelslike = value;
356370 }
357-
371+
358372 if (currentKey == " feelslike_c" && isMetric) {
359373 feelslike = value;
360374 }
361-
375+
362376 if (currentKey == " UV" ) {
363377 UV = value;
364378 }
365-
379+
366380 // Active alerts...added 18-Dec-2016
367381 if (currentKey == " type" && isAlerts) {
368382 activeAlertsCnt++;
@@ -426,9 +440,9 @@ void WundergroundClient::value(String value) {
426440 activeAlertsAttribution[currentAlert-1 ].replace (" </a>" ," " );
427441 activeAlertsAttribution[currentAlert-1 ].replace (" /'>" ," " );
428442 }
429-
443+
430444 // end fowlerk add
431-
445+
432446 if (currentKey == " dewpoint_f" && !isMetric) {
433447 dewPoint = value;
434448 }
@@ -447,7 +461,7 @@ void WundergroundClient::value(String value) {
447461// Modified below line to add check to ensure we are processing the 10-day forecast
448462// before setting the forecastTitle (day of week of the current forecast day).
449463// (The keyword title is used in both the current observation and the 10-day forecast.)
450- // Modified by fowlerk
464+ // Modified by fowlerk
451465 // if (currentKey == "title" && currentForecastPeriod < MAX_FORECAST_PERIODS) { // Removed, fowlerk
452466 if (currentKey == " title" && isForecast && currentForecastPeriod < MAX_FORECAST_PERIODS) {
453467 Serial.println (String (currentForecastPeriod) + " : " + value);
@@ -463,13 +477,13 @@ void WundergroundClient::value(String value) {
463477 forecastText[currentForecastPeriod] = value;
464478 }
465479 // end fowlerk add, 12/3/16
466-
480+
467481 // Added PoP (probability of precipitation) key following...fowlerk, 12/22/16
468482 if (currentKey == " pop" && isForecast && currentForecastPeriod < MAX_FORECAST_PERIODS) {
469483 PoP[currentForecastPeriod] = value;
470484 }
471485 // end fowlerk add, 12/22/16
472-
486+
473487 // The detailed forecast period has only one forecast per day with low/high for both
474488 // night and day, starting at index 1.
475489 int dailyForecastPeriod = (currentForecastPeriod - 1 ) * 2 ;
@@ -502,19 +516,19 @@ void WundergroundClient::value(String value) {
502516 currentForecastPeriod = 0 ;
503517 }
504518 forecastMonth[currentForecastPeriod] = value;
505- }
519+ }
506520
507521 if (currentKey == " day" && isSimpleForecast && currentForecastPeriod < MAX_FORECAST_PERIODS) {
508522 // Added by fowlerk to handle transition from txtforecast to simpleforecast, as
509523 // the key "period" doesn't appear until after some of the key values needed and is
510524 // used as an array index.
511525 if (isSimpleForecast && currentForecastPeriod == 19 ) {
512526 currentForecastPeriod = 0 ;
513- }
527+ }
514528 forecastDay[currentForecastPeriod] = value;
515529 }
516530 // end fowlerk add
517-
531+
518532}
519533
520534void WundergroundClient::endArray () {
@@ -575,6 +589,9 @@ String WundergroundClient::getSeconds() {
575589String WundergroundClient::getDate () {
576590 return date;
577591}
592+ String WundergroundClient::getObservationDate () {
593+ return observationDate;
594+ }
578595long WundergroundClient::getCurrentEpoch () {
579596 return localEpoc + ((millis () - localMillisAtUpdate) / 1000 );
580597}
@@ -725,17 +742,17 @@ String WundergroundClient::getForecastHighTemp(int period) {
725742}
726743// fowlerk added...
727744String WundergroundClient::getForecastDay (int period) {
728- // Serial.print("Day period: "); Serial.println(period);
745+ // Serial.print("Day period: "); Serial.println(period);
729746 return forecastDay[period];
730747}
731748
732749String WundergroundClient::getForecastMonth (int period) {
733- // Serial.print("Month period: "); Serial.println(period);
750+ // Serial.print("Month period: "); Serial.println(period);
734751 return forecastMonth[period];
735752}
736753
737754String WundergroundClient::getForecastText (int period) {
738- // Serial.print("Forecast period: "); Serial.println(period);
755+ // Serial.print("Forecast period: "); Serial.println(period);
739756 return forecastText[period];
740757}
741758
@@ -788,4 +805,4 @@ String WundergroundClient::getMeteoconIcon(String iconText) {
788805 if (iconText == " nt_tstorms" ) return " &" ;
789806
790807 return " )" ;
791- }
808+ }
0 commit comments