matryer / xbar-plugins

Plugin repository for xbar (the BitBar reboot)
https://xbarapp.com
2.45k stars 1.04k forks source link

re: Weather Underground #237

Closed shpokas closed 8 years ago

shpokas commented 8 years ago

FAO: (@asnodgrass) why is plugin always picking one station - in my case EVRA. There are other stations closer to my location. Is it possible to change this?

screenshot 2016-02-12 12 05 53
cesards commented 8 years ago

+1

asnodgrass commented 8 years ago

@shpokas By default, I'm using the geo-location function of the Weather Underground API, which relies on your IP address. If you like, you can specify a station ID (using the formats allowed by the API; see docs) by changing this line:

LOCATION = 'autoip'

Or, alternatively, use a wrapper script and supply the station ID as an argument:

Wunderground.30m.rb <my_api_key> [my_preferred_location] [use_imperial_units]

Some example locations:

Raleigh,NC
KRDU    (Raleigh airport code)
pws:KNCRALEI108     (Downtown Raleigh personal weather station)
35.90,-78.83     (Raleigh airport lat/long)

You can use the main WU website to browse available stations.

shpokas commented 8 years ago

Well, interesting, 'EVRA' is the only one that works. If I replace 'autoip' with some other station ID, tried 'IRGA6', 'IMRUPE8', 'IRGASPIL3' and 'EVRA', only EVRA gives something, in all other cases I get "WU API Error". Also tried with KRDU and KNCRALEI108 and only KRDU works. As I understand it now, only airport codes work, but not Station ID's.

/bitbar-wu/wunderground.30m.rb

WU API Error

querynotfound: No cities match your search query)

asnodgrass commented 8 years ago

@shpokas I'd try prefixing those station IDs with "pws:", since that's the syntax WU uses for personal weather stations (e.g. other than airport). Example:

$ ruby Wunderground.30m.rb -API_KEY_REDACTED- pws:IRGA6
☁️ 2.9º C
---
Conditions: Overcast
Feels Like: 2.9º C
Dewpoint: 1.7º C
Wind Chill: NAº C
Relative Humidity: 92%
Pressure: 1012 hPa, rising
Visibility: 10.0 km
Winds: Calm
---
Location: Alsungas iela, RÄ«ga,
Station ID: IRGA6
Station Report: Mon, 15 Feb 2016 10:10:21 -0500
---
Forecast | href=http://www.wunderground.com/global/stations/26422.html
Historical Data | href=http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=IRGA6
Station Location | href=http://maps.google.com/maps/place/56.918903,24.076408/@56.918903,24.076408,10z
shpokas commented 8 years ago

Indeed, this works. Thanks a lot for suggestion!

Location: Alsungas iela, RÄ«ga,

Is this Wunderground API poorly handling unicode? I'd expect to see "Rīga".

asnodgrass commented 8 years ago

re: garbled characters Yes, that's from WU -- I'm just showing whatever they pass to me. You can even see this in the normal WU web site. Hard to say whether that's WU being weak on encoding, the station using something other than UTF-8 during data uploads, or both.