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.

Weather Apixu
#1
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"
Reply


Messages In This Thread
Weather Apixu - by arivera - 13.09.2019, 15:36
RE: Weather Apixu - by admin - 13.09.2019, 15:39
RE: Weather Apixu - by arivera - 13.09.2019, 16:34
RE: Weather Apixu - by admin - 13.09.2019, 17:18
RE: Weather Apixu - by arivera - 15.09.2019, 17:54
RE: Weather Apixu - by Domoticatorino - 02.10.2019, 08:14
RE: Weather Apixu - by admin - 02.10.2019, 08:20
RE: Weather Apixu - by Domoticatorino - 02.10.2019, 08:36
RE: Weather Apixu - by admin - 02.10.2019, 08:42
RE: Weather Apixu - by Domoticatorino - 02.10.2019, 08:58
RE: Weather Apixu - by admin - 02.10.2019, 09:31

Forum Jump: