This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

API for WOW
#1
Hello,

I try to send data from a weather station to "WOW"

The instructions from them is folowing...

Using the API directly
If you're a developer and would like to use the API directly, details are provided below.
Upload URL:
WOW expects an HTTP request, in the form of either GET or POST, to the following URL. When received, WOW will interpret and validate the information supplied and respond as below.
The URL to send your request to is: http://wow.metoffice.gov.uk/automaticreading? followed by a set of key/value pairs indicating pieces of data.
Response and Errors
All requests will return a status code. A success is indicated by 200. Anything else is a failure. A human readable error message will accompany all errors in JSON format.
Mandatory Information:
All uploads must contain 4 pieces of mandatory information plus at least 1 piece of weather data.
  • Site ID - siteid:
    The unique numeric id of the site

  • Authentication Key - siteAuthenticationKey:
    A pin number, chosen by the user to authenticate with WOW.

  • Date - dateutc:
    Each observation must have a date, in the date encoding specified below.

  • Software Type - softwaretype
    The name of the software, to identify which piece of software and which version is uploading data

Date Encoding:
The date must be in the following format: YYYY-mm-DD HH:mmConfuseds, where ':' is encoded as %3A, and the space is encoded as either '+' or %20. An example, valid date would be: 2011-02-29+10%3A32%3A55, for the 2nd of Feb, 2011 at 10:32:55. Note that the time is in 24 hour format. Also note that the date must be adjusted to UTC time - equivalent to the GMT time zone.. This is especially important for users outside the UK, and British users must also take note of the difference between British Summer Time and UTC
Weather Data:
The following is a list of items of weather data that can be uploaded to WOW. Provide each piece of information as a key/value pair, e.g. winddir=225.5 or tempf=32.2. Note that values should not be quoted or escaped.

Frequency of submitting observations
It is recommended that the interval between automatic observations from your AWS is at least 5 minutes.
Pressure & MSLP:
Some weather stations record Mean Sea Level Pressure, and some record Station Pressure (also referred to as Air Pressure). The Site Definition in WOW will be used to determine which pressure measurement to use. If your site specifies a unit for Air Pressure, and MSLP is marked as 'Not Captured', then baromin will be treated as an Air Pressure reading. Otherwise it will be treated as an MSLP reading. To edit your site definition and ensure the correct pressure is selected, visit the edit pages of your site and the options for pressure will be near the bottom. Ensure one is set to 'hectopascals (hPa)' and the other is set to 'not captured'. WOW will then automatically work out the other measurement and store it for you.
Example URL:
://wow.metoffice.gov.uk/automaticreading?siteid=123456&siteAuthenticationKey=654321&dateutc=2011-02-02+10%3A32%3A55&winddir=230&windspeedmph=12&windgustmph=12&windgustdir=25&humidity=90&dewptf=68.2&tempf=70&rainin=0&dailyrainin=5&baromin=29.1&soiltempf=25&soilmoisture=25&visibility=25&softwaretype=weathersoftware1.0
Standard vs. Alternative units



My try to script is like this, but it boes not work. How can i get it work?

/Fredrik

Code:
local http = require("socket.http")
local ltn12 = require("ltn12")
local https = require('ssl.https')
local json = require('json')


Urlsend= 'http://wow.metoffice.gov.uk/automaticreading?'


local dateTime=os.date("%Y-%m-%d %H:%M:%S")

TimeForm='&dateutc='

ID='siteid='

SiteId='...'

SitAutKe='siteAuthenticationKey='

SiteAuthenticationKey='...'

Soft='&softwaretype='

Softwaretype='SpaceLynk'

And='&'

value1 = 'tempc='
value2 = grp.getvalue('32/1/5')
value3 = '&dailyrainin='
value4 = grp.getvalue('32/1/31')
value5 = '&winddir='
value6 = grp.getvalue('32/1/3')
value7 = '&rainin='
value8 = grp.getvalue('32/1/30')
value9 = '&windspeedmph='
value10 = grp.getvalue('32/1/1')
value11 = '&humidity='
value12 = grp.getvalue('32/1/11')
value13 = '&windgustmph='
value14 = grp.getvalue('32/1/2')
value15 = '&baromin='
value16 = grp.getvalue('32/1/15')



body= ('..ID..SiteId..And..SitAutKe..SiteAuthenticationKey..TimeForm..tostring(dateTime)..And.. tostring(value1).. tostring(value2).. tostring(value3).. tostring(value4).. tostring(value5).. tostring(value6).. tostring(value7).. tostring(value8).. tostring(value9).. tostring(value10).. tostring(value11).. tostring(value12).. tostring(value13).. tostring(value14).. tostring(value15).. tostring(value16)..Soft..Softwaretype')



local response_body = {}

res, code, headers, status = http.request{
url = "http://wow.metoffice.gov.uk/automaticreading?",
method = "POST",
headers ={
["Authorization"] = "Bearer ..SiteId..SiteAuthenticationKey",
["Content-Type"] = "application/json",
["Accept"] = "application/json"
},
source = ltn12.source.string(body),
sink = ltn12.sink.table(response_body)
}


log(response_body)
log(body)
log(res,code,headers,status)
Reply


Messages In This Thread
API for WOW - by jobb@nordstrandsel.se - 20.09.2023, 10:10
RE: API for WOW - by admin - 20.09.2023, 10:39
RE: API for WOW - by jobb@nordstrandsel.se - 20.09.2023, 11:51
RE: API for WOW - by admin - 20.09.2023, 12:09
RE: API for WOW - by jobb@nordstrandsel.se - 20.09.2023, 12:50

Forum Jump: