baerengraben / ioBroker.swiss-weather-api

Adds Free SRG-SSR Weather API to ioBroker
MIT License
14 stars 13 forks source link

Adapter v1.0.2 stops running: Cannot read property 'id' of undefined / "Resource not found error" #68

Closed guggu1 closed 2 years ago

guggu1 commented 2 years ago

Hello, the adapter stopped running on my Rasperrry PI. Error log entries see below. I did not make any changes to my raspi. It just stopped running some time after I have upgraded the adapter to 1.0.2 (I could not get 1.0.1 to work. There was some login error).

I observe the exact same effect on a brand new system, where I made a fresh install of the operating system, npm, node.js , ioBroker and the swiss-weather-api adapter. No objects are created by the adapter. In view of this fact I cannot think of the problem being due to some corruption in the original system

Any ideas?

Christoph S

Error log entries:

1) swiss-weather-api.0 2021-11-20 23:33:38.583 error TypeError: Cannot read property 'id' of undefined at IncomingMessage. (/opt/iobroker/node_modules/iobroker.swiss-weather-api/main.js:3052:23) at IncomingMessage.emit (events.js:326:22) at endReadableNT (_stream_readable.js:1241:12) at processTicksAndRejections (internal/process/task_queues.js:84:21)
2) swiss-weather-api.0 2021-11-20 23:33:38.584 error Cannot read property 'id' of undefined

3) === this one may be the culprit. I have never seen this before the problem with the adapter occurred ==============

host.raspberrypi 2021-11-20 23:33:39.176 error Caught by controller[0]: (node:14309) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
4) host.raspberrypi 2021-11-20 23:33:39.178 error instance system.adapter.swiss-weather-api.0 terminated with code 6 (UNCAUGHT_EXCEPTION)
guggu1 commented 2 years ago

additionally got the following by starting the adapter in debug mode from terminal (iobroker debug swiss-weather-api.0):

2021-11-21 00:42:02.742 - info: swiss-weather-api.0 (15832) starting. Version 1.0.2 in /opt/iobroker/node_modules/iobroker.swiss-weather-api, node: v12.22.5, js-controller: 3.3.19 2021-11-21 00:42:02.849 - info: swiss-weather-api.0 (15832) longitude/longitude will be set by self-Config - longitude: 8.0414 latitude: 46.6242 2021-11-21 00:42:02.885 - debug: swiss-weather-api.0 (15832) use system language for weekday names: 2021-11-21 00:42:12.867 - debug: swiss-weather-api.0 (15832) Successfull DNS resolve for api.srgssr.ch: ["3.120.122.149"] 2021-11-21 00:42:12.870 - debug: swiss-weather-api.0 (15832) There is no geolocationId, so getting one before calling forecasts... 2021-11-21 00:42:12.872 - debug: swiss-weather-api.0 (15832) getting Token... 2021-11-21 00:42:12.874 - debug: swiss-weather-api.0 (15832) "lagSQfVGtdyJwDQJkXteWbAxGeR0t8tz:pSH5ASzUPJ2kCLO4" converted to Base64 is "bGFnU1FmVkd0ZHlKd0RRSmtYdGVXYkF4R2VSMHQ4dHo6cFNINUFTelVQSjJrQ0xPNA=="

2021-11-21 00:42:12.876 - debug: swiss-weather-api.0 (15832) Options to get Access Token: {"json":true,"method":"POST","hostname":"api.srgssr.ch","port":null,"path":"/oauth/v1/accesstoken?grant_type=client_credentials","headers":{"Authorization":"Basic bGFnU1FmVkd0ZHlKd0RRSmtYdGVXYkF4R2VSMHQ4dHo6cFNINUFTelVQSjJrQ0xPNA==","Cache-Control":"no-cache","Content-Length":0,"Postman-Token":"24264e32-2de0-f1e3-f3f8-eab014bb6d76"}} (node:15832) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.

2021-11-21 00:42:13.165 - debug: swiss-weather-api.0 (15832) Answer of Request Access Token: {"access_token":"hTFT2poPolSimWJkFrkrWSRMiKcV", "expires_in": 2591999, "token_type":"Bearer"}

2021-11-21 00:42:13.167 - debug: swiss-weather-api.0 (15832) Access_Token : hTFT2poPolSimWJkFrkrWSRMiKcV 2021-11-21 00:42:13.168 - debug: swiss-weather-api.0 (15832) Getting GeolocationId.... 2021-11-21 00:42:13.169 - debug: swiss-weather-api.0 (15832) Options to get GeolocationId: {"method":"GET","hostname":"api.srgssr.ch","port":null,"path":"/srf-meteo/geolocations?latitude=46.6242&longitude=8.0414","headers":{"authorization":"Bearer hTFT2poPolSimWJkFrkrWSRMiKcV"}}

2021-11-21 00:42:13.377 - debug: swiss-weather-api.0 (15832) Answer of getGeolocation Request: [] 2021-11-21 00:42:13.378 - debug: swiss-weather-api.0 (15832) Body: [] 2021-11-21 00:42:13.380 - error: swiss-weather-api.0 (15832) uncaught exception: Cannot read property 'id' of undefined 2021-11-21 00:42:13.382 - error: swiss-weather-api.0 (15832) TypeError: Cannot read property 'id' of undefined at IncomingMessage. (/opt/iobroker/node_modules/iobroker.swiss-weather-api/main.js:3052:23) at IncomingMessage.emit (events.js:326:22) at endReadableNT (_stream_readable.js:1241:12) at processTicksAndRejections (internal/process/task_queues.js:84:21)

2021-11-21 00:42:13.383 - error: swiss-weather-api.0 (15832) Cannot read property 'id' of undefined 2021-11-21 00:42:13.391 - debug: swiss-weather-api.0 (15832) Cron job destroyed 2021-11-21 00:42:13.392 - info: swiss-weather-api.0 (15832) cleaned everything up... 2021-11-21 00:42:13.394 - info: swiss-weather-api.0 (15832) terminating 2021-11-21 00:42:13.396 - warn: swiss-weather-api.0 (15832) Terminated (UNCAUGHT_EXCEPTION): Without reason

guggu1 commented 2 years ago

I have the following versions installed on the new system: ======== Rasperry PI ========: PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)" NAME="Raspbian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

============== ioBroker ===============

pi@raspberrypi:~ $ iobroker version 3.3.19

======= npm ========= pi@raspberrypi:~ $ iobroker version 3.3.19

=======. nodejs ======== pi@raspberrypi:~ $ node -v v12.22.5

ckuratle commented 2 years ago

Hi Same problems with adapter Version 1.0.2 , node: v14.18.1, js-controller: 3.3.18 running Windows11

The problem startet after update to Node 14.18.1

Regards

florian1984 commented 2 years ago

Got same issue. I've not updated any adapter. I think they have changed something in the API.

Matt77CHE commented 2 years ago

I don't have this issue; everything works fine:

florian1984 commented 2 years ago

I could find the reason. The Request for geolaction return an empty string. When I rode API docs I see that the request is made wrong in the adapter:

from: 2992 "path": "/srf-meteo/geolocations?latitude=" + self.config.Latitude + "&longitude=" + self.config.Longitude, to: 2992 "path": "/srf-meteo/geolocations/?latitude=" + self.config.Latitude + "&longitude=" + self.config.Longitude,

After that the adapter is starting again but for some unknown reason I get a wrong Geolocation ID 0.0000 :(👎

image

guggu1 commented 2 years ago

Boy, this did the trick. I managed to change to code locally. Adapter runs as smooth as before.

Thanks

Christoph S

florian1984 commented 2 years ago

yeah but the weather is somehow somewhere in usa for me ;-) ... getting GeoLocation ID 0.0000 don't know why ;)

guggu1 commented 2 years ago

same here. Did not realise that. I lost all my VIS objects (shame on me, no backup), hence I never verified if the data were OK. Just saw that the adapter was running.

Hope this will be fixed soon. I am not good enough a programmer to figure out the fix.

florian1984 commented 2 years ago

Hope too, Im bit mad with SRG. I wrote them an email today. For me they send wrong Response. It looks like that they have changed their API. I cannot test it anymore because I've reached free limit ;-).

guggu1 commented 2 years ago

just create a new app. Then you0ll get another 50 requests.

CCS

On 22 Nov 2021, at 11:52, florian1984 @.***> wrote:

Hope too, Im bit mad with SRG. I wrote them an email today. For me they send wrong Response. It looks like that they have changed their API. I cannot test it anymore because I've reached free limit ;-).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/baerengraben/ioBroker.swiss-weather-api/issues/68#issuecomment-975396399, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFR4AD67BICZFQVKQNTOPEDUNIOGZANCNFSM5ION3TJQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

florian1984 commented 2 years ago

the most API currently not working correctlys. SRF not answer my mails. Great service. Now i know why i pay serafe fees, shi news s** service.

I will change to openweather.

baerengraben commented 2 years ago

Yes, I can confirm there something is going wrong. I check it now...

baerengraben commented 2 years ago

...Ok, the endpoint https://api.srgssr.ch/srf-meteo/geolocations for getting the geolocation-id is not working properly anymore.

I don't think that it is a problem with the adapter. You can check this out here: https://developer.srgssr.ch/apis/srf-weather/docs/geolocation-latitude-and-longitude

If you do a test, then you see that even this testpage is doing the request as GET /srf-meteo/geolocations?latitude=xxxx&longitude=xxxx

And normaly parameters a attached to an URL with "'?....." and not with "/?...." => At least this was the standard back then, when I studied IT ;)

I wrote it to api@srgssr.ch and hope that they are answer soon...

florian1984 commented 2 years ago

Yes its not the adapter fault ;).

Im waiting 2 days for an answer from them. I saw the same thing. But anyways /? or ?para1.... both work not correctly. First send empty object, /? send an json but with weather info from USA with geoID 0.0000 .... ;-).

From the API Documentation its /?latitude=,longitude= see here https://developer.srgssr.ch/apis/srf-weather/docs/geolocation-latitude-and-longitude

Normally its true if it's a normal GET Parameter ?parameter=value is the right syntax ... ^^

baerengraben commented 2 years ago

Hope they are answering soon. If not, I do have two other direct contacts to SRG. When I do not get an answer, I will try to contact them directly.

PS: I used openweather too. But I was never happy with their data-quality. That's because I wrote the srf-weather adapter. Now the data-quality is good, but it seems that this is the frist time SRG is doing API-Technology ^^

florian1984 commented 2 years ago

that's true. I loved your adapter and the weather data quality :-). First I wanted to look at kachelmann weather but they not offer an api :(. OK, hope they get the things working again. Have many logic on this weather data ;).

mi1985 commented 2 years ago

today i got a response from the srg. they fixed the api issue. But the adapter still using geo id 0. Via https://developer.srgssr.ch/apis/srf-weather/docs/geolocation-latitude-and-longitude i can see a correct response body. Any idea what is wrong?

baerengraben commented 2 years ago

Just tested it now. And I can confirm, that it is working again. No Issues here. @mi1985 : Is longitude and latitude set correctly? Maybe you could reinstall Adapter just to be shure everything is set correctly. If it is not working, can you provide your debug-log?

mi1985 commented 2 years ago

I reeinstalled the adapter. Now the adpater get a geo id and the adapter is using it for the forecast request. But now it hangs in the forecast request process.

2021-11-24 22:20:17.624 error Forecast - Resource not found 2021-11-24 22:20:17.624 debug Return Code: 404.02.001 2021-11-24 22:20:17.624 debug Answer of forecast Request: { "code": "404.02.001", "message": "Resource not found error", "info": "https://developer.srgssr.ch" } 2021-11-24 22:20:17.524 info Getting forecast for GeolocationId: 47.4467,9.4050 2021-11-24 22:20:17.523 debug Options to get forecast: {"method":"GET","hostname":"api.srgssr.ch","port":null,"path":"/srf-meteo/forecast/47.4467,9.4050","headers":{"authorization":"Bearer xy*"}} 2021-11-24 22:20:17.523 debug Getting Forecast for geolocation id: 47.4467,9.4050

*Bearer replaced

I try it out via https://developer.srgssr.ch/apis/srf-weather/docs/forecast-geolocationid and there it works fine.

baerengraben commented 2 years ago

I can reproduce it. My Geolocation-id is working properly. Yours not. the requests sent through the adapter compared to https://developer.srgssr.ch/apis/srf-weather/docs/forecast-geolocationid are the same. Realy strange. I'll have to do further tests.

baerengraben commented 2 years ago

Hm.. Did now a direct test with your geolocation id 47.4467,9.4050 Now I get a "resource not found" on the developer-page:

image

Can you retest this? ...Maybe they are in the middle of "doing something" ;)

florian1984 commented 2 years ago

Get the same message. If you use manual settings in the app it's working:

1) https://developer.srgssr.ch/apis/srf-weather/docs/geolocationnames-name-or-zip < getting right long latitude. 2) enter the values in the adapter settings.

But I have some bad feelings to use this API anymore :(. They still not write me. They change API without any announcement or infos. If I work in my company like that I could find a new job.

mi1985 commented 2 years ago

ok, thanks for the info. At the moment max api calls reached and they fixed the trick with remove and add a new app. So I have to wait. But I am completly with you regarding the quality of the api. I extend my script with basic check if the swiss api response is up to date if note use an another data source.

baerengraben commented 2 years ago

I do not think it is an adapter problem. I did not change anything on it and before it worked without problems. From my point of view it is 100% because they changed something. Unfortunately I can't currently track what it is. Because the requests from the developer side and from the adapter are the same. And some locations are working (my location).

I reported this to srg. And I got already an answer. They also confirm, that actually it is not possible to get an Info, when they change something on the API. SRG confirms, that they are working on it.

florian1984 commented 2 years ago

Im wondering how many paying customer they still have...

baerengraben commented 2 years ago

Well, good question. Because we use the service for free, I guess we have to be a little patient and/or lenient. I hope it works better for the paying customers and that SRG will get better in operating this API. Normally the API would have to be operated with a "version-management" to ensure an operational stability. That is definitely missing at the moment.

guggu1 commented 2 years ago

the adapter/interface is working again, it seems - by some miracle. I have not changed anything. I don't think the SRF folks' reliability can be trusted. I hope the news they broadcast in TV are more reliable.

guggu1 commented 2 years ago

my previous statement is incorrect, too. I am still in Sierra San Felipe. But no errors are reported.

florian1984 commented 2 years ago

the news are even worser ;). OK I cannot call it "news". Corona, corona, corona 5G, 4G its so boring all the time ....

For me its working I've used this https://developer.srgssr.ch/apis/srf-weather/docs/geolocationnames-name-or-zip < getting right long latitude. After entering the corrected location everything works fine (since 3days).

guggu1 commented 2 years ago

the news are even worser ;). OK I cannot call it "news". Corona, corona, corona 5G, 4G its so boring all the time ....

For me its working I've used this https://developer.srgssr.ch/apis/srf-weather/docs/geolocationnames-name-or-zip < getting right long latitude. After entering the corrected location everything works fine (since 3days).

does not work here after I have obtained to coordinates from SRG for zip 4102.

Did you apply the fix suggested by floian1984?

If I apply the fix, I get

swiss-weather-api.1 2021-11-29 10:41:24.561 info Getting forecast for GeolocationId: 0.0000,0.0000

If I run the original code, I get

swiss-weather-api.1 2021-11-29 10:39:03.483 error Forecast - Resource not found

CCS

swiss-weather-api.1 2021-11-29 10:39:03.483 error Forecast - Resource not found
swiss-weather-api.1 2021-11-29 10:39:03.483 error Forecast - Resource not found
florian1984 commented 2 years ago

For me its currently working without any change in 1.02 version:

image

I restart the adapter every day, so I would know it if something go wrong. I did the same. Getting my geolocation for my postal code. Strange, maybe SRG still not fixed it yet?

baerengraben commented 2 years ago

That's really strange. My GeolocationId works since 4 days again without problems. I use the latitude and longitude directly from ioBroker. I don't even have to enter them manually (via https://developer.srgssr.ch/apis/srf-weather/docs/geolocationnames-name-or-zip )

I will do some testing (again). Hope I will find some reason.

mi1985 commented 2 years ago

Since Friday, after removing latitude and longitude from the adapter, everyhing is ok.

TomasiDeveloping commented 2 years ago

I put the adapter back in service today after the problems. The adapter now runs properly again and also the latitude and longitude are correctly taken directly from ioBroker

baerengraben commented 2 years ago

I did a test today on https://developer.srgssr.ch/apis/srf-weather/docs/:

I assume, there is still something wrong with that API. So I reported that Issue to api@srgssr.ch.

baerengraben commented 2 years ago

I have received a quick answer from SRG. The error message "Resource not found error" in this case is unfortunately a bit inaccurate:

The Meteo Freemium Product allows you to get forcasts for only one Location. So API-Requests for different locations will throw this error.

This means: API is working correctly by now => only the error message is confusing.

So I'm closing this issue.