getting openweathermap station_id

1,850 views
Skip to first unread message

Paolo Benvenuto

unread,
Feb 12, 2017, 1:09:56 AM2/12/17
to weewx-user

Hi! I registered on openweathermap, I got a key, but I cannot realize how can I get a station_id in order to put it in weewx.con as explained in https://github.com/weewx/weewx/wiki/openweathermap


Any hint is appreciated.

Andrew Milner

unread,
Feb 12, 2017, 1:23:56 AM2/12/17
to weewx-user

Paolo Benvenuto

unread,
Feb 12, 2017, 6:06:51 AM2/12/17
to weewx-user
Il giorno domenica 12 febbraio 2017 07:23:56 UTC+1, Andrew Milner ha scritto:
It says:

"Register your station in our system using the new API version and get a unique identifier for the station."

The problem is: how?

Andrew Milner

unread,
Feb 12, 2017, 6:33:29 AM2/12/17
to weewx-user
Have you tried their support desk??

it looks to me as though you need to use something like 'postman' to submit the request and receive their response to see the returned id.

or - just try something like
Add your API key as an APPID parameter to the GET request (APPID=APIKEY) like in the following examples:
api.openweathermap.org/data/2.5/weather?id=524901&APPID=**************

mwall

unread,
Feb 12, 2017, 9:05:14 AM2/12/17
to weewx-user
On Sunday, February 12, 2017 at 6:06:51 AM UTC-5, Paolo Benvenuto wrote:
Il giorno domenica 12 febbraio 2017 07:23:56 UTC+1, Andrew Milner ha scritto:
It says:

"Register your station in our system using the new API version and get a unique identifier for the station."

The problem is: how?

did you follow the instructions?

once you have an account, login to openweathermap and you'll see a page where you can create station identifiers.

m
 
owm-signup.png

mwall

unread,
Feb 12, 2017, 9:15:06 AM2/12/17
to weewx-user
the openweathermap web site is a bit confusing.  it is oriented toward people who need to download data more than for people who want to upload data, the terms they use have changed over the years, and their step-by-step instructions are not accurate if taken literally.

fwiw, i have been using the 'name' associated with a 'key' as the 'station_id' and 'appid', respectively.

that works for me with either their 3.0 api or their pre-3.0 api

if that does not work for you, contact the openweathermap support then let us know what you discover

m

Paolo Benvenuto

unread,
Feb 12, 2017, 2:19:22 PM2/12/17
to weewx...@googlegroups.com
2017-02-12 15:15 GMT+01:00 mwall <mw...@users.sourceforge.net>:
the openweathermap web site is a bit confusing.  it is oriented toward people who need to download data more than for people who want to upload data, the terms they use have changed over the years, and their step-by-step instructions are not accurate if taken literally.

fwiw, i have been using the 'name' associated with a 'key' as the 'station_id' and 'appid', respectively.

that works for me with either their 3.0 api or their pre-3.0 api

no, it doesn't work, I get in syslog:

restx: OWM: Failed to publish record 2017-02-12 20:15:00 CET (1486926900): Failed upload after 3 tries

 
if that does not work for you, contact the openweathermap support then let us know what you discover

m

--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/3rCKMUCcEF0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mwall

unread,
Feb 12, 2017, 2:24:56 PM2/12/17
to weewx-user
On Sunday, February 12, 2017 at 2:19:22 PM UTC-5, Paolo Benvenuto wrote:
2017-02-12 15:15 GMT+01:00 mwall:
the openweathermap web site is a bit confusing.  it is oriented toward people who need to download data more than for people who want to upload data, the terms they use have changed over the years, and their step-by-step instructions are not accurate if taken literally.

fwiw, i have been using the 'name' associated with a 'key' as the 'station_id' and 'appid', respectively.

that works for me with either their 3.0 api or their pre-3.0 api

no, it doesn't work, I get in syslog:

restx: OWM: Failed to publish record 2017-02-12 20:15:00 CET (1486926900): Failed upload after 3 tries

paolo,

in the log you should see the reason for each failure.

to see even more detail, set debug=2 in weewx.conf then restart weewx.

that will show you the actual url weewx is using to contact openweathermap.  try using that URL in a web browser to figure out why it is failing.

m

Paolo Benvenuto

unread,
Feb 12, 2017, 3:29:42 PM2/12/17
to weewx...@googlegroups.com
set debug=2, I get in syslog:

Feb 12 21:25:18 paolo weewx[23343]: restx: OWM: data: [{"wind_speed": 1.9818231070544203, "wind_gust": 2.9000072071117438, "station_id": "PaoloBenve_Pra", "humidity": 74.0, "pressure": 1025.244803951798, "dt": 1486931100.0, "wind_deg": 36.034851470886125, "temperature": 8.149999999999997}]
Feb 12 21:25:24 paolo weewx[23343]: restx: OWM: Failed upload attempt 2: HTTP Error 400: Bad Request
Feb 12 21:25:29 paolo weewx[23343]: restx: OWM: Failed upload attempt 3: HTTP Error 400: Bad Request
Feb 12 21:25:34 paolo weewx[23343]: restx: OWM: Failed to publish record 2017-02-12 21:25:00 CET (1486931100): Failed upload after 3 tries

I think the idea of using name and value of key for station is bad, because the docs say that the coordinates and altitude of the station must be set in the station creation, and I haven't done anything so.

Paolo Benvenuto

unread,
Feb 12, 2017, 3:45:06 PM2/12/17
to weewx...@googlegroups.com
https://openweathermap.desk.com/customer/portal/questions/16677527-three-not-so-simple-steps-to-connect-your-weather-station it says "The PWS service has been disabled temporarily. We are working on a major upgrade."


don Paolo Benvenuto

Chotechai Piyavongsiri

unread,
Jun 15, 2017, 5:06:44 AM6/15/17
to weewx-user
Hi,

I just got the api key from OWM and struggle to find way to get the station id. Now I did it by installing Postman plugin from Chrome webstore. Then you open the plugin from the Chrome browser and it will provide a rather simple UI for you to fill in the station request, header, and submit the url to get your station id. I attach a series of screenshots for better illustration.
01_webstore.PNG
02_postman.PNG
03_postman.PNG
04_postmand_register.PNG
05_input1.PNG
06_content_type.PNG
07_json_request.PNG
08_json_response.PNG

john hutchison

unread,
Aug 17, 2017, 10:45:27 PM8/17/17
to weewx-user
Chotechai Piyavongsiri,

I get the following message when using postman:

{
   
"code": 400001,
   
"message": "unmarshal type error: expected=[]types.MeasurementRequest, got=object, offset=1"
}



Other than my appid and body, your screenshots match my postman entries.

Here is my body entry:

{
   
"external_id": "ktxlames3",
   
"name": "Lamesa, Texas",
   
"latitude": 32.742908,
   
"longitude": -101.965671,
   
"altitude": 3004
}

I have tried upper and lowercase external_id, AGL and ASL for the altitude, and making the longitude positive (just to see), and it still returns the above error and more specifically "Error 400 Bad Request - the request cannot be fufilled due to bad syntax.
The only difference is my header doesn't match yours although it is Content-type - application/json:

access-control-allow-credentials true
access
-control-allow-methods GET, POST
access
-control-allow-origin →*
connection
keep-alive
content
-length 107
content
-type application/json; charset=utf-8
date
Fri, 18 Aug 2017 02:38:16 GMT
server
openresty


john hutchison

unread,
Aug 17, 2017, 11:03:50 PM8/17/17
to weewx-user
I fixed it. Was using the publish url from the syslog


instead of the registration url


Marty Thompson

unread,
Sep 17, 2017, 5:25:00 PM9/17/17
to weewx-user
Hi i have the same error
where did you change the code
cheers

Marty Thompson

unread,
Sep 17, 2017, 6:46:45 PM9/17/17
to weewx...@googlegroups.com
Well dumb me found it any way still getting a 401 error
But if I paste the URL I get the right info back
Is there a more detailed log I can look at?

john hutchison

unread,
Sep 17, 2017, 9:34:02 PM9/17/17
to weewx-user
In the POST field for postman, do you have

john hutchison

unread,
Sep 17, 2017, 9:38:06 PM9/17/17
to weewx-user
In Postman, you should have a button that says "code" under the save button. Can you copy the output of that and post it here, removing your appid and personal info of course?

Here is mine:
POST /data/3.0/stations?appid=myAppID HTTP/1.1
Host: api.openweathermap.org
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: myPostmanToken

{
   
"external_id": "myExternalID",
   
"name": "SPMS Lamesa Weather Station",
   
"latitude": myLatitude,
   
"longitude": myLongitude,
   
"altitude": 3004
}


Marty Thompson

unread,
Sep 17, 2017, 10:02:45 PM9/17/17
to weewx-user
this is the error that comes up
 Sep 18 03:00:26 IQLDCOOM4 weewx[2043]: restx: OWM: Failed upload attempt 2: HTTP Error 401: Unauthorized
Sep 18 03:00:35 IQLDCOOM4 weewx[2043]: restx: OWM: Failed upload attempt 3: HTTP Error 401: Unauthorized
Sep 18 03:00:40 IQLDCOOM4 weewx[2043]: restx: OWM: Failed to publish record 2017-09-18 03:00:00 +01 (1505700000): Failed upload after 3 tries




and the ouput
POST /data/3.0/stations?appid=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxdd17df6c HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxx

{
    "external_id": "COOMQLDAU",
    "name": "Coomera Live Weather",
    "latitude":  -xxxxxxxx,
    "longitude": xxxxxxxxx,
    "altitude": 32
}

thanks for helping
Reply all
Reply to author
Forward
0 new messages