Read the statement by Michael Teeuw here.
MMM-DynamicWeather Failed getting api: 401
-
Each time this module tries to check the weather, I see the following using pm2 logs:
0|MagicMirror | [2024-10-26 10:13:25.994] [INFO] [MMM-DynamicWeather] Getting Weather API data 0|MagicMirror | [2024-10-26 10:13:26.195] [ERROR] [MMM-DynamicWeather] Failed getting api: 401At the last restart I got these errors at startup - the gbm_wrapper errors before the MMM-DynamicWeather specific errors may or may not be connected, I have no idea.
0|MagicMir | [2505:1026/090323.361257:ERROR:gbm_wrapper.cc(74)] Failed to get fd for plane.: No such file or directory (2) 0|MagicMir | [2505:1026/090323.363120:ERROR:gbm_wrapper.cc(257)] Failed to export buffer to dma_buf: No such file or directory (2) 0|MagicMir | [2505:1026/090323.363549:ERROR:gbm_wrapper.cc(74)] Failed to get fd for plane.: No such file or directory (2) 0|MagicMir | [2505:1026/090323.363873:ERROR:gbm_wrapper.cc(257)] Failed to export buffer to dma_buf: No such file or directory (2) 0|MagicMir | [2024-10-26 09:03:28.184] [ERROR] [MMM-DynamicWeather] Failed getting api: AggregateError [ETIMEDOUT]: 0|MagicMir | at internalConnectMultiple (node:net:1117:18) 0|MagicMir | at internalConnectMultiple (node:net:1185:5) 0|MagicMir | at Timeout.internalConnectMultipleTimeout (node:net:1711:5) 0|MagicMir | at listOnTimeout (node:internal/timers:575:11) 0|MagicMir | at process.processTimers (node:internal/timers:514:7) { 0|MagicMir | code: 'ETIMEDOUT', 0|MagicMir | [errors]: [ 0|MagicMir | Error: connect ETIMEDOUT 38.89.70.158:443 0|MagicMir | at createConnectionError (node:net:1647:14) 0|MagicMir | at Timeout.internalConnectMultipleTimeout (node:net:1706:38) 0|MagicMir | at listOnTimeout (node:internal/timers:575:11) 0|MagicMir | at process.processTimers (node:internal/timers:514:7) { 0|MagicMir | errno: -110, 0|MagicMir | code: 'ETIMEDOUT', 0|MagicMir | syscall: 'connect', 0|MagicMir | address: '38.89.70.158', 0|MagicMir | port: 443 0|MagicMir | }, 0|MagicMir | Error: connect ENETUNREACH 2604:86c0:5001:b::2:443 - Local (:::0) 0|MagicMir | at internalConnectMultiple (node:net:1181:16) 0|MagicMir | at Timeout.internalConnectMultipleTimeout (node:net:1711:5) 0|MagicMir | at listOnTimeout (node:internal/timers:575:11) 0|MagicMir | at process.processTimers (node:internal/timers:514:7) { 0|MagicMir | errno: -101, 0|MagicMir | code: 'ENETUNREACH', 0|MagicMir | syscall: 'connect', 0|MagicMir | address: '2604:86c0:5001:b::2', 0|MagicMir | port: 443 0|MagicMir | } 0|MagicMir | ] 0|MagicMir | }Config code for this module is:
{module: 'MMM-DynamicWeather', // https://github.com/scottcl88/MMM-DynamicWeather disabled: false, position: "fullscreen_above", config: { apiKey: "123456789xxx", // 19 Sep 2024 Ver 3 lat: "12.34567", lon: "-123.4567, // Hometown weatherInterval: 600000, // 10 minutes hideFlower: false, //display animation at the bottom of a flower growing if the current weather is > realisticClouds: true, } },Any ideas on troubleshooting this?
-
@sdetweil --Sam, thanks!! for your patience. I do have this resolved, at least in one MM instance.
I did go back and commit the one command I missed as advised above, but still no joy. But then, …
Strangely enough while I WAS using a valid ver 3 API key, you were right in saying my issue was an invalid API key in the call… After doing the above I was still getting a 401 error, so I accepted that the computers were doing exactly what I was telling them to do [as opposed to what I WANTED them to do]. I discovered the root cause after copying in the API key again and comparing. What I found was this:
apiKey: "123456789"When it should have been this:
api_key: "123456789"I’m not sure why I started using “apiKey” instead of “api_key”, but putting it the way the module wants it fixed my issue. Thanks again!
-
@JohnGalt
Hi,this module uses the old OpenWeater Map Api in version 2.5 to get the current weather.
This version of the Api stopped working recently.
The module needs to be migrated to the new version 3 Api.
As the data is returned in nearly the same format as before it might be enough to change the version in the hard coded Url of 2.5 to 3.You will also need to get a new Api key for the new version. You will need to provide credit card information but 1000 calls a day a free.
-
@wishmaster270 – Thanks for the quick reply. I do already have the ver 3.0 API key, so I guess we will see if the module gets updated.
Meanwhile, would you happen to already know where the 2.5 call is hard-coded? I’d be willing to tinker and see if I can get it to work while waiting for an/the update to accommodate ver 3.0 APIs.
-
@JohnGalt
Hi,you will need to change line 108 in
MMM-DynamicWeather.jsand line 130 inMMM-DynamicWeather.ts.Both show this at the moment:
this.url = "https://api.openweathermap.org/data/2.5/weather?appid=" + this.config.api_key;And you will need to change it to:
this.url = "https://api.openweathermap.org/data/3.0/onecall?appid=" + this.config.api_key;But no guarantee this will work.
-
I created a PR to switch to the new API :-)
-
@KristjanESPERANTO so, he could checkout your pr
in the module foldergit fetch origin pull/52/head:with_30_apikey -
@wishmaster270 --Thanks! I appreciate the effort, but it didn’t work for me. I will wait for your PR to go thru…
-
@sdetweil – Thanks, Sam.
If I want to try this, can I just do it in the module folder now, or do I go back in there first and undo the edits I performed manually? I’m not clear on whether it does or doesn’t make a difference.
-
@JohnGalt in the module folder
if you made file changes, you should revert those first
git reset --hard HEAD -
@sdetweil – I intended to try the above, but the MagicMirror indicated it was due for an update, so I ran your update script first… Now it won’t run.
Rather than hijacking this thread, I will put the particulars in a new thread.
i just didn’t want if to look like I left this one hanging out there…
-
@JohnGalt have you resolved this?
-
@sdetweil – No, it’s still erroring but oddly, possibly not on every API call.
I just now fired up a terminal session and ran pm2 logs. The output appears to show this module getting weather API data without error, then the last log lines show errors.
The really strange part is there appear to be timestamps for sucessful and error API calls right around the same time [but not contiguous in the log display]. pm2 logs output follows:
0|MagicMir | [2024-11-08 08:33:43.472] [INFO] [MMM-DynamicWeather] Getting Weather API data 0|MagicMir | [2024-11-08 08:36:28.802] [INFO] Newsfeed-Fetcher: Broadcasting 30 items. 0|MagicMir | [2024-11-08 08:36:34.550] [INFO] Newsfeed-Fetcher: Broadcasting 31 items. 0|MagicMir | [2024-11-08 08:37:18.166] [INFO] Newsfeed-Fetcher: Broadcasting 25 items. 0|MagicMir | [2024-11-08 08:41:10.851] [INFO] Newsfeed-Fetcher: Broadcasting 35 items. 0|MagicMir | [2024-11-08 08:43:43.885] [INFO] [MMM-DynamicWeather] Getting Weather API data 0|MagicMir | [2024-11-08 08:46:29.642] [INFO] Newsfeed-Fetcher: Broadcasting 30 items. 0|MagicMir | [2024-11-08 08:46:34.913] [INFO] Newsfeed-Fetcher: Broadcasting 32 items. 0|MagicMir | [2024-11-08 08:47:18.479] [INFO] Newsfeed-Fetcher: Broadcasting 25 items. 0|MagicMir | [2024-11-08 08:53:43.477] [INFO] [MMM-DynamicWeather] Getting Weather API data 0|MagicMir | [2024-11-08 08:56:11.172] [INFO] Newsfeed-Fetcher: Broadcasting 35 items. 0|MagicMir | [2024-11-08 08:56:30.089] [INFO] Newsfeed-Fetcher: Broadcasting 30 items. 0|MagicMir | [2024-11-08 08:56:35.273] [INFO] Newsfeed-Fetcher: Broadcasting 32 items. 0|MagicMir | [2024-11-08 08:57:18.818] [INFO] Newsfeed-Fetcher: Broadcasting 25 items. 0|MagicMir | [2024-11-08 09:03:43.477] [INFO] [MMM-DynamicWeather] Getting Weather API data 0|MagicMir | [2024-11-08 09:06:30.344] [INFO] Newsfeed-Fetcher: Broadcasting 30 items. 0|MagicMir | [2024-11-08 09:06:35.673] [INFO] Newsfeed-Fetcher: Broadcasting 32 items. 0|MagicMir | [2024-11-08 09:07:19.177] [INFO] Newsfeed-Fetcher: Broadcasting 25 items. 0|MagicMir | [2024-11-08 09:11:11.483] [INFO] Newsfeed-Fetcher: Broadcasting 35 items. 0|MagicMir | [2024-11-08 09:13:43.480] [INFO] [MMM-DynamicWeather] Getting Weather API data /home/pi/.pm2/logs/MagicMirror-error.log last 50 lines: 0|MagicMir | [2024-11-08 01:03:43.562] [ERROR] [MMM-DynamicWeather] Failed getting api: 401 0|MagicMir | [2024-11-08 01:13:43.563] [ERROR] [MMM-DynamicWeather] Failed getting api: 401 0|MagicMir | [2024-11-08 01:23:43.532] [ERROR] [MMM-DynamicWeather] Failed getting api: 401 0|MagicMir | [2024-11-08 01:33:43.574] [ERROR] [MMM-DynamicWeather] Failed getting api: 401 0|MagicMir | [2024-11-08 01:43:43.559] [ERROR] [MMM-DynamicWeather] Failed getting api: 401 0|MagicMir | [2024-11-08 01:53:43.559] [ERROR] [MMM-DynamicWeather] Failed getting api: 401 <snip> 0|MagicMir | [2024-11-08 08:53:43.658] [ERROR] [MMM-DynamicWeather] Failed getting api: 401 0|MagicMir | [2024-11-08 09:03:43.690] [ERROR] [MMM-DynamicWeather] Failed getting api: 401 0|MagicMir | [2024-11-08 09:13:43.694] [ERROR] [MMM-DynamicWeather] Failed getting api: 401 -
@JohnGalt the 2 logs are stdout and stderr. pm2 shows them separately not merged like at console
401 means your apikey is bad.
did you install the pull request
https://forum.magicmirror.builders/post/120866 -
@sdetweil – Thanks Sam. I’m certain the API key is good, as I can format queries as web addresses and paste them into the browser and get openweathermap to return the data.
I didn’t install the pull request.
-
@JohnGalt you NEED to install the pull request to get the updated module code using the 3.0 api…
-
@sdetweil Yes, I realize that… I guess I skipped some thoughts that were rolling around in my head but never made it to the keyboard: I had disabled the module, figuring I would just wait for it to be updated.
I should have some time this evening to go in and install the pull request - I will let you know what happens.
-
@JohnGalt yes, but its unlikely to be updated by the author, but you have the pull request as a substitute/the update
-
@sdetweil – OK, so I did install the pull request, and it’s not working. After following the steps above, I still get errors:
Actions taken: - git fetch origin pull/52/head:with_30_apikey - realized I misread the instructions, so went back, and did the reset... - git reset --hard HEAD - git fetch origin pull/52/head:with_30_apikey - enable module in config.js - pm2 restart MM ] Results as shown in pm2 logs, which was running at the time: Immediate Results: 0|MagicMirror | [2024-11-11 17:02:25.687] [ERROR] [MMM-DynamicWeather] Failed getting api: AggregateError [ETIMEDOUT]: 0|MagicMirror | at internalConnectMultiple (node:net:1117:18) 0|MagicMirror | at internalConnectMultiple (node:net:1185:5) 0|MagicMirror | at Timeout.internalConnectMultipleTimeout (node:net:1711:5) 0|MagicMirror | at listOnTimeout (node:internal/timers:575:11) 0|MagicMirror | at process.processTimers (node:internal/timers:514:7) { 0|MagicMirror | code: 'ETIMEDOUT', 0|MagicMirror | [errors]: [ 0|MagicMirror | Error: connect ETIMEDOUT 38.89.70.82:443 0|MagicMirror | at createConnectionError (node:net:1647:14) 0|MagicMirror | at Timeout.internalConnectMultipleTimeout (node:net:1706:38) 0|MagicMirror | at listOnTimeout (node:internal/timers:575:11) 0|MagicMirror | at process.processTimers (node:internal/timers:514:7) { 0|MagicMirror | errno: -110, 0|MagicMirror | code: 'ETIMEDOUT', 0|MagicMirror | syscall: 'connect', 0|MagicMirror | address: '38.89.70.82', 0|MagicMirror | port: 443 0|MagicMirror | }, 0|MagicMirror | Error: connect ENETUNREACH 2604:86c0:5001:b::2:443 - Local (:::0) 0|MagicMirror | at internalConnectMultiple (node:net:1181:16) 0|MagicMirror | at Timeout.internalConnectMultipleTimeout (node:net:1711:5) 0|MagicMirror | at listOnTimeout (node:internal/timers:575:11) 0|MagicMirror | at process.processTimers (node:internal/timers:514:7) { 0|MagicMirror | errno: -101, 0|MagicMirror | code: 'ENETUNREACH', 0|MagicMirror | syscall: 'connect', 0|MagicMirror | address: '2604:86c0:5001:b::2', 0|MagicMirror | port: 443 0|MagicMirror | } 0|MagicMirror | ] 0|MagicMirror | } 0|MagicMirror | [2024-11-11 17:02:25.701] [LOG] [MMM-OpenWeatherMapForecast] 11-Nov-24 17:02 ** ERROR ** fetch failed Periodic Fetch results: 0|MagicMirror | [2024-11-11 17:12:23.363] [ERROR] [MMM-DynamicWeather] Failed getting api: 401 0|MagicMirror | [2024-11-11 17:12:29.902] [INFO] Newsfeed-Fetcher: Broadcasting 30 items. 0|MagicMirror | [2024-11-11 17:12:30.278] [INFO] Newsfeed-Fetcher: Broadcasting 24 items. 0|MagicMirror | [2024-11-11 17:12:30.611] [INFO] Newsfeed-Fetcher: Broadcasting 25 items. 0|MagicMirror | [2024-11-11 17:17:29.108] [INFO] Newsfeed-Fetcher: Broadcasting 40 items. 0|MagicMirror | [2024-11-11 17:22:23.126] [INFO] [MMM-DynamicWeather] Getting Weather API data 0|MagicMirror | [2024-11-11 17:22:23.324] [ERROR] [MMM-DynamicWeather] Failed getting api: 401 -
@JohnGalt said in MMM-DynamicWeather Failed getting api: 401:
- git fetch origin pull/52/head:with_30_apikey - enable module in config.jsoops… I forgot a step
- git fetch origin pull/52/head:with_30_apikey - get checkout with_30_apikey <==== THIS STEP - enable module in config.jsI just tested on my system and it worked ok
I REALLY dont’t like the module shipping node_modules folder, cause if this is one a different platform it will cause trouble
so I would do (and did event tho it worked)cd ~/MagicMirror sudo rm -rf node_modules npm installmy test config
{ module: "MMM-DynamicWeather", position: "fullscreen_above", config: { // See https://github.com/scottcl88/MMM-DynamicWeather for more information. api_key: "my 3.0 apikey", lat: "38.89511000", // random lon: "-77.03637000" // random } }, -
@sdetweil --Sam, thanks!! for your patience. I do have this resolved, at least in one MM instance.
I did go back and commit the one command I missed as advised above, but still no joy. But then, …
Strangely enough while I WAS using a valid ver 3 API key, you were right in saying my issue was an invalid API key in the call… After doing the above I was still getting a 401 error, so I accepted that the computers were doing exactly what I was telling them to do [as opposed to what I WANTED them to do]. I discovered the root cause after copying in the API key again and comparing. What I found was this:
apiKey: "123456789"When it should have been this:
api_key: "123456789"I’m not sure why I started using “apiKey” instead of “api_key”, but putting it the way the module wants it fixed my issue. Thanks again!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login