AlexeyMal / esp8266-weather-station

esp8266 weather station using Open-Meteo API
3 stars 1 forks source link

double "sunday" in the two daily forecast pages #2

Closed IU5HKU closed 3 weeks ago

IU5HKU commented 3 weeks ago

I've played around with your code, it works great, but i can't understand why i obtain always a double sunday in the forecast pages. I've read that you ask for 8 days of forecast, and you are using the two functions drawForecast() and drawForecast2() to display the related pages. These two function relay on drawForecastDetails() who have as parameter the number of the day to display (0 to 7, total 8 days), but the timeInfo structure after a sunday, is always another sunday. With a SerialPrint() i've printed the dayindex and the WDAY_NAMES[timeInfo->tmwday] and here is the result:

dayIndex = 0 WDAY_NAMES = FRI dayIndex = 1 WDAY_NAMES = SAT dayIndex = 2 WDAY_NAMES = SUN dayIndex = 3 WDAY_NAMES = SUN

as you can see the fourth timeinfo structure is reported as sunday again, despite sunday was the previous one...can you help me please to solve this behaviour ? There is some change in the open-meteo API? Or i'm doing wrong something? Thank you so much for your time. Greets MC

AlexeyMal commented 3 weeks ago

Dear Marco,I have looked at my weather station and also see the double Sunday at the moment. What a surprise! I observe this problem for the first time after some weeks of normal operation. I believe Open-meteo sends these erroneous data at the moment. You can check this via the api web page. Let us see if the problem disappears tomorrow. For me it is not a problem of the weather station code, it was working fine for me.Best regards,Alexey

AlexeyMal commented 3 weeks ago

I have an idea of what it can be:the time will be shifted at the night from Saturday to Sunday from summer to winter time!Probably the unix timestamp "dt" we get from open-meteo for the daily forecast from sunday on is already 24:00 winter time, and when we recalculate it to the date with current summer time we get the wrong day. Or vice versa. Anyhow, we have only today to debug/fix it. Tomorrow the problem will disapper for one year.A hot fix can be to add one hour in ms to dt before calculating the day of the daily forecast.

IU5HKU commented 3 weeks ago

Ok, maybe this could be the problem, we can check using the API page of open-meteo, under the graph you have a link who points to the complete reply in json format, i've just checked it on the fly, and the data seems correct. True! Only today to fix the code! :-\ Anyway, thank you for your time, have a nice day :-)

IU5HKU commented 3 weeks ago

Just checking your String OpenWeatherMapOneCall::buildPath() function , where you have a test string in the comments to put in the browser to obtain the open-meteo reply, and this is what you obtain in the dt field:

"daily":{"time":[1729893600,1729980000,1730066400,1730152800,1730239200,1730325600,1730412000,1730498400]

i wanna write a small code to dump this structures and read it in human understandable format...

IU5HKU commented 3 weeks ago

It doesn't matter to write a single line of code, nowadays you have everything you need already made online:

https://www.unixtimestamp.com/

and yes, the problem is the difference from summer to winter time, i don't have enough time to fix it, but now i know where this "double sunday" comes from. Anyway could be a great idea to have a double sunday in the week,why fix it... :-)

AlexeyMal commented 3 weeks ago

Just fixed as suggested by adding 1 hour to the daily forecast dt. Sucessfully tested yesterday :)