weather-widget
weather-widget copied to clipboard
Switch to OpenWeatherMap API
Use the OpenWeatherMap API to fetch weather data (see #55)
Use the OpenWeatherMap API to fetch weather data (see #55)
It seems the Darksky API finally stopped responding some time this week, and the OpenWeatherMap version isn't working properly either. TLS is now required by Node, but even when flagging it to "1" in "get-weather" and entering API keys, the widget seems broken. It saying it's trying to return undefined data.
@jetblackrx89 Give the PR another try. Improved error handling a bit and fixed a bug with the API keys.
@jetblackrx89 Give the PR another try. Improved error handling a bit and fixed a bug with the API keys.
Thanks for the quick reply. It's now crashing with this. The path is valid.
node:internal/modules/cjs/loader:944
throw err;
^
Error: Cannot find module '/Users/USERNAME/Library/Application Support/Übersicht/widgets/weather.widget/get-weather'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
at Function.Module._load (node:internal/modules/cjs/loader:774:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47 {
If I manually install it via NPM like this, I get a new error.
$ npm install "/Users/USERNAME/Library/Application\ Support/Übersicht/widgets/weather.widget/get-weather"
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3
New error:
undefined is not an object (evaluating 'weather.temperature')
@jetblackrx89 Note that the widget needs to point to folders with index.coffee files. In case you checked out this repository it expects the inner weather.widget folder.
I'm very sorry but I am having a hard time interpreting what is mean by "point to folders with index.coffee files" and "inner weather.widget folder". I downloaded your repo as a .zip just now and put the entire "top level" directory of that .zip into the Application Support folder for Übersicht and now it's back to stating it cannot find "get-weather", and it's still referring to the old path even though it's now 1 directory deeper. I'm at a loss here.
Current file scheme:
$ ls -laR /Users/USERNAME/Library/Application\ Support/Übersicht/widgets/weather-widget-openweathermap/
total 800
drwxr-xr-x 10 USERNAME staff 320 Apr 3 12:11 .
drwx------ 7 USERNAME staff 224 Apr 3 12:11 ..
-rw-r--r--@ 1 USERNAME staff 6148 Apr 3 12:15 .DS_Store
-rwxr-xr-x 1 USERNAME staff 1552 Apr 2 16:06 README.md
-rwxr-xr-x 1 USERNAME staff 113949 Apr 2 16:06 originalIcons.png
-rwxr-xr-x 1 USERNAME staff 102680 Apr 2 16:06 screenshot.png
drwxr-xr-x 5 USERNAME staff 160 Apr 3 12:08 weather.widget
-rwxr-xr-x 1 USERNAME staff 36953 Apr 2 16:06 weather.widget.zip
-rwxr-xr-x 1 USERNAME staff 107 Apr 2 16:06 widget.json
-rwxr-xr-x 1 USERNAME staff 130411 Apr 2 16:06 yahooIcons.png
/Users/USERNAME/Library/Application Support/Übersicht/widgets/weather-widget-openweathermap//weather.widget:
total 400
drwxr-xr-x 5 USERNAME staff 160 Apr 3 12:08 .
drwxr-xr-x 10 USERNAME staff 320 Apr 3 12:11 ..
-rwxr-xr-x 1 USERNAME staff 3681 Apr 2 16:06 get-weather
-rwxr-xr-x 1 USERNAME staff 184969 Apr 2 16:06 icons.svg
-rw-r--r--@ 1 USERNAME staff 8405 Apr 2 19:25 index.coffee
Now I again get this error:
Error: Cannot find module '/Users/USERNAME/Library/Application Support/Übersicht/widgets/weather.widget/get-weather'
I think the way I had it before ("weather.widget" being directly in the "widgets" folder) was closer to a "working" condition but as I said it is throwing an error for a temperature object. Did you see that part of the last message?
undefined is not an object (evaluating 'weather.temperature')
@jetblackrx89 You should only put the directory <repository-zip>/weather.widget
into the Ubersicht widget folder. The location of the widget folder can also be set in the Ubersicht preferences.
The folder configured in the preferences (e.g. /some/path/widgets
) should look similar to this.
drwxr-xr-x@ - roele staff 28 Oct 2021 ├── widgets
drwxr-xr-x@ - roele staff 27 Oct 2021 │ ├── simple-clock.widget
.rw-r--r--@ 1.7k roele staff 25 Sep 2020 │ │ └── index.coffee
drwxr-xr-x@ - roele staff 27 Oct 2021 │ └── weather.widget
.rw-r--r--@ 3.7k roele staff 6 Apr 2020 │ ├── get-weather
.rwxr--r--@ 185k roele staff 17 Jul 2018 │ ├── icons.svg
.rw-r--r--@ 8.2k roele staff 15 Dec 2021 │ └── index.coffee
Understood. That is how I originally had it. Sorry if I overcomplicated this, but what I am trying to say is the widget is still failing to load with this error:
undefined is not an object (evaluating 'weather.temperature')
Thanks
Are you sure you're using the patched (Pull Request 55) version? Try with the attached version, this is a checkout of my pull request which i zipped up. weather.widget-pr-55.zip
If that still does not work, my only suggestion would be to try to debug what is going on.
You can trigger the debugger from the Ubersicht context menu. In the script tab you can select the weather-widget script and set a breakpoint on the update
function to be able to inspect what output
is coming in from the get-weather
script. You will have to trigger a "refresh widgets" from the context menu since the refresh interval is very low (10min.?) by default.
I'm very sorry for the confusion. What was actually happening is that I'd moved the old widget was to a subdirectory called "disabled", but the app still looks within there for any valid widgets. This entire time, the old widget overlaying onto of your new one. Unfortunately, now with the new widget, OpenWeather is stating it's returning a 401 error. My API key is "0ddb1cbdeecf2a86f7a6e66cb7045043" (I don't mind if others see it, I can always make a new one later). It says the issue may be that on a free plan, a "401" error may mean that the API doesn't report back all the requested info. Is that a known limitation? I need a paid plan?
Your API Key seems indeed invalid which can be validated with a simple cURL request. Maybe try to generate a new one?
curl --location 'https://api.openweathermap.org/data/2.5/onecall?appid=0ddb1cbdeecf2a86f7a6e66cb7045043&lat=47.416&lon=8.583&units=metric&lang=en'
I finally got an email from OpenWeather and they are claiming the below new API key is valid, but it seems to only work selectively. It seems "onecall" API has been replaced with a "weather" API based on the URL scheme they now suggest.
Example of how they suggest to make the API call. It returns valid data:
https://api.openweathermap.org/data/2.5/weather?q=27517&APPID=667b6819fbd3746b15f54deeb8f1438e
Using the same API key the way you suggest, it returns a 401 code:
https://api.openweathermap.org/data/2.5/onecall?appid=667b6819fbd3746b15f54deeb8f1438e
Looks like they changed their plans as well and the /onecall API is not free anymore. Newly generated API keys wont work with the older API version. Unfortunately the free /weather endpoint is not sufficient as it does not have any forecast data. Guess this widget became useless at this point unless someone is okey with a paid subscription.
https://openweathermap.org/api/one-call-3#current
Hi @roele and @jetblackrx89. First of all, thank you @roele for compiling the widget to run OpenWeather, you're a lifesaver as most of the Ubersicht weather widgets run on DarkskyAPI and are not of any use any more.
Regarding the OpenWeather API, I suggest checking in the members' section, under the tab "billing plans" to which plan you're subscribed. I noticed that if you subscribed BOTH to the "OneCall 3.0" API and the Free Professional Collections API, the API keys that were generated do not work with the widget, whereas if you subscribe only to the free professional plan (unsubscribe from the OneCall API), they would work normally. Weirdly, if you subscribe to OneCall 3.0, you get API keys compatible only with the 3.0 API, whereas if you subscribe only to the professional collections you get backward compatibility. So what I would suggest trying is to unsubscribe from the onecall API, keep the subscription to the free Professional API and generate a new API key, which I believe should work.
So what I would suggest trying is to unsubscribe from the onecall API, keep the subscription to the free Professional API and generate a new API key, which I believe should work.
Thank you, but I believe the "free" plan and "professional collections free" are synonymous. It seems that's what my plan defaulted to without subscribing or paying for OneCall API yet.
So what I would suggest trying is to unsubscribe from the onecall API, keep the subscription to the free Professional API and generate a new API key, which I believe should work.
Thank you, but I believe the "free" plan and "professional collections free" are synonymous. It seems that's what my plan defaulted to without subscribing or paying for OneCall API yet.
weird, I don't get why my key works. I just made another key to check this out, and the new key doesn't work only the old one :/. The widget works fine with my original key. Possibly my account is older than I thought.
I was looking around and apparently, after September 2022 they depreciated the 2.5 version but the old keys will still work with the old API structure. Any new keys will work with the new API structure, version 3 and later, so new users are locked out, the same as DarkSky. Any information I could find was from other git repos that discussed the same problem, OpenWeather makes it very difficult to understand what is going on. Sorry I haven't been useful on this.
Can someone explains to me WHY my newly created OpenWeatherMap API works with this Ubersicht widget and NOT with the amazing fork created by @roele ?
@gtrooper The iwn-widget
just shows the weather for the current day while weather-widget
also shows a 5 day forecast. The use of the API endpoint https://api.openweathermap.org/data/2.5/weather is still free unlike the endpoint i used https://api.openweathermap.org/data/2.5/onecall
@gtrooper The
iwn-widget
just shows the weather for the current day whileweather-widget
also shows a 5 day forecast. The use of the API endpoint https://api.openweathermap.org/data/2.5/weather is still free unlike the endpoint i used https://api.openweathermap.org/data/2.5/onecall
Oh I see ! So they stopped offering free service for Weather Data for more than 1 day pretty much, right ? Anyways, your widget was so good I really miss the 3 days forecast and the look of your widget if we dont count the icons which were the same, was so much better.. Thank you for the kind explanation !