NOAA tide data

I want to base a scene on current tide level so that I will get an alert if the water level is high enough to cause flood issues. I can get the measured water level from the NOAA site but I am not sure how to incorporate this information into a scene. Any advice on how to approach this is greatly appreciated.

Presumably you can retrieve the information with an HTTP request - is there a particular format or API that the NOAA website has available? Should be very easy to pull this into a scene, or even a virtual device for other applications to use. The machinery is all there to do it. What documentation do you have of the site? What are you real requirements?

This URL:
http://tidesandcurrents.noaa.gov/api/datagetter?date=latest&station=8461490&product=water_level&datum=mllw&units=english&time_zone=lst_ldt&application=web_services&format=xml

Yields:




Where 0.710 is the measured tide in ft

The documentation on the site is very complete (http://tidesandcurrents.noaa.gov/stationhome.html?id=8461490) The data output is JSON, XML or CSV. Once I see how to utilize the output for one parameter, I can utilize other points as well.

OK, great. I find the API documentation here:

http://tidesandcurrents.noaa.gov/api/

For Vera, or indeed in general, you are probably better off requesting the data in JSON format (by including [tt]&format=json[/tt] on the URL request) which gives:

{"metadata":{"id":"8461490","name":"New London","lat":"41.3614","lon":"-72.0900"},"data":[{"t":"2016-02-21 17:00", "v":"1.117", "s":"0.010", "f":"1,0,0,0", "q":"p"}]}

you can retrieve the JSON data and turn it into Lua like this:

local json = require "dkjson"

local url = "http://tidesandcurrents.noaa.gov/api/datagetter?date=latest&station=8461490&format=json&product=water_level&datum=mllw&units=english&time_zone=lst_ldt&application=web_services&format=xml"

local status, response = luup.inet.wget (url)
local d = json.decode (response)

and this gives you a Lua structure like this:

{
  data = {{
      f = "1,0,0,0",
      q = "p",
      s = "0.016",
      t = "2016-02-21 17:06",
      v = "1.215"
    }},
  metadata = {
    id = "8461490",
    lat = "41.3614",
    lon = "-72.0900",
    name = "New London"
  }
}

You can index the various parts of the table to access the data you need:

local v = d.data[1].v
local name = d.metadata.name

Hope this points you in the right direction.

Wow! That is exactly what I needed. This technique opens up all the NOAA data for use. Thanks so much for helping.