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 service not working anymore?
#76
(30.07.2020, 15:03)admin Wrote: Which one are you using?
Hello admin, this is my script.


Code:
require('json')
http = require('socket.http')
escape = require('socket.url').escape

key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
location = 'xxxx'

url = 'http://api.weatherstack.com/current?access_key=%s&query=%s'
url = string.format(url, key, escape(location))

res = http.request(url)

data = json.pdecode(res)
if type(data) ~= 'table' then
  alert('no se pudieron cargar los datos del clima')
  return
end

if data.error then
  log('error', data.error)
  return
end

current = data.current

-- temperature
grp.write('32/1/1', current.temperature)
-- "feels like" temperature
grp.write('32/1/2', current.feelslike)
-- humidity as percentage
grp.write('32/1/3', current.humidity)
-- wind speed in kilometers per hour
grp.write('32/1/4', current.wind_speed)
-- uv index
grp.write('32/1/5', current.uv_index)
-- weather condition text
grp.write('32/1/6', current.weather_descriptions[1])
-- pressure
grp.write('32/1/7', current.pressure)
-- precipitation amount
grp.write('32/1/8', current.precip)
Reply


Messages In This Thread
RE: Weather service not working anymore? - by davidchispas - 30.07.2020, 15:22

Forum Jump: