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?
#44
(30.01.2019, 21:19)Erwin van der Zwart Wrote: Hi,

Is already in the script but this sample uses the object names instead of GA’s.

Change in all lines grp.update('Weather precipitation', ... to grp.update('1/1/1', ... etcetera

BR,

Erwin

require('socket.http')

forecast = {}

function parsetag(parser, tag, attributes)
  if tag == '27/3/0' then
    table.insert(forecast, {})
  elseif tag == '27/3/1' then
    forecast[ #forecast ].symbol = attributes.name
  elseif tag == '27/3/2' then
    forecast[ #forecast ].precipitation = attributes.value
  elseif tag == '27/3/3' then
    forecast[ #forecast ].wind_direction = attributes.code
  elseif tag == '27/3/4' then
    forecast[ #forecast ].wind_speed = attributes.mps
  elseif tag == '27/3/6' then
    forecast[ #forecast ].temperature = attributes.value
  elseif tag == '27/3/5' then
    forecast[ #forecast ].pressure = attributes.value
  end
end

url = 'http://www.yr.no/place/United_Kingdom/England/London/varsel.xml'
data, err = socket.http.request(url)

if data then
  require('lxp').new({
    StartElement = parsetag
  }):parse(data)

 
  grp.update('27/3/7', tonumber(forecast[1].precipitation))
  grp.update('27/3/8', forecast[1].symbol)
  grp.update('27/3/9', forecast[1].wind_direction)
  grp.update('27/3/10', tonumber(forecast[1].wind_speed))
  grp.update('27/3/11', tonumber(forecast[1].temperature))
  grp.update('27/3/12', tonumber(forecast[1].pressure))

  --log(forecast)
  
else
  alert('Fetch failed: ' .. tostring(err))
end



Still not getting any value, what am i doing wrong. :Smile  ?
Reply


Messages In This Thread
RE: Weather service not working anymore? - by Tokatubs - 24.02.2019, 00:16

Forum Jump: