felixhageloh / weather-widget

A weather widget for Übersicht
64 stars 32 forks source link

Fix "weather.bylocation" isn't available anymore #28

Closed jnbt closed 8 years ago

jnbt commented 8 years ago

Otherwise Yahoo returns the error "No definition found for Table weather.bylocation".

The updated get-weather follows the basic examples at: https://developer.yahoo.com/weather/#examples

Basically I substituted:

select * from weather.bylocation where location='Amsterdam, NH' and unit='f'

with:

select * from weather.forecast 
  where woeid in (select woeid from geo.places(1) where text='Amsterdam, NH') 
  and u='f'
felixhageloh commented 8 years ago

thanks! Can you also update the zip so I can just merge this in?

jnbt commented 8 years ago

@felixhageloh Thanks for your feedback. I've updated the ZIP archive.

felixhageloh commented 8 years ago

great thanks!

felixhageloh commented 8 years ago

Do you know anything about this by any chance https://github.com/felixhageloh/weather-widget/issues/29#issuecomment-199315090? Did the API maybe change again (apparently this change was working for a while and then stopped working again)?

jnbt commented 8 years ago

Something strange is happening here. For me the current state (from my PR) is still working.

Example: https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D'Bochum%2C%20NW')and%20u%3D'c'&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&format=json

What kind of response are you getting? Simple opening the URL in the browser should be sufficient.

jnbt commented 8 years ago

I have the feeling that YQL isn't the best maintained product. If problems continue to appear one could also think about switching the provider, e.g. OpenWeatherMap (http://openweathermap.org/forecast5)

felixhageloh commented 8 years ago

I think you are right about that :D ... well it is free. This is what I get from visiting the url you provided (prettified the json):

{
  "query": {
    "count": 1,
    "created": "2016-03-22T14:48:25Z",
    "lang": "en-us",
    "results": {
      "channel": {
        "title": "Yahoo! Weather - Bochum, DE",
        "link": "http://us.rd.yahoo.com/dailynews/rss/weather/Bochum__DE/*http://weather.yahoo.com/forecast/GMXX3998_c.html",
        "description": "Yahoo! Weather for Bochum, DE",
        "language": "en-us",
        "lastBuildDate": "Tue, 22 Mar 2016 2:59 pm CET",
        "ttl": "60",
        "location": {
          "city": "Bochum",
          "country": "Germany",
          "region": "NW"
        },
        "units": {
          "distance": "km",
          "pressure": "mb",
          "speed": "km/h",
          "temperature": "C"
        },
        "wind": {
          "chill": "7",
          "direction": "300",
          "speed": "11.27"
        },
        "atmosphere": {
          "humidity": "73",
          "pressure": "1013.6",
          "rising": "2",
          "visibility": ""
        },
        "astronomy": {
          "sunrise": "6:29 am",
          "sunset": "6:49 pm"
        },
        "image": {
          "title": "Yahoo! Weather",
          "width": "142",
          "height": "18",
          "link": "http://weather.yahoo.com",
          "url": "http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"
        },
        "item": {
          "title": "Conditions for Bochum, DE at 2:59 pm CET",
          "lat": "51.49",
          "long": "7.21",
          "link": "http://us.rd.yahoo.com/dailynews/rss/weather/Bochum__DE/*http://weather.yahoo.com/forecast/GMXX3998_c.html",
          "pubDate": "Tue, 22 Mar 2016 2:59 pm CET",
          "condition": {
            "code": "26",
            "date": "Tue, 22 Mar 2016 2:59 pm CET",
            "temp": "9",
            "text": "Cloudy"
          },
          "description": "\n<img src=\"http://l.yimg.com/a/i/us/we/52/26.gif\"/><br />\n<b>Current Conditions:</b><br />\nCloudy, 9 C<BR />\n<BR /><b>Forecast:</b><BR />\nTue - Cloudy. High: 11 Low: 6<br />\nWed - AM Showers. High: 9 Low: 1<br />\nThu - Mostly Cloudy. High: 11 Low: 6<br />\nFri - Light Rain. High: 9 Low: 6<br />\nSat - Partly Cloudy. High: 15 Low: 8<br />\n<br />\n<a href=\"http://us.rd.yahoo.com/dailynews/rss/weather/Bochum__DE/*http://weather.yahoo.com/forecast/GMXX3998_c.html\">Full Forecast at Yahoo! Weather</a><BR/><BR/>\n(provided by <a href=\"http://www.weather.com\" >The Weather Channel</a>)<br/>\n",
          "forecast": [
            {
              "code": "26",
              "date": "22 Mar 2016",
              "day": "Tue",
              "high": "11",
              "low": "6",
              "text": "Cloudy"
            },
            {
              "code": "39",
              "date": "23 Mar 2016",
              "day": "Wed",
              "high": "9",
              "low": "1",
              "text": "AM Showers"
            },
            {
              "code": "28",
              "date": "24 Mar 2016",
              "day": "Thu",
              "high": "11",
              "low": "6",
              "text": "Mostly Cloudy"
            },
            {
              "code": "11",
              "date": "25 Mar 2016",
              "day": "Fri",
              "high": "9",
              "low": "6",
              "text": "Light Rain"
            },
            {
              "code": "30",
              "date": "26 Mar 2016",
              "day": "Sat",
              "high": "15",
              "low": "8",
              "text": "Partly Cloudy"
            }
          ],
          "guid": {
            "isPermaLink": "false",
            "content": "GMXX3998_2016_03_26_7_00_CET"
          }
        }
      }
    }
  }
}
jnbt commented 8 years ago

This is the strange part about it. Either the users in #29 are using the old version or the API behaves in a non-deterministic way.

felixhageloh commented 8 years ago

does it maybe depend on your region? I.E. they haven't rolled out the same api for all their regions/data centers?

jnbt commented 8 years ago

Maybe, I'm calling the API from Germany which is working.

felixhageloh commented 8 years ago

nur ne Idee was schiefgehen könnte :) - danke für Deine Hilfe übrigens!

jnbt commented 8 years ago

:laughing: