elewin / pi-weather-station

MIT License
294 stars 60 forks source link

Stopped retrieving weather data #32

Open halifax57 opened 2 years ago

halifax57 commented 2 years ago

My system was running continuously and perfectly for several months, and about 3-4 days ago it stopped retrieving weather data. Map and radar and time/sunrise/sunset are all good but conditions and forecasts are gone. In that display space, the program now displays:

"Could not retrieve weather data. Is your API key valid? Request failed with status code 401"

I checked all of my API keys, tried a few alternatives, and then plugged in the original API key from tomorrow.io.

In looking at the API calls graph on tomorrow.io, I see that it was consistently pulling 180-ish calls every day, then it dropped to 86 suddenly for one day, then 4 the next day, and then 0 and that's where it has been for several days.

Any suggestions?

Thanks, Harry

halifax57 commented 2 years ago

I found this documented problem at tomorrow.io that is parallel in time with my problem, yet I cannot get API key functioning back:

Jul 5, 2022 No incidents reported.

Jul 4, 2022 High Error Rate on Timeline API Resolved - This incident has been resolved and all API keys are working as expected. If you continue to experience any errors please be in touch with our team at support@tomorrow.io. We will of course continue to monitor all API behavior and we appreciate your patience as we implemented a fix for this. Jul 4, 17:51 UTC Update - A fix has been implemented and we are seeing a decrease in errors. We are continuing to monitor the events until we reach an all-clear status. Jul 4, 16:32 UTC Identified - The issue has been identified and the team is working on deploying the fix. Jul 4, 16:17 UTC Investigating - We are currently investigating an issue impacting our timeline API. API calls are currently returning a high volume of 401 and 301 errors. Our team is working diligently to investigate this and we expect a fix to be implemented shortly. We will continue to update accordingly. Jul 4, 16:03 UTC

halifax57_t-io-API fail

k5map commented 2 years ago

halifax57,

Am I correct in your page shows the weather data in the right pane or do you have a blank page with the error about retrieving the map?

halifax57 commented 2 years ago

Thanks for the reply, I very much appreciate it. On my display, I have a blank page with the error about retrieving weather data on the right side. See the attached image. I do have a support ticket with tomorrow.io ...

IMG_2157

k5map commented 2 years ago

Well fudge... we're both having different problems. If you have time, could you please provide the version of Node & NPM you have installed? When I check the Mapbox site, it shows that my RPi is not making any API calls so I'm trying to see if the issue is related to a specific version of Node/NPM. Capture

halifax57 commented 2 years ago

OK. Maybe you have two independent issues? As requested: NPM version 6.14.17 Node version v14.19.3 Thank you!

fcrwx commented 2 years ago

I am seeing the same issue and got it working with the following workaround:

  1. created a free API key at https://ipstack.com/product
  2. modified server/geolocationCtrl.js, changing the GET call from "https://freegeoip.app/json/" to "http://api.ipstack.com/{my_ip_address}?access_key={my_api_key}"
  3. restarted the server (npm start)

Hope that helps

BTW, I am on node v12.22.12 and npm 6.14.16

k5map commented 2 years ago

fcrwx,

I can't thank you enough! That resolved my issue. Much Thanks!

k5map commented 2 years ago

fcrwx,

Since you've dug into the code, maybe you can answer a question of mine... we obtain keys from Mapbox and Tomorrow.io but on the webpage in the bottom left corner, it shows Leaflet & RainViewer. Any idea what relationship those sites have to this app?

halifax57 commented 2 years ago

No joy with my weather-side issue. I'm glad that k5map got his problem fixed, though! fcrwx, thanks for looking into this.

tomorrow.io support said that they tested my API key and it worked for them. So I am at a complete loss as to why I cannot get this working again. They had a major API system crash on Monday July 4, the exact time that my failure showed up. They got it back up and running a day later but I am left with the problem. Pretty weird.

mlcampbe commented 2 years ago

halifax57, can you confirm that your pi can pull the data manually using curl? For example, try the following and see if you get data or an error.

curl -v "https://api.tomorrow.io/v4/timelines?location=34.57,86.84&fields=temperature,precipitationProbability,precipitationIntensity,windSpeed&timesteps=1h&apikey=<your-key>&endTime=2022-07-09T12:14:32.193Z"

be sure to replace with your actual weather-api key and you will likely need to adjust the endTime value too. This should be the same command that the app is trying to fetch. In my case I get 24 1-hour intervals of data all wrapped into a json string.

This will at least prove if the problem is with the app itself or with your api key (or perhaps a networking error).

halifax57 commented 2 years ago

Hi Mike, Thanks for the help. Here is the output from entering your curl command, using my API key where XXXXXXXXXXXX is below. I tried it with an endTime of 18:32Z too and got the same result. What does this tell you? Thanks again!

$ curl -v "https://api.tomorrow.io/v4/timelines?location=34.57,86.84&fields=temperature,precipitationProbability,precipitationIntensity,windSpeed&timesteps=1h&apikey=&endTime=2022-07-09T12:14:32.193Z"

mlcampbe commented 2 years ago

The last line "Invalid Key" seems to be the problem to me. The app is sending off this same command to retrieve the weather data and I suspect it fails the same way too. Therefore I would ignore the app right now and focus on getting the curl command to work.

The network connection looks ok as it made the connection to api.tomorrow.io successfully. The problem is that the tomorrow.io is rejecting your api-key for some reason. Are there any special characters in it such as * or & or ( that might be getting interpreted?

You might try logging into https://app.tomorrow.io/development/keys and verifying the key you are using is what is shown there. Maybe try to create a new api key?

halifax57 commented 2 years ago

Hi Mike, Thanks. I am not that experienced with curl so I think I will try to get a new key from tomorrow.io There are no special characters in the api-key. Thank you again!

halifax57 commented 2 years ago

Mike, When I enter the curl command from tomorrow.api on my key page directly into the console, it works:

curl --request GET --url \ 'https://api.tomorrow.io/v4/timelines?location=-73.98529171943665,40.75872069597532&fields=temperature&timesteps=1h&units=metric&apikey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' {"data":{"timelines":[{"timestep":"1h","endTime":"2022-07-13T02:00:00Z","startTime":"2022-07-08T14:00:00Z","intervals":[{"startTime":"2022-07-08T14:00:00Z","values":{"temperature":-41.16}},{"startTime":"2022-07-08T15:00:00Z","values":{"temperature":-41.55}},{"startTime":"2022-07-08T16:00:00Z","values":{"temperature":-42.13}},{"startTime":"2022-07-08T17:00:00Z","values":{"temperature":-43.01}},{"startTime":"2022-07-08T18:00:00Z","values":{"temperature":-43.49}},{"startTime":"2022-07-08T19:00:00Z","values":{"temperature":-43.58}},{"startTime":"2022-07-08T20:00:00Z","values":{"temperature":-43.51}},{"startTime":"2022-07-08T21:00:00Z","values":{"temperature":-43.72}},{"startTime":"2022-07-08T22:00:00Z","values":{"temperature":-43.83}},{"startTime":"2022-07-08T23:00:00Z","values":{"temperature":-44}},{"startTime":"2022-07-09T00:00:00Z","values":{"temperature":-44.15}},{"startTime":"2022-07-09T01:00:00Z","values":{"temperature":-44.95}},{"startTime":"2022-07-09T02:00:00Z","values":{"temperature":-45.8}},{"startTime":"2022-07-09T03:00:00Z","values":{"temperature":-46.07}},{"startTime":"2022-07-09T04:00:00Z","values":{"temperature":-46.06}},{"startTime":"2022-07-09T05:00:00Z","values":{"temperature":-46.51}},{"startTime":"2022-07-09T06:00:00Z","values":{"temperature":-46.37}},{"startTime":"2022-07-09T07:00:00Z","values":{"temperature":-46.35}},{"startTime":"2022-07-09T08:00:00Z","values":{"temperature":-46.66}},{"startTime":"2022-07-09T09:00:00Z","values":{"temperature":-47.17}},{"startTime":"2022-07-09T10:00:00Z","values":{"temperature":-47.77}},{"startTime":"2022-07-09T11:00:00Z","values":{"temperature":-47.92}},{"startTime":"2022-07-09T12:00:00Z","values":{"temperature":-48.09}},{"startTime":"2022-07-09T13:00:00Z","values":{"temperature":-48.16}},{"startTime":"2022-07-09T14:00:00Z","values":{"temperature":-47.41}},{"startTime":"2022-07-09T15:00:00Z","values":{"temperature":-47.27}},{"startTime":"2022-07-09T16:00:00Z","values":{"temperature":-48.21}},{"startTime":"2022-07-09T17:00:00Z","values":{"temperature":-48.19}},{"startTime":"2022-07-09T18:00:00Z","values":{"temperature":-49.32}},{"startTime":"2022-07-09T19:00:00Z","values":{"temperature":-49.98}},{"startTime":"2022-07-09T20:00:00Z","values":{"temperature":-50.31}},{"startTime":"2022-07-09T21:00:00Z","values":{"temperature":-50.93}},{"startTime":"2022-07-09T22:00:00Z","values":{"temperature":-51.37}},{"startTime":"2022-07-09T23:00:00Z","values":{"temperature":-51.32}},{"startTime":"2022-07-10T00:00:00Z","values":{"temperature":-51.18}},{"startTime":"2022-07-10T01:00:00Z","values":{"temperature":-51.02}},{"startTime":"2022-07-10T02:00:00Z","values":{"temperature":-50.67}},{"startTime":"2022-07-10T03:00:00Z","values":{"temperature":-50.44}},{"startTime":"2022-07-10T04:00:00Z","values":{"temperature":-50.2}},{"startTime":"2022-07-10T05:00:00Z","values":{"temperature":-50.03}},{"startTime":"2022-07-10T06:00:00Z","values":{"temperature":-49.88}},{"startTime":"2022-07-10T07:00:00Z","values":{"temperature":-49.71}},{"startTime":"2022-07-10T08:00:00Z","values":{"temperature":-49.64}},{"startTime":"2022-07-10T09:00:00Z","values":{"temperature":-49.94}},{"startTime":"2022-07-10T10:00:00Z","values":{"temperature":-50.4}},{"startTime":"2022-07-10T11:00:00Z","values":{"temperature":-50.93}},{"startTime":"2022-07-10T12:00:00Z","values":{"temperature":-51.36}},{"startTime":"2022-07-10T13:00:00Z","values":{"temperature":-51.77}},{"startTime":"2022-07-10T14:00:00Z","values":{"temperature":-52.18}},{"startTime":"2022-07-10T15:00:00Z","values":{"temperature":-52.63}},{"startTime":"2022-07-10T16:00:00Z","values":{"temperature":-53.09}},{"startTime":"2022-07-10T17:00:00Z","values":{"temperature":-53.52}},{"startTime":"2022-07-10T18:00:00Z","values":{"temperature":-53.92}},{"startTime":"2022-07-10T19:00:00Z","values":{"temperature":-54.25}},{"startTime":"2022-07-10T20:00:00Z","values":{"temperature":-54.53}},{"startTime":"2022-07-10T21:00:00Z","values":{"temperature":-54.68}},{"startTime":"2022-07-10T22:00:00Z","values":{"temperature":-54.86}},{"startTime":"2022-07-10T23:00:00Z","values":{"temperature":-54.8}},{"startTime":"2022-07-11T00:00:00Z","values":{"temperature":-54.79}},{"startTime":"2022-07-11T01:00:00Z","values":{"temperature":-54.83}},{"startTime":"2022-07-11T02:00:00Z","values":{"temperature":-54.69}},{"startTime":"2022-07-11T03:00:00Z","values":{"temperature":-54.44}},{"startTime":"2022-07-11T04:00:00Z","values":{"temperature":-54.32}},{"startTime":"2022-07-11T05:00:00Z","values":{"temperature":-54.47}},{"startTime":"2022-07-11T06:00:00Z","values":{"temperature":-54.42}},{"startTime":"2022-07-11T07:00:00Z","values":{"temperature":-54.55}},{"startTime":"2022-07-11T08:00:00Z","values":{"temperature":-54.48}},{"startTime":"2022-07-11T09:00:00Z","values":{"temperature":-54.61}},{"startTime":"2022-07-11T10:00:00Z","values":{"temperature":-54.6}},{"startTime":"2022-07-11T11:00:00Z","values":{"temperature":-54.8}},{"startTime":"2022-07-11T12:00:00Z","values":{"temperature":-54.79}},{"startTime":"2022-07-11T13:00:00Z","values":{"temperature":-54.88}},{"startTime":"2022-07-11T14:00:00Z","values":{"temperature":-55.46}},{"startTime":"2022-07-11T15:00:00Z","values":{"temperature":-56.17}},{"startTime":"2022-07-11T16:00:00Z","values":{"temperature":-56.61}},{"startTime":"2022-07-11T17:00:00Z","values":{"temperature":-57.18}},{"startTime":"2022-07-11T18:00:00Z","values":{"temperature":-57.59}},{"startTime":"2022-07-11T19:00:00Z","values":{"temperature":-58.08}},{"startTime":"2022-07-11T20:00:00Z","values":{"temperature":-58.6}},{"startTime":"2022-07-11T21:00:00Z","values":{"temperature":-58.91}},{"startTime":"2022-07-11T22:00:00Z","values":{"temperature":-59.3}},{"startTime":"2022-07-11T23:00:00Z","values":{"temperature":-59.41}},{"startTime":"2022-07-12T00:00:00Z","values":{"temperature":-59.08}},{"startTime":"2022-07-12T01:00:00Z","values":{"temperature":-58.77}},{"startTime":"2022-07-12T02:00:00Z","values":{"temperature":-58}},{"startTime":"2022-07-12T03:00:00Z","values":{"temperature":-57.26}},{"startTime":"2022-07-12T04:00:00Z","values":{"temperature":-56.47}},{"startTime":"2022-07-12T05:00:00Z","values":{"temperature":-55.57}},{"startTime":"2022-07-12T06:00:00Z","values":{"temperature":-54.87}},{"startTime":"2022-07-12T07:00:00Z","values":{"temperature":-54}},{"startTime":"2022-07-12T08:00:00Z","values":{"temperature":-53.2}},{"startTime":"2022-07-12T09:00:00Z","values":{"temperature":-52.49}},{"startTime":"2022-07-12T10:00:00Z","values":{"temperature":-51.79}},{"startTime":"2022-07-12T11:00:00Z","values":{"temperature":-51.29}},{"startTime":"2022-07-12T12:00:00Z","values":{"temperature":-50.89}},{"startTime":"2022-07-12T13:00:00Z","values":{"temperature":-50.49}},{"startTime":"2022-07-12T14:00:00Z","values":{"temperature":-50.26}},{"startTime":"2022-07-12T15:00:00Z","values":{"temperature":-49.97}},{"startTime":"2022-07-12T16:00:00Z","values":{"temperature":-49.49}},{"startTime":"2022-07-12T17:00:00Z","values":{"temperature":-48.99}},{"startTime":"2022-07-12T18:00:00Z","values":{"temperature":-48.79}},{"startTime":"2022-07-12T19:00:00Z","values":{"temperature":-48.57}},{"startTime":"2022-07-12T20:00:00Z","values":{"temperature":-48.65}},{"startTime":"2022-07-12T21:00:00Z","values":{"temperature":-48.75}},{"startTime":"2022-07-12T22:00:00Z","values":{"temperature":-48.85}},{"startTime":"2022-07-12T23:00:00Z","values":{"temperature":-48.76}},{"startTime":"2022-07-13T00:00:00Z","values":{"temperature":-48.95}},{"startTime":"2022-07-13T01:00:00Z","values":{"temperature":-49.32}},{"startTime":"2022-07-13T02:00:00Z","values":{"temperature":-49.15}}]}]}}

...but not in the app. Should I do a complete refresh of the program? Kind regards!

mlcampbe commented 2 years ago

That is interesting. Are you running my curl command the the one from the website both from the same place (the pi)?

halifax57 commented 2 years ago

Yes, from the same command line on the same pi. Thank you again.

mlcampbe commented 2 years ago

That is just very odd then. Not sure I have any answer for you then.

halifax57 commented 2 years ago

Thanks, Mike. I appreciate your help which demonstrated what was working. Given my experience level debugging Linux, I will likely go back and start with a fresh OS and rebuild from scratch and see where that takes me. Kind regards!

lerilar commented 2 years ago

Hope you'll find an answer @halifax57 - the same 401 issue surfaced here as well :( API key curl from the tomorrow.io site works fine here too. tomorrow.io activity shows no 4xx errors however.

Snag_20abcf12

.

mlcampbe commented 2 years ago

Have you edited the project to change the references of climacell to tomorrow.io? The files in the project still use climacell which may redirect to tomorrow.io but perhaps is not fully equivalent?

lerilar commented 2 years ago

I have not edited anything - and that part worked fine until yesterday actually (when I updated the pi and rebooted). I see outgoing calls to data.climacell.co, but when I check in the browser they are redirected to tomorrow.io and tomorrow.io shows activity on that token at least. I have no idea which call is causing the 401 message to appear however. This is what it looks like:

Snag_226391ce

.

RNET1 commented 2 years ago

Have you tried entering the LAT LON values? I've had the same issues, but populating those fields and all is well again.

halifax57 commented 2 years ago

Have you edited the project to change the references of climacell to tomorrow.io? The files in the project still use climacell which may redirect to tomorrow.io but perhaps is not fully equivalent?

I have always used the tomorrow.io API key. It worked fine for months until tomorrow.io's July outage. Nothing since. Thanks.

halifax57 commented 2 years ago

I have not edited anything - and that part worked fine until yesterday actually (when I updated the pi and rebooted). I see outgoing calls to data.climacell.co, but when I check in the browser they are redirected to tomorrow.io and tomorrow.io shows activity on that token at least. I have no idea which call is causing the 401 message to appear however. This is what it looks like:

Snag_226391ce

.

That is exactly what my system has looked like since July 4th tomorrow.io outage. Radar and mapping fine, no wx data and it reports the error w/comment just like in your photo. Can't find my way back! I will be doing a build from scratch shortly as I do not have the depth of talent in this realm to debug competently. Of course, I am hoping somebody finds a fix in the meantime.

RNET1 commented 2 years ago

I recommend the easy test, unless you have already tried this... populate the LAT and LON in the settings * just to see if that makes a difference. I had odd behavior too - tried all sorts of tests, including new builds and even going back to V1 of the app. In the end, populating those LAT/LON values resulted in normal data display.

RNET1 commented 2 years ago

If adding LAT LON values does not work, here is the more challenging method:

Replace data.climacell.co with api.tomorrow.io Change in the client/src/AppContext.js file Note - there are a few references to change here, search for climacell to find them Then rebuilt the dist/bundle.min.js ... cd client
 npm run-script prod (If you are using nodejs v17 then it will fail with a "hash" error. You can get around this by the command "export NODE_OPTIONS=--openssl-legacy-provider" It must be run prior to the npm command however.

I have done this and populated the LAT/LON - all functions properly now. A reboot might be needed too -- sudo reboot

halifax57 commented 2 years ago

I recommend the easy test, unless you have already tried this... populate the LAT and LON in the settings * just to see if that makes a difference. I had odd behavior too - tried all sorts of tests, including new builds and even going back to V1 of the app. In the end, populating those LAT/LON values resulted in normal data display.

RNET1, I already had LAT/LONG data in my settings.json file, but I went in and looked again, then looked at the settings.example.json and saw that he had 4 decimal places for his LAT/LONG x.xxxx. I trimmed my 6-decimal place LAT/LONG to 4 and did a reboot and I am up and running. I rebooted a few times and all still good.

Thank you, kind friend, for the help! Yay!

lerilar commented 2 years ago

I did the exact same thing - trimmed to 4 decimals and boom it started working again. I still don't have the map showing anything but grey, but as long as I see the rainviewer I am happy. Thanks for all the help.

chrism583 commented 2 years ago

Editing my Lat/Lon in settings.json also resolved my issue of not seeing weather information. Thanks!!!

MrGingerT commented 2 years ago

Just to confirm entering the lant and long does fix the blank screen issue fully. No idea why though. Many Thanks to those who found this out.

mlcampbe commented 2 years ago

It certainly would be interesting for someone to try re-entering the lat/lon values with a 6-digit decimal and see if it still works or not.

RNET1 commented 2 years ago

Well, I have 7-digit decimal in LAT and 9 in LON. It works fine for me... However, I have also changed references from data.climacell.co to api.tomorrow.io in the client/src/AppContext.js file and rebuilt. It could be two issues, not sure. I have all normal operation now.

k5map commented 2 years ago

@fcrwx

When you modified the JS files in the SRC tree, did those changes take effect immediately or did you have to enter npm install or some other command before the changes would take effect?

RNET1 commented 2 years ago

If you modify the source files, then a rebuild is required: Replace data.climacell.co with api.tomorrow.io -- Change in the client/src/AppContext.js file (Note - there are a few references to change here, search for climacell to find them)

Then rebuild the dist/bundle.min.js ... run the following cd client
 npm run-script prod (The following is ONLY If you are using nodejs v17 (it will fail with a "hash" error). However, it must be run prior to the npm command
export NODE_OPTIONS=--openssl-legacy-provider

If you get any errors, read the output - it has directions to solve. Otherwise, post here for help.

bnelson333 commented 1 year ago

I was also getting an intermittent error on not being able to retrieve weather data but my error was error 429 not 401. I trimmed the lat/lon in settings.json per this thread from 6 decimal places to 4 and it also fixed my issue. Would the developer be able to implement a quick round function on that so others don't run into the same issue? (sorry I have no idea how to contribute to a project like this)