csparpa / pyowm

A Python wrapper around the OpenWeatherMap web API
https://pyowm.readthedocs.io
MIT License
789 stars 171 forks source link

Sunrise and Sunset are returning a value of zero #295

Closed jcrv2016 closed 4 years ago

jcrv2016 commented 4 years ago

Sunrise and Sunset times are returning a value of zero, both in the get_sunset_time() and get_sunrise_time() and the JSON data pull.

csparpa commented 4 years ago

Hi there. Please be more specific and provide with your code, so that I can help debugging. thanks

jcrv2016 commented 4 years ago

Hi Claudio,

Thanks so much for this project, btw.

import pyowm

owm =pyowm.OWM(OWM_KEY)
Forecaster = owm.daily_forecast_at_coords(40.79, -73.96)
weather = Forecaster.get_weather_at(datetime.now())
print(weather.to_JSON())

This is the output:

{"heat_index": null, "visibility_distance": null, "sunset_time": 0, "detailed_st atus": "sky is clear", "humidex": null, "reference_time": 1579107600, "rain": {} , "status": "Clear", "wind": {"deg": 132, "speed": 0.99}, "temperature": {"day": 277.46, "min": 277.46, "eve": 277.46, "max": 278.59, "morn": 277.46, "night": 2 78.59}, "humidity": 67, "weather_code": 800, "weather_icon_name": "01n", "clouds ": 0, "snow": {}, "sunrise_time": 0, "pressure": {"press": 1018, "sea_level": nu ll}, "dewpoint": null}

And for this:


print(weather.get_sunset_time())
print(weather.get_sunrise_time())

The output is 0 for both

-James

csparpa commented 4 years ago

Hi @jcrv2016, I've checked this out and it looks like the position of sunrise and sunset elements in the JSON of OWM API responses changed... I've put a fix on the new 2.10-LTS branch supporting PyOWM until PyOWM version 3 will be out

Take a look here for details

In short, you just need to install from sources on that branch