skiwithpete / alarmpi

This is the latest version of the alarm clock for Raspberry Pi project.
116 stars 49 forks source link

Adding option for OpenWeatherMap API #22

Open billmcc1280 opened 7 years ago

billmcc1280 commented 7 years ago

What are the odds of adding the option for OpenWeatherMap API? We each would have to get our own API key of course. I am able to get yahoo weather about three out of every ten attempts.

Thanks!

skiwithpete commented 7 years ago

I'm not against it.

Will you add it?

On Fri, Jan 20, 2017 at 10:54 PM, billmcc1280 notifications@github.com wrote:

What are the odds of adding the option for OpenWeatherMap API? We each would have to get our own API key of course. I am able to get yahoo weather about three out of every ten attempts.

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/skiwithpete/alarmpi/issues/22, or mute the thread https://github.com/notifications/unsubscribe-auth/AKACDePJm2szkC7FZBtmU6q7cx63R1PSks5rUYF6gaJpZM4Lp86K .

billmcc1280 commented 7 years ago

I will give it a valiant attempt. :)

mat-v commented 7 years ago

I've experienced the same problem. The issue with Yahoo returning null is also described here and in various other places.

I've been looking into using the wunderground API as a solution. Unfortunately I am complete new in this area s it takes some time to figure things out.

After requesting a key from wunderground your request URL will look like this: http://api.wunderground.com/api/41c***my API-key***/forecast/lang:EN/q/Germany/Berlin.json

And the response will look something like the code below. It shouldn't be too hard to mod the get_weather_yahoo.py to read the correct data from the wunderground json file but I didn't try yet.

Hope this comment is off some value to you! Please keep us posted about the progress, I will do so too :)

{
  "response": {
  "version":"0.1",
  "termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
  "features": {
  "forecast": 1
  }
    }
        ,
    "forecast":{
        "txt_forecast": {
        "date":"9:48 AM CET",
        "forecastday": [
        {
        "period":0,
        "icon":"cloudy",
        "icon_url":"http://icons.wxug.com/i/c/k/cloudy.gif",
        "title":"Saturday",
        "fcttext":"Overcast. Temps nearly steady in the mid 30s. Winds light and variable.",
        "fcttext_metric":"Generally cloudy. High 2C. Winds light and variable.",
        "pop":"10"
        }
        ,
        {
        "period":1,
        "icon":"nt_partlycloudy",
        "icon_url":"http://icons.wxug.com/i/c/k/nt_partlycloudy.gif",
        "title":"Saturday Night",
        "fcttext":"Mostly cloudy skies this evening will become partly cloudy after midnight. Widespread frost likely. Low 27F. Winds SE at 5 to 10 mph.",
        "fcttext_metric":"Considerable clouds this evening. Some decrease in clouds late. Widespread frost likely. Low -3C. Winds SE at 10 to 15 km/h.",
        "pop":"10"
        }
        ,
        {
        "period":2,
        "icon":"partlycloudy",
        "icon_url":"http://icons.wxug.com/i/c/k/partlycloudy.gif",
        "title":"Sunday",
        "fcttext":"Partly cloudy skies. High 33F. Winds SE at 5 to 10 mph.",
        "fcttext_metric":"Partly cloudy skies. High 1C. Winds SE at 10 to 15 km/h.",
        "pop":"10"
        }
        ,
        {
        "period":3,
        *** ETCETERA ***
    "epoch":"1485021600",
    "pretty":"7:00 PM CET on January 21, 2017",
    "day":21,
    "month":1,
    "year":2017,
    "yday":20,
    "hour":19,
    "min":"00",
    "sec":0,
    "isdst":"0",
    "monthname":"January",
    "monthname_short":"Jan",
    "weekday_short":"Sat",
    "weekday":"Saturday",
    "ampm":"PM",
    "tz_short":"CET",
    "tz_long":"Europe/Berlin"
},
        "period":1,
        "high": {
        "fahrenheit":"37",
        "celsius":"3"
        },
        "low": {
        "fahrenheit":"27",
        "celsius":"-3"
        },
        "conditions":"Overcast",
        "icon":"cloudy",
        "icon_url":"http://icons.wxug.com/i/c/k/cloudy.gif",
        "skyicon":"",
        "pop":10,
        "qpf_allday": {
        "in": 0.00,
        "mm": 0
        },
        *** ETCETERA ***