Closed marcelstoer closed 6 years ago
Part of https://github.com/ThingPulse/esp8266-weather-station-color/pull/45/commits/7429862d1bade8a3300d782d30e338c72a2feac8 can possibly be reused.
void WundergroundForecast::key(String key) {
currentKey = String(key);
if (currentKey == "simpleforecast") {
isSimpleForecast = true;
currentForecastPeriod = 1; //added for reset period in first pass, oterwise first period is 24
ShortTitleIndex = 0; // added as new value, also added in constructor (uint8_t) as private
}
void WundergroundForecast::value(String value) {
.
.
.
//modifed (removed "nt_" from "night" icon names)
if (currentKey == "icon" && !isSimpleForecast && currentForecastPeriod < maxForecasts) {
#ifndef NIGHTICONS
if (value.substring (0, 3) == "nt_") value.remove(0, 3);
#endif
forecasts[currentForecastPeriod].forecastIcon = value;
}
.
.
.
if (isSimpleForecast) { //added
int dailyForecastPeriod = (currentForecastPeriod - 1) * 2;
//added for correct draw russian short weekday names, also modifed in sketch
//String forecastTitleShort added in WGForecast struct
if (currentKey == "weekday_short" && dailyForecastPeriod < maxForecasts) {
forecasts[ShortTitleIndex].forecastTitleShort = value;
ShortTitleIndex += 2;
if (ShortTitleIndex >= 19) {
ShortTitleIndex = 0;
}
.
.
.
}
It's really irritating to see a sun icon displayed when it's clearly dark outside (good thing is you might be asleep and not even notice 😜).
Unfortunately, WU doesn't clearly distinguish icon types at night in the API but they do use dedicated icons. Example:
The
nt_
prefix in the file name denotes a night icon (nt = night-time?). Even though WU has a complete set of night-time icons most likely one would only have to support two variations: http://icons.wxug.com/i/c/k/nt_partlycloudy.gif & http://icons.wxug.com/i/c/k/nt_clear.gifBoth could be mapped to Meteocons icons:
Plan:
nt_clear
andnt_partlycloudy
toweathericons.h
icon_url
togetMeteoconIcon
with every invocationgetMeteoconIcon
doicon
equals "partlycloudy" or "clear"icon_url
contains "/nt_"