Fetches NIWA tide data and saves to ical format. Requires Python 3, probably a fairly recent version.
- Get yourself an API token from NIWA.
- Get your virtual environment in place:
python3 -m venv .venv --upgrade-deps
. - And activate it:
. .venv/bin/activate
. - Create an
.env
file with values forAPI_KEY
,LAT
andLONG
. You may also choose to set your own values forDAYS
(defaulting to 30) or, if you want,HOST
, although this seems very NIWA-specific and probably not useful elsewhere. - 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".
- Install the dependencies (
pip install -r requirements-base.txt
etc). - Run
python3 main.py
. - The calendar will be saved to the directory as
tidal.ics
.
- Run
./deploy.sh
, which will createlambda-bundle.zip
. - Deploy it.
Note that you can override environment variables when you call the function by providing lat
, long
or days
query string parameters.