kamek-pf/polybar-forecast

Invalid response from OpenWeatherMap

garret opened this issue · 6 comments

Hi, I have copied your script (v1.1.0 from releases page) and copied inside my polybar config folder. I have chmod the script and also created the config.toml file in the same folder of the script (which I modified with my openweathermap apikey and city code).

However, when I just launch the script I get this error (and thus no information on my polybar):

➜  ~ .config/polybar/scripts/forecast

Invalid response from OpenWeatherMap
➜  ~

Do you know what I am doing wrong?

You can try with curl first:

curl "http://api.openweathermap.org/data/2.5/weather?appid=__YOUR_API_KEY__&id=__YOUR_CITY_CODE__&units=metric&cnt=1" | jq

(replace __YOUR_API_KEY__ and __YOUR_CITY_CODE__ with your data, remove the underscores)

If you do not get a response with the same structure, there's something wrong with either your city code or your API key:

{
  "coord": {
    "lon": -73.59,
    "lat": 45.51
  },
  "weather": [
    {
      "id": 803,
      "main": "Clouds",
      "description": "broken clouds",
      "icon": "04d"
    }
  ],
  "base": "stations",
  "main": {
    "temp": 12.75,
    "feels_like": 9.22,
    "temp_min": 11,
    "temp_max": 14.44,
    "pressure": 1016,
    "humidity": 76
  },
  "visibility": 10000,
  "wind": {
    "speed": 4.6,
    "deg": 190
  },
  "clouds": {
    "all": 75
  },
  "dt": 1601993541,
  "sys": {
    "type": 1,
    "id": 943,
    "country": "CA",
    "sunrise": 1601981962,
    "sunset": 1602023100
  },
  "timezone": -14400,
  "id": 6077243,
  "name": "Montreal",
  "cod": 200
}

@kamek-pf I get exactly something like you posted though I had to install the package jq on my linux installation (Void Linux 64 bit). Still running your script I get the same Invalid response from OpenWeatherMap error.

I don't know what could be wrong, I just tried pulling the binary straight from the release page and I can't reproduce this issue :(

Could it be I miss some packages? Like I did not have this jq.

No, it's statically linked, it should be self sufficient ...
I don't maintain this repo anymore, you should try ntfd instead. If you're only interested in the weather stuff it supports the same functionality as well as notifications and a few other use cases.

Sorry I figured out the issue. In my config.toml I had a wrong character in my city id. I corrected the id and now it works. Sorry, I should have checked more carefully.