/tidal

Fetches NIWA tide data and saves to ical format

Primary LanguagePython

T I D A L

What

Fetches NIWA tide data and saves to ical format. Requires Python 3, probably a fairly recent version.

How

  1. Get yourself an API token from NIWA.
  2. Get your virtual environment in place: python3 -m venv .venv --upgrade-deps.
  3. And activate it: . .venv/bin/activate.
  4. Create an .env file with values for API_KEY, LAT and LONG. You may also choose to set your own values for DAYS (defaulting to 30) or, if you want, HOST, although this seems very NIWA-specific and probably not useful elsewhere.
  5. If you’d like a localised time included in the event description, then add a TIMEZONE value in your .env file, e.g. "Pacific/Auckland".

Generate a calendar locally

  1. Install the dependencies (pip install -r requirements-base.txt etc).
  2. Run python3 main.py.
  3. The calendar will be saved to the directory as tidal.ics.

Deploy as a lambda function

  1. Run ./deploy.sh, which will create lambda-bundle.zip.
  2. Deploy it.

Note that you can override environment variables when you call the function by providing lat, long or days query string parameters.