zli117 / EInk-Calendar

Smart calendar with EInk display and Raspberry Pi
MIT License
237 stars 23 forks source link

No daily weather #15

Open kairapl opened 3 years ago

kairapl commented 3 years ago

After following all the instructions in github page it turns out, that daily forecast doesn't work/needs different API. All of the fileds works like a charm besides 4 smaller weather fileds. While running script message says:

python3 /home/pi/EInk-Calendar/main.py -c /home/pi/EInk-Calendar/settings
Your API subscription level does not allow to perform this operation
Reason: Invalid API Key provided
2021-03-20 08:44:42,323 INFO Periodic update of the screen

I don't know unfortunately anything about python, so I can't repair it by myself.

zli117 commented 3 years ago

How did you generate the API keys

mav555555 commented 3 years ago

I encountered and worked this out myself... OpenWeatherMap have implemented restrictions on the API calls which are possible at the free tier, so the current day data returns and can be displayed, but the daily forecast data is where the API key error comes from. If your API key predates the change, however, you still get that daily forecast - it only affects new free tier users. The daily and forecast is bundled into the same calls in the v2 pyowm library (I think), but there is a workaround for it in the more recent v3 - but there are lots of other changes at the same time, so a bunch of stuff needs to be changed: https://pyowm.readthedocs.io/en/latest/v3/code-recipes.html ...Using the new functionality, one can use the OneCall to gather both the current day's data and the forecast. To swap that out changes are needed in the model/weather.py to change to, for example: one_call.forecast_daily[i].weather_code ...for the weather code. get_reference_time() converts to... one_call.current.reference_time(timeformat='date').date()

Two big changes though, is an additional step to use 'weather_manager()', and OneCall can only be called using lat and lon, rather than the city ID

Providing a full breakdown of the needed code changes is beyond my skills, though I did manage to fuss about and make it work for me. So I hope the above helps!