Parse html page with water level data and save it to a file.
First time setup: install Chrome/Chromium for puppeteer
npx puppeteer browsers install chromepnpm start --commitAndPush --copyToClipboard
Only catalunia, Spain is supported.
To run the script every day at 10:00 AM:
crontab -e
If using vim, press i to enter insert mode. First, add the PATH line (required for pnpm and Node to work in cron):
PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbinThen add your cron job(s):
0 10 * * * cd /Users/{userName}/water-level-tracker && pnpm start --commitAndPushType :wq to save and exit.
Note: The PATH line is essential because cron runs with a minimal environment. Without it, cron won't find pnpm or node.
launchd is the native macOS scheduler. It handles sleep better than cron via PreventSystemSleep.
The template includes an EnvironmentVariables section with the necessary PATH for Homebrew tools (pnpm and node).
Copy the template and replace {userName} with your username, then load it:
cp launchd/water-level-tracker.plist ~/Library/LaunchAgents/com.{userName}.water-level-tracker.plist
launchctl load ~/Library/LaunchAgents/com.{userName}.water-level-tracker.plistTo check the status:
launchctl list | grep water-level-trackerTo unload:
launchctl unload ~/Library/LaunchAgents/com.{userName}.water-level-tracker.plistLogs are saved to ~/Library/Logs/water-level-tracker.log and ~/Library/Logs/water-level-tracker.error.log.