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.

Wind speed close shutter
#1
Hello,

I have a task where I need to get current wind speed and if it is above certain number (in this case 12 meters/second), the shutter in outside would close. I wanted to do this from KNX weather station, but it seems it doesn't provide actual wind speed accurately, so my guess is I should propably use some API service. 

I have tried this script:


Quote:require('socket.http')

forecast = {}


function parsetag(parser, tag, attributes)
  if tag == 'time' then
    table.insert(forecast, {})
  elseif tag == 'symbol' then
    forecast[ #forecast ].symbol = attributes.name
  elseif tag == 'precipitation' then
    forecast[ #forecast ].precipitation = attributes.value
  elseif tag == 'windDirection' then
    forecast[ #forecast ].wind_direction = attributes.code
  elseif tag == 'windSpeed' then
    forecast[ #forecast ].wind_speed = attributes.mps
  elseif tag == 'temperature' then
    forecast[ #forecast ].temperature = attributes.value
  elseif tag == 'pressure' then
    forecast[ #forecast ].pressure = attributes.value
  end
end

url = 'http://www.yr.no/place/Lithuania/Klaipeda/Klaipėda/varsel.xml'
data, err = socket.http.request(url)

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

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

But it returns some odd numbers which doesn't really match the forecast from elsewhere, but then I thought maybe I just don't understand what it returns. So how data is returned? The table has 36 entries and I though maybe it is 35 from days starting from first entry (today) forecast, or no? Maybe it is some king of interval based?

Thank You
Reply


Messages In This Thread
Wind speed close shutter - by MantasJ - 08.02.2020, 06:56
RE: Wind speed close shutter - by admin - 08.02.2020, 07:04
RE: Wind speed close shutter - by Joep - 08.02.2020, 09:51

Forum Jump: