Logic Machine Forum
meteomatics temperature next day - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: meteomatics temperature next day (/showthread.php?tid=5014)



meteomatics temperature next day - KRIS DOCX - 10.10.2023

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}]}]}]}


RE: meteomatics temperature next day - Erwin van der Zwart - 10.10.2023

Try log(data) to see the LUA table but i think you need to drill down to data.data.value


RE: meteomatics temperature next day - admin - 11.10.2023

Try this:
Code:
value = data.data[1].coordinates[1].dates[1].value
grp.checkupdate('33/1/2', value)