@@ -174,7 +174,7 @@ void WundergroundClient::key(String key) {
174174 isForecast = false ;
175175 isAlerts = true ;
176176 }
177- // end fowlerk add
177+ // end fowlerk add
178178}
179179
180180void WundergroundClient::value (String value) {
@@ -252,7 +252,7 @@ void WundergroundClient::value(String value) {
252252 else isPM = false ;
253253 char tempHourBuff[3 ] = " " ; // fowlerk add for formatting, 12/22/16
254254 sprintf (tempHourBuff, " %2d" , tempHour); // fowlerk add for formatting, 12/22/16
255- moonriseTime = String (tempHourBuff); // fowlerk add for formatting, 12/22/16
255+ moonriseTime = String (tempHourBuff); // fowlerk add for formatting, 12/22/16
256256 // moonriseTime = value;
257257 }
258258 if (currentKey == " minute" ) {
@@ -268,7 +268,7 @@ void WundergroundClient::value(String value) {
268268 if (currentKey == " hour" ) {
269269 char tempHourBuff[3 ] = " " ; // fowlerk add for formatting, 12/22/16
270270 sprintf (tempHourBuff, " %2d" , value.toInt ()); // fowlerk add for formatting, 12/22/16
271- moonsetTime = String (tempHourBuff); // fowlerk add for formatting, 12/22/16
271+ moonsetTime = String (tempHourBuff); // fowlerk add for formatting, 12/22/16
272272 }
273273 if (currentKey == " minute" ) {
274274 char tempMinBuff[3 ] = " " ; // fowlerk add for formatting, 12/22/16
@@ -277,8 +277,12 @@ void WundergroundClient::value(String value) {
277277 }
278278 }
279279
280- if (currentKey == " wind_mph" ) {
281- windSpeed = value;
280+ if (currentKey == " wind_mph" && !isMetric) {
281+ windSpeed = value + " mph" ;
282+ }
283+
284+ if (currentKey == " wind_kph" && isMetric) {
285+ windSpeed = value + " km/h" ;
282286 }
283287
284288 if (currentKey == " wind_dir" ) {
@@ -287,15 +291,19 @@ void WundergroundClient::value(String value) {
287291
288292// end JJG add ////////////////////////////////////////////////////////////////////
289293
290- if (currentKey == " observation_time_rfc822 " ) {
294+ if (currentKey == " local_time_rfc822 " ) {
291295 date = value.substring (0 , 16 );
292296 }
293- // Begin add, fowlerk...04-Dec-2016
297+
298+ if (currentKey == " observation_time_rfc822" ) {
299+ observationDate = value.substring (0 , 16 );
300+ }
301+ // Begin add, fowlerk...04-Dec-2016
294302 if (currentKey == " observation_time" ) {
295303 observationTime = value;
296304 }
297- // end add, fowlerk
298-
305+ // end add, fowlerk
306+
299307 if (currentKey == " temp_f" && !isMetric) {
300308 currentTemp = value;
301309 }
@@ -328,15 +336,15 @@ void WundergroundClient::value(String value) {
328336 if (currentKey == " feelslike_f" && !isMetric) {
329337 feelslike = value;
330338 }
331-
339+
332340 if (currentKey == " feelslike_c" && isMetric) {
333341 feelslike = value;
334342 }
335-
343+
336344 if (currentKey == " UV" ) {
337345 UV = value;
338346 }
339-
347+
340348 // Active alerts...added 18-Dec-2016
341349 if (currentKey == " type" && isAlerts) {
342350 activeAlertsCnt++;
@@ -400,9 +408,9 @@ void WundergroundClient::value(String value) {
400408 activeAlertsAttribution[currentAlert-1 ].replace (" </a>" ," " );
401409 activeAlertsAttribution[currentAlert-1 ].replace (" /'>" ," " );
402410 }
403-
411+
404412 // end fowlerk add
405-
413+
406414 if (currentKey == " dewpoint_f" && !isMetric) {
407415 dewPoint = value;
408416 }
@@ -421,7 +429,7 @@ void WundergroundClient::value(String value) {
421429// Modified below line to add check to ensure we are processing the 10-day forecast
422430// before setting the forecastTitle (day of week of the current forecast day).
423431// (The keyword title is used in both the current observation and the 10-day forecast.)
424- // Modified by fowlerk
432+ // Modified by fowlerk
425433 // if (currentKey == "title" && currentForecastPeriod < MAX_FORECAST_PERIODS) { // Removed, fowlerk
426434 if (currentKey == " title" && isForecast && currentForecastPeriod < MAX_FORECAST_PERIODS) {
427435 Serial.println (String (currentForecastPeriod) + " : " + value);
@@ -437,13 +445,13 @@ void WundergroundClient::value(String value) {
437445 forecastText[currentForecastPeriod] = value;
438446 }
439447 // end fowlerk add, 12/3/16
440-
448+
441449 // Added PoP (probability of precipitation) key following...fowlerk, 12/22/16
442450 if (currentKey == " pop" && isForecast && currentForecastPeriod < MAX_FORECAST_PERIODS) {
443451 PoP[currentForecastPeriod] = value;
444452 }
445453 // end fowlerk add, 12/22/16
446-
454+
447455 // The detailed forecast period has only one forecast per day with low/high for both
448456 // night and day, starting at index 1.
449457 int dailyForecastPeriod = (currentForecastPeriod - 1 ) * 2 ;
@@ -476,19 +484,19 @@ void WundergroundClient::value(String value) {
476484 currentForecastPeriod = 0 ;
477485 }
478486 forecastMonth[currentForecastPeriod] = value;
479- }
487+ }
480488
481489 if (currentKey == " day" && isSimpleForecast && currentForecastPeriod < MAX_FORECAST_PERIODS) {
482490 // Added by fowlerk to handle transition from txtforecast to simpleforecast, as
483491 // the key "period" doesn't appear until after some of the key values needed and is
484492 // used as an array index.
485493 if (isSimpleForecast && currentForecastPeriod == 19 ) {
486494 currentForecastPeriod = 0 ;
487- }
495+ }
488496 forecastDay[currentForecastPeriod] = value;
489497 }
490498 // end fowlerk add
491-
499+
492500}
493501
494502void WundergroundClient::endArray () {
@@ -549,6 +557,9 @@ String WundergroundClient::getSeconds() {
549557String WundergroundClient::getDate () {
550558 return date;
551559}
560+ String WundergroundClient::getObservationDate () {
561+ return observationDate;
562+ }
552563long WundergroundClient::getCurrentEpoch () {
553564 return localEpoc + ((millis () - localMillisAtUpdate) / 1000 );
554565}
@@ -699,17 +710,17 @@ String WundergroundClient::getForecastHighTemp(int period) {
699710}
700711// fowlerk added...
701712String WundergroundClient::getForecastDay (int period) {
702- // Serial.print("Day period: "); Serial.println(period);
713+ // Serial.print("Day period: "); Serial.println(period);
703714 return forecastDay[period];
704715}
705716
706717String WundergroundClient::getForecastMonth (int period) {
707- // Serial.print("Month period: "); Serial.println(period);
718+ // Serial.print("Month period: "); Serial.println(period);
708719 return forecastMonth[period];
709720}
710721
711722String WundergroundClient::getForecastText (int period) {
712- // Serial.print("Forecast period: "); Serial.println(period);
723+ // Serial.print("Forecast period: "); Serial.println(period);
713724 return forecastText[period];
714725}
715726
0 commit comments