Temp for Wunderground
Posted: Saturday 06 March 2021 11:44
Hello, I am trying to get temperature value for a supposed json result without any success.I have not succeeded in any way so, either something I am doing wrong, or the result I get from the link is not json. I appreciate any help.
Code: Select all
local scriptVar = 'WundeMap'
return
{
on =
{
timer =
{
'every 1 minutes',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'WundeMap',
},
execute = function(dz, item)
-- Send status to domoticz
if item.isTimer then
dz.openURL({
url = 'https://api.weather.com/v2/pws/observations/current?apiKey=obfuscated&stationId=IMasxa4&numericPrecision=decimal&format=json&units=e',
method = 'GET',
callback = scriptVar, -- httpResponses above.
})
return
end
if item.isHTTPResponse then
if item.statusCode == 200 then
if item.isJSON then
rt = item.json
local temp = rt.observations.imperial["temp"]
dz.log(temp,dz.LOG_DEBUG)
end
end
end
end
}