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.

meteomatics temperature next day
#1
I would like to return the value provided by the meteomatics api to 33/1/2 but I'm confused on the data type i guess.


 --script
require('json')
https = require('ssl.https')
escape = require('socket.url').escape

res= https.request("https://api.meteomatics.com/2023-10-10T19:45:00.000+02:00/t_2m:C/51.0248817,4.6908515/json")
data = json.pdecode(res)

grp.write('33/1/2', dates[value])

--url entry in browser
--https://api.meteomatics.com/2023-10-10T19:45:00.000+02:00/t_2m:C/51.0248817,4.6908515/json

--Api returns json
--{"version":"3.0",
-- "user":"xtend_docx_kris",
-- "dateGenerated":"2023-10-10T17:49:11Z",
-- "status":"OK",
-- "data":
-- [{"parameter":"t_2m:C",
-- "coordinates":[{"lat":51.024882,
--  "lon":4.690852,
--  "dates":[{"date":"2023-10-10T17:45:00Z",
--  "value":20.3}]}]}]}
Reply
#2
Try log(data) to see the LUA table but i think you need to drill down to data.data.value
Reply
#3
Try this:
Code:
value = data.data[1].coordinates[1].dates[1].value
grp.checkupdate('33/1/2', value)
Reply


Forum Jump: