13.09.2019, 15:36
Hello, I created this scrip in several Logic Machine to know meteorological data and they worked correctly until a while ago they no longer work, they could help me find out what the error is or why they don't work.
Thank you
*****************************************************************************************************
-- https://www.apixu.com/
require('json')
https = require('ssl.https')
escape = require('socket.url').escape
key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' --API KEY
location = 'Alcobendas' -- lugar de clima
url = 'https://api.apixu.com/v1/forecast.json?key=%s&q=%s&days=2'
url = string.format(url, key, escape(location))
res = https.request(url)
data = json.pdecode(res)
if type(data) ~= 'table' then
alert('failed to load weather data')
log('failed to load weather data')
return
end
if data.error then
log('error', data.error)
return
end
current = data.current
today = data.forecast.forecastday[ 1 ].day
tomorrow = data.forecast.forecastday[ 2 ].day
--INFO UTILIZADA
-- temperature in C
grp.write('15/1/2', current.temp_c)
-- weather condition text
grp.write('15/1/1', current.condition.text)
-- minimum temperature in celsius for the day
grp.write('15/1/4', today.mintemp_c)
-- maximum temperature in celsius for the day
grp.write('15/1/5', today.maxtemp_c)
-- weather condition text
grp.write('15/1/3', today.condition.text)
-- maximum temperature in celsius for the day
grp.write('15/1/8', tomorrow.maxtemp_c)
-- weather condition text
grp.write('15/1/6', tomorrow.condition.text)
-- minimum temperature in celsius for the day
grp.write('15/1/7', tomorrow.mintemp_c)
-- "feels like" temperature in C
grp.write('15/1/9', current.feelslike_c)
-- humidity as percentage
grp.write('15/1/12', current.humidity)
-- wind speed in kilometers per hour
grp.write('15/1/11', current.wind_kph)
-- uv index
grp.write('15/1/15', current.uv)
-- pressure in millibars
grp.write('15/1/14', current.pressure_mb)
-- "wind_dir"
grp.write('15/1/10', current.wind_dir)
-- "sunrise"
Thank you
*****************************************************************************************************
-- https://www.apixu.com/
require('json')
https = require('ssl.https')
escape = require('socket.url').escape
key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' --API KEY
location = 'Alcobendas' -- lugar de clima
url = 'https://api.apixu.com/v1/forecast.json?key=%s&q=%s&days=2'
url = string.format(url, key, escape(location))
res = https.request(url)
data = json.pdecode(res)
if type(data) ~= 'table' then
alert('failed to load weather data')
log('failed to load weather data')
return
end
if data.error then
log('error', data.error)
return
end
current = data.current
today = data.forecast.forecastday[ 1 ].day
tomorrow = data.forecast.forecastday[ 2 ].day
--INFO UTILIZADA
-- temperature in C
grp.write('15/1/2', current.temp_c)
-- weather condition text
grp.write('15/1/1', current.condition.text)
-- minimum temperature in celsius for the day
grp.write('15/1/4', today.mintemp_c)
-- maximum temperature in celsius for the day
grp.write('15/1/5', today.maxtemp_c)
-- weather condition text
grp.write('15/1/3', today.condition.text)
-- maximum temperature in celsius for the day
grp.write('15/1/8', tomorrow.maxtemp_c)
-- weather condition text
grp.write('15/1/6', tomorrow.condition.text)
-- minimum temperature in celsius for the day
grp.write('15/1/7', tomorrow.mintemp_c)
-- "feels like" temperature in C
grp.write('15/1/9', current.feelslike_c)
-- humidity as percentage
grp.write('15/1/12', current.humidity)
-- wind speed in kilometers per hour
grp.write('15/1/11', current.wind_kph)
-- uv index
grp.write('15/1/15', current.uv)
-- pressure in millibars
grp.write('15/1/14', current.pressure_mb)
-- "wind_dir"
grp.write('15/1/10', current.wind_dir)
-- "sunrise"